note 103122 added to reflectionclass.getinterfacenames

From: Date: Sun, 27 Mar 2011 12:11:33 +0000
Subject: note 103122 added to reflectionclass.getinterfacenames
Groups: php.notes 
Request: Send a blank email to php-notes+get-178247@lists.php.net to get a copy of this message
It seems the interface names are actually listed in a defined order: - "extends" takes precedence over "implements" (i.e. first will be interfaces from (implemented in) the parent class (if any), then interfaces implemented in the class itself) - when multiple interfaces are implemented at one time/level, it can be: + from an "implements" : they're listed in the defined order + from an "extends" (a class extends another class which implements multiple interfaces; or an interface extends multiple interfaces) : they're listed in REVERSE order <?php interface Foo {} interface Bar {} interface Other {} interface Foobar extends Foo, Bar {} interface Barfoo extends Bar, Foo {} class Test1 implements Foo, Bar {} class Test2 implements Bar, Foo {} class Test3 extends Test1 {} class Test4 extends Test2 {} class Test5 extends Test1 implements Other {} class Test6 implements Foobar, Other {} class TestO implements Other {} class Test7 extends TestO implements Barfoo {} $r=new ReflectionClass('Test1'); print_r($r->getInterfaceNames()); // Foo, Bar $r=new ReflectionClass('Test2'); print_r($r->getInterfaceNames()); // Bar, Foo $r=new ReflectionClass('Test3'); print_r($r->getInterfaceNames()); // Bar, Foo $r=new ReflectionClass('Test4'); print_r($r->getInterfaceNames()); // Foo, Bar $r=new ReflectionClass('Test5'); print_r($r->getInterfaceNames()); // Bar, Foo, Other $r=new ReflectionClass('Test6'); print_r($r->getInterfaceNames()); // Foobar, Bar, Foo, Other $r=new ReflectionClass('Test7'); print_r($r->getInterfaceNames()); // Other, Barfoo, Foo, Bar ?> ---- Server IP: 69.147.83.197 Probable Submitter: 93.22.52.119 ---- Manual Page -- http://www.php.net/manual/en/reflectionclass.getinterfacenames.php Edit -- https://master.php.net/note/edit/103122 Del: integrated -- https://master.php.net/note/delete/103122/integrated Del: useless -- https://master.php.net/note/delete/103122/useless Del: bad code -- https://master.php.net/note/delete/103122/bad+code Del: spam -- https://master.php.net/note/delete/103122/spam Del: non-english -- https://master.php.net/note/delete/103122/non-english Del: in docs -- https://master.php.net/note/delete/103122/in+docs Del: other reasons-- https://master.php.net/note/delete/103122 Reject -- https://master.php.net/note/reject/103122 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#178247) next »