Browse Source
Fixed Bug #60217 (Requiring the same method from different traits)
Fixed Bug #60217 (Requiring the same method from different traits)
- also added test to check for inconsistent abstract method definitions, they need to be compatiblepull/271/head
4 changed files with 110 additions and 19 deletions
-
26Zend/tests/traits/bug60217a.phpt
-
26Zend/tests/traits/bug60217b.phpt
-
26Zend/tests/traits/bug60217c.phpt
-
51Zend/zend_compile.c
@ -0,0 +1,26 @@ |
|||
--TEST-- |
|||
Bug #60217 (Requiring the same method from different traits.) |
|||
--FILE-- |
|||
<?php |
|||
|
|||
trait T1 { |
|||
public abstract function foo(); |
|||
} |
|||
|
|||
trait T2 { |
|||
public abstract function foo(); |
|||
} |
|||
|
|||
class C { |
|||
use T1, T2; |
|||
|
|||
public function foo() { |
|||
echo "C::foo() works.\n"; |
|||
} |
|||
} |
|||
|
|||
$o = new C; |
|||
$o->foo(); |
|||
|
|||
--EXPECTF-- |
|||
C::foo() works. |
|||
@ -0,0 +1,26 @@ |
|||
--TEST-- |
|||
Bug #60217 (Requiring the same method from different traits and abstract methods have to be compatible) |
|||
--FILE-- |
|||
<?php |
|||
|
|||
trait TBroken1 { |
|||
public abstract function foo($a); |
|||
} |
|||
|
|||
trait TBroken2 { |
|||
public abstract function foo($a, $b = 0); |
|||
} |
|||
|
|||
class CBroken { |
|||
use TBroken1, TBroken2; |
|||
|
|||
public function foo($a) { |
|||
echo 'FOO'; |
|||
} |
|||
} |
|||
|
|||
$o = new CBroken; |
|||
$o->foo(1); |
|||
|
|||
--EXPECTF-- |
|||
Fatal error: Declaration of TBroken1::foo($a) must be compatible with TBroken2::foo($a, $b = 0) in %s on line %d |
|||
@ -0,0 +1,26 @@ |
|||
--TEST-- |
|||
Bug #60217 (Requiring the same method from different traits and abstract methods have to be compatible, in both directions.) |
|||
--FILE-- |
|||
<?php |
|||
|
|||
trait TBroken1 { |
|||
public abstract function foo($a, $b = 0); |
|||
} |
|||
|
|||
trait TBroken2 { |
|||
public abstract function foo($a); |
|||
} |
|||
|
|||
class CBroken { |
|||
use TBroken1, TBroken2; |
|||
|
|||
public function foo($a) { |
|||
echo 'FOO'; |
|||
} |
|||
} |
|||
|
|||
$o = new CBroken; |
|||
$o->foo(1); |
|||
|
|||
--EXPECTF-- |
|||
Fatal error: Declaration of TBroken1::foo($a, $b = 0) must be compatible with TBroken2::foo($a) in %s on line %d |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue