1
0
Fork 0

phpstan level 6 in src/Composer/Package/Archiver (refs #10159) (#10195)

pull/10206/head
pistej 2021-10-20 21:54:38 +02:00 committed by GitHub
parent cbc686c16a
commit dbd0ccaad8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 26 additions and 16 deletions

View File

@ -36,6 +36,11 @@ class ArchivableFilesFilter extends FilterIterator
return true; return true;
} }
/**
* @param string $sources
*
* @return void
*/
public function addEmptyDir(PharData $phar, $sources) public function addEmptyDir(PharData $phar, $sources)
{ {
foreach ($this->dirs as $filepath) { foreach ($this->dirs as $filepath) {

View File

@ -35,9 +35,9 @@ class ArchivableFilesFinder extends \FilterIterator
/** /**
* Initializes the internal Symfony Finder with appropriate filters * Initializes the internal Symfony Finder with appropriate filters
* *
* @param string $sources Path to source files to be archived * @param string $sources Path to source files to be archived
* @param array $excludes Composer's own exclude rules from composer.json * @param string[] $excludes Composer's own exclude rules from composer.json
* @param bool $ignoreFilters Ignore filters when looking for files * @param bool $ignoreFilters Ignore filters when looking for files
*/ */
public function __construct($sources, array $excludes, $ignoreFilters = false) public function __construct($sources, array $excludes, $ignoreFilters = false)
{ {

View File

@ -52,6 +52,8 @@ class ArchiveManager
/** /**
* @param ArchiverInterface $archiver * @param ArchiverInterface $archiver
*
* @return void
*/ */
public function addArchiver(ArchiverInterface $archiver) public function addArchiver(ArchiverInterface $archiver)
{ {

View File

@ -44,7 +44,7 @@ abstract class BaseExcludeFilter
* Negated patterns overwrite exclude decisions of previous filters. * Negated patterns overwrite exclude decisions of previous filters.
* *
* @param string $relativePath The file's path relative to the sourcePath * @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 * @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 * 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 * @param callable $lineParser The parser to be used on each line
* *
* @return array Exclude patterns to be used in filter() * @return array<array{0: string, 1: bool, 2: bool}> Exclude patterns to be used in filter()
*/ */
protected function parseLines(array $lines, $lineParser) protected function parseLines(array $lines, $lineParser)
{ {
@ -99,9 +99,9 @@ abstract class BaseExcludeFilter
/** /**
* Generates a set of exclude patterns for filter() from gitignore rules * 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<int, array{0: string, 1: bool, 2: bool}> Exclude patterns
*/ */
protected function generatePatterns($rules) protected function generatePatterns($rules)
{ {
@ -118,7 +118,7 @@ abstract class BaseExcludeFilter
* *
* @param string $rule An exclude rule in gitignore syntax * @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) protected function generatePattern($rule)
{ {

View File

@ -20,8 +20,8 @@ namespace Composer\Package\Archiver;
class ComposerExcludeFilter extends BaseExcludeFilter class ComposerExcludeFilter extends BaseExcludeFilter
{ {
/** /**
* @param string $sourcePath Directory containing sources to be filtered * @param string $sourcePath Directory containing sources to be filtered
* @param array $excludeRules An array of exclude rules from composer.json * @param string[] $excludeRules An array of exclude rules from composer.json
*/ */
public function __construct($sourcePath, array $excludeRules) public function __construct($sourcePath, array $excludeRules)
{ {

View File

@ -52,7 +52,7 @@ class GitExcludeFilter extends BaseExcludeFilter
* *
* @param string $line A line from .gitignore * @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) public function parseGitIgnoreLine($line)
{ {
@ -64,7 +64,7 @@ class GitExcludeFilter extends BaseExcludeFilter
* *
* @param string $line A line from .gitattributes * @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) public function parseGitAttributesLine($line)
{ {

View File

@ -54,7 +54,7 @@ class HgExcludeFilter extends BaseExcludeFilter
* *
* @param string $line A line from .hgignore * @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) public function parseHgIgnoreLine($line)
{ {
@ -80,7 +80,7 @@ class HgExcludeFilter extends BaseExcludeFilter
* *
* @param string $line A line from .hgignore in glob mode * @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) protected function patternFromGlob($line)
{ {
@ -95,7 +95,7 @@ class HgExcludeFilter extends BaseExcludeFilter
* *
* @param string $line A line from .hgignore in regexp mode * @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) public function patternFromRegex($line)
{ {

View File

@ -84,6 +84,9 @@ class ZipArchiver implements ArchiverInterface
return isset(static::$formats[$format]) && $this->compressionAvailable(); return isset(static::$formats[$format]) && $this->compressionAvailable();
} }
/**
* @return bool
*/
private function compressionAvailable() private function compressionAvailable()
{ {
return class_exists('ZipArchive'); return class_exists('ZipArchive');