Skip to content

Commit

Permalink
Allow phpstan 2.x (#17)
Browse files Browse the repository at this point in the history
* Allow phpstan 2.x

* Attempt fixing windows CI
  • Loading branch information
Seldaek authored Nov 25, 2024
1 parent 9ab27fb commit 4b0a223
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
6 changes: 4 additions & 2 deletions src/PhpFileParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class PhpFileParser
*
* @param string $path The file to check
* @throws \RuntimeException
* @return array<int, class-string> The found classes
* @return list<class-string> The found classes
*/
public static function findClasses(string $path): array
{
Expand Down Expand Up @@ -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;
}
}

Expand Down
6 changes: 3 additions & 3 deletions tests/ClassMapGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down

0 comments on commit 4b0a223

Please sign in to comment.