| Newsgroups |
php.notes |
| Message-ID |
<[email protected]> |
This is an example using ReflectionMethod() to check if the parent class method is abstract or not. Calling an abstract method of a parent class will crash PHP.
<?php
abstract class modProcessor {
abstract public function process();
}
class ConcreteClass extends modProcessor {
public function process() {
$reflectionMethod = new ReflectionMethod('modProcessor', 'process');
if (! $reflectionMethod->isAbstract()) {
parent::process();
} else {
echo "Cannot call abstract parent method";
}
}
}
$c = new ConcreteClass($modx);
$c->process();
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 2607:fb90:9982:e850:b83a:f6c5:a9aa:8d61)
----
Manual Page -- https://php.net/manual/en/reflectionmethod.isabstract.php
Edit -- https://main.php.net/note/edit/130355
Del: integrated -- https://main.php.net/note/delete/130355/integrated
Del: useless -- https://main.php.net/note/delete/130355/useless
Del: bad code -- https://main.php.net/note/delete/130355/bad+code
Del: spam -- https://main.php.net/note/delete/130355/spam
Del: non-english -- https://main.php.net/note/delete/130355/non-english
Del: in docs -- https://main.php.net/note/delete/130355/in+docs
Del: other reasons-- https://main.php.net/note/delete/130355
Reject -- https://main.php.net/note/reject/130355
Search -- https://main.php.net/manage/user-notes.php