PHPackages                             dgame/php-type-annotation - 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. dgame/php-type-annotation

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

dgame/php-type-annotation
=========================

php type annotation

v0.1.0(8y ago)04MITPHPPHP ^7.1

Since Sep 20Pushed 6y ago1 watchersCompare

[ Source](https://github.com/Dgame/php-type-annotation)[ Packagist](https://packagist.org/packages/dgame/php-type-annotation)[ Docs](https://github.com/php-type-annotation)[ RSS](/packages/dgame-php-type-annotation/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

php-type-annotation
===================

[](#php-type-annotation)

[![Build Status](https://camo.githubusercontent.com/2283280ac076ab1a92c4327331b55f18520142a774fc237f87f0a1fa7f2c756b/68747470733a2f2f7472617669732d63692e6f72672f4467616d652f7068702d747970652d616e6e6f746174696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Dgame/php-type-annotation)[![BCH compliance](https://camo.githubusercontent.com/db9195c4ecc2cf26b5ffaf75aff034f1591ae4286458c7d467293ca5dda9ca3b/68747470733a2f2f626574746572636f64656875622e636f6d2f656467652f62616467652f4467616d652f7068702d747970652d616e6e6f746174696f6e3f6272616e63683d6d6173746572)](https://bettercodehub.com/)[![StyleCI](https://camo.githubusercontent.com/5183ba99a34bcd436c08f658a1a1a4cab090a898185f5360b4ebb21a90aa0397/68747470733a2f2f7374796c6563692e696f2f7265706f732f3130343130373733382f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/104107738)[![codecov](https://camo.githubusercontent.com/5daa3095186eea87360e78b2e5a139deeba6435047bc210bde95a9ebaac8472d/68747470733a2f2f636f6465636f762e696f2f67682f4467616d652f7068702d747970652d616e6e6f746174696f6e2f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/Dgame/php-type-annotation)[![Build Status](https://camo.githubusercontent.com/59ebd3c2c392c61217837f50fb4fd9e2b7c2bf0e5af929029834e6fbfa43d569/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4467616d652f7068702d747970652d616e6e6f746174696f6e2f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Dgame/php-type-annotation/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/c7ffa5d19dc9e3378886a0d253bbff60bcb79c313a84910c5b47282dbf813827/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4467616d652f7068702d747970652d616e6e6f746174696f6e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Dgame/php-type-annotation/?branch=master)[![Dependency Status](https://camo.githubusercontent.com/3335a60a5b055e4a5ca931edfeb87e8e5325f5ffbed0df603ba1b28ec056e491/68747470733a2f2f67656d6e617369756d2e636f6d2f6261646765732f6769746875622e636f6d2f4467616d652f7068702d747970652d616e6e6f746174696f6e2e737667)](https://gemnasium.com/github.com/Dgame/php-type-annotation)

Parses your PHP-Doc-Annotations
-------------------------------

[](#parses-your-php-doc-annotations)

### Parse single Doc-Comments

[](#parse-single-doc-comments)

```
$parser     = new AnnotationParser();
$annotation = $parser->parsePropertyAnnotations('@property string[] $ids');
$this->assertNotEmpty($annotation);
$this->assertCount(1, $annotation);
$this->assertTrue($annotation[0]->getType()->hasNext());
$this->assertEquals(1, $annotation[0]->getType()->getDimension());
$this->assertEquals('string', $annotation[0]->getType()->getBaseType()->export());
$this->assertEquals('string[]', $annotation[0]->getType()->export());
$this->assertTrue($annotation[0]->hasId());
$this->assertEquals('$ids', $annotation[0]->getId());
$this->assertEquals('ids', $annotation[0]->getName());

$annotation = $parser->parseVariableAnnotations('@var string[]');
$this->assertNotEmpty($annotation);
$this->assertCount(1, $annotation);
$this->assertTrue($annotation[0]->getType()->hasNext());
$this->assertEquals(1, $annotation[0]->getType()->getDimension());
$this->assertEquals('string', $annotation[0]->getType()->getBaseType()->export());
$this->assertEquals('string[]', $annotation[0]->getType()->export());
$this->assertFalse($annotation[0]->hasId());
$this->assertEmpty($annotation[0]->getId());
$this->assertEmpty($annotation[0]->getName());
```

### Or a whole Reflection

[](#or-a-whole-reflection)

```
$annotation = new Annotation(new ReflectionClass(Test::class));
$this->assertCount(3, $annotation->getAllProperties());
$this->assertCount(3, $annotation->getAllMethodsParameters());
$this->assertTrue($annotation->hasProperty('streets'));
$this->assertEquals('string[]', $annotation->getProperty('streets')->getType()->export());
$this->assertTrue($annotation->hasProperty('nummer'));
$this->assertEquals('float', $annotation->getProperty('nummer')->getType()->export());
$this->assertTrue($annotation->hasProperty('einwohner'));
$this->assertEquals('int', $annotation->getProperty('einwohner')->getType()->export());
$this->assertTrue($annotation->hasMethodParameter('setStreets', 'streets'));
$this->assertEquals('string[]', $annotation->getMethodParameter('setStreets', 'streets')->getType()->export());
$this->assertTrue($annotation->hasMethodParameter('setNummer', 'nr'));
$this->assertEquals('float', $annotation->getMethodParameter('setNummer', 'nr')->getType()->export());
$this->assertTrue($annotation->hasMethodParameter('setEinwohner', 'einwohner'));
$this->assertEquals('int', $annotation->getMethodParameter('setEinwohner', 'einwohner')->getType()->export());
```

Compare the Doc-Type-Hints with actual PHP-Expressions
------------------------------------------------------

[](#compare-the-doc-type-hints-with-actual-php-expressions)

### Verify implicit matching...

[](#verify-implicit-matching)

```
$this->assertTrue(AnnotationType::parse('string[]')->isImplicit(['a', 'b']));
$this->assertTrue(AnnotationType::parse('string[]')->isImplicit([]));
$this->assertTrue(AnnotationType::parse('string[]')->isImplicit([4, 2]));
$this->assertTrue(AnnotationType::parse('string[]')->isImplicit([4.1, 2.3]));
$this->assertFalse(AnnotationType::parse('string[]')->isImplicit(42));
$this->assertFalse(AnnotationType::parse('string[]')->isImplicit('a'));
$this->assertFalse(AnnotationType::parse('int[]')->isImplicit('a'));
$this->assertFalse(AnnotationType::parse('int[]')->isImplicit(['a', 'b']));
$this->assertFalse(AnnotationType::parse('int[]')->isImplicit(42));
$this->assertTrue(AnnotationType::parse('int[]')->isImplicit([4, 2]));
$this->assertTrue(AnnotationType::parse('int[]')->isImplicit([4.1, 2.3]));
$this->assertTrue(AnnotationType::parse('int[][]')->isImplicit([[4, 2]]));
```

### ...or explicit matching

[](#or-explicit-matching)

```
$this->assertTrue(AnnotationType::parse('string[]')->isSame(['a', 'b']));
$this->assertTrue(AnnotationType::parse('string[]')->isSame([]));
$this->assertFalse(AnnotationType::parse('string[]')->isSame([4, 2]));
$this->assertFalse(AnnotationType::parse('string[]')->isSame([4.1, 2.3]));
$this->assertFalse(AnnotationType::parse('string[]')->isSame(42));
$this->assertFalse(AnnotationType::parse('string[]')->isSame('a'));
$this->assertFalse(AnnotationType::parse('int[]')->isSame('a'));
$this->assertFalse(AnnotationType::parse('int[]')->isSame(['a', 'b']));
$this->assertFalse(AnnotationType::parse('int[]')->isSame(42));
$this->assertTrue(AnnotationType::parse('int[]')->isSame([4, 2]));
$this->assertFalse(AnnotationType::parse('int[]')->isSame([4.1, 2.3]));
$this->assertTrue(AnnotationType::parse('int[][]')->isSame([[4, 2]]));
```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3159d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2a9fa98c1a3e70a521430fc2fba266657b2c981b5d8a36bf236fad01f9846dcd?d=identicon)[Dgame](/maintainers/Dgame)

---

Top Contributors

[![Dgame](https://avatars.githubusercontent.com/u/2406877?v=4)](https://github.com/Dgame "Dgame (11 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dgame-php-type-annotation/health.svg)

```
[![Health](https://phpackages.com/badges/dgame-php-type-annotation/health.svg)](https://phpackages.com/packages/dgame-php-type-annotation)
```

###  Alternatives

[reportico/yii2-reportico

Reportico

2116.5k](/packages/reportico-yii2-reportico)[pishran/laravel-persian-string

Convert Arabic/English/etc numbers and characters to Persian numbers and characters in Laravel models.

206.7k](/packages/pishran-laravel-persian-string)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
