andrewcarteruk/typed-arrays
Composer 安装命令:
composer require andrewcarteruk/typed-arrays
包简介
Typed arrays in PHP.
README 文档
README
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.
统计信息
- 总下载量: 33
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 38
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-01-21