diff --git a/.github/workflows/integrate.yaml b/.github/workflows/integrate.yaml index 44fbb68..ebd2abc 100644 --- a/.github/workflows/integrate.yaml +++ b/.github/workflows/integrate.yaml @@ -18,8 +18,8 @@ jobs: fail-fast: false matrix: php-version: - - 8.0 - 8.1 + - 8.2 dependencies: - highest @@ -64,20 +64,14 @@ jobs: fail-fast: false matrix: php-version: - - 8.0 - 8.1 - 8.2 symfony-version: - - 5 - 6 - 7 exclude: - - php-version: 8.0 - symfony-version: 6 - - php-version: 8.0 - symfony-version: 7 - php-version: 8.1 symfony-version: 7 diff --git a/README.md b/README.md index b793748..ccac626 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ vendor/bin/psalm-plugin enable psalm/plugin-symfony | Symfony Psalm Plugin | PHP | Symfony | Psalm | |----------------------|------------|---------|-------| -| 5.x | ^7.4, ^8.0 | 5, 6, 7 | 5 | +| 5.x | ^8.0 | 5, 6, 7 | 5 | | 4.x | ^7.4, ^8.0 | 4, 5, 6 | 4 | | 3.x | ^7.1, ^8.0 | 4, 5, 6 | 4 | | 2.x | ^7.1, ^8.0 | 4, 5 | 4 | diff --git a/composer.json b/composer.json index 6d3bc61..d30e15d 100644 --- a/composer.json +++ b/composer.json @@ -10,10 +10,10 @@ } ], "require": { - "php": "^7.4 || ^8.0", + "php": "^8.1", "ext-simplexml": "*", "symfony/framework-bundle": "^5.0 || ^6.0 || ^7.0", - "vimeo/psalm": "^5.1" + "vimeo/psalm": "^5.24" }, "require-dev": { "symfony/form": "^5.0 || ^6.0 || ^7.0", diff --git a/src/Handler/ContainerHandler.php b/src/Handler/ContainerHandler.php index 849e300..e750deb 100644 --- a/src/Handler/ContainerHandler.php +++ b/src/Handler/ContainerHandler.php @@ -35,10 +35,7 @@ class ContainerHandler implements AfterMethodCallAnalysisInterface, AfterClassLi 'Symfony\Bundle\FrameworkBundle\Test\TestContainer', ]; - /** - * @var ContainerMeta|null - */ - private static $containerMeta; + private static ?ContainerMeta $containerMeta = null; /** * @var array collection of cower-cased class names that are present in the container @@ -114,7 +111,7 @@ public static function afterMethodCallAnalysis(AfterMethodCallAnalysisEvent $eve } else { try { $serviceId = \constant($className.'::'.$idArgument->name->name); - } catch (\Exception $e) { + } catch (\Exception) { return; } } @@ -133,7 +130,7 @@ public static function afterMethodCallAnalysis(AfterMethodCallAnalysisEvent $eve } $class = $service->getClass(); - if ($class) { + if (null !== $class) { $codebase->classlikes->addFullyQualifiedClassName($class); $event->setReturnTypeCandidate(new Union([new TNamedObject($class)])); } @@ -152,7 +149,7 @@ public static function afterMethodCallAnalysis(AfterMethodCallAnalysisEvent $eve ); } } - } catch (ServiceNotFoundException $e) { + } catch (ServiceNotFoundException) { IssueBuffer::accepts( new ServiceNotFound($serviceId, new CodeLocation($statements_source, $firstArg->value)), $statements_source->getSuppressedIssues() @@ -160,7 +157,7 @@ public static function afterMethodCallAnalysis(AfterMethodCallAnalysisEvent $eve } } - public static function afterClassLikeVisit(AfterClassLikeVisitEvent $event) + public static function afterClassLikeVisit(AfterClassLikeVisitEvent $event): void { $codebase = $event->getCodebase(); $statements_source = $event->getStatementsSource(); @@ -221,7 +218,7 @@ function ($c) use ($methodName) { private static function followsParameterNamingConvention(string $name): bool { - if (0 === strpos($name, 'env(')) { + if (str_starts_with($name, 'env(')) { return true; } diff --git a/src/Symfony/ContainerMeta.php b/src/Symfony/ContainerMeta.php index e055ac8..e7d86bb 100644 --- a/src/Symfony/ContainerMeta.php +++ b/src/Symfony/ContainerMeta.php @@ -19,22 +19,19 @@ class ContainerMeta /** * @var array */ - private $classNames = []; + private array $classNames = []; /** * @var array */ - private $classLocators = []; + private array $classLocators = []; /** * @var array> */ - private $serviceLocators = []; + private array $serviceLocators = []; - /** - * @var ContainerBuilder - */ - private $container; + private ContainerBuilder $container; public function __construct(array $containerXmlPaths) { @@ -67,10 +64,7 @@ public function get(string $id, ?string $contextClass = null): Definition return $definition; } - /** - * @return mixed|null - */ - public function getParameter(string $key) + public function getParameter(string $key): mixed { return $this->container->getParameter($key); } @@ -111,7 +105,7 @@ private function init(array $containerXmlPaths): void $this->classLocators[$this->container->getDefinition($id)->getClass() ?? $id] = (string) $reference; } elseif ($definition->hasTag('container.service_locator')) { continue; - } elseif ($className = $definition->getClass()) { + } elseif (null !== $className = $definition->getClass()) { $this->classNames[] = $className; } } @@ -138,10 +132,10 @@ private function addServiceLocator(string $key, string $id, Reference $reference try { $definition = $this->getDefinition((string) $reference); $className = $definition->getClass(); - if ($className) { + if (null !== $className) { $this->classNames[] = $className; } - } catch (ServiceNotFoundException $e) { + } catch (ServiceNotFoundException) { } } @@ -155,7 +149,7 @@ private function getDefinition(string $id): Definition } catch (ServiceNotFoundException $serviceNotFoundException) { try { $alias = $this->container->getAlias($id); - } catch (InvalidArgumentException $e) { + } catch (InvalidArgumentException) { throw $serviceNotFoundException; }