2017 © Pedro Peláez
 

library type-parser

Library for parsing property types defined using @var PHPDoc annotation

image

vanio/type-parser

Library for parsing property types defined using @var PHPDoc annotation

  • Friday, January 6, 2017
  • by maryo
  • Repository
  • 3 Watchers
  • 4 Stars
  • 2,824 Installations
  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 10 % Grown

The README.md

Type Parser

Build Status Coverage Status PHP7 License, (*1)

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[], (*2)

PSR-5 ABNF: https://github.com/phpDocumentor/fig-standards/blob/master/proposed/phpdoc.md#user-content-abnf, (*3)

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)

The Versions

06/01 2017

dev-master

9999999-dev https://github.com/vaniocz/type-parser

Library for parsing property types defined using @var PHPDoc annotation

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marek Štípek

parser docblock type annotation var type resolver