|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34299 ReflectionClass::isInstantiable() returns true for abstract classes
Submitted: 2005-08-29 23:16 UTC Modified: 2005-08-30 09:39 UTC
From: dennis at inmarket dot lviv dot ua Assigned: helly
Status: Closed Package: Class/Object related
PHP Version: 5.0.4 OS: *
Private report: No CVE-ID:
 [2005-08-29 23:16 UTC] dennis at inmarket dot lviv dot ua
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:
Cannot instantiate abstract class

Actual result:
Class X is instantiable
Fatal error: Cannot instantiate abstract class X in /path/to/abstract.php on line 9


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-29 23:33 UTC]
Please try using this CVS snapshot:
For Windows:

 [2005-08-30 09:39 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Fri Nov 27 02:01:29 2015 UTC