Bug #79925 [Opn->Ver]: Magic method __set_state signature check does not support covariance
| From: | requinix@php.net | Date: | Sun, 02 Aug 2020 21:42:56 +0000 |
| Subject: | Bug #79925 [Opn->Ver]: Magic method __set_state signature check does not support covariance | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-228379@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79925&edit=1
ID: 79925
Updated by: requinix@php.net
Reported by: ondrej at mirtes dot cz
Summary: Magic method __set_state signature check does not
support covariance
-Status: Open
+Status: Verified
Type: Bug
-Package: *General Issues
+Package: Class/Object related
Operating System: All
PHP Version: 8.0Git-2020-08-02 (Git)
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2020-08-02 21:35:54] ondrej at mirtes dot cz
Description:
------------
Magic methods from this RFC https://wiki.php.net/rfc/magic-methods-signature
should support covariance but don't. You should be able to narrow down a return type but
currently can't.
Test script:
---------------
<?php
class Foo
{
/**
* @param mixed[] $properties
* @return Type
*/
public static function __set_state(array $properties): self
{
return new self();
}
}
Expected result:
----------------
nothing
Actual result:
--------------
Fatal error: Foo::__set_state(): Return type must be object when declared in...
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79925&edit=1