#34299 [Fbk->Asn]: ReflectionClass::isInstantiable() returns true for abstract classes
| From: | helly@php.net | Date: | Mon, 29 Aug 2005 22:06:55 +0000 |
| Subject: | #34299 [Fbk->Asn]: ReflectionClass::isInstantiable() returns true for abstract classes | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-84154@lists.php.net to get a copy of this message | ||
ID: 34299
Updated by: helly@php.net
Reported By: dennis at inmarket dot lviv dot ua
-Status: Feedback
+Status: Assigned
Bug Type: Class/Object related
-Operating System: WinXP
+Operating System: *
-PHP Version: 5.1.0RC1
+PHP Version: 5.0.4
-Assigned To:
+Assigned To: helly
Previous Comments:
------------------------------------------------------------------------
[2005-08-29 23:33:24] sniper@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
------------------------------------------------------------------------
[2005-08-29 23:16:21] dennis at inmarket dot lviv dot ua
Description:
------------
ReflectionClass::isInstantiable() returns true for abstract classes. Of
course, subsequent call to ReflectionClass::newInstance() fails. Please
note: this is not the same as bug #28895 (which claims to be solved) -
that bug submitter stressed that isAbstract always returns false. In
this case, isAbstract returns true, but the isInstantiable also returns
true.
Reproduce code:
---------------
<?
abstract class X {}
$rc = new ReflectionClass('X');
echo $rc->isAbstract() ? 'yes' : 'no', "\n";
if($rc->isInstantiable()) {
echo "Class X is instantiable";
$x = $rc->newInstance();
} else {
echo "Cannot instantiate abstract class";
}
?>
Expected result:
----------------
yes
Cannot instantiate abstract class
Actual result:
--------------
yes
Class X is instantiable
Fatal error: Cannot instantiate abstract class X in
/path/to/abstract.php on line 9
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34299&edit=1