- 移除对抽象类和接口参数类型的限制检查 - 简化对象类型推断逻辑,统一处理所有类类型 - 更新 addObject 方法,阻止为抽象类、接口、内部类创建实例 - 修正参数类型处理中的重复对象添加问题pull/1/head
parent
ee81d116ef
commit
71627fd920
3 changed files with 46 additions and 11 deletions
@ -0,0 +1,24 @@ |
||||
--TEST-- |
||||
abstract class and abstract method |
||||
--FILE-- |
||||
<?php |
||||
namespace { |
||||
use App1\Dog; |
||||
use App1\Animal; |
||||
|
||||
function foo(Animal $animal) { |
||||
$rs = $animal->speak(); |
||||
var_dump($rs); |
||||
} |
||||
|
||||
function main() { |
||||
include __DIR__ . "/abstract-class.inc"; |
||||
$dog = new Dog("Buddy"); |
||||
foo($dog); |
||||
echo "done\n"; |
||||
} |
||||
} |
||||
?> |
||||
--EXPECT-- |
||||
string(4) "woof" |
||||
done |
||||
@ -0,0 +1,14 @@ |
||||
<?php |
||||
namespace App1 { |
||||
interface Speakable { |
||||
public function speak(): string; |
||||
} |
||||
abstract class Animal implements Speakable { |
||||
protected string $name; |
||||
} |
||||
class Dog extends Animal { |
||||
public function speak(): string { |
||||
return "woof"; |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue