-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enforce __set_state() parameter type
This fixes one of the issues reported in bug #79925. The parameter type check for this particular method was missed.
- Loading branch information
Showing
2 changed files
with
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--TEST-- | ||
__set_state first parameter must be an array | ||
--FILE-- | ||
<?php | ||
|
||
class Foo { | ||
public static function __set_state(int $properties) {} | ||
} | ||
|
||
?> | ||
--EXPECTF-- | ||
Fatal error: Foo::__set_state(): Parameter #1 ($properties) must be of type array when declared in %s on line %d |
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
5d4659c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nikic Does it also allow contravariance with
mixed $properties
?5d4659c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nikic Also, thank you! You're awesome! 🔥
5d4659c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, contravariance is already allowed there (and tested for some other methods).