fix(compiler): 修复声明先后影响跨命名空间接口类型校验 #21
Merged
韩天峰
merged 2 commits from fix-interface-impl-param-type-cross-ns into master 1 month ago
2 changed files with 65 additions and 2 deletions
@ -0,0 +1,62 @@ |
|||||||
|
--TEST-- |
||||||
|
Cross-namespace interface implementation parameter compatibility is declaration-order independent |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
namespace A { |
||||||
|
use B\I0; |
||||||
|
use B\I1; |
||||||
|
use B\I2; |
||||||
|
|
||||||
|
abstract class Test implements I2 |
||||||
|
{ |
||||||
|
public function test(I1 $a): bool |
||||||
|
{ |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
public function testParent(I0 $a): bool |
||||||
|
{ |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
namespace B { |
||||||
|
interface I0 |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
interface I1 extends I0 |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
interface I2 |
||||||
|
{ |
||||||
|
public function test(I1 $a): bool; |
||||||
|
|
||||||
|
public function testParent(I1 $a): bool; |
||||||
|
} |
||||||
|
|
||||||
|
class Impl1 implements I1 |
||||||
|
{ |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
namespace { |
||||||
|
class Concrete extends \A\Test |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
function main() |
||||||
|
{ |
||||||
|
$obj = new Concrete(); |
||||||
|
var_dump($obj->test(new \B\Impl1())); |
||||||
|
var_dump($obj->testParent(new \B\Impl1())); |
||||||
|
echo "done\n"; |
||||||
|
} |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
bool(true) |
||||||
|
bool(true) |
||||||
|
done |
||||||
Loading…
Reference in new issue