radebatz/type-info-extras

Extras for symfony/type-info

dev-main 2025-03-10 20:50 UTC

This package is auto-updated.

Last update: 2025-03-10 20:52:37 UTC


README

build License: MIT

TypeInfoExtras

Library adding some extra features to the Symfony Type Info component.

Based on the type-info:7.3 branch.

Basic Usage

<?php

use Radebatz\TypeInfoExtras\TypeResolver\StringTypeResolver as ExtraStringTypeResolver;

$resolver = new ExtraStringTypeResolver();

$type = $resolver->resolve('html-escaped-string');
echo get_class($type); //  Radebatz\TypeInfoExtras\Type\ExplicitType
echo $type->getExplicitType() // "html-escaped-string"

$type = $resolver->resolve('class-string<Foo>');
echo get_class($type); //  Radebatz\TypeInfoExtras\Type\ClassLikeType
echo $type->getExplicitType(); // "class-string"
echo get_class($type->getObjectType()); // Symfony\Component\TypeInfo\Type\ObjectType
echo $type->getObjectType(); // Foo

$type = $resolver->resolve('int<5,20>');
echo get_class($type); //  Radebatz\TypeInfoExtras\Type\IntRangeType

If your code is doing instanceof checks on the returned Type, then you will need to add another case and treat Radebatz\TypeInfoExtras\Tests\Type\ExplicitType same as BuiltinType.