Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/symfony/type-info
Extracts PHP types information.
https://github.com/symfony/type-info
component php phpdoc phpstan symfony symfony-component type
Last synced: 1 day ago
JSON representation
Extracts PHP types information.
- Host: GitHub
- URL: https://github.com/symfony/type-info
- Owner: symfony
- License: mit
- Created: 2024-02-04T09:44:18.000Z (11 months ago)
- Default Branch: 7.1
- Last Pushed: 2024-10-27T15:25:08.000Z (about 2 months ago)
- Last Synced: 2024-10-29T15:14:58.760Z (about 2 months ago)
- Topics: component, php, phpdoc, phpstan, symfony, symfony-component, type
- Language: PHP
- Homepage: https://symfony.com/type-info
- Size: 152 KB
- Stars: 90
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
TypeInfo Component
==================The TypeInfo component extracts PHP types information.
**This Component is experimental**.
[Experimental features](https://symfony.com/doc/current/contributing/code/experimental.html)
are not covered by Symfony's
[Backward Compatibility Promise](https://symfony.com/doc/current/contributing/code/bc.html).Getting Started
---------------```bash
composer require symfony/type-info
composer require phpstan/phpdoc-parser # to support raw string resolving
``````php
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
---------* [Contributing](https://symfony.com/doc/current/contributing/index.html)
* [Report issues](https://github.com/symfony/symfony/issues) and
[send Pull Requests](https://github.com/symfony/symfony/pulls)
in the [main Symfony repository](https://github.com/symfony/symfony)