Skip to content

Instantly share code, notes, and snippets.

@Danack
Last active April 27, 2020 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Danack/aee8c9b6bd87a086b704a5aa6da29530 to your computer and use it in GitHub Desktop.
Save Danack/aee8c9b6bd87a086b704a5aa6da29530 to your computer and use it in GitHub Desktop.
changes_magic
s/
"Ensure correct magic methods' signatures when typed"
/
"Ensure correct signatures of magic methods"
/
Introduction
It is currently possible to write magic methods that have signatures that don't match the signature expected, such as `__toString() : float` or `__isset() : Closure`.
This behaviour of allowing incorrect signatures was reported as [a bug](https://bugs.php.net/69718).
As ensuring magic methods have correct signatures is a backward compatible break for code that currently has incorrect signatures, this change would only be appropriate in a major PHP release.
s/
This RFC proposes to introduce the following signatures checks when magic methods are typed.
Important: only, and only if, any of the listed magic methods use type hints and/or return types, these checks will be performed. In case they don't have types declared, nothing specific will happen.
/
This RFC proposes to add parameter and return types per the following details. Other magic methods will be not modified.
/
s/
The __construct and __destruct methods won't suffer any change.
/
The __construct and __destruct methods won't be changed.
/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment