PHPackages                             andrewcarteruk/typed-arrays - 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. andrewcarteruk/typed-arrays

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

andrewcarteruk/typed-arrays
===========================

Typed arrays in PHP.

v0.2(10y ago)38331MITPHPPHP &gt;=5.4

Since Jan 22Pushed 10y ago2 watchersCompare

[ Source](https://github.com/AndrewCarterUK/TypedArrays)[ Packagist](https://packagist.org/packages/andrewcarteruk/typed-arrays)[ Docs](http://github.com/AndrewCarterUK/TypedArrays)[ RSS](/packages/andrewcarteruk-typed-arrays/feed)WikiDiscussions master Synced 2mo ago

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

Typed Arrays
============

[](#typed-arrays)

[![Build Status](https://camo.githubusercontent.com/c5eadbd88798c5d5035e09539381c9c804f09367412f48c862b26db513c5cbb9/68747470733a2f2f7472617669732d63692e6f72672f416e64726577436172746572554b2f54797065644172726179732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/AndrewCarterUK/TypedArrays)[![Code Coverage](https://camo.githubusercontent.com/9eec53596ea27250ca4e9b5bc002a41c0e2fa76e0cf17d19fb77248393b068e0/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f416e64726577436172746572554b2f54797065644172726179732f6261646765732f636f7665726167652e706e673f623d6d617374657226726566726573685f746f6b656e3d31)](https://scrutinizer-ci.com/g/AndrewCarterUK/TypedArrays/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/db8a619289f89ac66bd50e826826d8fab3ea11763afdff81184318000717bc5f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f416e64726577436172746572554b2f54797065644172726179732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d617374657226726566726573685f746f6b656e3d31)](https://scrutinizer-ci.com/g/AndrewCarterUK/TypedArrays/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/fd3228816a3cf0ba0ef7e3767a7f1f1e4a7f8a33f560c600c1912e544bbcc7c7/68747470733a2f2f706f7365722e707567782e6f72672f616e64726577636172746572756b2f74797065642d6172726179732f762f737461626c65)](https://packagist.org/packages/andrewcarteruk/typed-arrays)[![Total Downloads](https://camo.githubusercontent.com/5b24a9040e22e85913d029e45b0a4939671e0eb7bbc4f47b4544862fe5dc9837/68747470733a2f2f706f7365722e707567782e6f72672f616e64726577636172746572756b2f74797065642d6172726179732f646f776e6c6f616473)](https://packagist.org/packages/andrewcarteruk/typed-arrays)[![License](https://camo.githubusercontent.com/40e0bf3057ff070804055874ddc65df5713a02cfb2180c02fe4318fe1285ffa1/68747470733a2f2f706f7365722e707567782e6f72672f616e64726577636172746572756b2f74797065642d6172726179732f6c6963656e7365)](https://packagist.org/packages/andrewcarteruk/typed-arrays)

Typed arrays in PHP.

By [AndrewCarterUK ![(Twitter)](https://camo.githubusercontent.com/6bdedfb2ec11bea20e0fb9720641fd26240465c2361f25955ca995df499d5d20/687474703a2f2f692e696d6775722e636f6d2f77577a583975422e706e67)](https://twitter.com/AndrewCarterUK)

Install
-------

[](#install)

Install using [Composer](https://getcomposer.org).

```
composer require andrewcarteruk/typed-arrays ^0.2
```

Warning
-------

[](#warning)

These are objects that act like arrays, they are not native PHP arrays and will not pass an `is_array()` test.

As they are objects, unlike PHP arrays, they are always passed by reference.

Example Usage
-------------

[](#example-usage)

```
use TypedArray\StringArray;

$stringArray = new StringArray(['Hello, World!', 'foo' => 'bar']);
// Or, $stringArray = new StringArray();

try {
    $stringArray[] = 1;
} catch (\InvalidArgumentException $exception) {
    echo $exception->getMessage() . PHP_EOL;
}
```

```
use App\Farm\Chicken;
use TypedArray\InstanceArray;

$chickenArray = new InstanceArray(Chicken::class, [new Chicken('Bob')]);

$chickenArray[] = new Chicken('Tony');
$chickenArray['foo'] = new Chicken('Alice');

try {
    $chickenArray[] = 1;
} catch (\InvalidArgumentException $exception) {
    echo $exception->getMessage() . PHP_EOL;
}
```

Available Types
---------------

[](#available-types)

`ArrayArray`, `BoolArray`, `CallableArray`, `FloatArray`, `InstanceArray($classPath)`, `IntArray`, `NumericArray`, `ObjectArray`, `ResourceArray`, `ScalarArray`, `StringArray`.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

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

2

Last Release

3763d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6e7abce428a9dc9c76f4275ca8d8d11ad55138d72f3e3e2b01c6b2da5b479cc0?d=identicon)[AndrewCarterUK](/maintainers/AndrewCarterUK)

---

Top Contributors

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

---

Tags

arraystringclassobjectDoublearraystyped

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/andrewcarteruk-typed-arrays/health.svg)

```
[![Health](https://phpackages.com/badges/andrewcarteruk-typed-arrays/health.svg)](https://phpackages.com/packages/andrewcarteruk-typed-arrays)
```

###  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)[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k394.3M1.5k](/packages/nette-utils)[cuyz/valinor

Dependency free PHP library that helps to map any input into a strongly-typed structure.

1.5k9.2M108](/packages/cuyz-valinor)[phootwork/lang

Missing PHP language constructs

1224.8M8](/packages/phootwork-lang)[yzen.dev/plain-to-class

Class-transformer to transform your dataset into a structured object

16293.9k6](/packages/yzendev-plain-to-class)[michaldudek/foundation

A set of useful PHP classes.

13111.9k13](/packages/michaldudek-foundation)

PHPackages © 2026

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