ID: 28895
Updated by: [EMAIL PROTECTED]
Reported By: nlhowell at cableone dot net
-Status: Open
+Status: Closed
Bug Type: Unknown/Other Function
Operating System: *
PHP Version: 5.0.0
Assigned To: helly
New Comment:
Should be fixed now (obviously we need a testsuit for Reflection API
any volunteers?)
Previous Comments:
------------------------------------------------------------------------
[2004-07-20 20:20:08] [EMAIL PROTECTED]
Unfortunatley this wasn't fixed in 5 really.
------------------------------------------------------------------------
[2004-07-20 19:45:25] Jared dot Williams1 at ntworld dot com
Doesnt seem to be fixed.
---
abstract class Expression
{
function isConstant() { return FALSE; }
}
abstract class ConstantExpression extends Expression
{
function isConstant() { return TRUE; }
}
abstract class NumberExpression extends ConstantExpression
{
protected $number;
function __construct($number) { $this->number = $number; }
function getValue() { return $this->number; }
}
class IntegerExpression extends NumberExpression
{
}
class RealExpression extends NumberExpression
{
}
echo '<table>';
foreach(get_declared_classes() as $className)
{
$class = new ReflectionClass($className);
if ($class->isUserDefined())
{
echo
'<tr><td>'.htmlspecialchars($class->getName()).'</td><td>'.($class->isAbstract()
? 'YES' : 'NO').'</td></tr>';
}
unset($class);
}
echo '</table>';
--
Reports everything as not abstract.
Used latest win32 snapshot available,
PHP Version 5.0.1-dev
System Windows NT WIN2KS 5.0 build 2195
Build Date Jul 20 2004 16:21:09
------------------------------------------------------------------------
[2004-07-04 18:06:03] nlhowell at cableone dot net
Latest CVS (200407041430) has this bug listed as fixed.
------------------------------------------------------------------------
[2004-06-23 17:05:37] nlhowell at cableone dot net
Note that the first two lines are the important ones in the expected
and actual results.
------------------------------------------------------------------------
[2004-06-23 17:03:35] nlhowell at cableone dot net
Description:
------------
If you define an abstract class, ReflectionClass says it is not
abstract and is instantiable.
Reproduce code:
---------------
<?php
abstract class X { private $y = 5; }
$class = new ReflectionClass("X");
print "Class X:<br>";
print "Abstract: ";
var_dump($class->isAbstract());
print "<br>Instantiable: ";
var_dump($class->isInstantiable());
print "<br><br>Reflection Export:<pre>";
Reflection::Export($class);
print "</pre><br>var_dump of X:<pre>";
var_dump(new X());
print "</pre><br>";
?>
Expected result:
----------------
Class X:<br>Abstract: bool(true)
<br>Instantiable: bool(false)
<br><br>Reflection Export:<pre>Class [ <user> abstract class X ] {
@@ c:\Inetpub\wwwroot\php5lib2\test.php5 4-4
- Constants [0] {
}
- Static properties [0] {
}
- Static methods [0] {
}
- Properties [1] {
Property [ <default> private $y ]
}
- Methods [0] {
}
}
</pre><br>var_dump of X:<pre><br />
<b>Fatal error</b>: Cannot instantiate abstract class X in
<b>c:\Inetpub\wwwroot\php5lib2\test.php5</b> on line <b>15</b><br />
Actual result:
--------------
Class X:<br>Abstract: bool(false)
<br>Instantiable: bool(true)
<br><br>Reflection Export:<pre>Class [ <user> abstract class X ] {
@@ c:\Inetpub\wwwroot\php5lib2\test.php5 4-4
- Constants [0] {
}
- Static properties [0] {
}
- Static methods [0] {
}
- Properties [1] {
Property [ <default> private $y ]
}
- Methods [0] {
}
}
</pre><br>var_dump of X:<pre><br />
<b>Fatal error</b>: Cannot instantiate abstract class X in
<b>c:\Inetpub\wwwroot\php5lib2\test.php5</b> on line <b>15</b><br />
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=28895&edit=1