Skip to content

Commit 11089aa

Browse files
authored
Merge branch refs/heads/1.12.x into 2.0.x
2 parents d453064 + 098fb94 commit 11089aa

File tree

4 files changed

+14
-22
lines changed

4 files changed

+14
-22
lines changed

src/Rules/Keywords/RequireFileExistsRule.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ private function doesFileExist(string $path, Scope $scope): bool
7777
private function doesFileExistForDirectory(string $path, string $workingDirectory): bool
7878
{
7979
$fileHelper = new FileHelper($workingDirectory);
80-
$normalisedPath = $fileHelper->normalizePath($path);
81-
$absolutePath = $fileHelper->absolutizePath($normalisedPath);
80+
$absolutePath = $fileHelper->absolutizePath($path);
8281

8382
return is_file($absolutePath);
8483
}

tests/PHPStan/Rules/Keywords/RequireFileExistsRuleTest.php

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,11 @@
1616
class RequireFileExistsRuleTest extends RuleTestCase
1717
{
1818

19-
private RequireFileExistsRule $rule;
20-
21-
public function setUp(): void
22-
{
23-
parent::setUp();
24-
25-
$this->rule = $this->getDefaultRule();
26-
}
19+
private string $currentWorkingDirectory = __DIR__ . '/../';
2720

2821
protected function getRule(): Rule
2922
{
30-
return $this->rule;
23+
return new RequireFileExistsRule($this->currentWorkingDirectory);
3124
}
3225

3326
public static function getAdditionalConfigFiles(): array
@@ -37,11 +30,6 @@ public static function getAdditionalConfigFiles(): array
3730
];
3831
}
3932

40-
private function getDefaultRule(): RequireFileExistsRule
41-
{
42-
return new RequireFileExistsRule(__DIR__ . '/../');
43-
}
44-
4533
public function testBasicCase(): void
4634
{
4735
$this->analyse([__DIR__ . '/data/require-file-simple-case.php'], [
@@ -124,13 +112,13 @@ public function testRelativePathWithIncludePath(): void
124112

125113
public function testRelativePathWithSameWorkingDirectory(): void
126114
{
127-
$this->rule = new RequireFileExistsRule(__DIR__);
115+
$this->currentWorkingDirectory = __DIR__;
116+
$this->analyse([__DIR__ . '/data/require-file-relative-path.php'], []);
117+
}
128118

129-
try {
130-
$this->analyse([__DIR__ . '/data/require-file-relative-path.php'], []);
131-
} finally {
132-
$this->rule = $this->getDefaultRule();
133-
}
119+
public function testBug11738(): void
120+
{
121+
$this->analyse([__DIR__ . '/data/bug-11738/bug-11738.php'], []);
134122
}
135123

136124
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
require_once('../bug-11738-included.php');

0 commit comments

Comments
 (0)