TypePHP 编译器
https://swoole.com/aot/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
870 B
32 lines
870 B
<?php
|
|
|
|
use TypePhp\Exception\TestError;
|
|
|
|
/**
|
|
* PHP 8.3 typed class constants are covariant: an override may narrow the
|
|
* declared type (int|string -> int, mixed -> string, ?int -> int) but never
|
|
* widen it or move to an unrelated type.
|
|
*/
|
|
class ConstantOverrideCovarianceTest extends BaseTest
|
|
{
|
|
public function testNarrowingDeclaredTypeCompiles(): void
|
|
{
|
|
$this->compile('const_override_covariant.php');
|
|
}
|
|
|
|
public function testWideningDeclaredTypeIsRejected(): void
|
|
{
|
|
$this->exec(
|
|
'Declaration of `B::X` must be compatible with `A::X`',
|
|
'const_override_widened.php',
|
|
);
|
|
}
|
|
|
|
public function testUnrelatedDeclaredTypeIsRejected(): void
|
|
{
|
|
$this->exec(
|
|
'Declaration of `B::X` must be compatible with `A::X`',
|
|
'const_override_unrelated.php',
|
|
);
|
|
}
|
|
}
|
|
|