#32603 [Opn->Bgs]: there is no easy way to check if class implements some interface
| From: | tony2001@php.net | Date: | Mon, 03 Apr 2006 11:46:15 +0000 |
| Subject: | #32603 [Opn->Bgs]: there is no easy way to check if class implements some interface | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-95272@lists.php.net to get a copy of this message | ||
ID: 32603
Updated by: tony2001@php.net
Reported By: indeyets at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Feature/Change Request
PHP Version: 5.0.4
New Comment:
class_implements():
Parameters
class
An object (class instance) or __a string (class name)__.
Previous Comments:
------------------------------------------------------------------------
[2005-04-13 07:19:32] indeyets at gmail dot com
class_implements() requires object instantiaiton too. That is a step,
which I need to skip.
I need to check if Class implements interface, not Object!
------------------------------------------------------------------------
[2005-04-13 00:05:28] helly@php.net
How about: http://php.net/class-implements
------------------------------------------------------------------------
[2005-04-06 08:56:45] indeyets at gmail dot com
Description:
------------
there is no easy way to check if class implements some interface. This
is needed, when, for example, php-application has support for loading
external classes.
external classes have to implement some interface. And check for this
should happen BEFORE object creation. (for example, there might be a
need for some specific constructor syntax).
PHP 5.0 allows to do the following things:
1). $parent = get_parent_class("SomeClassName"). This would be
sufficient, if plugins _extend_ some base class. that's not our case -
wouldn't work for interfaces
2). if ($obj instanceof "SomeInterfaceName") {}. This would work, if
we
could create object before the interface check. Wouldn't work for
non-existen objects
3). reflection API. it can do the thing, but overhead (both in code
and
in resources) is too big
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=32603&edit=1