mirror of
https://github.com/php/php-src.git
synced 2024-09-24 19:37:26 +00:00
c5ba229617
- aliases that are not actually matching anything are treated as errors now. This will make sure that all methods that are expected to be in a class are actually there, or in case a trait changed for instance, that the code breaks already on composition - Precedence declarations are also checked to ensure that the method which is supposed to take precedence actually exists, however, the other traits mentioned in the declaration are not regarded. We are more lenient here, since this avoids unnecessary fragility. - fixed another seamingly unrelated test which broke in the progress but wasn't clear before either.
31 lines
532 B
PHP
31 lines
532 B
PHP
--TEST--
|
|
Aliasing on conflicting method should not cover up conflict.
|
|
--FILE--
|
|
<?php
|
|
error_reporting(E_ALL);
|
|
|
|
trait Hello {
|
|
public function sayHello() {
|
|
echo 'Hello';
|
|
}
|
|
}
|
|
|
|
trait World {
|
|
public function sayHello() {
|
|
echo ' World!';
|
|
}
|
|
}
|
|
|
|
|
|
class MyClass {
|
|
use Hello, World { sayHello as sayWorld; }
|
|
}
|
|
|
|
$o = new MyClass();
|
|
$o->sayHello();
|
|
$o->sayWorld();
|
|
|
|
?>
|
|
--EXPECTF--
|
|
Fatal error: Trait method sayHello has not been applied, because there are collisions with other trait methods on MyClass in %s on line %d
|