From 787f5036163e94839e721312072d6c0319aa19ba Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 15 Oct 2024 11:22:49 +0200 Subject: [PATCH] do not stumble over missing descriptions (#12152) --- phpstan/baseline.neon | 6 +++--- src/Composer/DependencyResolver/Problem.php | 2 +- src/Composer/Repository/RepositoryInterface.php | 2 +- src/Composer/Repository/RepositorySet.php | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/phpstan/baseline.neon b/phpstan/baseline.neon index 865d93b72..78f5ce38c 100644 --- a/phpstan/baseline.neon +++ b/phpstan/baseline.neon @@ -2381,7 +2381,7 @@ parameters: path: ../src/Composer/Repository/ComposerRepository.php - - message: "#^Method Composer\\\\Repository\\\\ComposerRepository\\:\\:getProviders\\(\\) should return array\\ but returns array\\\\.$#" + message: "#^Method Composer\\\\Repository\\\\ComposerRepository\\:\\:getProviders\\(\\) should return array\\ but returns array\\\\.$#" count: 1 path: ../src/Composer/Repository/ComposerRepository.php @@ -2496,7 +2496,7 @@ parameters: path: ../src/Composer/Repository/CompositeRepository.php - - message: "#^Only booleans are allowed in a ternary operator condition, array\\\\>\\> given\\.$#" + message: "#^Only booleans are allowed in a ternary operator condition, array\\\\>\\> given\\.$#" count: 1 path: ../src/Composer/Repository/CompositeRepository.php @@ -2714,7 +2714,7 @@ parameters: path: ../src/Composer/Repository/RepositorySet.php - - message: "#^Only booleans are allowed in an if condition, array\\\\> given\\.$#" + message: "#^Only booleans are allowed in an if condition, array\\\\> given\\.$#" count: 1 path: ../src/Composer/Repository/RepositorySet.php diff --git a/src/Composer/DependencyResolver/Problem.php b/src/Composer/DependencyResolver/Problem.php index 5576845e9..6910a39fa 100644 --- a/src/Composer/DependencyResolver/Problem.php +++ b/src/Composer/DependencyResolver/Problem.php @@ -649,7 +649,7 @@ class Problem $providers = $repositorySet->getProviders($packageName); if (\count($providers) > 0) { $providersStr = implode(array_map(static function ($p): string { - $description = $p['description'] !== '' ? ' '.substr($p['description'], 0, 100) : ''; + $description = $p['description'] !== '' ? ' '.substr($p['description'] ?? '', 0, 100) : ''; return ' - '.$p['name'].$description."\n"; }, count($providers) > $maxProviders + 1 ? array_slice($providers, 0, $maxProviders) : $providers)); diff --git a/src/Composer/Repository/RepositoryInterface.php b/src/Composer/Repository/RepositoryInterface.php index 3bcb1ea97..f90c96d50 100644 --- a/src/Composer/Repository/RepositoryInterface.php +++ b/src/Composer/Repository/RepositoryInterface.php @@ -104,7 +104,7 @@ interface RepositoryInterface extends \Countable * @param string $packageName package name which must be provided * * @return array[] an array with the provider name as key and value of array('name' => '...', 'description' => '...', 'type' => '...') - * @phpstan-return array + * @phpstan-return array */ public function getProviders(string $packageName); diff --git a/src/Composer/Repository/RepositorySet.php b/src/Composer/Repository/RepositorySet.php index 96c0c007b..dcde36327 100644 --- a/src/Composer/Repository/RepositorySet.php +++ b/src/Composer/Repository/RepositorySet.php @@ -284,7 +284,7 @@ class RepositorySet /** * @return array[] an array with the provider name as key and value of array('name' => '...', 'description' => '...', 'type' => '...') - * @phpstan-return array + * @phpstan-return array */ public function getProviders(string $packageName): array {