-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjust UnusedPrivateConstantRule for dynamic class constants
- Loading branch information
1 parent
1e32f7c
commit 1bf37b9
Showing
3 changed files
with
62 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
tests/PHPStan/Rules/DeadCode/data/unused-private-constant-dynamic-fetch.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php // lint >= 8.3 | ||
|
||
namespace UnusedPrivateConstantDynamicFetch; | ||
|
||
class Foo | ||
{ | ||
|
||
private const FOO = 1; | ||
|
||
public function doFoo(string $s): void | ||
{ | ||
echo self::{$s}; | ||
} | ||
|
||
} | ||
|
||
class Bar | ||
{ | ||
|
||
private const FOO = 1; | ||
|
||
public function doFoo(self $a, string $s): void | ||
{ | ||
echo $a::{$s}; | ||
} | ||
|
||
} | ||
|
||
class Baz | ||
{ | ||
|
||
private const FOO = 1; | ||
|
||
public function doFoo(\stdClass $a, string $s): void | ||
{ | ||
echo $a::{$s}; | ||
} | ||
|
||
} |