PHPackages                             lesphp/property-info-typed-array - 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. lesphp/property-info-typed-array

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

lesphp/property-info-typed-array
================================

Extract key and value types using PHP Attributes for array class properties. This dispense the use of PhpDocExtractor for typed arrays.

6.0.0(4y ago)01191MITPHPPHP &gt;=8.0.2

Since Apr 17Pushed 4y ago1 watchersCompare

[ Source](https://github.com/lesphp/property-info-typed-array)[ Packagist](https://packagist.org/packages/lesphp/property-info-typed-array)[ RSS](/packages/lesphp-property-info-typed-array/feed)WikiDiscussions main Synced 1mo ago

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

Typed array attribute for symfony/property-info
-----------------------------------------------

[](#typed-array-attribute-for-symfonyproperty-info)

This is a package that offer an PHP native attribute for symfony/property-info retrieve correct types of array elements. Now days, this is only possible with DocBlock annotation. DocBlocks is PHP first-class citizen, but it isn't for type checking/enforcing. A wrong class name inside a docblock is only textual documentation for PHP, but not for developer. Then, documentations can be removed/replaced and the program behavior should be the same.

Instalation
-----------

[](#instalation)

```
composer require lesphp/property-info-typed-array

```

Compatibility
-------------

[](#compatibility)

symfony/property-infolesphp/property-info-typed-array6.x6.xUsage
-----

[](#usage)

The TypedArray attribute is repeatable, them multiples annotations are evaluated as a OR clause.

```
use LesPhp\PropertyInfo\TypedArray;
use LesPhp\PropertyInfo\TypedArrayAttributeExtractor;

class FooBar {
    #[TypedArray(type: Baz::class, nullable: false, keyType: 'int')]
    private array $baz;

    #[TypedArray(type: Baz::class, nullable: true)]
    #[TypedArray(type: 'string', nullable: true)]
    private array $bazOrString;
}

$typedArrayExtractor = new TypedArrayAttributeExtractor();

$typedArrayExtractor->getTypes(Foo_Bar::class, 'baz');
$typedArrayExtractor->getTypes(Foo_Bar::class, 'bazOrString');
```

In combination with symfony/serializer, this can be a powerful annotation and dispense requirement of DocBlock annotation readers.

```
use LesPhp\PropertyInfo\TypedArrayAttributeExtractor;
use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
use Symfony\Component\PropertyInfo\PropertyInfoExtractor;
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
use Symfony\Component\Serializer\Normalizer\PropertyNormalizer;
use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Serializer;

$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader());
$propertyTypeExtractor = new PropertyInfoExtractor([new ReflectionExtractor()], [new TypedArrayAttributeExtractor()]);
$propertyNormalizer = new PropertyNormalizer($classMetadataFactory, null, $propertyTypeExtractor);

$serializer = new Serializer(
    [$propertyNormalizer, new ArrayDenormalizer()],
    [new JsonEncoder()]
);
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

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

1493d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/35bf43ea733f41fff08e0eb3a7f077219d4137846c236c49e6715cc96dc7c77e?d=identicon)[lainosantos](/maintainers/lainosantos)

---

Top Contributors

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

---

Tags

symfonyarraytypedproperty-info

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/lesphp-property-info-typed-array/health.svg)

```
[![Health](https://phpackages.com/badges/lesphp-property-info-typed-array/health.svg)](https://phpackages.com/packages/lesphp-property-info-typed-array)
```

###  Alternatives

[symfony/property-access

Provides functions to read and write from/to an object or array using a simple string notation

2.8k295.3M2.5k](/packages/symfony-property-access)[spomky-labs/pwa-bundle

Progressive Web App Manifest Generator Bundle for Symfony.

6144.4k1](/packages/spomky-labs-pwa-bundle)[maba/webpack-bundle

Bundle to Integrate Webpack to Symfony

123268.2k4](/packages/maba-webpack-bundle)[shapecode/hidden-entity-type-bundle

Hidden field for Symfony entities

28428.6k1](/packages/shapecode-hidden-entity-type-bundle)[selective/transformer

A strictly typed array transformer with dot-access, fluent interface and filters.

3817.8k1](/packages/selective-transformer)[minwork/array

Pack of advanced array functions specifically tailored for: associative (assoc) array, multidimensional array, array of objects and handling nested array elements

66256.1k5](/packages/minwork-array)

PHPackages © 2026

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