Skip to content

Commit

Permalink
Fix including relative path
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Sep 23, 2024
1 parent 4605833 commit 098fb94
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/Rules/Keywords/RequireFileExistsRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ private function doesFileExist(string $path, Scope $scope): bool
private function doesFileExistForDirectory(string $path, string $workingDirectory): bool
{
$fileHelper = new FileHelper($workingDirectory);
$normalisedPath = $fileHelper->normalizePath($path);
$absolutePath = $fileHelper->absolutizePath($normalisedPath);
$absolutePath = $fileHelper->absolutizePath($path);

return is_file($absolutePath);
}
Expand Down
5 changes: 5 additions & 0 deletions tests/PHPStan/Rules/Keywords/RequireFileExistsRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,9 @@ public function testRelativePathWithSameWorkingDirectory(): void
$this->analyse([__DIR__ . '/data/require-file-relative-path.php'], []);
}

public function testBug11738(): void
{
$this->analyse([__DIR__ . '/data/bug-11738/bug-11738.php'], []);
}

}
2 changes: 2 additions & 0 deletions tests/PHPStan/Rules/Keywords/data/bug-11738-included.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php

3 changes: 3 additions & 0 deletions tests/PHPStan/Rules/Keywords/data/bug-11738/bug-11738.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

require_once('../bug-11738-included.php');

0 comments on commit 098fb94

Please sign in to comment.