Skip to content

Commit 7c3f635

Browse files
committed
Test that it cannot read class properties
1 parent 24a9650 commit 7c3f635

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PHPStan\Rules\Keywords;
6+
7+
class ClassThatContainsProperties
8+
{
9+
public string $fileDoesNotExist = 'a-file-that-does-not-exist.php';
10+
}

tests/PHPStan/Rules/Keywords/RequireFileExistsRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,9 @@ public function testFileExistsUsingDIR(): void
8282
{
8383
$this->analyse([__DIR__ . '/data/file-exists-using-DIR.php'], []);
8484
}
85+
86+
public function testFileDoesNotExistButUsesClassProperties(): void
87+
{
88+
$this->analyse([__DIR__ . '/data/file-does-not-exist-but-uses-a-class-property.php'], []);
89+
}
8590
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php declare(strict_types=1);
2+
3+
use PHPStan\Rules\Keywords\ClassThatContainsProperties;
4+
5+
$class = new ClassThatContainsProperties();
6+
7+
include $class->fileDoesNotExist;
8+
include_once $class->fileDoesNotExist;
9+
require $class->fileDoesNotExist;
10+
require_once $class->fileDoesNotExist;

0 commit comments

Comments
 (0)