Bug #69718 [NEW]: Return values for magics can be nonsensical
| From: | stas@php.net | Date: | Thu, 28 May 2015 07:05:23 +0000 |
| Subject: | Bug #69718 [NEW]: Return values for magics can be nonsensical | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-192953@lists.php.net to get a copy of this message | ||
From: stas
Operating system: *
PHP version: master-Git-2015-05-28 (Git)
Package: Scripting Engine problem
Bug Type: Bug
Bug description:Return values for magics can be nonsensical
Description:
------------
Since we now allow defining return value types for functions, one can
also create definition for magic functions that make no sense, such as
__toString() : float or __isset() : Closure. I think we should restrict
such definitions - either to types that makes sense or in case of
methods that aren't supposed to return anything useful, completely. We
already do this for ctors, dtors and __clone but not consistently for
other magics.
Specifically, the following should be true:
__clone - no return type
__isset - only boolean allowed as return type
__sleep - only array allowed as return type
__set - no return type
__toString - only string allowed as return type
__wakeup - no return type
Also, may make sense to restrict argument types (of course, not typing
is always ok):
__call/__callStatic - only string for first and array for second
arguments
__get/__set/__isset/__unset - only string for the first argument
__set_state - only array is allowed as argument type
--
Edit bug report at https://bugs.php.net/bug.php?id=69718&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69718&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69718&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69718&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69718&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69718&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69718&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69718&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69718&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69718&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69718&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69718&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69718&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69718&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69718&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69718&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69718&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69718&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69718&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69718&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69718&r=mysqlcfg