-- Christoph Dorn <
[hidden email]> wrote
(on Monday, 11 October 2010, 11:05 AM -0700):
> Regarding issue:
http://framework.zend.com/issues/browse/ZF-10526>
> What is the consensus on using is_a() instead of 'instanceof'.
>
> is_a() throws a deprecation notice for PHP < 5.3.
>
> I don't want to use instanceof as I don't think the class needs to
> be loaded just for that one check.
>
> Should I be using a combination of get_class() and is_subclass_of()
> to replace is_a()?
instanceof does not require that the class referenced be loaded; it
simply checks to see if the class of the object matches it. (Search for
"instanceof Zend_Config" throughout the codebase -- most cases where we
match against it, the class is never required, since it's not explicitly
used.)
Additionally, instanceof checks inheritance, and will return true when
the object:
* implements an interface (if an interface name is given as the
argument)
* matches any class in the inheritance (extends) tree
It's exactly the functionality you want to use here.
--
Matthew Weier O'Phinney
Project Lead |
[hidden email]
Zend Framework |
http://framework.zend.com/PGP key:
http://framework.zend.com/zf-matthew-pgp-key.asc