Download the PHP package yiisoft/arrays without Composer
On this page you can find all versions of the php package yiisoft/arrays. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download yiisoft/arrays
More information about yiisoft/arrays
Files in yiisoft/arrays
Package arrays
Short Description Yii Array Helper
License BSD-3-Clause
Homepage https://www.yiiframework.com/
Informations about the package arrays
Yii Arrays
The package provides:
ArrayHelper
that has static methods to work with arrays;ArraySorter
that has static methods for sort arrays;ArrayAccessTrait
provides the implementation for \IteratorAggregate, \ArrayAccess and \Countable;ArrayableInterface
andArrayableTrait
for use in classes who want to support customizable representation of their instances.
Requirements
- PHP 8.0 or higher.
Installation
ArrayHelper usage
Array helper methods are static so usage is like the following:
Overall the helper has the following method groups.
Getting data
- getValue
- getValueByPath
- getColumn
- getObjectVars
Setting data
- addValue
- addValueByPath
- setValue
- setValueByPath
Removing data
- remove
- removeByPath
- removeValue
Detecting array types
- isIndexed
- isAssociative
HTML encoding and decoding values
- htmlDecode
- htmlEncode
Testing against arrays
- isIn
- isSubset
Transformation
- index
- group
- filter
- map
- merge
- parametrizedMerge
- renameKey
- toArray
Other
- keyExists
- pathExists
ArraySorter usage
Array sorter has one static method which usage is like the following:
ArrayAccessTrait usage
ArrayAccessTrait
provides the implementation for
\IteratorAggregate,
\ArrayAccess and
\Countable.
Note that ArrayAccessTrait
requires the class using it contain a property named data
which should be an array.
The data will be exposed by ArrayAccessTrait to support accessing the class object like an array.
Example of use:
ArrayableInterface and ArrayableTrait usage
ArrayableInterface
and its implementation ArrayableTrait
intended for use in classes who want to support customizable representation of their instances.
Example of use:
Testing
Unit testing
The package is tested with PHPUnit. To run tests:
Mutation testing
The package tests are checked with Infection mutation framework with Infection Static Analysis Plugin. To run it:
Static analysis
The code is statically analyzed with Psalm. To run static analysis:
License
The Yii Arrays is free software. It is released under the terms of the BSD License. Please see LICENSE
for more information.
Maintained by Yii Software.