From e49edb31bbf52c1fd8923301d5c8b0f33a2a9673 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 13 Jun 2026 15:52:25 +0200 Subject: [PATCH 01/12] Fix "Differing behaviors when requiring or including relatively vs using __DIR__" --- src/Rules/Keywords/RequireFileExistsRule.php | 22 ++++++++++++++++--- .../Keywords/RequireFileExistsRuleTest.php | 6 ++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/Rules/Keywords/RequireFileExistsRule.php b/src/Rules/Keywords/RequireFileExistsRule.php index b0d4def3093..cfd76c79494 100644 --- a/src/Rules/Keywords/RequireFileExistsRule.php +++ b/src/Rules/Keywords/RequireFileExistsRule.php @@ -3,11 +3,13 @@ namespace PHPStan\Rules\Keywords; use PhpParser\Node; +use PhpParser\Node\Expr; use PhpParser\Node\Expr\Include_; use PHPStan\Analyser\Scope; use PHPStan\DependencyInjection\AutowiredParameter; use PHPStan\DependencyInjection\RegisteredRule; use PHPStan\File\FileHelper; +use PHPStan\Node\Printer\ExprPrinter; use PHPStan\Rules\IdentifierRuleError; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleErrorBuilder; @@ -30,6 +32,7 @@ final class RequireFileExistsRule implements Rule public function __construct( #[AutowiredParameter] private string $currentWorkingDirectory, + private ExprPrinter $exprPrinter, ) { } @@ -49,7 +52,7 @@ public function processNode(Node $node, Scope $scope): array continue; } - $errors[] = $this->getErrorMessage($node, $path); + $errors[] = $this->getErrorMessage($node, $this->exprPrinter->printExpr($node->expr)); } return $errors; @@ -90,7 +93,7 @@ private function doesFileExistForDirectory(string $path, string $workingDirector private function getErrorMessage(Include_ $node, string $filePath): IdentifierRuleError { - $message = 'Path in %s() "%s" is not a file or it does not exist.'; + $message = 'Path in %s() %s is not a file or it does not exist.'; switch ($node->type) { case Include_::TYPE_REQUIRE: @@ -130,7 +133,7 @@ private function getErrorMessage(Include_ $node, string $filePath): IdentifierRu private function resolveFilePaths(Include_ $node, Scope $scope): array { $paths = []; - $type = $scope->getType($node->expr); + $type = $scope->getType($this->resolveMagicPaths($node->expr, $scope)); $constantStrings = $type->getConstantStrings(); foreach ($constantStrings as $constantString) { @@ -140,4 +143,17 @@ private function resolveFilePaths(Include_ $node, Scope $scope): array return $paths; } + private function resolveMagicPaths(Expr $expr, Scope $scope): Expr + { + if (!$expr instanceof Expr\BinaryOp\Concat) { + return $expr; + } + + if ($expr->left instanceof Node\Scalar\MagicConst\Dir && $expr->right instanceof Node\Scalar\String_) { + return new Node\Scalar\String_(dirname($scope->getFile()). $expr->right->value); + } + + return $expr; + } + } diff --git a/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleTest.php b/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleTest.php index 732819b506c..1527b6598ff 100644 --- a/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleTest.php +++ b/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleTest.php @@ -2,6 +2,7 @@ namespace PHPStan\Rules\Keywords; +use PHPStan\Node\Printer\ExprPrinter; use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use function get_include_path; @@ -21,7 +22,10 @@ class RequireFileExistsRuleTest extends RuleTestCase protected function getRule(): Rule { - return new RequireFileExistsRule($this->currentWorkingDirectory); + return new RequireFileExistsRule( + $this->currentWorkingDirectory, + self::getContainer()->getByType(ExprPrinter::class) + ); } public static function getAdditionalConfigFiles(): array From 3b43a97f8f772a0dfb51c8dc00330d0bf99452cd Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 13 Jun 2026 16:06:12 +0200 Subject: [PATCH 02/12] Update RequireFileExistsRule.php --- src/Rules/Keywords/RequireFileExistsRule.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Rules/Keywords/RequireFileExistsRule.php b/src/Rules/Keywords/RequireFileExistsRule.php index cfd76c79494..ae314a8dd84 100644 --- a/src/Rules/Keywords/RequireFileExistsRule.php +++ b/src/Rules/Keywords/RequireFileExistsRule.php @@ -52,7 +52,12 @@ public function processNode(Node $node, Scope $scope): array continue; } - $errors[] = $this->getErrorMessage($node, $this->exprPrinter->printExpr($node->expr)); + $pathExpr = $this->exprPrinter->printExpr($node->expr); + if (!str_contains('"', $pathExpr)) { + $pathExpr = '"' . trim($path, "'") . '"'; + } + + $errors[] = $this->getErrorMessage($node, $pathExpr); } return $errors; From 0c3c91ce5b2531996c06cac3fd95c661b015aed2 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 13 Jun 2026 16:07:48 +0200 Subject: [PATCH 03/12] Create RequireFileExistsRuleNoConstantPathTest.php --- ...equireFileExistsRuleNoConstantPathTest.php | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tests/PHPStan/Rules/Keywords/RequireFileExistsRuleNoConstantPathTest.php diff --git a/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleNoConstantPathTest.php b/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleNoConstantPathTest.php new file mode 100644 index 00000000000..ecb65f04ddd --- /dev/null +++ b/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleNoConstantPathTest.php @@ -0,0 +1,45 @@ + + */ +class RequireFileExistsRuleNoConstantPathTest extends RuleTestCase +{ + + private string $currentWorkingDirectory = __DIR__ . '/../'; + + protected function getRule(): Rule + { + return new RequireFileExistsRule( + $this->currentWorkingDirectory, + self::getContainer()->getByType(ExprPrinter::class) + ); + } + + public function testBug12203NoConstantPath(): void + { + $this->analyse([__DIR__ . '/data/bug-12203.php'], [ + [ + 'Path in require_once() "../bug-12203-sure-does-not-exist.php" is not a file or it does not exist.', + 5, + ], + [ + 'Path in require_once() "' . __DIR__ . DIRECTORY_SEPARATOR . 'data/../bug-12203-sure-does-not-exist.php" is not a file or it does not exist.', + 6, + ], + ]); + } + +} From 981b7d23acb49d6b5582bae5064939bfbf099af1 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 13 Jun 2026 16:11:55 +0200 Subject: [PATCH 04/12] Update RequireFileExistsRule.php --- src/Rules/Keywords/RequireFileExistsRule.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Rules/Keywords/RequireFileExistsRule.php b/src/Rules/Keywords/RequireFileExistsRule.php index ae314a8dd84..7dd9c880ad9 100644 --- a/src/Rules/Keywords/RequireFileExistsRule.php +++ b/src/Rules/Keywords/RequireFileExistsRule.php @@ -20,6 +20,8 @@ use function get_include_path; use function is_file; use function sprintf; +use function str_contains; +use function trim; use const PATH_SEPARATOR; /** @@ -155,7 +157,7 @@ private function resolveMagicPaths(Expr $expr, Scope $scope): Expr } if ($expr->left instanceof Node\Scalar\MagicConst\Dir && $expr->right instanceof Node\Scalar\String_) { - return new Node\Scalar\String_(dirname($scope->getFile()). $expr->right->value); + return new Node\Scalar\String_(dirname($scope->getFile()) . $expr->right->value); } return $expr; From 489a70054980fe75fb3eb3374dba82b727927351 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 13 Jun 2026 16:12:25 +0200 Subject: [PATCH 05/12] cs --- .../Keywords/RequireFileExistsRuleNoConstantPathTest.php | 7 +------ tests/PHPStan/Rules/Keywords/RequireFileExistsRuleTest.php | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleNoConstantPathTest.php b/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleNoConstantPathTest.php index ecb65f04ddd..d6534763687 100644 --- a/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleNoConstantPathTest.php +++ b/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleNoConstantPathTest.php @@ -5,12 +5,7 @@ use PHPStan\Node\Printer\ExprPrinter; use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; -use function get_include_path; -use function implode; -use function realpath; -use function set_include_path; use const DIRECTORY_SEPARATOR; -use const PATH_SEPARATOR; /** * @extends RuleTestCase @@ -24,7 +19,7 @@ protected function getRule(): Rule { return new RequireFileExistsRule( $this->currentWorkingDirectory, - self::getContainer()->getByType(ExprPrinter::class) + self::getContainer()->getByType(ExprPrinter::class), ); } diff --git a/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleTest.php b/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleTest.php index 1527b6598ff..42f23734f74 100644 --- a/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleTest.php +++ b/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleTest.php @@ -24,7 +24,7 @@ protected function getRule(): Rule { return new RequireFileExistsRule( $this->currentWorkingDirectory, - self::getContainer()->getByType(ExprPrinter::class) + self::getContainer()->getByType(ExprPrinter::class), ); } From 5d19ffd1c2e491b1ef2d32c30075f9b75340a595 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 13 Jun 2026 16:31:47 +0200 Subject: [PATCH 06/12] skip lines within file_exists()/is_file() --- src/Rules/Keywords/RequireFileExistsRule.php | 22 +++++++++++++++++++ ...equireFileExistsRuleNoConstantPathTest.php | 5 +++++ .../Keywords/RequireFileExistsRuleTest.php | 5 +++++ .../Keywords/data/include-in-file-exists.php | 9 ++++++++ 4 files changed, 41 insertions(+) create mode 100644 tests/PHPStan/Rules/Keywords/data/include-in-file-exists.php diff --git a/src/Rules/Keywords/RequireFileExistsRule.php b/src/Rules/Keywords/RequireFileExistsRule.php index 7dd9c880ad9..fefd9255baa 100644 --- a/src/Rules/Keywords/RequireFileExistsRule.php +++ b/src/Rules/Keywords/RequireFileExistsRule.php @@ -3,8 +3,11 @@ namespace PHPStan\Rules\Keywords; use PhpParser\Node; +use PhpParser\Node\Arg; use PhpParser\Node\Expr; +use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Expr\Include_; +use PhpParser\Node\Name\FullyQualified; use PHPStan\Analyser\Scope; use PHPStan\DependencyInjection\AutowiredParameter; use PHPStan\DependencyInjection\RegisteredRule; @@ -49,6 +52,10 @@ public function processNode(Node $node, Scope $scope): array $errors = []; $paths = $this->resolveFilePaths($node, $scope); + if ($this->isInFileExists($node, $scope)) { + return []; + } + foreach ($paths as $path) { if ($this->doesFileExist($path, $scope)) { continue; @@ -163,4 +170,19 @@ private function resolveMagicPaths(Expr $expr, Scope $scope): Expr return $expr; } + private function isInFileExists(Include_|Node $node, Scope $scope) + { + foreach (['file_exists', 'is_file'] as $funcName) { + $expr = new FuncCall(new FullyQualified($funcName), [ + new Arg($node->expr), + ]); + + if ($scope->getType($expr)->isTrue()->yes()) { + return true; + } + } + + return false; + } + } diff --git a/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleNoConstantPathTest.php b/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleNoConstantPathTest.php index d6534763687..c6cc169760c 100644 --- a/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleNoConstantPathTest.php +++ b/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleNoConstantPathTest.php @@ -37,4 +37,9 @@ public function testBug12203NoConstantPath(): void ]); } + public function testInFileExists(): void + { + $this->analyse([__DIR__ . '/data/include-in-file-exists.php'], []); + } + } diff --git a/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleTest.php b/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleTest.php index 42f23734f74..df58cbfd654 100644 --- a/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleTest.php +++ b/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleTest.php @@ -140,4 +140,9 @@ public function testBug12203(): void ]); } + public function testInFileExists(): void + { + $this->analyse([__DIR__ . '/data/include-in-file-exists.php'], []); + } + } diff --git a/tests/PHPStan/Rules/Keywords/data/include-in-file-exists.php b/tests/PHPStan/Rules/Keywords/data/include-in-file-exists.php new file mode 100644 index 00000000000..74e271d3309 --- /dev/null +++ b/tests/PHPStan/Rules/Keywords/data/include-in-file-exists.php @@ -0,0 +1,9 @@ + Date: Sat, 13 Jun 2026 16:35:53 +0200 Subject: [PATCH 07/12] Update RequireFileExistsRule.php --- src/Rules/Keywords/RequireFileExistsRule.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Rules/Keywords/RequireFileExistsRule.php b/src/Rules/Keywords/RequireFileExistsRule.php index fefd9255baa..06a70d530fd 100644 --- a/src/Rules/Keywords/RequireFileExistsRule.php +++ b/src/Rules/Keywords/RequireFileExistsRule.php @@ -170,7 +170,7 @@ private function resolveMagicPaths(Expr $expr, Scope $scope): Expr return $expr; } - private function isInFileExists(Include_|Node $node, Scope $scope) + private function isInFileExists(Include_ $node, Scope $scope): bool { foreach (['file_exists', 'is_file'] as $funcName) { $expr = new FuncCall(new FullyQualified($funcName), [ From aef31618e7940d35297d5ae72c89119f15f5e038 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 13 Jun 2026 16:45:34 +0200 Subject: [PATCH 08/12] Update RequireFileExistsRule.php --- src/Rules/Keywords/RequireFileExistsRule.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Rules/Keywords/RequireFileExistsRule.php b/src/Rules/Keywords/RequireFileExistsRule.php index 06a70d530fd..a9a14540408 100644 --- a/src/Rules/Keywords/RequireFileExistsRule.php +++ b/src/Rules/Keywords/RequireFileExistsRule.php @@ -164,7 +164,7 @@ private function resolveMagicPaths(Expr $expr, Scope $scope): Expr } if ($expr->left instanceof Node\Scalar\MagicConst\Dir && $expr->right instanceof Node\Scalar\String_) { - return new Node\Scalar\String_(dirname($scope->getFile()) . $expr->right->value); + return new Node\Scalar\String_(dirname($scope->getFile()) .'/'. $expr->right->value); } return $expr; From 1d5e64d79bf64aa0010e9c6ccef7504633128e2b Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 13 Jun 2026 16:47:59 +0200 Subject: [PATCH 09/12] Revert "Update RequireFileExistsRule.php" This reverts commit aef31618e7940d35297d5ae72c89119f15f5e038. --- src/Rules/Keywords/RequireFileExistsRule.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Rules/Keywords/RequireFileExistsRule.php b/src/Rules/Keywords/RequireFileExistsRule.php index a9a14540408..06a70d530fd 100644 --- a/src/Rules/Keywords/RequireFileExistsRule.php +++ b/src/Rules/Keywords/RequireFileExistsRule.php @@ -164,7 +164,7 @@ private function resolveMagicPaths(Expr $expr, Scope $scope): Expr } if ($expr->left instanceof Node\Scalar\MagicConst\Dir && $expr->right instanceof Node\Scalar\String_) { - return new Node\Scalar\String_(dirname($scope->getFile()) .'/'. $expr->right->value); + return new Node\Scalar\String_(dirname($scope->getFile()) . $expr->right->value); } return $expr; From 0fa6512a45bfcefcd5838546f4e8ac6aa39c06d5 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 13 Jun 2026 21:11:33 +0200 Subject: [PATCH 10/12] Update RequireFileExistsRule.php --- src/Rules/Keywords/RequireFileExistsRule.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Rules/Keywords/RequireFileExistsRule.php b/src/Rules/Keywords/RequireFileExistsRule.php index 06a70d530fd..6c1e8ee2072 100644 --- a/src/Rules/Keywords/RequireFileExistsRule.php +++ b/src/Rules/Keywords/RequireFileExistsRule.php @@ -49,20 +49,20 @@ public function getNodeType(): string public function processNode(Node $node, Scope $scope): array { - $errors = []; - $paths = $this->resolveFilePaths($node, $scope); - if ($this->isInFileExists($node, $scope)) { return []; } + $errors = []; + $paths = $this->resolveFilePaths($node, $scope); + foreach ($paths as $path) { if ($this->doesFileExist($path, $scope)) { continue; } $pathExpr = $this->exprPrinter->printExpr($node->expr); - if (!str_contains('"', $pathExpr)) { + if (!str_contains($pathExpr, '"')) { $pathExpr = '"' . trim($path, "'") . '"'; } From b5cc8ad9b828a52f5b3e088711d4718752b4c67e Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 13 Jun 2026 21:18:18 +0200 Subject: [PATCH 11/12] refactor --- src/Rules/Keywords/RequireFileExistsRule.php | 30 +++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/Rules/Keywords/RequireFileExistsRule.php b/src/Rules/Keywords/RequireFileExistsRule.php index 6c1e8ee2072..84b8354bbcb 100644 --- a/src/Rules/Keywords/RequireFileExistsRule.php +++ b/src/Rules/Keywords/RequireFileExistsRule.php @@ -17,6 +17,7 @@ use PHPStan\Rules\Rule; use PHPStan\Rules\RuleErrorBuilder; use PHPStan\ShouldNotHappenException; +use PHPStan\Type\Constant\ConstantStringType; use function array_merge; use function dirname; use function explode; @@ -57,6 +58,8 @@ public function processNode(Node $node, Scope $scope): array $paths = $this->resolveFilePaths($node, $scope); foreach ($paths as $path) { + $path = $path->getValue(); + if ($this->doesFileExist($path, $scope)) { continue; } @@ -142,32 +145,25 @@ private function getErrorMessage(Include_ $node, string $filePath): IdentifierRu } /** - * @return array + * @return array */ private function resolveFilePaths(Include_ $node, Scope $scope): array { - $paths = []; - $type = $scope->getType($this->resolveMagicPaths($node->expr, $scope)); - $constantStrings = $type->getConstantStrings(); - - foreach ($constantStrings as $constantString) { - $paths[] = $constantString->getValue(); - } + $expr = $node->expr; - return $paths; - } - - private function resolveMagicPaths(Expr $expr, Scope $scope): Expr - { if (!$expr instanceof Expr\BinaryOp\Concat) { - return $expr; + return $scope->getType($expr)->getConstantStrings(); } - if ($expr->left instanceof Node\Scalar\MagicConst\Dir && $expr->right instanceof Node\Scalar\String_) { - return new Node\Scalar\String_(dirname($scope->getFile()) . $expr->right->value); + if ($expr->left instanceof Node\Scalar\MagicConst\Dir) { + $paths = []; + foreach ($scope->getType($expr->right)->getConstantStrings() as $constantString) { + $paths[] = new ConstantStringType(dirname($scope->getFile()) . $constantString->getValue()); + } + return $paths; } - return $expr; + return $scope->getType($expr)->getConstantStrings(); } private function isInFileExists(Include_ $node, Scope $scope): bool From d8a9e5227171f8b0045745020edb041cf9fcd461 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 13 Jun 2026 21:44:23 +0200 Subject: [PATCH 12/12] improve error message --- src/Rules/Keywords/RequireFileExistsRule.php | 19 +++++++++++-------- ...equireFileExistsRuleNoConstantPathTest.php | 3 +-- .../Keywords/RequireFileExistsRuleTest.php | 3 +-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/Rules/Keywords/RequireFileExistsRule.php b/src/Rules/Keywords/RequireFileExistsRule.php index 84b8354bbcb..0a3e6e35a5b 100644 --- a/src/Rules/Keywords/RequireFileExistsRule.php +++ b/src/Rules/Keywords/RequireFileExistsRule.php @@ -24,8 +24,6 @@ use function get_include_path; use function is_file; use function sprintf; -use function str_contains; -use function trim; use const PATH_SEPARATOR; /** @@ -55,7 +53,8 @@ public function processNode(Node $node, Scope $scope): array } $errors = []; - $paths = $this->resolveFilePaths($node, $scope); + $usedMagicDirFallback = false; + $paths = $this->resolveFilePaths($node, $scope, $usedMagicDirFallback); foreach ($paths as $path) { $path = $path->getValue(); @@ -64,9 +63,10 @@ public function processNode(Node $node, Scope $scope): array continue; } - $pathExpr = $this->exprPrinter->printExpr($node->expr); - if (!str_contains($pathExpr, '"')) { - $pathExpr = '"' . trim($path, "'") . '"'; + if ($usedMagicDirFallback) { + $pathExpr = $this->exprPrinter->printExpr($node->expr); + } else { + $pathExpr = '"' . $path . '"'; } $errors[] = $this->getErrorMessage($node, $pathExpr); @@ -145,10 +145,11 @@ private function getErrorMessage(Include_ $node, string $filePath): IdentifierRu } /** - * @return array + * @return list */ - private function resolveFilePaths(Include_ $node, Scope $scope): array + private function resolveFilePaths(Include_ $node, Scope $scope, bool &$magicDirFallback): array { + $magicDirFallback = false; $expr = $node->expr; if (!$expr instanceof Expr\BinaryOp\Concat) { @@ -156,6 +157,8 @@ private function resolveFilePaths(Include_ $node, Scope $scope): array } if ($expr->left instanceof Node\Scalar\MagicConst\Dir) { + $magicDirFallback = true; + $paths = []; foreach ($scope->getType($expr->right)->getConstantStrings() as $constantString) { $paths[] = new ConstantStringType(dirname($scope->getFile()) . $constantString->getValue()); diff --git a/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleNoConstantPathTest.php b/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleNoConstantPathTest.php index c6cc169760c..b967cdbe56d 100644 --- a/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleNoConstantPathTest.php +++ b/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleNoConstantPathTest.php @@ -5,7 +5,6 @@ use PHPStan\Node\Printer\ExprPrinter; use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; -use const DIRECTORY_SEPARATOR; /** * @extends RuleTestCase @@ -31,7 +30,7 @@ public function testBug12203NoConstantPath(): void 5, ], [ - 'Path in require_once() "' . __DIR__ . DIRECTORY_SEPARATOR . 'data/../bug-12203-sure-does-not-exist.php" is not a file or it does not exist.', + "Path in require_once() __DIR__ . '/../bug-12203-sure-does-not-exist.php' is not a file or it does not exist.", 6, ], ]); diff --git a/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleTest.php b/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleTest.php index df58cbfd654..ee7835c51a7 100644 --- a/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleTest.php +++ b/tests/PHPStan/Rules/Keywords/RequireFileExistsRuleTest.php @@ -9,7 +9,6 @@ use function implode; use function realpath; use function set_include_path; -use const DIRECTORY_SEPARATOR; use const PATH_SEPARATOR; /** @@ -134,7 +133,7 @@ public function testBug12203(): void 5, ], [ - 'Path in require_once() "' . __DIR__ . DIRECTORY_SEPARATOR . 'data/../bug-12203-sure-does-not-exist.php" is not a file or it does not exist.', + "Path in require_once() __DIR__ . '/../bug-12203-sure-does-not-exist.php' is not a file or it does not exist.", 6, ], ]);