PHP code example of radebatz / type-info-extras

1. Go to this page and download the library: Download radebatz/type-info-extras library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

radebatz / type-info-extras example snippets




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