#41137 [Opn->Bgs]: is_a() for interfaces
| From: | cellog@php.net | Date: | Thu, 19 Apr 2007 15:01:34 +0000 |
| Subject: | #41137 [Opn->Bgs]: is_a() for interfaces | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-111686@lists.php.net to get a copy of this message | ||
ID: 41137
Updated by: cellog@php.net
Reported By: amadeusz dot jasak at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Feature/Change Request
Operating System: -
PHP Version: 5.2.1
New Comment:
quoting the manual (http://php.net/is_a):
"bool is_a ( object $object, string $class_name )
Checks if the given object is of this class or has this class as one
of its parents."
'foo' is not an object (it is a string), and therefore is_a()
returns false.
is_a('foo', 'foo')
is also false for the same reason.
Previous Comments:
------------------------------------------------------------------------
[2007-04-19 06:31:39] amadeusz dot jasak at gmail dot com
Description:
------------
is_a function will be works if first argument is class name and next
argument is interface name. Currently it isn't working... I can't check
for class (not object) is implementing some interface
Reproduce code:
---------------
<?php
inteface factory
{
public static function _factory($params);
}
class foo implements factory
{
public static function _factory($params)
{
$t = new foo();
return $t; // Sweet use of factory ;)
}
}
var_dump
(
is_a('foo', 'factory'), // Currently return false, but true is
expected
is_a($foo = new foo(), 'factory') // It is working but it isn't
practicly
);
?>
Expected result:
----------------
bool(true)
bool(true)
Actual result:
--------------
bool(false)
bool(true)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41137&edit=1