|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-09-10 19:46 UTC] stas@php.net
-Type: Bug
+Type: Feature/Change Request
-Package: PHP Language Specification
+Package: Scripting Engine problem
[2017-08-05 04:47 UTC] stas@php.net
-Status: Open
+Status: Suspended
[2017-08-05 04:47 UTC] stas@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 03:00:01 2025 UTC |
Description: ------------ Example 1: <?php class A{} class B{} trait X{ abstract function test(B $b); function doSomething(){ // can only be B. nothing should be allowed to change the signature of test(B) $this->test(new B); } } interface Contract{ function test(A $a); } class Implementation implements Contract{ use X; // incompatible, but compiles function test(A $a){} } ------------------------------------------------------- Example 2: <?php class A{} class B{} trait X{ function tryA(A $a){ $this->test($a); } function test(A $a){} // can't solve signatures incompatibility... } trait Y{ function tryB(B $b){ $this->test($b); } function test(B $b){} // ...when arguments are different } class Example{ use X, Y{ X::test insteadof Y; // this doesn't actually solve anything } } class A{} class B{} $x = new Example; $x->tryA(new A); $x->tryB(new B); (insteadof can only work if resolution happens between two identical signatures)