- 添加接口类型检测功能,实现 hasInterface 方法 - 修改对象赋值逻辑,对接口类型变量进行特殊处理 - 增强返回值类型检查,支持接口类型的动态类型检测 - 更新类继承关系检查,支持接口实现关系验证 - 添加测试用例验证接口类型推断功能 - 修复接口名称存储时的转义问题 - 默认开启错误回溯打印功能便于调试pull/1/head
parent
45a4582d03
commit
26dfc99094
4 changed files with 121 additions and 20 deletions
@ -0,0 +1,33 @@ |
|||||||
|
--TEST-- |
||||||
|
type hits |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
interface TransportInterface |
||||||
|
{ |
||||||
|
public function send(string $message, ?string $envelope = null); |
||||||
|
} |
||||||
|
|
||||||
|
class FooA implements TransportInterface { |
||||||
|
public function send(string $message, ?string $envelope = null) |
||||||
|
{ |
||||||
|
var_dump($message, $envelope); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
function create_transport() : TransportInterface { |
||||||
|
return new FooA; |
||||||
|
} |
||||||
|
|
||||||
|
function configure_transport(FooA $o) { |
||||||
|
$o->send('Hello World', 'foo@bar'); |
||||||
|
} |
||||||
|
|
||||||
|
function main() |
||||||
|
{ |
||||||
|
$obj = create_transport(); |
||||||
|
configure_transport($obj); |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
string(11) "Hello World" |
||||||
|
string(7) "foo@bar" |
||||||
@ -0,0 +1,49 @@ |
|||||||
|
--TEST-- |
||||||
|
type hits |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
namespace Symfony\Component\Mailer\Transport { |
||||||
|
interface TransportInterface |
||||||
|
{ |
||||||
|
public function send(string $message, ?string $envelope = null); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
namespace Symfony\Component\Mailer\Transport\Smtp { |
||||||
|
use Symfony\Component\Mailer\Transport\TransportInterface; |
||||||
|
class EsmtpTransport implements TransportInterface { |
||||||
|
public function send(string $message, ?string $envelope = null) |
||||||
|
{ |
||||||
|
var_dump($message, $envelope); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
namespace { |
||||||
|
use Symfony\Component\Mailer\Transport\TransportInterface; |
||||||
|
use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport; |
||||||
|
|
||||||
|
class Baz { |
||||||
|
function create_transport() : TransportInterface { |
||||||
|
return new EsmtpTransport; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
class FooB { |
||||||
|
function configure(FooA $o) { |
||||||
|
$o->send('Hello World', 'foo@bar'); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
function main() |
||||||
|
{ |
||||||
|
$baz = new Baz; |
||||||
|
$obj = $baz->create_transport(); |
||||||
|
$foo = new FooB; |
||||||
|
$foo->configure($obj); |
||||||
|
} |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
string(11) "Hello World" |
||||||
|
string(7) "foo@bar" |
||||||
Loading…
Reference in new issue