Bug #74476 [Opn->Nab]: Cast and TypeHint do not have the expected behavior

From: Date: Wed, 19 Apr 2017 21:28:24 +0000
Subject: Bug #74476 [Opn->Nab]: Cast and TypeHint do not have the expected behavior
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-208670@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74476&edit=1 ID: 74476 Updated by: cmb@php.net Reported by: tonin at bolzan dot io Summary: Cast and TypeHint do not have the expected behavior -Status: Open +Status: Not a bug Type: Bug -Package: PHP Language Specification +Package: Scripting Engine problem Operating System: All PHP Version: 7.1.4 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Note that there is an RFC[1] under dicussion which suggests to introduce object type declarations. [1] <https://wiki.php.net/rfc/object-typehint> Previous Comments: ------------------------------------------------------------------------ [2017-04-19 20:02:14] tonin at bolzan dot io 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 this bug report at https://bugs.php.net/bug.php?id=74476&edit=1

« previous php.bugs (#208670) next »