|
|
|
@ -7,6 +7,25 @@ use PhpAot\Php\Reflection; |
|
|
|
|
|
|
|
|
|
|
|
class ReflectionTest extends TestCase |
|
|
|
class ReflectionTest extends TestCase |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
public function testGetFunctionReturnTypeUnionReturnsNull(): void |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
eval('function php_aot_reflection_union_return(): int|string { return 1; }'); |
|
|
|
|
|
|
|
$this->assertNull(Reflection::getFunctionReturnType('php_aot_reflection_union_return')); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function testGetFunctionReturnTypeIntersectionReturnsNull(): void |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
eval(' |
|
|
|
|
|
|
|
interface PhpAotReflectionI1 {} |
|
|
|
|
|
|
|
interface PhpAotReflectionI2 {} |
|
|
|
|
|
|
|
final class PhpAotReflectionBoth implements PhpAotReflectionI1, PhpAotReflectionI2 {} |
|
|
|
|
|
|
|
function php_aot_reflection_intersection_return(): PhpAotReflectionI1&PhpAotReflectionI2 { |
|
|
|
|
|
|
|
return new PhpAotReflectionBoth(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
'); |
|
|
|
|
|
|
|
$this->assertNull(Reflection::getFunctionReturnType('php_aot_reflection_intersection_return')); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function testIsInternalClass(): void |
|
|
|
public function testIsInternalClass(): void |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Standard PHP internal classes |
|
|
|
// Standard PHP internal classes |
|
|
|
@ -125,6 +144,33 @@ class ReflectionTest extends TestCase |
|
|
|
$this->assertEquals('string', $type); |
|
|
|
$this->assertEquals('string', $type); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function testGetMethodReturnTypeUnionReturnsNull(): void |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
eval(' |
|
|
|
|
|
|
|
class PhpAotReflectionUnionMethodReturn { |
|
|
|
|
|
|
|
public function value(): int|string { |
|
|
|
|
|
|
|
return 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
'); |
|
|
|
|
|
|
|
$this->assertNull(Reflection::getMethodReturnType('PhpAotReflectionUnionMethodReturn', 'value')); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function testGetMethodReturnTypeIntersectionReturnsNull(): void |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
eval(' |
|
|
|
|
|
|
|
interface PhpAotReflectionMethodI1 {} |
|
|
|
|
|
|
|
interface PhpAotReflectionMethodI2 {} |
|
|
|
|
|
|
|
final class PhpAotReflectionMethodBoth implements PhpAotReflectionMethodI1, PhpAotReflectionMethodI2 {} |
|
|
|
|
|
|
|
class PhpAotReflectionIntersectionMethodReturn { |
|
|
|
|
|
|
|
public function value(): PhpAotReflectionMethodI1&PhpAotReflectionMethodI2 { |
|
|
|
|
|
|
|
return new PhpAotReflectionMethodBoth(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
'); |
|
|
|
|
|
|
|
$this->assertNull(Reflection::getMethodReturnType('PhpAotReflectionIntersectionMethodReturn', 'value')); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function testGetMethodReturnTypeNonexistent(): void |
|
|
|
public function testGetMethodReturnTypeNonexistent(): void |
|
|
|
{ |
|
|
|
{ |
|
|
|
$type = Reflection::getMethodReturnType('NonExistent_' . uniqid(), 'test'); |
|
|
|
$type = Reflection::getMethodReturnType('NonExistent_' . uniqid(), 'test'); |
|
|
|
|