diff --git a/phpstan.neon b/phpstan.neon index 30e9572..e9a9e7e 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,18 +1,5 @@ parameters: - level: 6 + level: 10 paths: - src - tests - ignoreErrors: - - '#type has no value type specified in iterable type#' - - '#has parameter .* with no value type specified in iterable type#' - - '#has no value type specified in iterable type array#' - - '#configureOptions\(\) has no return type specified.#' - - '#configure\(\) has no return type specified#' - - '#process\(\) has no return type specified#' - - '#should return Iterator but returns Traversable#' - - '#Negated boolean expression is always false#' - checkGenericClassInNonGenericObjectType: false - reportUnmatchedIgnoredErrors: false - inferPrivatePropertyTypeFromConstructor: true - treatPhpDocTypesAsCertain: false diff --git a/src/Task/FileFetchTask.php b/src/Task/FileFetchTask.php index 0ea81a2..b915e67 100644 --- a/src/Task/FileFetchTask.php +++ b/src/Task/FileFetchTask.php @@ -16,7 +16,6 @@ use CleverAge\ProcessBundle\Model\AbstractConfigurableTask; use CleverAge\ProcessBundle\Model\IterableTaskInterface; use CleverAge\ProcessBundle\Model\ProcessState; -use League\Flysystem\Filesystem; use League\Flysystem\FilesystemException; use League\Flysystem\FilesystemOperator; use Symfony\Component\DependencyInjection\ServiceLocator; @@ -32,6 +31,9 @@ class FileFetchTask extends AbstractConfigurableTask implements IterableTaskInte protected FilesystemOperator $destinationFS; + /** + * @var array + */ protected array $matchingFiles = []; /** @@ -49,8 +51,12 @@ public function initialize(ProcessState $state): void // Configure options parent::initialize($state); - $this->sourceFS = $this->storages->get($this->getOption($state, 'source_filesystem')); - $this->destinationFS = $this->storages->get($this->getOption($state, 'destination_filesystem')); + /** @var string $sourceFilesystemOption */ + $sourceFilesystemOption = $this->getOption($state, 'source_filesystem'); + $this->sourceFS = $this->storages->get($sourceFilesystemOption); + /** @var string $destinationFilesystemOption */ + $destinationFilesystemOption = $this->getOption($state, 'destination_filesystem'); + $this->destinationFS = $this->storages->get($destinationFilesystemOption); } /** @@ -69,7 +75,9 @@ public function execute(ProcessState $state): void return; } - $this->doFileCopy($state, $file, $this->getOption($state, 'remove_source')); + /** @var bool $removeSourceOption */ + $removeSourceOption = $this->getOption($state, 'remove_source'); + $this->doFileCopy($state, $file, $removeSourceOption); $state->setOutput($file); } @@ -92,16 +100,19 @@ public function next(ProcessState $state): bool */ protected function findMatchingFiles(ProcessState $state): void { + /** @var ?string $filePattern */ $filePattern = $this->getOption($state, 'file_pattern'); if ($filePattern) { foreach ($this->sourceFS->listContents('/') as $file) { - if ('file' === $file['type'] - && preg_match($filePattern, (string) $file['path']) - && !\in_array($file['path'], $this->matchingFiles, true)) { - $this->matchingFiles[] = $file['path']; + if ('file' === $file->type() + && preg_match($filePattern, $file->path()) + && !\in_array($file->path(), $this->matchingFiles, true) + ) { + $this->matchingFiles[] = $file->path(); } } } else { + /** @var array|string|null $input */ $input = $state->getInput(); if (!$input) { throw new \UnexpectedValueException('No pattern neither input provided for the Task'); diff --git a/src/Task/ListContentTask.php b/src/Task/ListContentTask.php index 8c394cd..c804135 100644 --- a/src/Task/ListContentTask.php +++ b/src/Task/ListContentTask.php @@ -26,6 +26,9 @@ */ class ListContentTask extends AbstractConfigurableTask implements IterableTaskInterface { + /** + * @var list<\League\Flysystem\StorageAttributes>|null + */ protected ?array $fsContent = null; /** @@ -50,10 +53,13 @@ protected function configureOptions(OptionsResolver $resolver): void public function execute(ProcessState $state): void { if (null === $this->fsContent || null === key($this->fsContent)) { - $filesystem = $this->storages->get($this->getOption($state, 'filesystem')); - $pattern = $this->getOption($state, 'file_pattern'); + /** @var string $filesystemOption */ + $filesystemOption = $this->getOption($state, 'filesystem'); + $filesystem = $this->storages->get($filesystemOption); + /** @var ?string $patternOption */ + $patternOption = $this->getOption($state, 'file_pattern'); - $this->fsContent = $this->getFilteredFilesystemContents($filesystem, $pattern); + $this->fsContent = $this->getFilteredFilesystemContents($filesystem, $patternOption); } if (null === key($this->fsContent)) { @@ -76,13 +82,15 @@ public function next(ProcessState $state): bool } /** + * @return list<\League\Flysystem\StorageAttributes> + * * @throws FilesystemException */ protected function getFilteredFilesystemContents(FilesystemOperator $filesystem, ?string $pattern = null): array { $results = []; foreach ($filesystem->listContents('') as $item) { - if (null === $pattern || preg_match($pattern, (string) $item['path'])) { + if (null === $pattern || preg_match($pattern, $item->path())) { $results[] = $item; } } diff --git a/src/Task/RemoveFileTask.php b/src/Task/RemoveFileTask.php index 5bb0af9..2f195f4 100644 --- a/src/Task/RemoveFileTask.php +++ b/src/Task/RemoveFileTask.php @@ -41,7 +41,10 @@ protected function configureOptions(OptionsResolver $resolver): void public function execute(ProcessState $state): void { - $filesystem = $this->storages->get($this->getOption($state, 'filesystem')); + /** @var string $filesystemOption */ + $filesystemOption = $this->getOption($state, 'filesystem'); + $filesystem = $this->storages->get($filesystemOption); + /** @var string $filePath */ $filePath = $state->getInput(); try {