note 130355 added to reflectionmethod.isabstract

From: Date: Sun, 08 Jun 2025 00:02:25 +0000
Subject: note 130355 added to reflectionmethod.isabstract
Groups: php.notes 
Request: Send a blank email to php-notes+get-222207@lists.php.net to get a copy of this message
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

« previous php.notes (#222207) next »