mirror of
https://github.com/danog/Valinor.git
synced 2024-11-30 04:39:05 +01:00
fix: ensure native mixed types remain valid
This commit is contained in:
parent
1b80a1df9d
commit
18ccbebb9a
@ -81,7 +81,7 @@ final class Reflection
|
||||
/** @var ReflectionNamedType $type */
|
||||
$name = $type->getName();
|
||||
|
||||
if ($name !== 'null' && $type->allowsNull()) {
|
||||
if ($name !== 'null' && $type->allowsNull() && $name !== 'mixed') {
|
||||
return $name . '|null';
|
||||
}
|
||||
|
||||
|
@ -105,6 +105,20 @@ final class ReflectionTest extends TestCase
|
||||
self::assertSame('int|float', Reflection::flattenType($type));
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP >= 8
|
||||
*/
|
||||
public function test_mixed_type_is_handled(): void
|
||||
{
|
||||
$object = new class () {
|
||||
public mixed $someProperty;
|
||||
};
|
||||
|
||||
/** @var ReflectionType $type */
|
||||
$type = (new ReflectionProperty($object, 'someProperty'))->getType();
|
||||
self::assertSame('mixed', Reflection::flattenType($type));
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP >= 8.1
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user