[PHP-BUG] Bug #74476 [NEW]: Cast and TypeHint do not have the expected behavior
[email protected] ("tonin at bolzan dot io") Wed, 19 Apr 2017 20:02:18 GMT
| Newsgroups | php.standards |
|---|---|
| Message-ID | <[email protected]> |
From: tonin at bolzan dot io
Operating system: All
PHP version: 7.1.4
Package: PHP Language Specification
Bug Type: Bug
Bug description:Cast and TypeHint do not have the expected behavior
Description:
------------
Cast and TypeHint do not have the expected behavior
(function () : object { return (object) []; })();
must be an instance of object, instance of stdClass returned
Test script:
---------------
php -a
php > (function () : object { return (object) []; })();
PHP Warning: Uncaught TypeError: Return value of {closure}() must be an
instance of object, instance of stdClass returned in php shell code:1
Stack trace:
#0 php shell code(1): {closure}()
#1 {main}
thrown in php shell code on line 1
Expected result:
----------------
Work normal
Actual result:
--------------
PHP Warning: Uncaught TypeError: Return value of {closure}() must be an
instance of object, instance of stdClass returned in php shell code:1
Stack trace:
#0 php shell code(1): {closure}()
#1 {main}
thrown in php shell code on line 1
--
Edit bug report at https://bugs.php.net/bug.php?id=74476&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74476&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74476&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74476&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=74476&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=74476&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=74476&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=74476&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=74476&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=74476&r=support
Expected behavior: https://bugs.php.net/fix.php?id=74476&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=74476&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=74476&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=74476&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74476&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=74476&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=74476&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=74476&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74476&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=74476&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=74476&r=mysqlcfg