From dbd0ccaad857aadf585ebdef4c1c1a5fe3971d28 Mon Sep 17 00:00:00 2001 From: pistej Date: Wed, 20 Oct 2021 21:54:38 +0200 Subject: [PATCH] phpstan level 6 in src/Composer/Package/Archiver (refs #10159) (#10195) --- .../Package/Archiver/ArchivableFilesFilter.php | 5 +++++ .../Package/Archiver/ArchivableFilesFinder.php | 6 +++--- src/Composer/Package/Archiver/ArchiveManager.php | 2 ++ src/Composer/Package/Archiver/BaseExcludeFilter.php | 12 ++++++------ .../Package/Archiver/ComposerExcludeFilter.php | 4 ++-- src/Composer/Package/Archiver/GitExcludeFilter.php | 4 ++-- src/Composer/Package/Archiver/HgExcludeFilter.php | 6 +++--- src/Composer/Package/Archiver/ZipArchiver.php | 3 +++ 8 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/Composer/Package/Archiver/ArchivableFilesFilter.php b/src/Composer/Package/Archiver/ArchivableFilesFilter.php index 863b6e99b..6f25923d7 100644 --- a/src/Composer/Package/Archiver/ArchivableFilesFilter.php +++ b/src/Composer/Package/Archiver/ArchivableFilesFilter.php @@ -36,6 +36,11 @@ class ArchivableFilesFilter extends FilterIterator return true; } + /** + * @param string $sources + * + * @return void + */ public function addEmptyDir(PharData $phar, $sources) { foreach ($this->dirs as $filepath) { diff --git a/src/Composer/Package/Archiver/ArchivableFilesFinder.php b/src/Composer/Package/Archiver/ArchivableFilesFinder.php index 98cdf941b..96459f872 100644 --- a/src/Composer/Package/Archiver/ArchivableFilesFinder.php +++ b/src/Composer/Package/Archiver/ArchivableFilesFinder.php @@ -35,9 +35,9 @@ class ArchivableFilesFinder extends \FilterIterator /** * Initializes the internal Symfony Finder with appropriate filters * - * @param string $sources Path to source files to be archived - * @param array $excludes Composer's own exclude rules from composer.json - * @param bool $ignoreFilters Ignore filters when looking for files + * @param string $sources Path to source files to be archived + * @param string[] $excludes Composer's own exclude rules from composer.json + * @param bool $ignoreFilters Ignore filters when looking for files */ public function __construct($sources, array $excludes, $ignoreFilters = false) { diff --git a/src/Composer/Package/Archiver/ArchiveManager.php b/src/Composer/Package/Archiver/ArchiveManager.php index 356c53646..d41d5df1b 100644 --- a/src/Composer/Package/Archiver/ArchiveManager.php +++ b/src/Composer/Package/Archiver/ArchiveManager.php @@ -52,6 +52,8 @@ class ArchiveManager /** * @param ArchiverInterface $archiver + * + * @return void */ public function addArchiver(ArchiverInterface $archiver) { diff --git a/src/Composer/Package/Archiver/BaseExcludeFilter.php b/src/Composer/Package/Archiver/BaseExcludeFilter.php index 0d9fda409..71462ef98 100644 --- a/src/Composer/Package/Archiver/BaseExcludeFilter.php +++ b/src/Composer/Package/Archiver/BaseExcludeFilter.php @@ -44,7 +44,7 @@ abstract class BaseExcludeFilter * Negated patterns overwrite exclude decisions of previous filters. * * @param string $relativePath The file's path relative to the sourcePath - * @param bool $exclude Whether a previous filter wants to exclude this file + * @param bool $exclude Whether a previous filter wants to exclude this file * * @return bool Whether the file should be excluded */ @@ -70,10 +70,10 @@ abstract class BaseExcludeFilter /** * Processes a file containing exclude rules of different formats per line * - * @param array $lines A set of lines to be parsed + * @param string[] $lines A set of lines to be parsed * @param callable $lineParser The parser to be used on each line * - * @return array Exclude patterns to be used in filter() + * @return array Exclude patterns to be used in filter() */ protected function parseLines(array $lines, $lineParser) { @@ -99,9 +99,9 @@ abstract class BaseExcludeFilter /** * Generates a set of exclude patterns for filter() from gitignore rules * - * @param array $rules A list of exclude rules in gitignore syntax + * @param string[] $rules A list of exclude rules in gitignore syntax * - * @return array Exclude patterns + * @return array Exclude patterns */ protected function generatePatterns($rules) { @@ -118,7 +118,7 @@ abstract class BaseExcludeFilter * * @param string $rule An exclude rule in gitignore syntax * - * @return array An exclude pattern + * @return array{0: string, 1: bool, 2: bool} An exclude pattern */ protected function generatePattern($rule) { diff --git a/src/Composer/Package/Archiver/ComposerExcludeFilter.php b/src/Composer/Package/Archiver/ComposerExcludeFilter.php index 9e663869c..3a5a5179d 100644 --- a/src/Composer/Package/Archiver/ComposerExcludeFilter.php +++ b/src/Composer/Package/Archiver/ComposerExcludeFilter.php @@ -20,8 +20,8 @@ namespace Composer\Package\Archiver; class ComposerExcludeFilter extends BaseExcludeFilter { /** - * @param string $sourcePath Directory containing sources to be filtered - * @param array $excludeRules An array of exclude rules from composer.json + * @param string $sourcePath Directory containing sources to be filtered + * @param string[] $excludeRules An array of exclude rules from composer.json */ public function __construct($sourcePath, array $excludeRules) { diff --git a/src/Composer/Package/Archiver/GitExcludeFilter.php b/src/Composer/Package/Archiver/GitExcludeFilter.php index f79734855..f08d460f7 100644 --- a/src/Composer/Package/Archiver/GitExcludeFilter.php +++ b/src/Composer/Package/Archiver/GitExcludeFilter.php @@ -52,7 +52,7 @@ class GitExcludeFilter extends BaseExcludeFilter * * @param string $line A line from .gitignore * - * @return array An exclude pattern for filter() + * @return array{0: string, 1: bool, 2: bool} An exclude pattern for filter() */ public function parseGitIgnoreLine($line) { @@ -64,7 +64,7 @@ class GitExcludeFilter extends BaseExcludeFilter * * @param string $line A line from .gitattributes * - * @return array|null An exclude pattern for filter() + * @return array{0: string, 1: bool, 2: bool}|null An exclude pattern for filter() */ public function parseGitAttributesLine($line) { diff --git a/src/Composer/Package/Archiver/HgExcludeFilter.php b/src/Composer/Package/Archiver/HgExcludeFilter.php index b83b7756b..95880475e 100644 --- a/src/Composer/Package/Archiver/HgExcludeFilter.php +++ b/src/Composer/Package/Archiver/HgExcludeFilter.php @@ -54,7 +54,7 @@ class HgExcludeFilter extends BaseExcludeFilter * * @param string $line A line from .hgignore * - * @return array|null An exclude pattern for filter() + * @return array{0: string, 1: bool, 2: bool}|null An exclude pattern for filter() */ public function parseHgIgnoreLine($line) { @@ -80,7 +80,7 @@ class HgExcludeFilter extends BaseExcludeFilter * * @param string $line A line from .hgignore in glob mode * - * @return array An exclude pattern for filter() + * @return array{0: string, 1: bool, 2: bool} An exclude pattern for filter() */ protected function patternFromGlob($line) { @@ -95,7 +95,7 @@ class HgExcludeFilter extends BaseExcludeFilter * * @param string $line A line from .hgignore in regexp mode * - * @return array An exclude pattern for filter() + * @return array{0: string, 1: bool, 2: bool} An exclude pattern for filter() */ public function patternFromRegex($line) { diff --git a/src/Composer/Package/Archiver/ZipArchiver.php b/src/Composer/Package/Archiver/ZipArchiver.php index 3be7ccc71..20d279086 100644 --- a/src/Composer/Package/Archiver/ZipArchiver.php +++ b/src/Composer/Package/Archiver/ZipArchiver.php @@ -84,6 +84,9 @@ class ZipArchiver implements ArchiverInterface return isset(static::$formats[$format]) && $this->compressionAvailable(); } + /** + * @return bool + */ private function compressionAvailable() { return class_exists('ZipArchive');