Debian Codegraph @

vendor/radebatz/type-info-extras/Readme.md

raw
1 [![build](https://github.com/DerManoMann/type-info-extras/actions/workflows/build.yml/badge.svg)](https://github.com/DerManoMann/type-info-extras/actions/workflows/build.yml)
2 [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
3
4 TypeInfoExtras
5 ==============
6
7 Library adding some extra features to the Symfony [Type Info](https://github.com/symfony/type-info) component.
8
9 Compatible with Symfony
10 [type-info:7.3.8+](https://github.com/symfony/type-info/tree/7.3),
11 [type-info:7.4.1+](https://github.com/symfony/type-info/tree/7.4),
12 [type-info:8.0+](https://github.com/symfony/type-info/tree/8.0)
13 and [type-info:8.1+](https://github.com/symfony/type-info/tree/8.1).
14
15 Basic Usage
16 -----------
17
18 ```php
19 <?php
20
21 use Radebatz\TypeInfoExtras\TypeResolver\StringTypeResolver as ExtraStringTypeResolver;
22
23 $resolver = new ExtraStringTypeResolver();
24
25 $type = $resolver->resolve('html-escaped-string');
26 echo get_class($type); // Radebatz\TypeInfoExtras\Type\ExplicitType
27 echo $type->getExplicitType() // "html-escaped-string"
28
29 $type = $resolver->resolve('class-string<Foo>');
30 echo get_class($type); // Radebatz\TypeInfoExtras\Type\ClassLikeType
31 echo $type->getExplicitType(); // "class-string"
32 echo get_class($type->getObjectType()); // Symfony\Component\TypeInfo\Type\ObjectType
33 echo $type->getObjectType(); // Foo
34
35 $type = $resolver->resolve('int<5,20>');
36 echo get_class($type); // Radebatz\TypeInfoExtras\Type\IntRangeType
37
38 ```
39
40 If your code is doing `instanceof` checks on the returned `Type`, then you will need to add another case and treat
41 `Radebatz\TypeInfoExtras\Tests\Type\ExplicitType` same as `BuiltinType`.