8000 GitHub - ddebowczyk/type-info: Extracts PHP types information.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ddebowczyk/type-info

 
 

Repository files navigation

TypeInfo Component

The TypeInfo component extracts PHP types information.

This Component is experimental. Experimental features are not covered by Symfony's Backward Compatibility Promise.

Getting Started

composer require symfony/type-info
composer require phpstan/phpdoc-parser # to support raw string resolving
<?php

use Symfony\Component\TypeInfo\Type;
use Symfony\Component\TypeInfo\TypeResolver\TypeResolver;

// Instantiate a new resolver
$typeResolver = TypeResolver::create();

// Then resolve types for any subject
$typeResolver->resolve(new \ReflectionProperty(Dummy::class, 'id')); // returns an "int" Type instance
$typeResolver->resolve('bool'); // returns a "bool" Type instance

// Types can be instantiated thanks to static factories
$type = Type::list(Type::nullable(Type::bool()));

// Type instances have several helper methods
$type->getBaseType() // returns an "array" Type instance
$type->getCollectionKeyType(); // returns an "int" Type instance
$type->getCollectionValueType()->isNullable(); // returns true

Resources

About

Extracts PHP types information.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • 2A19 PHP 100.0%
0