diff --git a/psalm.xml b/psalm.xml index e146644fc..1c9425bc1 100644 --- a/psalm.xml +++ b/psalm.xml @@ -41,6 +41,9 @@ + + + @@ -59,6 +62,7 @@ + diff --git a/tests/stubs/oc_files_storage_common.php b/tests/stubs/oc_files_storage_common.php new file mode 100644 index 000000000..549461917 --- /dev/null +++ b/tests/stubs/oc_files_storage_common.php @@ -0,0 +1,358 @@ +stat() . + */ +abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, IConstructableStorage { + use LocalTempFileTrait; + + protected ?Cache $cache = null; + protected ?Scanner $scanner = null; + protected ?Watcher $watcher = null; + protected ?Propagator $propagator = null; + protected $storageCache; + protected ?Updater $updater = null; + + protected array $mountOptions = []; + protected $owner = null; + + public function __construct(array $parameters) { + } + + protected function remove(string $path): bool + { + } + + #[\Override] + public function is_dir(string $path): bool + { + } + + #[\Override] + public function is_file(string $path): bool + { + } + + #[\Override] + public function filesize(string $path): int|float|false + { + } + + #[\Override] + public function isReadable(string $path): bool + { + } + + #[\Override] + public function isUpdatable(string $path): bool + { + } + + #[\Override] + public function isCreatable(string $path): bool + { + } + + #[\Override] + public function isDeletable(string $path): bool + { + } + + #[\Override] + public function isSharable(string $path): bool + { + } + + #[\Override] + public function getPermissions(string $path): int + { + } + + #[\Override] + public function filemtime(string $path): int|false + { + } + + #[\Override] + public function file_get_contents(string $path): string|false + { + } + + #[\Override] + public function file_put_contents(string $path, mixed $data): int|float|false + { + } + + #[\Override] + public function rename(string $source, string $target): bool + { + } + + #[\Override] + public function copy(string $source, string $target): bool + { + } + + #[\Override] + public function getMimeType(string $path): string|false + { + } + + #[\Override] + public function hash(string $type, string $path, bool $raw = false): string|false + { + } + + #[\Override] + public function getLocalFile(string $path): string|false + { + } + + protected function searchInDir(string $query, string $dir = ''): array + { + } + + /** + * @inheritDoc + * Check if a file or folder has been updated since $time + * + * The method is only used to check if the cache needs to be updated. Storage backends that don't support checking + * the mtime should always return false here. As a result storage implementations that always return false expect + * exclusive access to the backend and will not pick up files that have been added in a way that circumvents + * Nextcloud filesystem. + */ + #[\Override] + public function hasUpdated(string $path, int $time): bool + { + } + + protected function getCacheDependencies(): CacheDependencies + { + } + + #[\Override] + public function getCache(string $path = '', ?IStorage $storage = null): ICache + { + } + + #[\Override] + public function getScanner(string $path = '', ?IStorage $storage = null): IScanner + { + } + + #[\Override] + public function getWatcher(string $path = '', ?IStorage $storage = null): IWatcher + { + } + + #[\Override] + public function getPropagator(?IStorage $storage = null): IPropagator + { + } + + #[\Override] + public function getUpdater(?IStorage $storage = null): IUpdater + { + } + + #[\Override] + public function getStorageCache(?IStorage $storage = null): \OC\Files\Cache\Storage + { + } + + #[\Override] + public function getOwner(string $path): string|false + { + } + + #[\Override] + public function getETag(string $path): string|false + { + } + + /** + * clean a path, i.e. remove all redundant '.' and '..' + * making sure that it can't point to higher than '/' + * + * @param string $path The path to clean + * @return string cleaned path + */ + public function cleanPath(string $path): string + { + } + + /** + * Test a storage for availability + */ + #[\Override] + public function test(): bool + { + } + + #[\Override] + public function free_space(string $path): int|float|false + { + } + + #[\Override] + public function isLocal(): bool + { + } + + /** + * Check if the storage is an instance of $class or is a wrapper for a storage that is an instance of $class + */ + #[\Override] + public function instanceOfStorage(string $class): bool + { + } + + #[Override] + public function getDirectDownload(string $path): array|false + { + } + + #[Override] + public function getDirectDownloadById(string $fileId): array|false + { + } + + #[\Override] + public function verifyPath(string $path, string $fileName): void + { + } + + /** + * Get the filename validator + * (cached for performance) + */ + protected function getFilenameValidator(): IFilenameValidator + { + } + + public function setMountOptions(array $options): void + { + } + + public function getMountOption(string $name, mixed $default = null): mixed + { + } + + #[\Override] + public function copyFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath, bool $preserveMtime = false): bool + { + } + + #[\Override] + public function moveFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath): bool + { + } + + #[\Override] + public function getMetaData(string $path): ?array + { + } + + #[\Override] + public function acquireLock(string $path, int $type, ILockingProvider $provider): void + { + } + + #[\Override] + public function releaseLock(string $path, int $type, ILockingProvider $provider): void + { + } + + #[\Override] + public function changeLock(string $path, int $type, ILockingProvider $provider): void + { + } + + /** + * @return array{available: bool, last_checked: int} + */ + #[\Override] + public function getAvailability(): array + { + } + + #[\Override] + public function setAvailability(bool $isAvailable): void + { + } + + #[\Override] + public function setOwner(?string $user): void + { + } + + #[\Override] + public function needsPartFile(): bool + { + } + + #[\Override] + public function writeStream(string $path, $stream, ?int $size = null): int + { + } + + #[\Override] + public function getDirectoryContent(string $directory): \Traversable + { + } +} diff --git a/tests/stubs/oc_files_storage_dav.php b/tests/stubs/oc_files_storage_dav.php new file mode 100644 index 000000000..50724a99c --- /dev/null +++ b/tests/stubs/oc_files_storage_dav.php @@ -0,0 +1,456 @@ +applyBearerToken((string)$settings['bearerToken']); + } + } + + /** + * Register a callback invoked when a request comes back with HTTP 401. The + * callback should return a fresh bearer token, or null to give up. When a + * non-empty token is returned the failing request is replayed once. + * + * @param (callable(): ?string)|null $callback + */ + public function setRefreshTokenCallback(?callable $callback): void { + $this->refreshTokenCallback = $callback === null ? null : \Closure::fromCallable($callback); + } + + #[\Override] + public function send(RequestInterface $request): SabreResponseInterface { + try { + return parent::send($request); + } catch (ClientHttpException $e) { + if ($e->getHttpStatus() !== 401 || $this->retrying || $this->refreshTokenCallback === null) { + throw $e; + } + $this->retrying = true; + try { + $newToken = ($this->refreshTokenCallback)(); + if (!is_string($newToken) || $newToken === '') { + throw $e; + } + $this->applyBearerToken($newToken); + return parent::send($request); + } finally { + $this->retrying = false; + } + } + } + + private function applyBearerToken(string $token): void { + /** @psalm-suppress InvalidArrayOffset */ + $curlType = $this->curlSettings[CURLOPT_HTTPAUTH] ?? 0; + $curlType |= CURLAUTH_BEARER; + $this->addCurlSetting(CURLOPT_HTTPAUTH, $curlType); + $this->addCurlSetting(CURLOPT_XOAUTH2_BEARER, $token); + } +} + +/** + * Class DAV + * + * @package OC\Files\Storage + */ +class DAV extends Common { + /** @var string */ + protected $password; + /** @var string */ + protected $user; + protected ?int $authType = null; + /** @var string */ + protected $host; + /** @var bool */ + protected $secure; + protected bool $verify; + /** @var string */ + protected $root; + /** @var string */ + protected $certPath; + /** @var bool */ + protected $ready; + /** The resolved bearer token for AUTH_BEARER (access token or exchanged token) */ + protected string $bearerToken = ''; + /** @var Client */ + protected $client; + /** @var ArrayCache */ + protected $statCache; + /** @var IClientService */ + protected $httpClientService; + /** @var ICertificateManager */ + protected $certManager; + protected LoggerInterface $logger; + protected IEventLogger $eventLogger; + protected IMimeTypeDetector $mimeTypeDetector; + protected IOCMDiscoveryService $discoveryService; + protected ISignatureManager $signatureManager; + protected OCMSignatoryManager $signatoryManager; + protected IAppConfig $appConfig; + protected IURLGenerator $urlGenerator; + + protected const PROPFIND_PROPS = [ + '{DAV:}getlastmodified', + '{DAV:}getcontentlength', + '{DAV:}getcontenttype', + '{http://owncloud.org/ns}permissions', + '{http://open-collaboration-services.org/ns}share-permissions', + '{http://open-cloud-mesh.org/ns}share-permissions', + '{DAV:}resourcetype', + '{DAV:}getetag', + '{DAV:}quota-available-bytes', + ]; + + /** + * @param array $parameters + * @throws \Exception + */ + public function __construct(array $parameters) + { + } + + protected function init(): void + { + } + + /** + * Exchange refresh token for access token via the remote server's token endpoint + * + * @return string The access token + * @throws StorageNotAvailableException If token exchange fails + */ + protected function exchangeRefreshToken(): string + { + } + + /** + * Check if bearer authentication is being used + */ + protected function isBearerAuth(): bool + { + } + + /** + * Wrap a Guzzle-based operation with retry-on-401 using the bearer-token + * refresh. Sabre-based operations don't need this — {@see BearerAuthAwareSabreClient} + * handles 401 transparently on its own. + * + * @template T + * @param callable(): T $operation + * @return T + * @throws \GuzzleHttp\Exception\ClientException + */ + protected function withAuthRetry(callable $operation): mixed + { + } + + /** + * Exchange the long-lived refresh token for a new short-lived access token + * and update {@see $bearerToken} (and the stored password so subsequent + * init() calls reuse the same token). Used as the refresh callback for the + * Sabre client and by {@see withAuthRetry} for the Guzzle paths. + * + * @return string|null new access token, or null if the exchange failed + */ + protected function refreshAccessToken(): ?string + { + } + + /** + * Clear the stat cache + */ + public function clearStatCache(): void + { + } + + #[\Override] + public function getId(): string + { + } + + public function createBaseUri(): string + { + } + + #[\Override] + public function mkdir(string $path): bool + { + } + + #[\Override] + public function rmdir(string $path): bool + { + } + + #[\Override] + public function opendir(string $path) + { + } + + /** + * @return array + */ + protected function getPropfindProperties(): array + { + } + + /** + * Get property value from cached PROPFIND response. + * For accessing app-specific properties not included in getMetaData(). + * + * @param string $path + * @param string $propertyName + * @return mixed + */ + public function getPropfindPropertyValue(string $path, string $propertyName): mixed + { + } + + /** + * Propfind call with cache handling. + * + * First checks if information is cached. + * If not, request it from the server then store to cache. + * + * @param string $path path to propfind + * + * @return array|false propfind response or false if the entry was not found + * + * @throws ClientHttpException + */ + protected function propfind(string $path): array|false + { + } + + #[\Override] + public function filetype(string $path): string|false + { + } + + #[\Override] + public function file_exists(string $path): bool + { + } + + #[\Override] + public function unlink(string $path): bool + { + } + + #[\Override] + public function fopen(string $path, string $mode) + { + } + + public function writeBack(string $tmpFile, string $path): void + { + } + + #[\Override] + public function free_space(string $path): int|float|false + { + } + + #[\Override] + public function touch(string $path, ?int $mtime = null): bool + { + } + + #[\Override] + public function file_put_contents(string $path, mixed $data): int|float|false + { + } + + protected function uploadFile(string $path, string $target): void + { + } + + #[\Override] + public function rename(string $source, string $target): bool + { + } + + #[\Override] + public function copy(string $source, string $target): bool + { + } + + #[\Override] + public function getMetaData(string $path): ?array + { + } + + #[\Override] + public function stat(string $path): array|false + { + } + + #[\Override] + public function getMimeType(string $path): string|false + { + } + + #[\Override] + public function cleanPath(string $path): string + { + } + + /** + * URL encodes the given path but keeps the slashes + * + * @param string $path to encode + * @return string encoded path + */ + protected function encodePath(string $path): string + { + } + + /** + * @return bool + * @throws StorageInvalidException + * @throws StorageNotAvailableException + */ + protected function simpleResponse(string $method, string $path, ?string $body, int $expected): bool + { + } + + /** + * check if curl is installed + */ + public static function checkDependencies(): bool + { + } + + #[\Override] + public function isUpdatable(string $path): bool + { + } + + #[\Override] + public function isCreatable(string $path): bool + { + } + + #[\Override] + public function isSharable(string $path): bool + { + } + + #[\Override] + public function isDeletable(string $path): bool + { + } + + #[\Override] + public function getPermissions(string $path): int + { + } + + #[\Override] + public function getETag(string $path): string|false + { + } + + protected function parsePermissions(string $permissionsString): int + { + } + + #[\Override] + public function hasUpdated(string $path, int $time): bool + { + } + + /** + * Interpret the given exception and decide whether it is due to an + * unavailable storage, invalid storage or other. + * This will either throw StorageInvalidException, StorageNotAvailableException + * or do nothing. + * + * @param Exception $e sabre exception + * @param string $path optional path from the operation + * + * @throws StorageInvalidException if the storage is invalid, for example + * when the authentication expired or is invalid + * @throws StorageNotAvailableException if the storage is not available, + * which might be temporary + * @throws ForbiddenException if the action is not allowed + */ + protected function convertException(Exception $e, string $path = ''): void + { + } + + #[\Override] + public function getDirectoryContent(string $directory): \Traversable + { + } +} diff --git a/tests/stubs/oc_files_storage_storage.php b/tests/stubs/oc_files_storage_storage.php new file mode 100644 index 000000000..d53b1140c --- /dev/null +++ b/tests/stubs/oc_files_storage_storage.php @@ -0,0 +1,65 @@ + + */ + public function getMetaData(string $path): ?array; + + /** + * Get the contents of a directory with metadata + * + * The metadata array will contain the following fields + * + * - name + * - mimetype + * - mtime + * - size + * - etag + * - storage_mtime + * - permissions + * + * @return \Traversable> + */ + public function getDirectoryContent(string $directory): \Traversable; +} diff --git a/tests/stubs/oca_files_sharing_isharedstorage.php b/tests/stubs/oca_files_sharing_isharedstorage.php new file mode 100644 index 000000000..3ab5ca14e --- /dev/null +++ b/tests/stubs/oca_files_sharing_isharedstorage.php @@ -0,0 +1,19 @@ + */ -class Command implements SignalableCommandInterface +class Command { // see https://tldp.org/LDP/abs/html/exitcodes.html public const SUCCESS = 0; @@ -40,15 +40,23 @@ class Command implements SignalableCommandInterface public const INVALID = 2; /** - * @deprecated since Symfony 7.3, use the #[AsCommand] attribute instead + * @var string|null The default command name + * + * @deprecated since Symfony 6.1, use the AsCommand attribute instead + */ + protected static $defaultName; + + /** + * @var string|null The default command description + * + * @deprecated since Symfony 6.1, use the AsCommand attribute instead */ + protected static $defaultDescription; + public static function getDefaultName(): ?string { } - /** - * @deprecated since Symfony 7.3, use the #[AsCommand] attribute instead - */ public static function getDefaultDescription(): ?string { } @@ -58,7 +66,7 @@ public static function getDefaultDescription(): ?string * * @throws LogicException When the command name is empty */ - public function __construct(?string $name = null, ?callable $code = null) + public function __construct(?string $name = null) { } @@ -66,16 +74,24 @@ public function __construct(?string $name = null, ?callable $code = null) * Ignores validation errors. * * This is mainly useful for the help command. + * + * @return void */ - public function ignoreValidationErrors(): void + public function ignoreValidationErrors() { } - public function setApplication(?Application $application): void + /** + * @return void + */ + public function setApplication(?Application $application = null) { } - public function setHelperSet(HelperSet $helperSet): void + /** + * @return void + */ + public function setHelperSet(HelperSet $helperSet) { } @@ -98,8 +114,10 @@ public function getApplication(): ?Application * * Override this to check for x or y and return false if the command cannot * run properly under the current conditions. + * + * @return bool */ - public function isEnabled(): bool + public function isEnabled() { } @@ -126,7 +144,7 @@ protected function configure() * * @see setCode() */ - protected function execute(InputInterface $input, OutputInterface $output): int + protected function execute(InputInterface $input, OutputInterface $output) { } @@ -178,21 +196,12 @@ public function run(InputInterface $input, OutputInterface $output): int } /** - * Supplies suggestions when resolving possible completion options for input (e.g. option or argument). + * Adds suggestions to $suggestions for the current completion input (e.g. option or argument). */ public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void { } - /** - * Gets the code that is executed by the command. - * - * @return ?callable null if the code has not been set with setCode() - */ - public function getCode(): ?callable - { - } - /** * Sets the code to execute when running this command. * @@ -255,31 +264,31 @@ public function getNativeDefinition(): InputDefinition /** * Adds an argument. * - * @param $mode The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL - * @param $default The default value (for InputArgument::OPTIONAL mode only) + * @param $mode The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL + * @param $default The default value (for InputArgument::OPTIONAL mode only) * @param array|\Closure(CompletionInput,CompletionSuggestions):list $suggestedValues The values used for input completion * * @return $this * * @throws InvalidArgumentException When argument mode is not valid */ - public function addArgument(string $name, ?int $mode = null, string $description = '', mixed $default = null, array|\Closure $suggestedValues = []): static + public function addArgument(string $name, ?int $mode = null, string $description = '', mixed $default = null): static { } /** * Adds an option. * - * @param $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts - * @param $mode The option mode: One of the InputOption::VALUE_* constants - * @param $default The default value (must be null for InputOption::VALUE_NONE) + * @param $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts + * @param $mode The option mode: One of the InputOption::VALUE_* constants + * @param $default The default value (must be null for InputOption::VALUE_NONE) * @param array|\Closure(CompletionInput,CompletionSuggestions):list $suggestedValues The values used for input completion * * @return $this * * @throws InvalidArgumentException If option mode is invalid or incompatible */ - public function addOption(string $name, string|array|null $shortcut = null, ?int $mode = null, string $description = '', mixed $default = null, array|\Closure $suggestedValues = []): static + public function addOption(string $name, string|array|null $shortcut = null, ?int $mode = null, string $description = '', mixed $default = null): static { } @@ -422,18 +431,12 @@ public function getUsages(): array /** * Gets a helper instance by name. * + * @return HelperInterface + * * @throws LogicException if no HelperSet is defined * @throws InvalidArgumentException if the helper is not defined */ - public function getHelper(string $name): HelperInterface - { - } - - public function getSubscribedSignals(): array - { - } - - public function handleSignal(int $signal, int|false $previousExitCode = 0): int|false + public function getHelper(string $name): mixed { } } diff --git a/tests/stubs/symfony_component_console_helper_helper.php b/tests/stubs/symfony_component_console_helper_helper.php index 7c69d6f46..9ae9afa84 100644 --- a/tests/stubs/symfony_component_console_helper_helper.php +++ b/tests/stubs/symfony_component_console_helper_helper.php @@ -21,9 +21,12 @@ */ abstract class Helper implements HelperInterface { - protected ?HelperSet $helperSet = null; + protected $helperSet; - public function setHelperSet(?HelperSet $helperSet): void + /** + * @return void + */ + public function setHelperSet(?HelperSet $helperSet = null) { } @@ -54,15 +57,24 @@ public static function substr(?string $string, int $from, ?int $length = null): { } - public static function formatTime(int|float $secs, int $precision = 1): string + /** + * @return string + */ + public static function formatTime(int|float $secs, int $precision = 1) { } - public static function formatMemory(int $memory): string + /** + * @return string + */ + public static function formatMemory(int $memory) { } - public static function removeDecoration(OutputFormatterInterface $formatter, ?string $string): string + /** + * @return string + */ + public static function removeDecoration(OutputFormatterInterface $formatter, ?string $string) { } } diff --git a/tests/stubs/symfony_component_console_helper_helperinterface.php b/tests/stubs/symfony_component_console_helper_helperinterface.php index 8c4da3c91..ab626c938 100644 --- a/tests/stubs/symfony_component_console_helper_helperinterface.php +++ b/tests/stubs/symfony_component_console_helper_helperinterface.php @@ -20,8 +20,10 @@ interface HelperInterface { /** * Sets the helper set associated with this helper. + * + * @return void */ - public function setHelperSet(?HelperSet $helperSet): void; + public function setHelperSet(?HelperSet $helperSet); /** * Gets the helper set associated with this helper. @@ -30,6 +32,8 @@ public function getHelperSet(): ?HelperSet; /** * Returns the canonical name of this helper. + * + * @return string */ - public function getName(): string; + public function getName(); } diff --git a/tests/stubs/symfony_component_console_helper_questionhelper.php b/tests/stubs/symfony_component_console_helper_questionhelper.php index 14c50aedf..8dd76875e 100644 --- a/tests/stubs/symfony_component_console_helper_questionhelper.php +++ b/tests/stubs/symfony_component_console_helper_questionhelper.php @@ -51,15 +51,19 @@ public function getName(): string /** * Prevents usage of stty. + * + * @return void */ - public static function disableStty(): void + public static function disableStty() { } /** * Outputs the question prompt. + * + * @return void */ - protected function writePrompt(OutputInterface $output, Question $question): void + protected function writePrompt(OutputInterface $output, Question $question) { } @@ -72,8 +76,10 @@ protected function formatChoiceQuestionChoices(ChoiceQuestion $question, string /** * Outputs an error message. + * + * @return void */ - protected function writeError(OutputInterface $output, \Exception $error): void + protected function writeError(OutputInterface $output, \Exception $error) { } } diff --git a/tests/stubs/symfony_component_console_helper_table.php b/tests/stubs/symfony_component_console_helper_table.php index 7e6f7d5a0..373b3ffff 100644 --- a/tests/stubs/symfony_component_console_helper_table.php +++ b/tests/stubs/symfony_component_console_helper_table.php @@ -39,14 +39,16 @@ class Table private const DISPLAY_ORIENTATION_HORIZONTAL = 'horizontal'; private const DISPLAY_ORIENTATION_VERTICAL = 'vertical'; - public function __construct(private OutputInterface $output) + public function __construct(OutputInterface $output) { } /** * Sets a style definition. + * + * @return void */ - public static function setStyleDefinition(string $name, TableStyle $style): void + public static function setStyleDefinition(string $name, TableStyle $style) { } @@ -133,7 +135,7 @@ public function setHeaders(array $headers): static /** * @return $this */ - public function setRows(array $rows): static + public function setRows(array $rows) { } @@ -207,8 +209,10 @@ public function setVertical(bool $vertical = true): static * | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | * | 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien | * +---------------+-----------------------+------------------+ + * + * @return void */ - public function render(): void + public function render() { } } diff --git a/tests/stubs/symfony_component_console_input_inputargument.php b/tests/stubs/symfony_component_console_input_inputargument.php index 403c8f5c5..8a106813a 100644 --- a/tests/stubs/symfony_component_console_input_inputargument.php +++ b/tests/stubs/symfony_component_console_input_inputargument.php @@ -25,31 +25,20 @@ */ class InputArgument { - /** - * Providing an argument is required (e.g. just 'app:foo' is not allowed). - */ public const REQUIRED = 1; - - /** - * Providing an argument is optional (e.g. 'app:foo' and 'app:foo bar' are both allowed). This is the default behavior of arguments. - */ public const OPTIONAL = 2; - - /** - * The argument accepts multiple values and turn them into an array (e.g. 'app:foo bar baz' will result in value ['bar', 'baz']). - */ public const IS_ARRAY = 4; /** * @param string $name The argument name - * @param int-mask-of|null $mode The argument mode: a bit mask of self::REQUIRED, self::OPTIONAL and self::IS_ARRAY + * @param int|null $mode The argument mode: a bit mask of self::REQUIRED, self::OPTIONAL and self::IS_ARRAY * @param string $description A description text * @param string|bool|int|float|array|null $default The default value (for self::OPTIONAL mode only) * @param array|\Closure(CompletionInput,CompletionSuggestions):list $suggestedValues The values used for input completion * * @throws InvalidArgumentException When argument mode is not valid */ - public function __construct(private string $name, ?int $mode = null, private string $description = '', string|bool|int|float|array|null $default = null, private \Closure|array $suggestedValues = []) + public function __construct(string $name, ?int $mode = null, string $description = '', string|bool|int|float|array|null $default = null, \Closure|array $suggestedValues = []) { } @@ -80,8 +69,12 @@ public function isArray(): bool /** * Sets the default value. + * + * @return void + * + * @throws LogicException When incorrect default value is given */ - public function setDefault(string|bool|int|float|array|null $default): void + public function setDefault(string|bool|int|float|array|null $default = null) { } @@ -92,15 +85,12 @@ public function getDefault(): string|bool|int|float|array|null { } - /** - * Returns true if the argument has values for input completion. - */ public function hasCompletion(): bool { } /** - * Supplies suggestions when command resolves possible completion options for input. + * Adds suggestions to $suggestions for the current completion input. * * @see Command::complete() */ diff --git a/tests/stubs/symfony_component_console_input_inputinterface.php b/tests/stubs/symfony_component_console_input_inputinterface.php index c177d960b..aaed5fd01 100644 --- a/tests/stubs/symfony_component_console_input_inputinterface.php +++ b/tests/stubs/symfony_component_console_input_inputinterface.php @@ -18,6 +18,9 @@ * InputInterface is the interface implemented by all input classes. * * @author Fabien Potencier + * + * @method string __toString() Returns a stringified representation of the args passed to the command. + * InputArguments MUST be escaped as well as the InputOption values passed to the command. */ interface InputInterface { @@ -50,22 +53,28 @@ public function hasParameterOption(string|array $values, bool $onlyParams = fals * @param string|array $values The value(s) to look for in the raw parameters (can be an array) * @param string|bool|int|float|array|null $default The default value to return if no result is found * @param bool $onlyParams Only check real parameters, skip those following an end of options (--) signal + * + * @return mixed */ - public function getParameterOption(string|array $values, string|bool|int|float|array|null $default = false, bool $onlyParams = false): mixed; + public function getParameterOption(string|array $values, string|bool|int|float|array|null $default = false, bool $onlyParams = false); /** * Binds the current Input instance with the given arguments and options. * + * @return void + * * @throws RuntimeException */ - public function bind(InputDefinition $definition): void; + public function bind(InputDefinition $definition); /** * Validates the input. * + * @return void + * * @throws RuntimeException When not enough arguments are given */ - public function validate(): void; + public function validate(); /** * Returns all the given arguments merged with the default values. @@ -77,16 +86,20 @@ public function getArguments(): array; /** * Returns the argument value for a given argument name. * + * @return mixed + * * @throws InvalidArgumentException When argument given doesn't exist */ - public function getArgument(string $name): mixed; + public function getArgument(string $name); /** * Sets an argument value by name. * + * @return void + * * @throws InvalidArgumentException When argument given doesn't exist */ - public function setArgument(string $name, mixed $value): void; + public function setArgument(string $name, mixed $value); /** * Returns true if an InputArgument object exists by name or position. @@ -103,16 +116,20 @@ public function getOptions(): array; /** * Returns the option value for a given option name. * + * @return mixed + * * @throws InvalidArgumentException When option given doesn't exist */ - public function getOption(string $name): mixed; + public function getOption(string $name); /** * Sets an option value by name. * + * @return void + * * @throws InvalidArgumentException When option given doesn't exist */ - public function setOption(string $name, mixed $value): void; + public function setOption(string $name, mixed $value); /** * Returns true if an InputOption object exists by name. @@ -126,13 +143,8 @@ public function isInteractive(): bool; /** * Sets the input interactivity. - */ - public function setInteractive(bool $interactive): void; - - /** - * Returns a stringified representation of the args passed to the command. * - * InputArguments MUST be escaped as well as the InputOption values passed to the command. + * @return void */ - public function __toString(): string; + public function setInteractive(bool $interactive); } diff --git a/tests/stubs/symfony_component_console_input_inputoption.php b/tests/stubs/symfony_component_console_input_inputoption.php index aa1c2caaf..ab5680e57 100644 --- a/tests/stubs/symfony_component_console_input_inputoption.php +++ b/tests/stubs/symfony_component_console_input_inputoption.php @@ -46,19 +46,19 @@ class InputOption public const VALUE_IS_ARRAY = 8; /** - * The option allows passing a negated variant (e.g. --ansi or --no-ansi). + * The option may have either positive or negative value (e.g. --ansi or --no-ansi). */ public const VALUE_NEGATABLE = 16; /** * @param string|array|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts - * @param int-mask-of|null $mode The option mode: One of the VALUE_* constants + * @param int|null $mode The option mode: One of the VALUE_* constants * @param string|bool|int|float|array|null $default The default value (must be null for self::VALUE_NONE) * @param array|\Closure(CompletionInput,CompletionSuggestions):list $suggestedValues The values used for input completion * * @throws InvalidArgumentException If option mode is invalid or incompatible */ - public function __construct(string $name, string|array|null $shortcut = null, ?int $mode = null, private string $description = '', string|bool|int|float|array|null $default = null, private array|\Closure $suggestedValues = []) + public function __construct(string $name, string|array|null $shortcut = null, ?int $mode = null, string $description = '', string|bool|int|float|array|null $default = null, array|\Closure $suggestedValues = []) { } @@ -112,19 +112,14 @@ public function isArray(): bool { } - /** - * Returns true if the option allows passing a negated variant. - * - * @return bool true if mode is self::VALUE_NEGATABLE, false otherwise - */ public function isNegatable(): bool { } /** - * Sets the default value. + * @return void */ - public function setDefault(string|bool|int|float|array|null $default): void + public function setDefault(string|bool|int|float|array|null $default = null) { } @@ -142,15 +137,12 @@ public function getDescription(): string { } - /** - * Returns true if the option has values for input completion. - */ public function hasCompletion(): bool { } /** - * Supplies suggestions when command resolves possible completion options for input. + * Adds suggestions to $suggestions for the current completion input. * * @see Command::complete() */ diff --git a/tests/stubs/symfony_component_console_output_consoleoutput.php b/tests/stubs/symfony_component_console_output_consoleoutput.php index afab04598..6a01816e3 100644 --- a/tests/stubs/symfony_component_console_output_consoleoutput.php +++ b/tests/stubs/symfony_component_console_output_consoleoutput.php @@ -45,15 +45,24 @@ public function section(): ConsoleSectionOutput { } - public function setDecorated(bool $decorated): void + /** + * @return void + */ + public function setDecorated(bool $decorated) { } - public function setFormatter(OutputFormatterInterface $formatter): void + /** + * @return void + */ + public function setFormatter(OutputFormatterInterface $formatter) { } - public function setVerbosity(int $level): void + /** + * @return void + */ + public function setVerbosity(int $level) { } @@ -61,7 +70,10 @@ public function getErrorOutput(): OutputInterface { } - public function setErrorOutput(OutputInterface $error): void + /** + * @return void + */ + public function setErrorOutput(OutputInterface $error) { } diff --git a/tests/stubs/symfony_component_console_output_consoleoutputinterface.php b/tests/stubs/symfony_component_console_output_consoleoutputinterface.php index 1f8f147ce..9c0049c8f 100644 --- a/tests/stubs/symfony_component_console_output_consoleoutputinterface.php +++ b/tests/stubs/symfony_component_console_output_consoleoutputinterface.php @@ -24,7 +24,10 @@ interface ConsoleOutputInterface extends OutputInterface */ public function getErrorOutput(): OutputInterface; - public function setErrorOutput(OutputInterface $error): void; + /** + * @return void + */ + public function setErrorOutput(OutputInterface $error); public function section(): ConsoleSectionOutput; } diff --git a/tests/stubs/symfony_component_console_output_consolesectionoutput.php b/tests/stubs/symfony_component_console_output_consolesectionoutput.php index dcfd6ccf2..a5c231792 100644 --- a/tests/stubs/symfony_component_console_output_consolesectionoutput.php +++ b/tests/stubs/symfony_component_console_output_consolesectionoutput.php @@ -43,15 +43,19 @@ public function setMaxHeight(int $maxHeight): void * Clears previous output for this section. * * @param int $lines Number of lines to clear. If null, then the entire output of this section is cleared + * + * @return void */ - public function clear(?int $lines = null): void + public function clear(?int $lines = null) { } /** * Overwrites the previous output with a new message. + * + * @return void */ - public function overwrite(string|iterable $message): void + public function overwrite(string|iterable $message) { } @@ -77,7 +81,10 @@ public function addNewLineOfInputSubmit(): void { } - protected function doWrite(string $message, bool $newline): void + /** + * @return void + */ + protected function doWrite(string $message, bool $newline) { } } diff --git a/tests/stubs/symfony_component_console_output_output.php b/tests/stubs/symfony_component_console_output_output.php index 62d3f827e..123ebf17b 100644 --- a/tests/stubs/symfony_component_console_output_output.php +++ b/tests/stubs/symfony_component_console_output_output.php @@ -17,14 +17,13 @@ /** * Base class for output classes. * - * There are six levels of verbosity: + * There are five levels of verbosity: * * * normal: no option passed (normal output) * * verbose: -v (more output) * * very verbose: -vv (highly extended output) * * debug: -vvv (all debug output) - * * quiet: -q (only output errors) - * * silent: --silent (no output) + * * quiet: -q (no output) * * @author Fabien Potencier */ @@ -39,7 +38,10 @@ public function __construct(?int $verbosity = self::VERBOSITY_NORMAL, bool $deco { } - public function setFormatter(OutputFormatterInterface $formatter): void + /** + * @return void + */ + public function setFormatter(OutputFormatterInterface $formatter) { } @@ -47,7 +49,10 @@ public function getFormatter(): OutputFormatterInterface { } - public function setDecorated(bool $decorated): void + /** + * @return void + */ + public function setDecorated(bool $decorated) { } @@ -55,7 +60,10 @@ public function isDecorated(): bool { } - public function setVerbosity(int $level): void + /** + * @return void + */ + public function setVerbosity(int $level) { } @@ -63,10 +71,6 @@ public function getVerbosity(): int { } - public function isSilent(): bool - { - } - public function isQuiet(): bool { } @@ -83,16 +87,24 @@ public function isDebug(): bool { } - public function writeln(string|iterable $messages, int $options = self::OUTPUT_NORMAL): void + /** + * @return void + */ + public function writeln(string|iterable $messages, int $options = self::OUTPUT_NORMAL) { } - public function write(string|iterable $messages, bool $newline = false, int $options = self::OUTPUT_NORMAL): void + /** + * @return void + */ + public function write(string|iterable $messages, bool $newline = false, int $options = self::OUTPUT_NORMAL) { } /** * Writes a message to the output. + * + * @return void */ - abstract protected function doWrite(string $message, bool $newline): void; + abstract protected function doWrite(string $message, bool $newline); } diff --git a/tests/stubs/symfony_component_console_output_outputinterface.php b/tests/stubs/symfony_component_console_output_outputinterface.php index 969a3b022..19a817901 100644 --- a/tests/stubs/symfony_component_console_output_outputinterface.php +++ b/tests/stubs/symfony_component_console_output_outputinterface.php @@ -17,12 +17,9 @@ * OutputInterface is the interface implemented by all Output classes. * * @author Fabien Potencier - * - * @method bool isSilent() */ interface OutputInterface { - public const VERBOSITY_SILENT = 8; public const VERBOSITY_QUIET = 16; public const VERBOSITY_NORMAL = 32; public const VERBOSITY_VERBOSE = 64; @@ -39,23 +36,29 @@ interface OutputInterface * @param bool $newline Whether to add a newline * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), * 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL + * + * @return void */ - public function write(string|iterable $messages, bool $newline = false, int $options = 0): void; + public function write(string|iterable $messages, bool $newline = false, int $options = 0); /** * Writes a message to the output and adds a newline at the end. * * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), * 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL + * + * @return void */ - public function writeln(string|iterable $messages, int $options = 0): void; + public function writeln(string|iterable $messages, int $options = 0); /** * Sets the verbosity of the output. * * @param self::VERBOSITY_* $level + * + * @return void */ - public function setVerbosity(int $level): void; + public function setVerbosity(int $level); /** * Gets the current verbosity of the output. @@ -86,15 +89,20 @@ public function isDebug(): bool; /** * Sets the decorated flag. + * + * @return void */ - public function setDecorated(bool $decorated): void; + public function setDecorated(bool $decorated); /** * Gets the decorated flag. */ public function isDecorated(): bool; - public function setFormatter(OutputFormatterInterface $formatter): void; + /** + * @return void + */ + public function setFormatter(OutputFormatterInterface $formatter); /** * Returns current output formatter instance. diff --git a/tests/stubs/symfony_component_console_output_streamoutput.php b/tests/stubs/symfony_component_console_output_streamoutput.php index 6d356e3a2..492a5d6e9 100644 --- a/tests/stubs/symfony_component_console_output_streamoutput.php +++ b/tests/stubs/symfony_component_console_output_streamoutput.php @@ -50,7 +50,10 @@ public function getStream() { } - protected function doWrite(string $message, bool $newline): void + /** + * @return void + */ + protected function doWrite(string $message, bool $newline) { } diff --git a/tests/stubs/symfony_component_console_question_confirmationquestion.php b/tests/stubs/symfony_component_console_question_confirmationquestion.php index 16dc7905b..0db6fe2fa 100644 --- a/tests/stubs/symfony_component_console_question_confirmationquestion.php +++ b/tests/stubs/symfony_component_console_question_confirmationquestion.php @@ -23,7 +23,7 @@ class ConfirmationQuestion extends Question * @param bool $default The default answer to return, true or false * @param string $trueAnswerRegex A regex to match the "yes" answer */ - public function __construct(string $question, bool $default = true, private string $trueAnswerRegex = '/^y/i') + public function __construct(string $question, bool $default = true, string $trueAnswerRegex = '/^y/i') { } } diff --git a/tests/stubs/symfony_component_console_question_question.php b/tests/stubs/symfony_component_console_question_question.php index ead7b5bd0..c04b412b9 100644 --- a/tests/stubs/symfony_component_console_question_question.php +++ b/tests/stubs/symfony_component_console_question_question.php @@ -25,10 +25,8 @@ class Question * @param string $question The question to ask to the user * @param string|bool|int|float|null $default The default answer to return if the user enters nothing */ - public function __construct( - private string $question, - private string|bool|int|float|null $default = null, - ) { + public function __construct(string $question, string|bool|int|float|null $default = null) + { } /** @@ -61,23 +59,6 @@ public function setMultiline(bool $multiline): static { } - /** - * Returns the timeout in seconds. - */ - public function getTimeout(): ?int - { - } - - /** - * Sets the maximum time the user has to answer the question. - * If the user does not answer within this time, an exception will be thrown. - * - * @return $this - */ - public function setTimeout(?int $seconds): static - { - } - /** * Returns whether the user response must be hidden. */ @@ -132,8 +113,6 @@ public function setAutocompleterValues(?iterable $values): static /** * Gets the callback function used for the autocompleter. - * - * @return (callable(string):string[])|null */ public function getAutocompleterCallback(): ?callable { @@ -144,29 +123,23 @@ public function getAutocompleterCallback(): ?callable * * The callback is passed the user input as argument and should return an iterable of corresponding suggestions. * - * @param (callable(string):string[])|null $callback - * * @return $this */ - public function setAutocompleterCallback(?callable $callback): static + public function setAutocompleterCallback(?callable $callback = null): static { } /** * Sets a validator for the question. * - * @param (callable(mixed):mixed)|null $validator - * * @return $this */ - public function setValidator(?callable $validator): static + public function setValidator(?callable $validator = null): static { } /** * Gets the validator for the question. - * - * @return (callable(mixed):mixed)|null */ public function getValidator(): ?callable { @@ -197,7 +170,7 @@ public function getMaxAttempts(): ?int /** * Sets a normalizer for the response. * - * @param callable(mixed):mixed $normalizer + * The normalizer can be a callable (a string), a closure or a class implementing __invoke. * * @return $this */ @@ -208,13 +181,16 @@ public function setNormalizer(callable $normalizer): static /** * Gets the normalizer for the response. * - * @return (callable(mixed):mixed)|null + * The normalizer can ba a callable (a string), a closure or a class implementing __invoke. */ public function getNormalizer(): ?callable { } - protected function isAssoc(array $array): bool + /** + * @return bool + */ + protected function isAssoc(array $array) { }