From 80dcee28fc97adb71f7be9c6c307ae0d9c5f140d Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 25 Nov 2024 16:49:41 +0100 Subject: [PATCH 1/2] Allow phpstan 2.x --- composer.json | 8 ++++---- src/PhpFileParser.php | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 8d22b72..496912c 100644 --- a/composer.json +++ b/composer.json @@ -20,10 +20,10 @@ }, "require-dev": { "phpunit/phpunit": "^8", - "phpstan/phpstan": "^1.6", - "phpstan/phpstan-deprecation-rules": "^1", - "phpstan/phpstan-strict-rules": "^1.1", - "phpstan/phpstan-phpunit": "^1", + "phpstan/phpstan": "^1.12 || ^2", + "phpstan/phpstan-deprecation-rules": "^1 || ^2", + "phpstan/phpstan-strict-rules": "^1.1 || ^2", + "phpstan/phpstan-phpunit": "^1 || ^2", "symfony/filesystem": "^5.4 || ^6" }, "autoload": { diff --git a/src/PhpFileParser.php b/src/PhpFileParser.php index 78622de..b687bce 100644 --- a/src/PhpFileParser.php +++ b/src/PhpFileParser.php @@ -24,7 +24,7 @@ class PhpFileParser * * @param string $path The file to check * @throws \RuntimeException - * @return array The found classes + * @return list The found classes */ public static function findClasses(string $path): array { @@ -98,7 +98,9 @@ public static function findClasses(string $path): array $name = substr($name, 0, $colonPos); } } - $classes[] = ltrim($namespace . $name, '\\'); + /** @var class-string */ + $className = ltrim($namespace . $name, '\\'); + $classes[] = $className; } } From 71088d0a289eb1b95d562e2a12737d2f18862229 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 25 Nov 2024 16:55:55 +0100 Subject: [PATCH 2/2] Attempt fixing windows CI --- tests/ClassMapGeneratorTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/ClassMapGeneratorTest.php b/tests/ClassMapGeneratorTest.php index 615e18a..f18a52e 100644 --- a/tests/ClassMapGeneratorTest.php +++ b/tests/ClassMapGeneratorTest.php @@ -283,9 +283,9 @@ public function testGetRawPSR4Violations(): void $classMap = $this->generator->getClassMap(); $rawViolations = $classMap->getRawPsrViolations(); - $classWithoutNameSpaceFilepath = __DIR__ . '/Fixtures/psrViolations/ClassWithoutNameSpace.php'; - $classWithIncorrectSubNamespaceFilepath = __DIR__ . '/Fixtures/psrViolations/ClassWithIncorrectSubNamespace.php'; - $classWithNameSpaceOutsideConfiguredScopeFilepath = __DIR__ . '/Fixtures/psrViolations/ClassWithNameSpaceOutsideConfiguredScope.php'; + $classWithoutNameSpaceFilepath = strtr(__DIR__, '\\', '/') . '/Fixtures/psrViolations/ClassWithoutNameSpace.php'; + $classWithIncorrectSubNamespaceFilepath = strtr(__DIR__, '\\', '/') . '/Fixtures/psrViolations/ClassWithIncorrectSubNamespace.php'; + $classWithNameSpaceOutsideConfiguredScopeFilepath = strtr(__DIR__, '\\', '/') . '/Fixtures/psrViolations/ClassWithNameSpaceOutsideConfiguredScope.php'; self::assertArrayHasKey($classWithoutNameSpaceFilepath, $rawViolations); self::assertCount(1, $rawViolations[$classWithoutNameSpaceFilepath]);