-
Notifications
You must be signed in to change notification settings - Fork 463
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Detect mismatch between readonly/non-readonly class parent
- Loading branch information
1 parent
795a560
commit 986cbdf
Showing
3 changed files
with
85 additions
and
0 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
41 changes: 41 additions & 0 deletions
41
tests/PHPStan/Rules/Classes/data/extends-readonly-class.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,41 @@ | ||
<?php // lint >= 8.2 | ||
|
||
namespace ExtendsReadOnlyClass; | ||
|
||
class Nonreadonly | ||
{ | ||
|
||
} | ||
|
||
readonly class ReadonlyClass | ||
{ | ||
|
||
} | ||
|
||
class Lorem extends Nonreadonly // ok | ||
{ | ||
|
||
} | ||
|
||
readonly class Ipsum extends ReadonlyClass // ok | ||
{ | ||
|
||
} | ||
|
||
readonly class Foo extends Nonreadonly // not ok | ||
{ | ||
|
||
} | ||
|
||
class Bar extends ReadonlyClass // not ok | ||
{ | ||
|
||
} | ||
|
||
new class extends ReadonlyClass { // not ok | ||
|
||
}; | ||
|
||
new readonly class extends Nonreadonly { // not ok | ||
|
||
}; |