php-src/Zend/tests/traits/language011.phpt
Stefan Marr c5ba229617 Fixed Bug #60165 (Aliasing unexisting trait should throw/trigger the exception/error)
- 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.
2011-11-17 21:04:15 +00:00

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