|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-09-19 17:59 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
[2018-09-19 17:59 UTC] requinix@php.net
[2018-09-19 19:40 UTC] rawsrc at gmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 24 05:00:01 2025 UTC |
Description: ------------ Hi, Standard PHP 7.2.10 installation on Windows 7x64. Test script: --------------- <?php declare(strict_types=1); namespace ns1 { class abc { } }; namespace ns2 { interface interfaceXyz { public function getMe(): \ns1\abc; } }; namespace ns3 { class def extends \ns1\abc { function checkInstance() { return ($this instanceof \ns1\abc) ? '\ns3\def is an instance of \ns1\abc' : '\ns3\def is different of \ns1\abc'; } } echo (new def)->checkInstance(); // result = "\ns3\def is an instance of \ns1\abc" }; namespace ns4 { class ghi implements \ns2\interfaceXyz { public function getMe(): \ns3\def { // here : \ns3\def (derivated from \ns1\abc ) is an instance of \ns1\abc but is not compliant with the interface that expect an \ns1\abc instance !!! return 'hello world'; } } echo (new ghi)->getMe(); } Expected result: ---------------- Hello world Actual result: -------------- \ns3\def is an instance of \ns1\abc Fatal error: Declaration of ns4\ghi::getMe(): ns3\def must be compatible with ns2\interfaceXyz::getMe(): ns1\abc