Req #66476 [Opn->Nab]: Test if abstract conditions are OK
| From: | nikic@php.net | Date: | Mon, 13 Jan 2014 16:19:55 +0000 |
| Subject: | Req #66476 [Opn->Nab]: Test if abstract conditions are OK | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-183773@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66476&edit=1
ID: 66476
Updated by: nikic@php.net
Reported by: dev at toine dot pro
Summary: Test if abstract conditions are OK
-Status: Open
+Status: Not a bug
Type: Feature/Change Request
Package: *General Issues
Operating System: Debian
PHP Version: 5.4.24
Block user comment: N
Private report: N
New Comment:
You *can't* create a class that does not satisfy all the conditions (that's the point of
having conditions). If you want to do that you must mark the class abstract as well. In that case
you can use isAbstract() to check whether it is instantiable.
Previous Comments:
------------------------------------------------------------------------
[2014-01-13 14:57:25] dev at toine dot pro
Description:
------------
Hi!
Currently when we extends on abstract class we cannot test if all conditions are met before
instantiate the class.
This is not usefull, can you improve ReflectionClass::isInstantiable or create new method for this
feature?
Test script:
---------------
class classTest extends abstractTest {
// Missing methodTest
}
abstract class abstractTest {
abstract public function methodTest();
}
Expected result:
----------------
class classTest extends abstractTest {
// Missing methodTest
}
abstract class abstractTest {
abstract public function methodTest();
}
$reflectionClass = new ReflectionClass('calssTest');
if($reflectionClass->IsInstantiable()) {
// OK
} else {
// Cutom error
}
Actual result:
--------------
Fatal error: Class classTest contains 1 abstract method and must therefore be declared abstract or
implement the remaining methods (abstractTest::methodTest)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66476&edit=1