Last active
October 24, 2017 17:10
-
-
Save FlorianWolters/5195674 to your computer and use it in GitHub Desktop.
Demonstrates a PHP bug: The "final" keyword for a method is ignored if used in a trait (https://bugs.php.net/bug.php?id=62204)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* FinalKeywordIgnoredInTrait.php | |
* | |
* PHP 5.4.13 (cli) (built: Mar 15 2013 02:05:59) | |
* Copyright (c) 1997-2013 The PHP Group | |
* Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies | |
* with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans | |
* | |
* @link https://bugs.php.net/bug.php?id=62204 | |
*/ | |
trait ExampleTrait | |
{ | |
final function execute() | |
{ | |
} | |
} | |
class Example | |
{ | |
use ExampleTrait; | |
// Should raise an \E_FATAL with the following message: | |
// "Cannot override final method Example::execute() in [...] on line 26" | |
function execute() | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
trait isn't abide by class inherit constraint?
PHP should raise an
\E_FATAL
when the parent class defined afinal
method.my english is not good ==!
Example