Skip to content

Commit

Permalink
add similar test for static properties
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Jul 19, 2024
1 parent d50653f commit 577a168
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace TomasVotruba\UnusedPublic\Tests\Rules\UnusedPublicPropertyRule\Fixture;

class UseBaseClassViaSubClass
class PropertyUsedViaSubClass
{
private SubClass $prop;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace TomasVotruba\UnusedPublic\Tests\Rules\UnusedPublicPropertyRule\Fixture;

class StaticPropertyUsedViaSubClass
{
private SubClass $prop;

protected function doFoo() {
$this->prop::$x = 1;
}
}

class SubClass extends BaseClass
{
}

class BaseClass
{
static public int $x;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function testRule(array $filePaths, array $expectedErrorMessagesWithLines
public static function provideData(): Iterator
{
yield [[__DIR__ . '/Fixture/PropertyUsedViaSubClass.php'], []];
yield [[__DIR__ . '/Fixture/StaticPropertyUsedViaSubClass.php'], []];

$errorMessage = sprintf(UnusedPublicPropertyRule::ERROR_MESSAGE, LocalyUsedPublicProperty::class, 'name');
yield [[__DIR__ . '/Fixture/LocalyUsedPublicProperty.php'],
Expand Down

0 comments on commit 577a168

Please sign in to comment.