vanio/type-parser
Composer 安装命令:
composer require vanio/type-parser
包简介
Library for parsing property types defined using @var PHPDoc annotation
README 文档
README
Library for parsing type expressions and/or property types defined using var PHPDoc annotation almost as defined in PSR-5 specification draft, just a little bit more permissive. It also supports merging two (or more) types like int|string -> scalar or string[]|int[] -> scalar[]
PSR-5 ABNF: https://github.com/phpDocumentor/fig-standards/blob/master/proposed/phpdoc.md#user-content-abnf
Example
<?php use Doctrine\Common\Cache\FilesystemCache; use Vanio\TypeParser\CachingParser; use Vanio\TypeParser\Tests\Fixtures\Foo; use Vanio\TypeParser\TypeParser; $typeParser = new CachingParser(new TypeParser, new FilesystemCache(__DIR__ . '/cache')); $type = $typeParser->parsePropertyTypes(Foo::class); $type['scalar']->type(); // /** @var int|string */ -> new CompoundType(Type::INTEGER, Type::STRING) -> new SimpleType(Type::SCALAR)
统计信息
- 总下载量: 21.82k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 0
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-03-07