#26867 [Opn->Csd]: get_declared_classes() does not return interfaces

From: Date: Mon, 02 May 2005 09:30:22 +0000
Subject: #26867 [Opn->Csd]: get_declared_classes() does not return interfaces
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-78507@lists.php.net to get a copy of this message
ID: 26867 Updated by: andrey@php.net Reported By: jaba at inbox dot lv -Status: Open +Status: Closed Bug Type: Feature/Change Request Operating System: Any PHP Version: 5.0.0b3 (beta3) New Comment: As far as I remember interface_exists() was added in 5.0.2 . In 5.0.0 and 5.0.1 class_exists() used to return TRUE when asked for a existing interface. Starting 5.0.2 class_exists() doesn't do that anymore. Previous Comments: ------------------------------------------------------------------------ [2004-01-11 10:57:55] jaba at inbox dot lv If this behaviour of get_declared_classes() is considered ok, then what about class_exists()? Then we need interface_exists(), don't we? And we shoud have false returned if class_exists() called for an interface! Otherwise it turns out that word "class" is not used clearly: in class_exists() it includes interfaces, but in get_declared_classes() - no more! ------------------------------------------------------------------------ [2004-01-11 10:22:23] sniper@php.net Use get_declared_interfaces() ------------------------------------------------------------------------ [2004-01-10 19:37:40] jaba at inbox dot lv I mixed up expected with actual results. ------------------------------------------------------------------------ [2004-01-10 19:36:09] jaba at inbox dot lv Description: ------------ At PHP5 we have a nice thing called interface. get_declared_classes() returns an array of all - abstract and non-abstract classes, but the array does not contain my interfaces. If interface is loaded by __autoload just like classes, shouldn't it be loaded into classes register too? Is there any way to check is it interface or what? Reproduce code: --------------- <?php interface Dao { function Open(); function Close(); } echo "<p>class_exists('Dao') says that Dao "; echo ( class_exists('Dao') ? 'is defined' : 'is not defined' ); $classes = get_declared_classes(); echo "<p>get_declared_classes() says that Dao "; echo ( in_array('Dao',$classes) ? 'is defined' : 'is not defined' ); ?> Expected result: ---------------- class_exists('Dao') says that Dao is defined get_declared_classes() says that Dao is not defined Actual result: -------------- class_exists('Dao') says that Dao is defined get_declared_classes() says that Dao is defined ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=26867&edit=1

« previous php.bugs (#78507) next »