Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51262 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20503 invoked from network); 13 Jan 2011 00:16:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Jan 2011 00:16:10 -0000 Authentication-Results: pb1.pair.com header.from=marc@easen.co.uk; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=marc@easen.co.uk; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain easen.co.uk from 74.125.82.170 cause and error) X-PHP-List-Original-Sender: marc@easen.co.uk X-Host-Fingerprint: 74.125.82.170 mail-wy0-f170.google.com Received: from [74.125.82.170] ([74.125.82.170:53740] helo=mail-wy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 96/0E-45151-9444E2D4 for ; Wed, 12 Jan 2011 19:16:10 -0500 Received: by wyb39 with SMTP id 39so1168620wyb.29 for ; Wed, 12 Jan 2011 16:16:06 -0800 (PST) Received: by 10.216.68.4 with SMTP id k4mr1356857wed.63.1294877766176; Wed, 12 Jan 2011 16:16:06 -0800 (PST) Received: from [192.168.0.5] (5acccde2.bb.sky.com [90.204.205.226]) by mx.google.com with ESMTPS id f52sm679473wes.35.2011.01.12.16.16.03 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 12 Jan 2011 16:16:05 -0800 (PST) Content-Type: multipart/mixed; boundary=Apple-Mail-13-890463293 Date: Thu, 13 Jan 2011 00:15:59 +0000 Message-ID: <44B48568-D359-4BF8-B9A5-E2A15C37A88F@easen.co.uk> To: internals@lists.php.net Mime-Version: 1.0 (Apple Message framework v1082) X-Mailer: Apple Mail (2.1082) Subject: [PATCH] Bug #53727 Inconsistent behavior of is_subclass_of with interfaces From: marc@easen.co.uk (Marc Easen) --Apple-Mail-13-890463293 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Hello, I have attached a patch to the following bug, but I believe the bug is = incorrect... If is_subclass_of() is used in conjunction with a interface it should = always return false because it's not a class, it's an interface. Test: ------ interface MyInterface { const TEST_CONSTANT =3D true; } class ParentClass implements MyInterface { } class ChildClass extends ParentClass { } echo (is_subclass_of('ChildClass', 'MyInterface') ? 'true' : 'false') . = "\n"; echo (defined('ChildClass::TEST_CONSTANT') ? 'true' : 'false') . "\n"; echo (is_subclass_of('ParentClass', 'MyInterface') ? 'true' : 'false') . = "\n"; echo (defined('ParentClass::TEST_CONSTANT') ? 'true' : 'false') . "\n"; Expected result: ---------------- false true false true Actual result: -------------- true true false true --Apple-Mail-13-890463293 Content-Disposition: attachment; filename=subclass_patch.txt Content-Type: text/plain; x-unix-mode=0644; name="subclass_patch.txt" Content-Transfer-Encoding: quoted-printable Index: ext/standard/tests/class_object/is_subclass_of_variation_002.phpt =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- ext/standard/tests/class_object/is_subclass_of_variation_002.phpt = (revision 306670) +++ ext/standard/tests/class_object/is_subclass_of_variation_002.phpt = (working copy) @@ -80,6 +80,15 @@ var_dump( is_subclass_of($object, $value) ); }; =20 + +// Bug #53727 - Inconsistent behavior of is_subclass_of with interfaces +interface MyInterface {} +class ParentClass implements MyInterface { } +class ChildClass extends ParentClass { } +echo "\nBug #53727\n"; +echo (is_subclass_of('ChildClass', 'MyInterface') ? 'true' : 'false') . = "\n"; +echo (is_subclass_of('ParentClass', 'MyInterface') ? 'true' : 'false') = . "\n"; + echo "Done"; ?> --EXPECTF-- @@ -168,4 +177,8 @@ =20 Arg value =20 bool(false) + +Bug #53727 +false +false Done \ No newline at end of file Index: Zend/zend_builtin_functions.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- Zend/zend_builtin_functions.c (revision 306670) +++ Zend/zend_builtin_functions.c (working copy) @@ -855,6 +855,9 @@ retval =3D 0; } else { if (only_subclass) { + if ((*ce)->ce_flags & ZEND_ACC_INTERFACE) { + RETURN_FALSE; + } if (!instance_ce) { instance_ce =3D Z_OBJCE_P(obj)->parent; } else { --Apple-Mail-13-890463293 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Kind Regards Marc --Apple-Mail-13-890463293--