From ba5525fa79de94f740f47f00b37eb2b1763c6b62 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Tue, 17 Sep 2024 08:46:33 +0200 Subject: [PATCH 1/3] Normalize path in TypeInferenceTestCase --- src/Testing/TypeInferenceTestCase.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Testing/TypeInferenceTestCase.php b/src/Testing/TypeInferenceTestCase.php index a80e510da3..e95aaeb812 100644 --- a/src/Testing/TypeInferenceTestCase.php +++ b/src/Testing/TypeInferenceTestCase.php @@ -301,12 +301,14 @@ public static function findTestDataFilesFromDirectory(string $directory): array $finder = new Finder(); $finder->followLinks(); $files = []; + + $fileHelper = new FileHelper($directory); foreach ($finder->files()->name('*.php')->in($directory) as $fileInfo) { $path = $fileInfo->getPathname(); if (self::isFileLintSkipped($path)) { continue; } - $files[] = $path; + $files[] = $fileHelper->normalizePath($path); } return $files; From 6414a38f522fa750f25c1f87b99438656a827750 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Tue, 17 Sep 2024 08:57:43 +0200 Subject: [PATCH 2/3] Normalize path also outside of the nsrt/ directory --- src/Testing/TypeInferenceTestCase.php | 3 +-- tests/PHPStan/Analyser/NodeScopeResolverTest.php | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Testing/TypeInferenceTestCase.php b/src/Testing/TypeInferenceTestCase.php index e95aaeb812..f2ac734585 100644 --- a/src/Testing/TypeInferenceTestCase.php +++ b/src/Testing/TypeInferenceTestCase.php @@ -302,13 +302,12 @@ public static function findTestDataFilesFromDirectory(string $directory): array $finder->followLinks(); $files = []; - $fileHelper = new FileHelper($directory); foreach ($finder->files()->name('*.php')->in($directory) as $fileInfo) { $path = $fileInfo->getPathname(); if (self::isFileLintSkipped($path)) { continue; } - $files[] = $fileHelper->normalizePath($path); + $files[] = $path; } return $files; diff --git a/tests/PHPStan/Analyser/NodeScopeResolverTest.php b/tests/PHPStan/Analyser/NodeScopeResolverTest.php index 2b8b3b4284..a4bfe75364 100644 --- a/tests/PHPStan/Analyser/NodeScopeResolverTest.php +++ b/tests/PHPStan/Analyser/NodeScopeResolverTest.php @@ -3,6 +3,7 @@ namespace PHPStan\Analyser; use EnumTypeAssertions\Foo; +use PHPStan\File\FileHelper; use PHPStan\Testing\TypeInferenceTestCase; use stdClass; use function array_shift; @@ -209,7 +210,10 @@ public static function dataFile(): iterable $base = dirname(__DIR__, 3) . '/'; $baseLength = strlen($base); + $fileHelper = new FileHelper($base); foreach (self::findTestFiles() as $file) { + $file = $fileHelper->normalizePath($file); + $testName = $file; if (str_starts_with($file, $base)) { $testName = substr($file, $baseLength); From a52d9a596111c71a6c9ab805fe7d8237137fda10 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Tue, 17 Sep 2024 08:59:40 +0200 Subject: [PATCH 3/3] cs --- src/Testing/TypeInferenceTestCase.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Testing/TypeInferenceTestCase.php b/src/Testing/TypeInferenceTestCase.php index f2ac734585..a80e510da3 100644 --- a/src/Testing/TypeInferenceTestCase.php +++ b/src/Testing/TypeInferenceTestCase.php @@ -301,7 +301,6 @@ public static function findTestDataFilesFromDirectory(string $directory): array $finder = new Finder(); $finder->followLinks(); $files = []; - foreach ($finder->files()->name('*.php')->in($directory) as $fileInfo) { $path = $fileInfo->getPathname(); if (self::isFileLintSkipped($path)) {