TypedArrays
Typed arrays in PHP
Install / Use
/learn @AndrewCarterUK/TypedArraysREADME
Typed Arrays
Typed arrays in PHP.
Install
Install using Composer.
composer require andrewcarteruk/typed-arrays ^0.2
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
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
ArrayArray, BoolArray, CallableArray, FloatArray, InstanceArray($classPath), IntArray, NumericArray, ObjectArray, ResourceArray, ScalarArray, StringArray.
Related Skills
node-connect
345.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
106.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
345.9kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
345.9kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。



