Doc #79521 [Opn]: Fix `__set_state` documentation
| From: | requinix@php.net | Date: | Sun, 26 Apr 2020 03:06:10 +0000 |
| Subject: | Doc #79521 [Opn]: Fix `__set_state` documentation | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-17517@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79521&edit=1
ID: 79521
Updated by: requinix@php.net
Reported by: carusogabriel@php.net
Summary: Fix
__set_state documentation
Status: Open
Type: Documentation Problem
-Package: Documentation problem
+Package: Class/Object related
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
The fact that you can get away without arguments is for the usual reasons: the signature of
__set_state is not enforced by the engine, and it is not an error to pass more arguments than are
defined in a function signature.
The return value is simply being ignored. Also not an error.
Related: the magic-methods-signature RFC
https://wiki.php.net/rfc/magic-methods-signature
It doesn't include __set_state, but this is likely just an oversight.
See also bug #69718
Previous Comments:
------------------------------------------------------------------------
[2020-04-26 02:59:47] carusogabriel@php.net
Description:
------------
The documentation (https://php.net/manual/en/language.oop5.magic.php#object.set-state) of the magic
method __set_state says:
- it MUST take an array argument
- it MUST return an object
Ok, two problems:
- it CAN take an argument, is not mandatory, e.g.: https://3v4l.org/gTlmV
- it CAN return, is not mandatory: https://3v4l.org/SG8Hs
Should we fix its documentation? Something like
-static __set_state ( array $properties ) : object
+static __set_state ( [array $properties] ) : mixed
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79521&edit=1