note 128890 added to reflectionclass.isabstract

From: Date: Fri, 15 Sep 2023 13:06:43 +0000
Subject: note 128890 added to reflectionclass.isabstract
Groups: php.notes 
Request: Send a blank email to php-notes+get-220850@lists.php.net to get a copy of this message
For traits: - ReflectionClass::isAbstract returns true if the trait contains at least one un-implemented abstract method, including those declared into used traits. - ReflectionClass::isAbstract returns false if all methods are implemented. <?php trait TI { public function has() {} } var_dump((new ReflectionClass(TI::class))->isAbstract()); trait TT { abstract public function has(); } trait T { use TT; } var_dump((new ReflectionClass(T::class))->isAbstract()); ?> Will output: bool(false) bool(true) For interfaces: - ReflectionClass::isAbstract returns true if the interface contains at least one method, including into its extended interfaces. - ReflectionClass::isAbstract returns false if the interface contains no method. <?php interface AI {} var_dump((new ReflectionClass(AI::class))->isAbstract()); interface II { public function has(); } interface I extends II {} var_dump((new ReflectionClass(I::class))->isAbstract()); ?> Will output: bool(false) bool(true) For classes: - Reflection::isAbstract returns true if the class is marked as abstract, no matter if it contains abstract methods or not. ---- Server IP: 45.112.84.4 Probable Submitter: 45.91.157.134 (proxied: 2a01:e0a:9fc:9400:d6de:c649:55bc:3422) ---- Manual Page -- https://php.net/manual/en/reflectionclass.isabstract.php Edit -- https://main.php.net/note/edit/128890 Del: integrated -- https://main.php.net/note/delete/128890/integrated Del: useless -- https://main.php.net/note/delete/128890/useless Del: bad code -- https://main.php.net/note/delete/128890/bad+code Del: spam -- https://main.php.net/note/delete/128890/spam Del: non-english -- https://main.php.net/note/delete/128890/non-english Del: in docs -- https://main.php.net/note/delete/128890/in+docs Del: other reasons-- https://main.php.net/note/delete/128890 Reject -- https://main.php.net/note/reject/128890 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#220850) next »