From b0ec0f96ad7d1ef1fb229acc1e980149c5c58b09 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 19 Apr 2024 16:54:04 +0200 Subject: [PATCH] Update phpstan deps and fix a few array_filter issues --- composer.lock | 40 +++++++++---------- src/Composer/Command/GlobalCommand.php | 10 +++-- src/Composer/Command/InitCommand.php | 2 +- src/Composer/Command/UpdateCommand.php | 4 +- .../Package/Archiver/ArchiveManager.php | 4 +- src/Composer/Util/ErrorHandler.php | 4 +- src/Composer/Util/TlsHelper.php | 17 +++++--- .../Repository/PlatformRepositoryTest.php | 2 +- 8 files changed, 47 insertions(+), 36 deletions(-) diff --git a/composer.lock b/composer.lock index 58cc3d257..d701c6a42 100644 --- a/composer.lock +++ b/composer.lock @@ -2014,16 +2014,16 @@ "packages-dev": [ { "name": "phpstan/phpstan", - "version": "1.10.66", + "version": "1.10.67", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "94779c987e4ebd620025d9e5fdd23323903950bd" + "reference": "16ddbe776f10da6a95ebd25de7c1dbed397dc493" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/94779c987e4ebd620025d9e5fdd23323903950bd", - "reference": "94779c987e4ebd620025d9e5fdd23323903950bd", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/16ddbe776f10da6a95ebd25de7c1dbed397dc493", + "reference": "16ddbe776f10da6a95ebd25de7c1dbed397dc493", "shasum": "" }, "require": { @@ -2066,13 +2066,9 @@ { "url": "https://github.com/phpstan", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", - "type": "tidelift" } ], - "time": "2024-03-28T16:17:31+00:00" + "time": "2024-04-16T07:22:02+00:00" }, { "name": "phpstan/phpstan-deprecation-rules", @@ -2176,21 +2172,21 @@ }, { "name": "phpstan/phpstan-strict-rules", - "version": "1.5.2", + "version": "1.5.4", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-strict-rules.git", - "reference": "7a50e9662ee9f3942e4aaaf3d603653f60282542" + "reference": "8afd4af32bbff7b1f6df3d42bda45b2e661ba297" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/7a50e9662ee9f3942e4aaaf3d603653f60282542", - "reference": "7a50e9662ee9f3942e4aaaf3d603653f60282542", + "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/8afd4af32bbff7b1f6df3d42bda45b2e661ba297", + "reference": "8afd4af32bbff7b1f6df3d42bda45b2e661ba297", "shasum": "" }, "require": { "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.10.34" + "phpstan/phpstan": "^1.10.60" }, "require-dev": { "nikic/php-parser": "^4.13.0", @@ -2219,22 +2215,22 @@ "description": "Extra strict and opinionated rules for PHPStan", "support": { "issues": "https://github.com/phpstan/phpstan-strict-rules/issues", - "source": "https://github.com/phpstan/phpstan-strict-rules/tree/1.5.2" + "source": "https://github.com/phpstan/phpstan-strict-rules/tree/1.5.4" }, - "time": "2023-10-30T14:35:06+00:00" + "time": "2024-04-19T14:48:30+00:00" }, { "name": "phpstan/phpstan-symfony", - "version": "1.3.9", + "version": "1.3.12", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-symfony.git", - "reference": "a32bc86da24495025d7aafd1ba62444d4a364a98" + "reference": "f4b9407fa3203aebafd422ae8f0eb1ef94659a80" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-symfony/zipball/a32bc86da24495025d7aafd1ba62444d4a364a98", - "reference": "a32bc86da24495025d7aafd1ba62444d4a364a98", + "url": "https://api.github.com/repos/phpstan/phpstan-symfony/zipball/f4b9407fa3203aebafd422ae8f0eb1ef94659a80", + "reference": "f4b9407fa3203aebafd422ae8f0eb1ef94659a80", "shasum": "" }, "require": { @@ -2291,9 +2287,9 @@ "description": "Symfony Framework extensions and rules for PHPStan", "support": { "issues": "https://github.com/phpstan/phpstan-symfony/issues", - "source": "https://github.com/phpstan/phpstan-symfony/tree/1.3.9" + "source": "https://github.com/phpstan/phpstan-symfony/tree/1.3.12" }, - "time": "2024-03-16T16:50:20+00:00" + "time": "2024-04-14T13:30:23+00:00" }, { "name": "symfony/phpunit-bridge", diff --git a/src/Composer/Command/GlobalCommand.php b/src/Composer/Command/GlobalCommand.php index c6fc7fe7a..2841c2ae1 100644 --- a/src/Composer/Command/GlobalCommand.php +++ b/src/Composer/Command/GlobalCommand.php @@ -33,9 +33,13 @@ class GlobalCommand extends BaseCommand { $application = $this->getApplication(); if ($input->mustSuggestArgumentValuesFor('command-name')) { - $suggestions->suggestValues(array_values(array_filter(array_map(static function (Command $command) { - return $command->isHidden() ? null : $command->getName(); - }, $application->all())))); + $suggestions->suggestValues(array_values(array_filter( + array_map(static function (Command $command) { + return $command->isHidden() ? null : $command->getName(); + }, $application->all()), function (?string $cmd) { + return $cmd !== null; + } + ))); return; } diff --git a/src/Composer/Command/InitCommand.php b/src/Composer/Command/InitCommand.php index 606bff820..15228af29 100644 --- a/src/Composer/Command/InitCommand.php +++ b/src/Composer/Command/InitCommand.php @@ -87,7 +87,7 @@ EOT $io = $this->getIO(); $allowlist = ['name', 'description', 'author', 'type', 'homepage', 'require', 'require-dev', 'stability', 'license', 'autoload']; - $options = array_filter(array_intersect_key($input->getOptions(), array_flip($allowlist))); + $options = array_filter(array_intersect_key($input->getOptions(), array_flip($allowlist)), function ($val) { return $val !== null && $val !== []; }); if (isset($options['name']) && !Preg::isMatch('{^[a-z0-9_.-]+/[a-z0-9_.-]+$}D', $options['name'])) { throw new \InvalidArgumentException( diff --git a/src/Composer/Command/UpdateCommand.php b/src/Composer/Command/UpdateCommand.php index 40e566136..b4478cd04 100644 --- a/src/Composer/Command/UpdateCommand.php +++ b/src/Composer/Command/UpdateCommand.php @@ -296,7 +296,9 @@ EOT } } while (true); - $packages = array_filter($packages); + $packages = array_filter($packages, function (string $pkg) { + return $pkg !== ''; + }); if (!$packages) { throw new \InvalidArgumentException('You must enter minimum one package.'); } diff --git a/src/Composer/Package/Archiver/ArchiveManager.php b/src/Composer/Package/Archiver/ArchiveManager.php index 6efa47938..4b15fa844 100644 --- a/src/Composer/Package/Archiver/ArchiveManager.php +++ b/src/Composer/Package/Archiver/ArchiveManager.php @@ -99,7 +99,9 @@ class ArchiveManager $parts['source_reference'] = substr(sha1($sourceReference), 0, 6); } - $parts = array_filter($parts); + $parts = array_filter($parts, function (?string $part) { + return $part !== null; + }); foreach ($parts as $key => $part) { $parts[$key] = str_replace('/', '-', $part); } diff --git a/src/Composer/Util/ErrorHandler.php b/src/Composer/Util/ErrorHandler.php index 4ed0cfefb..38cf84e44 100644 --- a/src/Composer/Util/ErrorHandler.php +++ b/src/Composer/Util/ErrorHandler.php @@ -63,7 +63,9 @@ class ErrorHandler } return null; - }, array_slice(debug_backtrace(), 2)))); + }, array_slice(debug_backtrace(), 2)), function (?string $line) { + return $line !== null; + })); } } diff --git a/src/Composer/Util/TlsHelper.php b/src/Composer/Util/TlsHelper.php index aca227270..5ab2bf9c9 100644 --- a/src/Composer/Util/TlsHelper.php +++ b/src/Composer/Util/TlsHelper.php @@ -76,13 +76,18 @@ final class TlsHelper if (isset($info['extensions']['subjectAltName'])) { $subjectAltNames = Preg::split('{\s*,\s*}', $info['extensions']['subjectAltName']); - $subjectAltNames = array_filter(array_map(static function ($name): ?string { - if (0 === strpos($name, 'DNS:')) { - return strtolower(ltrim(substr($name, 4))); - } + $subjectAltNames = array_filter( + array_map(static function ($name): ?string { + if (0 === strpos($name, 'DNS:')) { + return strtolower(ltrim(substr($name, 4))); + } - return null; - }, $subjectAltNames)); + return null; + }, $subjectAltNames), + function (?string $san) { + return $san !== null; + } + ); $subjectAltNames = array_values($subjectAltNames); } diff --git a/tests/Composer/Test/Repository/PlatformRepositoryTest.php b/tests/Composer/Test/Repository/PlatformRepositoryTest.php index 74f6c3179..aa7ddb8dd 100644 --- a/tests/Composer/Test/Repository/PlatformRepositoryTest.php +++ b/tests/Composer/Test/Repository/PlatformRepositoryTest.php @@ -1237,7 +1237,7 @@ Linked Version => 1.2.11', $expectedLibraries = array_keys(array_filter($expectations, static function ($expectation): bool { return $expectation !== false; })); - self::assertCount(count(array_filter($expectedLibraries)), $libraries, sprintf('Expected: %s, got %s', var_export($expectedLibraries, true), var_export($libraries, true))); + self::assertCount(count($expectedLibraries), $libraries, sprintf('Expected: %s, got %s', var_export($expectedLibraries, true), var_export($libraries, true))); foreach ($extensions as $extension) { $expectations['ext-'.$extension] = $extensionVersion;