PHPackages                             vanio/type-parser - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. vanio/type-parser

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

vanio/type-parser
=================

Library for parsing property types defined using @var PHPDoc annotation

723.1k↓35.7%3PHPCI failing

Since Aug 24Pushed 3y ago4 watchersCompare

[ Source](https://github.com/vaniocz/type-parser)[ Packagist](https://packagist.org/packages/vanio/type-parser)[ RSS](/packages/vanio-type-parser/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (3)

Type Parser
===========

[](#type-parser)

[![Build Status](https://camo.githubusercontent.com/751f7108bcf05b3545502f080c5e48f907442a3294595d9184958d09d7ff8b55/68747470733a2f2f7472617669732d63692e6f72672f76616e696f637a2f747970652d7061727365722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/vaniocz/type-parser)[![Coverage Status](https://camo.githubusercontent.com/3e1fb582831ad9e92935cb9464600cdcce39ead1bc7145cbe1b56bd82ba28bce/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f76616e696f637a2f747970652d7061727365722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/vaniocz/type-parser?branch=master) [![PHP7](https://camo.githubusercontent.com/1707d1cf35d1b3dba207caa68b99d5e4af7689d1c4bf5ad784bf4b1ec532f507/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d372d3642374542392e737667)](https://camo.githubusercontent.com/1707d1cf35d1b3dba207caa68b99d5e4af7689d1c4bf5ad784bf4b1ec532f507/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d372d3642374542392e737667)[![License](https://camo.githubusercontent.com/4f48dbcb90aa78cf4cc0bd6459f8cedf91f3687c58505e7a984daa2f25b6f320/68747470733a2f2f706f7365722e707567782e6f72672f76616e696f2f747970652d7061727365722f6c6963656e7365)](https://github.com/vaniocz/type-parser/blob/master/LICENSE)

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` -&gt; `scalar` or `string[]|int[]` -&gt; `scalar[]`

PSR-5 ABNF:

Example
=======

[](#example)

```
