From d73c3e405007d480adf06eaa26d175dcad6368ca Mon Sep 17 00:00:00 2001 From: insign <1113045+insign@users.noreply.github.com> Date: Sat, 14 Feb 2026 03:34:00 +0000 Subject: [PATCH] refactor(types): improve return type hints and raise PHPStan level to 6 Upgraded PHPStan configuration to level 6 and resolved reported errors by adding specific array type hints (e.g., `array`, `array`) to method signatures and property docs. Improvements include: - Enhanced type safety in `Rclone`, `ProcessManager`, `CommandBuilder`, `Providers`, `FilterBuilder`, and `Logger`. - Refactored `Logger::redactContext` to correctly preserve associative array keys during recursion, fixing a bug where `array_map` with multiple arrays reindexed keys. - Updated `phpstan.neon.dist` to enforce level 6 analysis. --- phpstan.neon.dist | 2 +- src/CommandBuilder.php | 14 ++++ src/Exception/RcloneException.php | 6 +- src/FilterBuilder.php | 14 ++-- src/Logger.php | 35 ++++++++-- src/ProcessManager.php | 19 ++++-- src/ProgressParser.php | 3 + src/Providers/AbstractProvider.php | 20 ++++-- src/Providers/B2Provider.php | 3 + src/Providers/CryptProvider.php | 6 ++ src/Providers/DropboxProvider.php | 3 + src/Providers/FtpProvider.php | 3 + src/Providers/GDriveProvider.php | 3 + src/Providers/LocalProvider.php | 3 + src/Providers/MegaProvider.php | 3 + src/Providers/Provider.php | 3 + src/Providers/S3Provider.php | 3 + src/Providers/SFtpProvider.php | 3 + src/Providers/UnionProvider.php | 6 ++ src/Rclone.php | 106 +++++++++++++++-------------- src/RetryHandler.php | 2 + src/SecretsRedactor.php | 8 ++- 22 files changed, 187 insertions(+), 81 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 567bcf88..25aa3705 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,5 +1,5 @@ parameters: - level: 5 + level: 6 paths: - src excludePaths: diff --git a/src/CommandBuilder.php b/src/CommandBuilder.php index bd59d5c1..fa15a1ba 100644 --- a/src/CommandBuilder.php +++ b/src/CommandBuilder.php @@ -8,6 +8,10 @@ class CommandBuilder { + /** + * @param array $arr + * @return array + */ public static function prefixFlags(array $arr, string $prefix = 'RCLONE_'): array { $newArr = []; @@ -31,6 +35,12 @@ public static function prefixFlags(array $arr, string $prefix = 'RCLONE_'): arra return $newArr; } + /** + * @param array $globalFlags + * @param array $globalEnvs + * @param array $operationFlags + * @return array + */ public static function buildEnvironment( Provider $leftSide, Provider $rightSide, @@ -51,6 +61,10 @@ public static function buildEnvironment( return $envVars; } + /** + * @param array $args + * @return array + */ public static function buildCommandArgs(string $binary, string $command, array $args = []): array { return array_merge([$binary, $command], $args); diff --git a/src/Exception/RcloneException.php b/src/Exception/RcloneException.php index 66e8ab11..1c881efd 100644 --- a/src/Exception/RcloneException.php +++ b/src/Exception/RcloneException.php @@ -13,13 +13,13 @@ */ class RcloneException extends RuntimeException { - /** @var array Additional context about the error */ + /** @var array Additional context about the error */ protected array $context = []; /** * Set additional context for the exception. * - * @param array $context Contextual information (command, provider, path, etc.) + * @param array $context Contextual information (command, provider, path, etc.) */ public function setContext(array $context): self { @@ -31,7 +31,7 @@ public function setContext(array $context): self /** * Get the exception context. * - * @return array The context array. + * @return array The context array. */ public function getContext(): array { diff --git a/src/FilterBuilder.php b/src/FilterBuilder.php index 311f400d..0c20d1be 100644 --- a/src/FilterBuilder.php +++ b/src/FilterBuilder.php @@ -12,10 +12,10 @@ */ class FilterBuilder { - /** @var array Include patterns */ + /** @var array Include patterns */ private array $includes = []; - /** @var array Exclude patterns */ + /** @var array Exclude patterns */ private array $excludes = []; /** @var int|null Minimum file size in bytes */ @@ -56,7 +56,7 @@ public function include(string $pattern): self /** * Add multiple include patterns. * - * @param array $patterns Array of glob patterns + * @param array $patterns Array of glob patterns */ public function includeMany(array $patterns): self { @@ -82,7 +82,7 @@ public function exclude(string $pattern): self /** * Add multiple exclude patterns. * - * @param array $patterns Array of glob patterns + * @param array $patterns Array of glob patterns */ public function excludeMany(array $patterns): self { @@ -96,7 +96,7 @@ public function excludeMany(array $patterns): self /** * Include only files with specific extensions. * - * @param string|array $extensions Extension(s) without dot (e.g., "jpg", ["jpg", "png"]) + * @param string|array $extensions Extension(s) without dot (e.g., "jpg", ["jpg", "png"]) */ public function extensions(string|array $extensions): self { @@ -197,7 +197,7 @@ public function deleteExcluded(bool $delete = true): self /** * Convert the filter to rclone flags array. * - * @return array Flags to be merged with operation flags + * @return array Flags to be merged with operation flags */ public function toFlags(): array { @@ -240,7 +240,7 @@ public function toFlags(): array /** * Convert to command line arguments. * - * @return array Command line arguments + * @return array Command line arguments */ public function toArgs(): array { diff --git a/src/Logger.php b/src/Logger.php index 23233698..666069e1 100644 --- a/src/Logger.php +++ b/src/Logger.php @@ -27,6 +27,7 @@ class Logger private static bool $debugMode = false; + /** @var array}> */ private static array $logs = []; private static int $maxLogs = 1000; @@ -66,6 +67,8 @@ public static function isDebugMode(): bool /** * Log a debug message (only if debug mode is enabled). + * + * @param array $context */ public static function debug(string $message, array $context = []): void { @@ -76,6 +79,8 @@ public static function debug(string $message, array $context = []): void /** * Log an info message. + * + * @param array $context */ public static function info(string $message, array $context = []): void { @@ -84,6 +89,8 @@ public static function info(string $message, array $context = []): void /** * Log a warning message. + * + * @param array $context */ public static function warning(string $message, array $context = []): void { @@ -92,6 +99,8 @@ public static function warning(string $message, array $context = []): void /** * Log an error message. + * + * @param array $context */ public static function error(string $message, array $context = []): void { @@ -100,6 +109,8 @@ public static function error(string $message, array $context = []): void /** * Log a message at the specified level. + * + * @param array $context */ public static function log(string $level, string $message, array $context = []): void { @@ -129,6 +140,8 @@ public static function log(string $level, string $message, array $context = []): /** * Get all stored logs. + * + * @return array}> */ public static function getLogs(): array { @@ -145,6 +158,8 @@ public static function clearLogs(): void /** * Get logs filtered by level. + * + * @return array}> */ public static function getLogsByLevel(string $level): array { @@ -153,6 +168,8 @@ public static function getLogsByLevel(string $level): array /** * Log command execution (debug mode only). + * + * @param array $envs */ public static function logCommand(string $command, array $envs = []): void { @@ -180,27 +197,33 @@ public static function logResult(bool $success, float $duration, ?string $output /** * Redact sensitive information from context array. + * + * @param array $context + * @return array */ private static function redactContext(array $context): array { $sensitiveKeys = ['password', 'secret', 'token', 'key', 'credential', 'auth']; + $result = []; - $redact = function ($value, $key) use (&$redact, $sensitiveKeys) { + foreach ($context as $key => $value) { if (is_array($value)) { - return array_map($redact, $value, array_keys($value)); + $result[$key] = self::redactContext($value); + continue; } if (is_string($key)) { foreach ($sensitiveKeys as $sensitiveKey) { if (stripos($key, $sensitiveKey) !== false) { - return SecretsRedactor::REDACTED; + $result[$key] = SecretsRedactor::REDACTED; + continue 2; } } } - return $value; - }; + $result[$key] = $value; + } - return array_map($redact, $context, array_keys($context)); + return $result; } } diff --git a/src/ProcessManager.php b/src/ProcessManager.php index 1ff9f1ff..13e26376 100644 --- a/src/ProcessManager.php +++ b/src/ProcessManager.php @@ -32,13 +32,13 @@ class ProcessManager private static string $input = ''; - /** @var array Secrets to redact from error messages */ + /** @var array Secrets to redact from error messages */ private array $secrets = []; - /** @var array Last executed command (for debugging) */ + /** @var array Last executed command (for debugging) */ private array $lastCommand = []; - /** @var array Last environment variables (for debugging) */ + /** @var array Last environment variables (for debugging) */ private array $lastEnvs = []; public static function getTimeout(): int @@ -108,7 +108,7 @@ public static function guessBin(): string /** * Set secrets to be redacted from error messages. * - * @param array $secrets Array of secret values to redact. + * @param array $secrets Array of secret values to redact. */ public function setSecrets(array $secrets): self { @@ -120,7 +120,7 @@ public function setSecrets(array $secrets): self /** * Get the last executed command (for debugging). * - * @return array The command array. + * @return array The command array. */ public function getLastCommand(): array { @@ -142,7 +142,7 @@ public function getLastCommandString(): string * Get the last environment variables (for debugging). * Sensitive values are redacted. * - * @return array The environment variables with secrets redacted. + * @return array The environment variables with secrets redacted. */ public function getLastEnvs(): array { @@ -153,6 +153,9 @@ public function getLastEnvs(): array /** * Redact sensitive values from environment variables. + * + * @param array $envs + * @return array */ private function redactEnvValues(array $envs): array { @@ -174,6 +177,10 @@ private function redactEnvValues(array $envs): array return $redacted; } + /** + * @param array $command + * @param array $envs + */ public function run(array $command, array $envs = [], ?callable $onProgress = null, ?int $timeout = null): Process { $this->lastCommand = $command; diff --git a/src/ProgressParser.php b/src/ProgressParser.php index d46f24ee..91c17894 100644 --- a/src/ProgressParser.php +++ b/src/ProgressParser.php @@ -18,6 +18,7 @@ class ProgressParser /** @var string Buffer for incomplete lines */ private string $lineBuffer = ''; + /** @var array Default progress values */ private static array $defaultProgress = [ 'raw' => '', 'dataSent' => '0 B', @@ -135,6 +136,8 @@ public function getProgress(): object /** * Get progress as array for easier manipulation. + * + * @return array */ public function getProgressArray(): array { diff --git a/src/Providers/AbstractProvider.php b/src/Providers/AbstractProvider.php index b23d7bbb..6cbebd31 100644 --- a/src/Providers/AbstractProvider.php +++ b/src/Providers/AbstractProvider.php @@ -62,6 +62,9 @@ public function provider(): string return $this->provider; } + /** + * @return array + */ public function flags(): array { $prefix = 'RCLONE_CONFIG_' . $this->name() . '_'; @@ -69,6 +72,10 @@ public function flags(): array return $this->prefix_flags($prefix); } + /** + * @param string $prefix + * @return array + */ protected function prefix_flags(string $prefix): array { $prefixed = Rclone::prefix_flags($this->flags, $prefix); @@ -78,12 +85,12 @@ protected function prefix_flags(string $prefix): array return $prefixed; } - public function name() + public function name(): string { return $this->name; } - public function backend($path = null) + public function backend(?string $path = null): string { return $this->name() . ':' . $path; } @@ -106,6 +113,7 @@ public function isListsAsTree(): bool /** * Validate provider configuration. * + * @param array $flags * @throws InvalidArgumentException If required fields are missing. */ protected function validateConfig(array $flags): void @@ -129,7 +137,7 @@ protected function validateConfig(array $flags): void /** * Check for plaintext credentials and emit warnings. * - * @param array $flags The provider flags. + * @param array $flags The provider flags. * @param string $providerName The provider name for context. */ protected function checkCredentials(array $flags, string $providerName): void @@ -206,6 +214,8 @@ public function hasWarnings(): bool /** * Get the raw flags array. + * + * @return array */ public function getRawFlags(): array { @@ -214,6 +224,8 @@ public function getRawFlags(): array /** * Get sensitive field names that should be redacted. + * + * @return array */ public function getSensitiveFields(): array { @@ -223,7 +235,7 @@ public function getSensitiveFields(): array /** * Extract secret values from this provider for redaction purposes. * - * @return array List of secret values. + * @return array List of secret values. */ public function extractSecrets(): array { diff --git a/src/Providers/B2Provider.php b/src/Providers/B2Provider.php index 01c0717a..eebdc63d 100644 --- a/src/Providers/B2Provider.php +++ b/src/Providers/B2Provider.php @@ -10,6 +10,9 @@ class B2Provider extends Provider protected bool $dirAgnostic = true; + /** + * @param array $flags + */ public function __construct(string $name, array $flags = []) { parent::__construct($this->provider, $name, $flags); diff --git a/src/Providers/CryptProvider.php b/src/Providers/CryptProvider.php index ee408125..f93b3f59 100644 --- a/src/Providers/CryptProvider.php +++ b/src/Providers/CryptProvider.php @@ -12,6 +12,9 @@ class CryptProvider extends Provider protected Provider $wrappedProvider; + /** + * @param array $flags + */ public function __construct(string $name, array $flags = []) { if (! isset($flags['remote']) || ! $flags['remote'] instanceof Provider) { @@ -26,6 +29,9 @@ public function __construct(string $name, array $flags = []) parent::__construct($this->provider, $name, $flags); } + /** + * @return array + */ public function flags(): array { $cryptFlags = parent::flags(); diff --git a/src/Providers/DropboxProvider.php b/src/Providers/DropboxProvider.php index b31ffe07..d9fb6576 100644 --- a/src/Providers/DropboxProvider.php +++ b/src/Providers/DropboxProvider.php @@ -8,6 +8,9 @@ class DropboxProvider extends Provider { protected string $provider = 'dropbox'; + /** + * @param array $flags + */ public function __construct(string $name, array $flags = []) { parent::__construct($this->provider, $name, $flags); diff --git a/src/Providers/FtpProvider.php b/src/Providers/FtpProvider.php index da20eb63..eff01e61 100644 --- a/src/Providers/FtpProvider.php +++ b/src/Providers/FtpProvider.php @@ -8,6 +8,9 @@ class FtpProvider extends Provider { protected string $provider = 'ftp'; + /** + * @param array $flags + */ public function __construct(string $name, array $flags = []) { parent::__construct($this->provider, $name, $flags); diff --git a/src/Providers/GDriveProvider.php b/src/Providers/GDriveProvider.php index 2d145bef..2c020c66 100644 --- a/src/Providers/GDriveProvider.php +++ b/src/Providers/GDriveProvider.php @@ -8,6 +8,9 @@ class GDriveProvider extends Provider { protected string $provider = 'drive'; + /** + * @param array $flags + */ public function __construct(string $name, array $flags = []) { parent::__construct($this->provider, $name, $flags); diff --git a/src/Providers/LocalProvider.php b/src/Providers/LocalProvider.php index 10c77305..37228f3c 100644 --- a/src/Providers/LocalProvider.php +++ b/src/Providers/LocalProvider.php @@ -8,6 +8,9 @@ class LocalProvider extends Provider { protected string $provider = 'local'; + /** + * @param array $flags + */ public function __construct(string $name, array $flags = []) { parent::__construct($this->provider, $name, $flags); diff --git a/src/Providers/MegaProvider.php b/src/Providers/MegaProvider.php index 604c8565..77e38380 100644 --- a/src/Providers/MegaProvider.php +++ b/src/Providers/MegaProvider.php @@ -8,6 +8,9 @@ class MegaProvider extends Provider { protected string $provider = 'mega'; + /** + * @param array $flags + */ public function __construct(string $name, array $flags = []) { parent::__construct($this->provider, $name, $flags); diff --git a/src/Providers/Provider.php b/src/Providers/Provider.php index c928f512..b49cbc68 100644 --- a/src/Providers/Provider.php +++ b/src/Providers/Provider.php @@ -11,6 +11,9 @@ */ class Provider extends AbstractProvider { + /** + * @param array $flags + */ protected function __construct(string $provider, string $name, array $flags = []) { $this->provider = $provider; diff --git a/src/Providers/S3Provider.php b/src/Providers/S3Provider.php index e0ad2ff2..7ee76099 100644 --- a/src/Providers/S3Provider.php +++ b/src/Providers/S3Provider.php @@ -10,6 +10,9 @@ class S3Provider extends Provider protected bool $dirAgnostic = true; + /** + * @param array $flags + */ public function __construct(string $name, array $flags = []) { parent::__construct($this->provider, $name, $flags); diff --git a/src/Providers/SFtpProvider.php b/src/Providers/SFtpProvider.php index 89e707c3..57c74229 100644 --- a/src/Providers/SFtpProvider.php +++ b/src/Providers/SFtpProvider.php @@ -8,6 +8,9 @@ class SFtpProvider extends Provider { protected string $provider = 'sftp'; + /** + * @param array $flags + */ public function __construct(string $name, array $flags = []) { parent::__construct($this->provider, $name, $flags); diff --git a/src/Providers/UnionProvider.php b/src/Providers/UnionProvider.php index f19bb63d..fb82b810 100644 --- a/src/Providers/UnionProvider.php +++ b/src/Providers/UnionProvider.php @@ -13,6 +13,9 @@ class UnionProvider extends Provider /** @var Provider[] */ protected array $upstreamProviders = []; + /** + * @param array $flags + */ public function __construct(string $name, array $flags = []) { if (isset($flags['upstream_providers'])) { @@ -28,6 +31,9 @@ public function __construct(string $name, array $flags = []) parent::__construct($this->provider, $name, $flags); } + /** + * @return array + */ public function flags(): array { $allFlags = parent::flags(); diff --git a/src/Rclone.php b/src/Rclone.php index c663a928..fd270ad2 100644 --- a/src/Rclone.php +++ b/src/Rclone.php @@ -22,8 +22,10 @@ class Rclone private ProcessManager $processManager; // Static configuration - delegated to ProcessManager but kept for backward compatibility + /** @var array */ private static array $flags = []; + /** @var array */ private static array $envs = []; /** @var RetryHandler|null Retry handler for transient failures */ @@ -188,6 +190,8 @@ public function getLastCommand(): string /** * Get the last environment variables (for debugging). * Sensitive values are redacted. + * + * @return array */ public function getLastEnvs(): array { @@ -237,7 +241,7 @@ public static function setIdleTimeout(int $idleTimeout): void /** * Gets the globally set rclone flags. * - * @return array Array of flags. + * @return array Array of flags. */ public static function getFlags(): array { @@ -248,7 +252,7 @@ public static function getFlags(): array * Sets global rclone flags. These flags are applied to most rclone commands. * Example: ['retries' => 3, 'verbose' => true] * - * @param array $flags Array of flags. Boolean true will be converted to "true", false to "false". + * @param array $flags Array of flags. Boolean true will be converted to "true", false to "false". */ public static function setFlags(array $flags): void { @@ -258,7 +262,7 @@ public static function setFlags(array $flags): void /** * Gets the custom environment variables. * - * @return array Array of environment variables. + * @return array Array of environment variables. */ public static function getEnvs(): array { @@ -268,7 +272,7 @@ public static function getEnvs(): array /** * Sets custom environment variables, typically used for rclone parameters. * - * @param array $envs Array of environment variables. Boolean true will be converted to "true", false to "false". + * @param array $envs Array of environment variables. Boolean true will be converted to "true", false to "false". */ public static function setEnvs(array $envs): void { @@ -358,10 +362,10 @@ public function isRightSideListsAsTree(): bool /** * Prefixes array keys for rclone environment variables and transforms them. * - * @param array $arr The input array of flags or parameters. + * @param array $arr The input array of flags or parameters. * @param string $prefix The prefix to apply (e.g., 'RCLONE_', 'RCLONE_CONFIG_MYREMOTE_'). * - * @return array The processed array with prefixed keys and string-cast values. + * @return array The processed array with prefixed keys and string-cast values. */ public static function prefix_flags(array $arr, string $prefix = 'RCLONE_'): array { @@ -371,9 +375,9 @@ public static function prefix_flags(array $arr, string $prefix = 'RCLONE_'): arr /** * Consolidates all environment variables for the rclone process. * - * @param array $additional_operation_flags Flags specific to the current rclone operation. + * @param array $additional_operation_flags Flags specific to the current rclone operation. * - * @return array An array of environment variables to be passed to Symfony Process. + * @return array An array of environment variables to be passed to Symfony Process. */ private function allEnvs(array $additional_operation_flags = []): array { @@ -402,8 +406,8 @@ public static function obscure(string $secret): string * Centralized method to prepare and execute an rclone command. * * @param string $command The rclone command (e.g., 'lsjson', 'copy'). - * @param array $args Arguments for the command. - * @param array $operation_flags Additional operation flags. + * @param array $args Arguments for the command. + * @param array $operation_flags Additional operation flags. * @param callable|null $onProgress Optional progress callback. * @param int|null $timeout Optional per-operation timeout in seconds. * @@ -461,8 +465,8 @@ private function _run(string $command, array $args = [], array $operation_flags * Executes a simple rclone command that returns a string output. * * @param string $command The rclone command (e.g., 'lsjson'). - * @param array $args Arguments for the command. - * @param array $operation_flags Additional operation flags. + * @param array $args Arguments for the command. + * @param array $operation_flags Additional operation flags. * @param callable|null $onProgress Optional progress callback. * * @return string The trimmed standard output. @@ -478,8 +482,8 @@ private function simpleRun(string $command, array $args = [], array $operation_f * Executes an rclone command that performs a transfer and returns statistics. * * @param string $command The rclone command (e.g., 'copy', 'sync'). - * @param array $args Arguments for the command (source, destination). - * @param array $operation_flags Additional operation flags. + * @param array $args Arguments for the command (source, destination). + * @param array $operation_flags Additional operation flags. * @param callable|null $onProgress Optional progress callback. * * @return object An object containing the success status and transfer statistics. @@ -518,7 +522,7 @@ private function runAndGetStats(string $command, array $args = [], array $operat * * @param string $command The rclone command. * @param string|null $path The path on the left-side provider. - * @param array $flags Additional flags for the operation. + * @param array $flags Additional flags for the operation. * @param callable|null $onProgress Optional progress callback. * * @return string The output of the command. @@ -536,7 +540,7 @@ private function directRun(string $command, $path = null, array $flags = [], ?ca * @param string $command The rclone command. * @param string|null $left_path Path on the left-side provider. * @param string|null $right_path Path on the right-side provider. - * @param array $flags Additional flags for the operation. + * @param array $flags Additional flags for the operation. * @param callable|null $onProgress Optional progress callback. * * @return string The output of the command. @@ -618,9 +622,9 @@ public function getProgress(): object * Lists objects at the source path. (rclone lsjson) * * @param string $path Path to list. - * @param array $flags Additional flags. + * @param array $flags Additional flags. * - * @return array Array of objects, each representing a file or directory. + * @return array Array of objects, each representing a file or directory. * @throws JsonException If JSON decoding fails. */ public function ls(string $path, array $flags = []): array @@ -714,7 +718,7 @@ public function exists(string $path, string $type): object * @see https://rclone.org/commands/rclone_touch/ * * @param string $path Path to touch. - * @param array $flags Additional flags. + * @param array $flags Additional flags. * @param callable|null $onProgress Optional progress callback. * * @return bool True on success. @@ -732,7 +736,7 @@ public function touch(string $path, array $flags = [], ?callable $onProgress = n * @see https://rclone.org/commands/rclone_mkdir/ * * @param string $path Path to create. - * @param array $flags Additional flags. + * @param array $flags Additional flags. * @param callable|null $onProgress Optional progress callback. * * @return bool True on success. @@ -750,7 +754,7 @@ public function mkdir(string $path, array $flags = [], ?callable $onProgress = n * @see https://rclone.org/commands/rclone_rmdir/ * * @param string $path Path to remove. - * @param array $flags Additional flags. + * @param array $flags Additional flags. * @param callable|null $onProgress Optional progress callback. * * @return bool True on success. @@ -768,7 +772,7 @@ public function rmdir(string $path, array $flags = [], ?callable $onProgress = n * @see https://rclone.org/commands/rclone_rmdirs/ * * @param string $path Root path to search for empty directories. - * @param array $flags Additional flags. + * @param array $flags Additional flags. * @param callable|null $onProgress Optional progress callback. * * @return bool True on success. @@ -786,7 +790,7 @@ public function rmdirs(string $path, array $flags = [], ?callable $onProgress = * @see https://rclone.org/commands/rclone_purge/ * * @param string $path Path to purge. - * @param array $flags Additional flags. + * @param array $flags Additional flags. * @param callable|null $onProgress Optional progress callback. * * @return object Object with 'success' status and 'stats'. @@ -802,7 +806,7 @@ public function purge(string $path, array $flags = [], ?callable $onProgress = n * @see https://rclone.org/commands/rclone_delete/ * * @param string|null $path Path containing files to delete. - * @param array $flags Additional flags (e.g. --include, --exclude). + * @param array $flags Additional flags (e.g. --include, --exclude). * @param callable|null $onProgress Optional progress callback. * * @return object Object with 'success' status and 'stats'. @@ -818,7 +822,7 @@ public function delete(?string $path = null, array $flags = [], ?callable $onPro * @see https://rclone.org/commands/rclone_deletefile/ * * @param string $path Path to the file to delete. - * @param array $flags Additional flags. + * @param array $flags Additional flags. * @param callable|null $onProgress Optional progress callback. * * @return object Object with 'success' status and 'stats'. @@ -832,7 +836,7 @@ public function deletefile(string $path, array $flags = [], ?callable $onProgres * Prints the total size and number of objects in remote:path. (rclone size) * * @param string|null $path Path to get size of. - * @param array $flags Additional flags. + * @param array $flags Additional flags. * @param callable|null $onProgress Optional progress callback. * * @return object Object with 'count' and 'bytes' properties. @@ -852,7 +856,7 @@ public function size(?string $path = null, array $flags = [], ?callable $onProgr * @see https://rclone.org/commands/rclone_cat/ * * @param string $path Path to the file. - * @param array $flags Additional flags. + * @param array $flags Additional flags. * @param callable|null $onProgress Optional progress callback. * * @return string The file content. @@ -869,7 +873,7 @@ public function cat(string $path, array $flags = [], ?callable $onProgress = nul * * @param string $path Destination path on remote. * @param string $input Content to send. - * @param array $flags Additional flags. + * @param array $flags Additional flags. * @param callable|null $onProgress Optional progress callback. * * @return object Object with 'success' status and 'stats'. @@ -886,7 +890,7 @@ public function rcat(string $path, string $input, array $flags = [], ?callable $ * * @param string $local_path Path to the local file. * @param string $remote_path Destination path on the remote. - * @param array $flags Additional flags. + * @param array $flags Additional flags. * @param callable|null $onProgress Optional progress callback. * * @return object Object with 'success' status and 'stats'. @@ -903,7 +907,7 @@ public function upload_file(string $local_path, string $remote_path, array $flag * * @param string $remote_path The path of the file on the remote server. * @param ?string $local_destination_path The local path where the file should be saved. - * @param array $flags Additional flags for the download operation. + * @param array $flags Additional flags for the download operation. * @param ?callable $onProgress A callback function to track download progress. * * @return object The result object from the copy operation, with an added `local_path` property on success. @@ -952,7 +956,7 @@ public function download_to_local(string $remote_path, ?string $local_destinatio * * @param string $source_path Source path (file or directory). * @param string $dest_DIR_path Destination directory path. - * @param array $flags Additional flags. + * @param array $flags Additional flags. * @param callable|null $onProgress Optional progress callback. * * @return object Object with 'success' status and 'stats'. @@ -969,7 +973,7 @@ public function copy(string $source_path, string $dest_DIR_path, array $flags = * * @param string $source_path Source file or directory path. * @param string $dest_path Destination file or directory path. - * @param array $flags Additional flags. + * @param array $flags Additional flags. * @param callable|null $onProgress Optional progress callback. * * @return object Object with 'success' status and 'stats'. @@ -986,7 +990,7 @@ public function copyto(string $source_path, string $dest_path, array $flags = [] * * @param string $source_path Source path (file or directory). * @param string $dest_DIR_path Destination directory path. - * @param array $flags Additional flags. + * @param array $flags Additional flags. * @param callable|null $onProgress Optional progress callback. * * @return object Object with 'success' status and 'stats'. @@ -1003,7 +1007,7 @@ public function move(string $source_path, string $dest_DIR_path, array $flags = * * @param string $source_path Source file or directory path. * @param string $dest_path Destination file or directory path. - * @param array $flags Additional flags. + * @param array $flags Additional flags. * @param callable|null $onProgress Optional progress callback. * * @return object Object with 'success' status and 'stats'. @@ -1020,7 +1024,7 @@ public function moveto(string $source_path, string $dest_path, array $flags = [] * * @param string $source_path Source directory path. * @param string $dest_path Destination directory path. - * @param array $flags Additional flags. + * @param array $flags Additional flags. * @param callable|null $onProgress Optional progress callback. * * @return object Object with 'success' status and 'stats'. @@ -1037,7 +1041,7 @@ public function sync(string $source_path, string $dest_path, array $flags = [], * * @param string $source_path Source directory path. * @param string $dest_path Destination directory path. - * @param array $flags Additional flags. + * @param array $flags Additional flags. * @param callable|null $onProgress Optional progress callback. * * @return bool True if check succeeds. @@ -1055,7 +1059,7 @@ public function check(string $source_path, string $dest_path, array $flags = [], * @see https://rclone.org/commands/rclone_about/ * * @param string|null $path Path on the provider. - * @param array $flags Additional flags for the operation. + * @param array $flags Additional flags for the operation. * * @return object An object with quota details. * @throws JsonException @@ -1074,7 +1078,7 @@ public function about(?string $path = null, array $flags = []): object * @see https://rclone.org/commands/rclone_tree/ * * @param string|null $path The root path to list from. - * @param array $flags Additional rclone flags. + * @param array $flags Additional rclone flags. * * @return string The tree structure as a string. */ @@ -1090,7 +1094,7 @@ public function tree(?string $path = null, array $flags = []): string * * @param string $path The path to check for duplicates. * @param string $mode Deduplication strategy. - * @param array $flags Additional flags. + * @param array $flags Additional flags. * * @return object Object with 'success' status and 'stats' from the operation. */ @@ -1107,7 +1111,7 @@ public function dedupe(string $path, string $mode = 'interactive', array $flags * @see https://rclone.org/commands/rclone_cleanup/ * * @param string|null $path The path to clean up. - * @param array $flags Additional flags. + * @param array $flags Additional flags. * * @return object Object with 'success' status and 'stats'. */ @@ -1123,8 +1127,8 @@ public function cleanup(?string $path = null, array $flags = []): object * * @param string $command The backend command to run. * @param string|null $path The remote path for the command. - * @param array $options Associative array of options. - * @param array $arguments Positional arguments for the command. + * @param array $options Associative array of options. + * @param array $arguments Positional arguments for the command. * * @return string The raw output from the command. */ @@ -1157,9 +1161,9 @@ public function backend(string $command, ?string $path = null, array $options = * * @see https://rclone.org/commands/rclone_listremotes/ * - * @param array $flags Additional flags. + * @param array $flags Additional flags. * - * @return array List of remote names (without the trailing colon). + * @return array List of remote names (without the trailing colon). */ public static function listRemotes(array $flags = []): array { @@ -1224,7 +1228,7 @@ public static function configDump(): object * * @param string $path1 First path (source or destination). * @param string $path2 Second path (source or destination). - * @param array $flags Additional flags (e.g., 'resync' => true for initial sync). + * @param array $flags Additional flags (e.g., 'resync' => true for initial sync). * @param callable|null $onProgress Optional progress callback. * * @return object Object with 'success' status and 'stats'. @@ -1246,9 +1250,9 @@ public function bisync(string $path1, string $path2, array $flags = [], ?callabl * * @param string $hashAlgorithm The hash algorithm to use (e.g., 'md5', 'sha1', 'dropbox'). * @param string|null $path Path to checksum. - * @param array $flags Additional flags. + * @param array $flags Additional flags. * - * @return array Associative array of [path => hash]. + * @return array Associative array of [path => hash]. */ public function hashsum(string $hashAlgorithm, ?string $path = null, array $flags = []): array { @@ -1279,9 +1283,9 @@ public function hashsum(string $hashAlgorithm, ?string $path = null, array $flag * @see https://rclone.org/commands/rclone_md5sum/ * * @param string|null $path Path to checksum. - * @param array $flags Additional flags. + * @param array $flags Additional flags. * - * @return array Associative array of [path => md5hash]. + * @return array Associative array of [path => md5hash]. */ public function md5sum(?string $path = null, array $flags = []): array { @@ -1294,9 +1298,9 @@ public function md5sum(?string $path = null, array $flags = []): array * @see https://rclone.org/commands/rclone_sha1sum/ * * @param string|null $path Path to checksum. - * @param array $flags Additional flags. + * @param array $flags Additional flags. * - * @return array Associative array of [path => sha1hash]. + * @return array Associative array of [path => sha1hash]. */ public function sha1sum(?string $path = null, array $flags = []): array { diff --git a/src/RetryHandler.php b/src/RetryHandler.php index 43f35af4..04b0ec5f 100644 --- a/src/RetryHandler.php +++ b/src/RetryHandler.php @@ -203,6 +203,8 @@ private function calculateDelay(int $attempt): int /** * Get current configuration as array. + * + * @return array */ public function getConfig(): array { diff --git a/src/SecretsRedactor.php b/src/SecretsRedactor.php index ee2479c7..baf4cb56 100644 --- a/src/SecretsRedactor.php +++ b/src/SecretsRedactor.php @@ -66,7 +66,7 @@ public static function isEnabled(): bool * Redact sensitive information from a message. * * @param string $message The message that may contain secrets. - * @param array $knownSecrets Additional secrets to redact (values from provider config). + * @param array $knownSecrets Additional secrets to redact (values from provider config). * * @return string The message with secrets replaced by [REDACTED]. */ @@ -90,6 +90,8 @@ public static function redact(string $message, array $knownSecrets = []): string /** * Redact known secret values from the message. + * + * @param array $secrets */ private static function redactKnownSecrets(string $message, array $secrets): string { @@ -141,9 +143,9 @@ private static function redactUrls(string $message): string /** * Extract secrets from provider configuration for targeted redaction. * - * @param array $providerFlags The flags array from a Provider. + * @param array $providerFlags The flags array from a Provider. * - * @return array List of secret values that should be redacted. + * @return array List of secret values that should be redacted. */ public static function extractSecretsFromFlags(array $providerFlags): array {