diff --git a/src/PhpDocTypeReader.php b/src/PhpDocTypeReader.php index 7887178..ff796c0 100644 --- a/src/PhpDocTypeReader.php +++ b/src/PhpDocTypeReader.php @@ -20,6 +20,7 @@ use PhpDocTypeReader\Type\FloatType; use PhpDocTypeReader\Type\GenericType; use PhpDocTypeReader\Type\IntType; +use PhpDocTypeReader\Type\MixedType; use PhpDocTypeReader\Type\NullType; use PhpDocTypeReader\Type\ObjectType; use PhpDocTypeReader\Type\StringType; @@ -102,6 +103,8 @@ private function getTypeFromNodeType(TypeNode $type_node, IdentifierContext $ide { if ($type_node instanceof IdentifierTypeNode) { switch ($type_node->name) { + case 'mixed': + return new MixedType(); case 'int': return new IntType(); case 'string': diff --git a/src/Type/AtomicType.php b/src/Type/AtomicType.php index f700ba9..294f497 100644 --- a/src/Type/AtomicType.php +++ b/src/Type/AtomicType.php @@ -13,6 +13,6 @@ namespace PhpDocTypeReader\Type; -abstract class AtomicType implements Type +abstract class AtomicType extends MixedType { } diff --git a/src/Type/MixedType.php b/src/Type/MixedType.php new file mode 100644 index 0000000..baf57f3 --- /dev/null +++ b/src/Type/MixedType.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace PhpDocTypeReader\Type; + +class MixedType implements Type +{ +} diff --git a/src/Type/UnionType.php b/src/Type/UnionType.php index ce305fa..77c6703 100644 --- a/src/Type/UnionType.php +++ b/src/Type/UnionType.php @@ -13,7 +13,7 @@ namespace PhpDocTypeReader\Type; -class UnionType implements Type +class UnionType extends MixedType { /** @var AtomicType[] */ public array $types; diff --git a/tests/PhpDocTypeReaderTest.php b/tests/PhpDocTypeReaderTest.php index 5ee1090..bf36257 100644 --- a/tests/PhpDocTypeReaderTest.php +++ b/tests/PhpDocTypeReaderTest.php @@ -22,6 +22,7 @@ use PhpDocTypeReader\Type\FloatType; use PhpDocTypeReader\Type\GenericType; use PhpDocTypeReader\Type\IntType; +use PhpDocTypeReader\Type\MixedType; use PhpDocTypeReader\Type\NullType; use PhpDocTypeReader\Type\ObjectType; use PhpDocTypeReader\Type\StringType; @@ -46,6 +47,11 @@ public function varProvider(): array [] ); return [ + [ + new MixedType(), + '/** @var mixed */', + $default_identifier_context + ], [ new IntType(), '/** @var int */', @@ -133,6 +139,13 @@ public function paramProvider() [] ); return [ + [ + [ + 'mixed_var' => new MixedType() + ], + '/** @param mixed $mixed_var */', + $default_identifier_context + ], [ [ 'integer_var' => new IntType()