PHPackages                             ddruganov/php-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. ddruganov/php-typed-array

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

ddruganov/php-typed-array
=========================

Typed array support for php

1.0.5(4y ago)0101PHP

Since May 3Pushed 4y ago1 watchersCompare

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

READMEChangelogDependencies (2)Versions (7)Used By (1)

PhpTypedArray
=============

[](#phptypedarray)

Typed array support for php

Installation
------------

[](#installation)

`composer require ddruganov/php-typed-array`

How-to
------

[](#how-to)

Use `TypedArray` to create a container of a certain type:

```
final class SomeClass
{
    public TypedArray $typedArray;

    public function __construct()
    {
        $this->typedArray = TypedArray::of(TypeDescription::of(TypeDescription::INT));
    }
}
```

Unfortunately, something like this is entirely possible:

```
final class SomeClass
{
    public TypedArray $typedArray;

    public function __construct()
    {
        $this->typedArray = TypedArray::of(TypeDescription::of(TypeDescription::INT));
    }

    public function someMethod()
    {
        $this->typedArray = TypedArray::of(TypeDescription::of(TypeDescription::STRING));
    }
}
```

To counter that, define a class extending the typed array:

```
final class DummyArray extends TypedArray
{
    public function __construct()
    {
        parent::__construct(new TypeDescription(DummyClass::class));
    }

    public function offsetGet(mixed $offset): DummyClass
    {
        return parent::offsetGet($offset);
    }
}
```

You're good to go :)

### Merging

[](#merging)

```
$firstArray = new IntArray();
$firstArray[0] = 1;
$firstArray[1] = 2;

$secondArray = new IntArray();
$secondArray[0] = 3;
$secondArray[1] = 4;

$thirdArray = new IntArray();
$thirdArray[0] = 5;
$thirdArray[1] = 6;

$merged = IntArray::from($firstArray, $secondArray, $thirdArray);
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity52

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

Every ~0 days

Total

6

Last Release

1474d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b68509a8d66d630b4f6a4faef3a5cb2cbea6b5c78321cc6940aa78554a95a27a?d=identicon)[ddruganov](/maintainers/ddruganov)

---

Top Contributors

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

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/ddruganov-php-typed-array/health.svg)

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

###  Alternatives

[php-smpp/php-smpp

PHP-based SMPP client lib

234197.5k8](/packages/php-smpp-php-smpp)[demogorgorn/yii2-ajax-submit-button

AjaxSubmitButton renders an ajax button which is very similar to ajaxSubmitButton from Yii1.

29132.8k1](/packages/demogorgorn-yii2-ajax-submit-button)[tanmuhittin/nova-scroll-top

On route change scrolls to the top

22216.2k](/packages/tanmuhittin-nova-scroll-top)

PHPackages © 2026

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