note 130023 added to function.forward-static-call

From: Date: Thu, 13 Feb 2025 11:36:38 +0000
Subject: note 130023 added to function.forward-static-call
Groups: php.notes 
Request: Send a blank email to php-notes+get-221845@lists.php.net to get a copy of this message
You can skip a method in a class hierarchy using this function, and it also works within an object context. The following code has behaved the same way since PHP 5.3. <?php class Top { public function getName(): string { return "Top"; } } class Intermediate extends Top { public function getName(): string { return "Intermediate"; } } class Bottom extends Intermediate { public function exec(): void { echo $this->getName(), PHP_EOL; // Intermediate echo self::getName(), PHP_EOL; // Intermediate echo parent::getName(), PHP_EOL; // Intermediate echo static::getName(), PHP_EOL; // Intermediate echo forward_static_call('Top::getName'), PHP_EOL; // "Top" } } $bottom = new Bottom(); $bottom->exec(); ?> ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.137 (proxied: 84.55.60.33) ---- Manual Page -- https://php.net/manual/en/function.forward-static-call.php Edit -- https://main.php.net/note/edit/130023 Del: integrated -- https://main.php.net/note/delete/130023/integrated Del: useless -- https://main.php.net/note/delete/130023/useless Del: bad code -- https://main.php.net/note/delete/130023/bad+code Del: spam -- https://main.php.net/note/delete/130023/spam Del: non-english -- https://main.php.net/note/delete/130023/non-english Del: in docs -- https://main.php.net/note/delete/130023/in+docs Del: other reasons-- https://main.php.net/note/delete/130023 Reject -- https://main.php.net/note/reject/130023 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221845) next »