test(gen_stub): cover namespaced composite property types

master
韩天峰 3 hours ago
parent f2b0e9add9
commit 98321138ce
  1. 62
      tests/compiler/type_decl/namespaced-composite-property-arginfo.phpt

@ -0,0 +1,62 @@
--TEST--
Namespaced union and intersection properties generate valid arginfo identifiers
--FILE--
<?php
namespace NamespacedArginfo {
interface Left
{
}
interface Right
{
}
final class Both implements Left, Right
{
}
final class Alternative
{
}
final class Holder
{
public Left|Alternative $union;
public Left&Right $intersection;
public function __construct(Left|Alternative $union, Left&Right $intersection)
{
$this->union = $union;
$this->intersection = $intersection;
}
}
function run(): void
{
$both = new Both();
$holder = new Holder(new Alternative(), $both);
echo (new \ReflectionProperty(Holder::class, 'union'))->getType(), "\n";
echo (new \ReflectionProperty(Holder::class, 'intersection'))->getType(), "\n";
var_dump($holder->union instanceof Alternative);
var_dump($holder->intersection instanceof Both);
$holder->union = $both;
var_dump($holder->union instanceof Both);
}
}
namespace {
function main(): void
{
\NamespacedArginfo\run();
}
}
?>
--EXPECT--
NamespacedArginfo\Left|NamespacedArginfo\Alternative
NamespacedArginfo\Left&NamespacedArginfo\Right
bool(true)
bool(true)
bool(true)
Loading…
Cancel
Save