馃梼 Array manipulation library for PHP, called Arrayy!

Last update: May 8, 2022

Build Status codecov.io Codacy Badge Latest Stable Version Total Downloads License Donate to this project using Paypal Donate to this project using Patreon

馃梼 Arrayy

A PHP array manipulation library. Compatible with PHP 7+ & PHP 8+

\Arrayy\Type\StringCollection::create(['Array', 'Array'])->unique()->append('y')->implode() // Arrayy

documentation via gitbooks.io

Installation via "composer require"

composer require voku/arrayy

Multidimensional ArrayAccess

You can access / change the array via Object, Array or with "Arrayy"-syntax.

Access via "Arrayy"-syntax: (dot-notation)

$arrayy = new A(['Lars' => ['lastname' => 'Moelleken']]);

$arrayy->get('Lars'); // ['lastname' => 'Moelleken']
$arrayy->get('Lars.lastname'); // 'Moelleken'

Access via "array"-syntax:

$arrayy = new A(['Lars' => ['lastname' => 'Moelleken']]);

$arrayy['Lars'];             // ['lastname' => 'Moelleken']
$arrayy['Lars']['lastname']; // 'Moelleken'

Access via "object"-syntax:

$arrayy = new A(['Lars' => ['lastname' => 'Moelleken']]);

$arrayy->Lars; // Arrayy['lastname' => 'Moelleken']
$arrayy->Lars->lastname; // 'Moelleken'

Set values via "Arrayy"-syntax: (dot-notation)

$arrayy = new A(['Lars' => ['lastname' => 'Mueller']]);

$arrayy->set('Lars.lastname', 'Moelleken');
$arrayy->get('Lars.lastname'); // 'Moelleken'

Set values via "array"-syntax:

$arrayy = new A(['Lars' => ['lastname' => 'Moelleken']]);

$arrayy['Lars'] = array('lastname' => 'M眉ller');
$arrayy['Lars']['lastname']; // 'M眉ller'

Set values via "object"-syntax:

$arrayy = new A(['Lars' => ['lastname' => 'Moelleken']]);

$arrayy->Lars = array('lastname' => 'M眉ller');
$arrayy->Lars->lastname; // 'M眉ller'

PhpDoc @property checking

The library offers a type checking for @property phpdoc-class-comments, as seen below:

/**
 * @property int        $id
 * @property int|string $firstName
 * @property string     $lastName
 * @property null|City  $city
 *
 * @extends  \Arrayy\Arrayy<array-key,mixed>
 */
class User extends \Arrayy\Arrayy
{
  protected $checkPropertyTypes = true;

  protected $checkPropertiesMismatchInConstructor = true;
}

/**
 * @property string|null $plz
 * @property string      $name
 * @property string[]    $infos
 *
 * @extends  \Arrayy\Arrayy<array-key,mixed>
 */
class City extends \Arrayy\Arrayy
{
    protected $checkPropertyTypes = true;

    protected $checkPropertiesMismatchInConstructor = true;
}

$cityMeta = City::meta();
$city = new City(
    [
        $cityMeta->plz   => null,
        $cityMeta->name  => 'D眉sseldorf',
        $cityMeta->infos => ['lall'],
    ]
);

$userMeta = User::meta();
$user = new User(
    [
        $userMeta->id        => 1,
        $userMeta->firstName => 'Lars',
        $userMeta->lastName  => 'Moelleken',
        $userMeta->city      => $city,
    ]
);

var_dump($user['lastName']); // 'Moelleken'
var_dump($user[$userMeta->lastName]); // 'Moelleken'
var_dump($user->lastName); // Moelleken

var_dump($user['city.name']); // 'D眉sseldorf'
var_dump($user[$userMeta->city][$cityMeta->name]); // 'D眉sseldorf'
var_dump($user->city->name); // D眉sseldorf
  • "checkPropertyTypes": activate the type checking for all defined @property in the class-phpdoc
  • "checkPropertiesMismatchInConstructor": activate the property mismatch check, so you can only add an array with all needed properties (or an empty array) into the constructor

OO and Chaining

The library also offers OO method chaining, as seen below:

echo a(['f貌么', 'b脿艡', 'b脿艡'])->unique()->reverse()->implode(','); // 'b脿艡,f貌么'

Implemented Interfaces

Arrayy\Arrayy implements the IteratorAggregate interface, meaning that foreach can be used with an instance of the class:

$arrayy = a(['f貌么b脿艡', 'foo']);
foreach ($arrayy as $value) {
    echo $value;
}
// 'f貌么b脿艡'
// 'foo'

It implements the Countable interface, enabling the use of count() to retrieve the number of elements in the array:

$arrayy = a(['f貌么', 'foo']);
count($arrayy);  // 2

PHP 5.6 Creation

As of PHP 5.6, use function is available for importing functions. Arrayy exposes a namespaced function, Arrayy\create, which emits the same behaviour as Arrayy\Arrayy::create(). If running PHP 5.6, or another runtime that supports the use function syntax, you can take advantage of an even simpler API as seen below:

use function Arrayy\create as a;

// Instead of: A::create(['f貌么', 'b脿艡'])->reverse()->implode();
a(['f貌么', 'b脿艡'])->reverse()->implode(','); // 'b脿艡,f貌么'

Collections

If you need to group objects together, it's not a good idea to use a simple array or Arrayy object. For these cases you can use the AbstractCollection class.

It will throw a InvalidArgumentException if you try to add a non valid object into the collection.

e.g.: "YOURCollection.php" (see example /tests/CollectionTest.php on github)

use Arrayy\Collection\AbstractCollection;

/**
 * @extends  AbstractCollection<array-key,YOURInterface>
 */
class YOURCollection extends AbstractCollection
{
    /**
     * The type (FQCN) associated with this collection.
     *
     * @return string
     */
    public function getType(): string
    {
        return YOURInterface::class;
    }
}

$YOURobject1 = new YOURClass();
$YOURobject2 = new YOURClass();

$YOURcollection = new YOURCollection($YOURobject1);
$YOURcollection->add($YOURobject2); // add one more object

// Or, you can use an array of objects.
//
// $YOURcollection = new YOURCollection([$YOURobject1, $YOURobject2]);

// Or, if you don't want to create new classes ... 
// ... and you don't need typehints and autocompletion via classes.
//
// $YOURcollection = \Arrayy\Collection::construct(YOURInterface::class, [$YOURobject1]);
// $YOURcollection->add($YOURobject2); // add one more object

// Or, if you don't like classes at all. ;-)
//
// $YOURcollection = \Arrayy\collection(YOURInterface::class, [$YOURobject1]);
// $YOURcollection->add($YOURobject2); // add one more object

foreach ($YOURcollection as $YOURobject) {
    if ($YOURobject instanceof YOURInterface) {
        // Do something with $YOURobject
    }
}

You can also use "dot-notation" to get data from your collections e.g. $YOURcollection->get('3123.foo.bar');

Pre-Defined Typified Collections

simple example

This will throw a "TypeError"-Exception.

use Arrayy\Type\StringCollection;

$collection = new StringCollection(['A', 'B', 'C', 1]);

complex example

This will NOT throw a "TypeError"-Exception.

use Arrayy\Type\IntCollection;
use Arrayy\Type\StringCollection;
use Arrayy\Type\InstancesCollection;
use Arrayy\Type\TypeInterface;

$collection = InstancesCollection::construct(
    TypeInterface::class,
    [new StringCollection(['A', 'B', 'C']), new IntCollection([1])]
);

$collection->toArray(true); // [['A', 'B', 'C'], [1]]

Convert JSON-Data into Objects (Collection)

namespace Arrayy\tests\Collection;

use Arrayy\Collection\AbstractCollection;

/**
 * @extends  AbstractCollection<array-key,\Arrayy\tests\UserData>
 */
class UserDataCollection extends AbstractCollection
{
    /**
     * The type (FQCN) associated with this collection.
     *
     * @return string
     */
    public function getType()
    {
        return \Arrayy\tests\UserData::class;
    }
}

$json = '[{"id":1,"firstName":"Lars","lastName":"Moelleken","city":{"name":"D眉sseldorf","plz":null,"infos":["lall"]}}, {"id":1,"firstName":"Sven","lastName":"Moelleken","city":{"name":"K枚ln","plz":null,"infos":["foo"]}}]';
$userDataCollection = UserDataCollection::createFromJsonMapper($json);

/** @var \Arrayy\tests\UserData[] $userDatas */
$userDataCollection->getAll();

$userData0 = $userDataCollection[0];
echo $userData0->firstName; // 'Lars'
$userData0->city; // CityData::class
echo $userData0->city->name; // 'D眉sseldorf'

$userData1 = $userDataCollection[1];
echo $userData1->firstName; // 'Sven'
$userData1->city; // CityData::class
echo $userData1->city->name; // 'K枚ln'

Class methods

use a "default object"

Creates an Arrayy object.

$arrayy = new Arrayy(array('f貌么', 'b脿艡')); // Arrayy['f貌么', 'b脿艡']
create(array $array) : Arrayy (Immutable)

Creates an Arrayy object, via static "create()"-method

$arrayy = A::create(array('f貌么', 'b脿艡')); // Arrayy['f貌么', 'b脿艡']
createByReference(array &$array) : Arrayy (Mutable)

WARNING: Creates an Arrayy object by reference.

$array = array('f貌么', 'b脿艡');
$arrayy = A::createByReference($array); // Arrayy['f貌么', 'b脿艡']
createFromJson(string $json) : Arrayy (Immutable)

Create an new Arrayy object via JSON.

$str = '{"firstName":"John", "lastName":"Doe"}';
$arrayy = A::createFromJson($str); // Arrayy['firstName' => 'John', 'lastName' => 'Doe']
createFromJsonMapper(string $json) : Arrayy (Immutable)

Create an new Arrayy object via JSON and fill sub-objects is possible.

<?php

namespace Arrayy\tests;

/**
 * @property int                         $id
 * @property int|string                  $firstName
 * @property string                      $lastName
 * @property \Arrayy\tests\CityData|null $city
 *
 * @extends  \Arrayy\Arrayy<array-key,mixed>
 */
class UserData extends \Arrayy\Arrayy
{
    protected $checkPropertyTypes = true;

    protected $checkForMissingPropertiesInConstructor = true;
}

/**
 * @property string|null $plz
 * @property string      $name
 * @property string[]    $infos
 *
 * @extends  \Arrayy\Arrayy<array-key,mixed>
 */
class CityData extends \Arrayy\Arrayy
{
    protected $checkPropertyTypes = true;

    protected $checkPropertiesMismatchInConstructor = true;

    protected $checkForMissingPropertiesInConstructor = true;

    protected $checkPropertiesMismatch = true;
}

$json = '{"id":1,"firstName":"Lars","lastName":"Moelleken","city":{"name":"D眉sseldorf","plz":null,"infos":["lall"]}}';
$userData = UserData::createFromJsonMapper($json);

$userData; // => \Arrayy\tests\UserData::class
echo $userData->firstName; // 'Lars' 
$userData->city; // => \Arrayy\tests\CityData::class
echo $userData->city->name; // 'D眉sseldorf'
createFromObject(ArrayAccess $object) : Arrayy (Immutable)

Create an new instance filled with values from an object that have implemented ArrayAccess.

$object = A::create(1, 'foo');
$arrayy = A::createFromObject($object); // Arrayy[1, 'foo']
createFromObjectVars(\object $object) : Arrayy (Immutable)

Create an new instance filled with values from an object.

$object = new stdClass();
$object->x = 42;
$arrayy = A::createFromObjectVars($object); // Arrayy['x' => 42]
createWithRange() : Arrayy (Immutable)

Create an new instance containing a range of elements.

$arrayy = A::createWithRange(2, 4); // Arrayy[2, 3, 4]
createFromGeneratorImmutable() : Arrayy (Immutable)

Create an new instance filled with a copy of values from a "Generator"-object.

WARNING: Need more memory then the "A::createFromGeneratorFunction()" call, because we will fetch and store all keys and values from the Generator.

$generator = A::createWithRange(2, 4)->getGenerator();
$arrayy = A::createFromGeneratorImmutable($generator); // Arrayy[2, 3, 4]
createFromGeneratorFunction() : Arrayy (Immutable)

Create an new instance from a callable function which will return a Generator.

$generatorFunction = static function() {
    yield from A::createWithRange(2, 4)->getArray();
};
$arrayy = A::createFromGeneratorFunction($generatorFunction); // Arrayy[2, 3, 4]
createFromString(string $str) : Arrayy (Immutable)

Create an new Arrayy object via string.

$arrayy = A::createFromString(' foo, bar '); // Arrayy['foo', 'bar']

Instance Methods

Arrayy: All examples below make use of PHP 5.6 function importing, and PHP 5.4 short array syntax. For further details, see the documentation for the create method above, as well as the notes on PHP 5.6 creation.

"set an array value"
$arrayy = a(['f貌么' => 'b脿艡']);
$arrayy['foo'] = 'bar';
var_dump($arrayy); // Arrayy['f貌么' => 'b脿艡', 'foo' => 'bar']
"get an array value"
$arrayy = a(['f貌么' => 'b脿艡']);
var_dump($arrayy['f貌么']); // 'b脿艡'
"get the array"
$arrayy = a(['f貌么' => 'b脿艡']);
var_dump($arrayy->getArray()); // ['f貌么' => 'b脿艡']
"delete an array value"
$arrayy = a(['f貌么' => 'b脿艡', 'lall']);
unset($arrayy['f貌么']);
var_dump($arrayy); // Arrayy[0 => 'lall']
"check if an array value is-set"
$arrayy = a(['f貌么' => 'b脿艡']);
isset($arrayy['f貌么']); // true
"simple loop with an Arrayy-object"
$arrayy = a(['f貌么' => 'b脿艡']);
foreach ($arrayy) as $key => $value) {
  echo $key . ' | ' . $value; // f貌么 | b脿艡
}

Arrayy methods

add append appendArrayValues appendImmutable
appendToEachKey appendToEachValue arsort arsortImmutable
asort asortImmutable at average
changeKeyCase changeSeparator chunk clean
clear contains containsCaseInsensitive containsKey
containsKeys containsKeysRecursive containsValue containsValueRecursive
containsValues count countValues create
createByReference createFromArray createFromGeneratorFunction createFromGeneratorImmutable
createFromJson createFromJsonMapper createFromObject createFromObjectVars
createFromString createFromTraversableImmutable createWithRange current
customSortKeys customSortKeysImmutable customSortValues customSortValuesImmutable
delete diff diffKey diffKeyAndValue
diffRecursive diffReverse divide each
end exchangeArray exists fillWithDefaults
filter filterBy find findBy
first firstKey firstsImmutable firstsKeys
firstsMutable flatten flip get
getAll getArray getArrayCopy getColumn
getGenerator getGeneratorByReference getIterator getIteratorClass
getKeys getList getObject getPhpDocPropertiesFromClass
getRandom getRandomKey getRandomKeys getRandomValue
getRandomValues getValues getValuesYield group
has hasValue implode implodeKeys
indexBy indexOf initial intersection
intersectionMulti intersects invoke isAssoc
isEmpty isEqual isMultiArray isNumeric
isSequential jsonSerialize key keyExists
keys krsort krsortImmutable ksort
ksortImmutable last lastKey lastsImmutable
lastsMutable length map matches
matchesAny max mergeAppendKeepIndex mergeAppendNewIndex
mergePrependKeepIndex mergePrependNewIndex meta min
mostUsedValue mostUsedValues moveElement moveElementToFirstPlace
moveElementToLastPlace natcasesort natcasesortImmutable natsort
natsortImmutable next nth offsetExists
offsetGet offsetSet offsetUnset only
pad partition pop prepend
prependImmutable prependToEachKey prependToEachValue pull
push randomImmutable randomKey randomKeys
randomMutable randomValue randomValues randomWeighted
reduce reduce_dimension reindex reject
remove removeElement removeFirst removeLast
removeValue repeat replace replaceAllKeys
replaceAllValues replaceKeys replaceOneValue replaceValues
rest reverse rsort rsortImmutable
searchIndex searchValue serialize set
setAndGet setIteratorClass shift shuffle
size sizeIs sizeIsBetween sizeIsGreaterThan
sizeIsLessThan sizeRecursive slice sort
sortImmutable sortKeys sortKeysImmutable sortValueKeepIndex
sortValueNewIndex sorter splice split
stripEmpty swap toArray toJson
toList toPermutation toString uasort
uasortImmutable uksort uksortImmutable unique
uniqueKeepIndex uniqueNewIndex unserialize unshift
validate values walk where

add(mixed $value, int|string|null $key): static

Add new values (optional using dot-notation).

Parameters:

  • T $value
  • TKey $key

Return:

  • static <p>(Immutable) Return this Arrayy object, with the appended values.</p>

append(mixed $value, mixed $key): $this

Append a (key) + value to the current array.

EXAMPLE: a(['f貌么' => 'b脿艡'])->append('foo'); // Arrayy['f貌么' => 'b脿艡', 0 => 'foo']

Parameters:

  • T $value
  • TKey|null $key

Return:

  • $this <p>(Mutable) Return this Arrayy object, with the appended values.</p>

appendArrayValues(array $values, mixed $key): $this

Append a (key) + values to the current array.

EXAMPLE: a(['f貌么' => ['b脿艡']])->appendArrayValues(['foo1', 'foo2'], 'f貌么'); // Arrayy['f貌么' => ['b脿艡', 'foo1', 'foo2']]

Parameters:

  • array<array-key, T> $values
  • TKey|null $key

Return:

  • $this <p>(Mutable) Return this Arrayy object, with the appended values.</p>

appendImmutable(mixed $value, mixed $key): $this

Append a (key) + value to the current array.

EXAMPLE: a(['f貌么' => 'b脿艡'])->appendImmutable('foo')->getArray(); // ['f貌么' => 'b脿艡', 0 => 'foo']

Parameters:

  • T $value
  • TKey $key

Return:

  • $this <p>(Immutable) Return this Arrayy object, with the appended values.</p>

appendToEachKey(int|string $prefix): static

Add a suffix to each key.

Parameters:

  • int|string $prefix

Return:

  • static <p>(Immutable) Return an Arrayy object, with the prefixed keys.</p>

appendToEachValue(float|int|string $prefix): static

Add a prefix to each value.

Parameters:

  • float|int|string $prefix

Return:

  • static <p>(Immutable) Return an Arrayy object, with the prefixed values.</p>

arsort(): $this

Sort an array in reverse order and maintain index association.

Parameters: nothing

Return:

  • $this <p>(Mutable) Return this Arrayy object.</p>

arsortImmutable(): $this

Sort an array in reverse order and maintain index association.

Parameters: nothing

Return:

  • $this <p>(Immutable) Return this Arrayy object.</p>

asort(int $sort_flags): $this

Sort the entries by value.

Parameters:

  • `int $sort_flags [optional]

    You may modify the behavior of the sort using the optional parameter sort_flags, for details see sort.

`

Return:

  • $this <p>(Mutable) Return this Arrayy object.</p>

asortImmutable(int $sort_flags): $this

Sort the entries by value.

Parameters:

  • `int $sort_flags [optional]

    You may modify the behavior of the sort using the optional parameter sort_flags, for details see sort.

`

Return:

  • $this <p>(Immutable) Return this Arrayy object.</p>

at(\Closure $closure): static

Iterate over the current array and execute a callback for each loop.

EXAMPLE: $result = A::create(); $closure = function ($value, $key) use ($result) { $result[$key] = ':' . $value . ':'; }; a(['foo', 'bar' => 'bis'])->at($closure); // Arrayy[':foo:', 'bar' => ':bis:']

Parameters:

  • \Closure $closure

Return:

  • static <p>(Immutable)</p>

average(int $decimals): float|int

Returns the average value of the current array.

EXAMPLE: a([-9, -8, -7, 1.32])->average(2); // -5.67

Parameters:

  • int $decimals <p>The number of decimal-numbers to return.</p>

Return:

  • float|int <p>The average value.</p>

changeKeyCase(int $case): static

Changes all keys in an array.

Parameters:

  • int $case [optional] <p> Either <strong>CASE_UPPER</strong><br /> or <strong>CASE_LOWER</strong> (default)</p>

Return:

  • static <p>(Immutable)</p>

changeSeparator(string $separator): $this

Change the path separator of the array wrapper.

By default, the separator is: "."

Parameters:

  • string $separator <p>Separator to set.</p>

Return:

  • $this <p>(Mutable) Return this Arrayy object.</p>

chunk(int $size, bool $preserveKeys): static

Create a chunked version of the current array.

EXAMPLE: a([-9, -8, -7, 1.32])->chunk(2); // Arrayy[[-9, -8], [-7, 1.32]]

Parameters:

  • int $size <p>Size of each chunk.</p>
  • bool $preserveKeys <p>Whether array keys are preserved or no.</p>

Return:

  • static <p>(Immutable) A new array of chunks from the original array.</p>

clean(): static

Clean all falsy values from the current array.

EXAMPLE: a([-8 => -9, 1, 2 => false])->clean(); // Arrayy[-8 => -9, 1]

Parameters: nothing

Return:

  • static <p>(Immutable)</p>

clear(int|int[]|string|string[]|null $key): $this

WARNING!!! -> Clear the current full array or a $key of it.

EXAMPLE: a([-8 => -9, 1, 2 => false])->clear(); // Arrayy[]

Parameters:

  • int|int[]|string|string[]|null $key

Return:

  • $this <p>(Mutable) Return this Arrayy object, with an empty array.</p>

contains(float|int|string $value, bool $recursive, bool $strict): bool

Check if an item is in the current array.

EXAMPLE: a([1, true])->contains(true); // true

Parameters:

  • float|int|string $value
  • bool $recursive
  • bool $strict

Return:

  • bool

containsCaseInsensitive(mixed $value, bool $recursive): bool

Check if an (case-insensitive) string is in the current array.

EXAMPLE: a(['E', '茅'])->containsCaseInsensitive('脡'); // true

Parameters:

  • mixed $value
  • bool $recursive

Return:

  • bool

containsKey(int|string $key): bool

Check if the given key/index exists in the array.

EXAMPLE: a([1 => true])->containsKey(1); // true

Parameters:

  • int|string $key <p>key/index to search for</p>

Return:

  • bool <p>Returns true if the given key/index exists in the array, false otherwise.</p>

containsKeys(array $needles, bool $recursive): bool

Check if all given needles are present in the array as key/index.

EXAMPLE: a([1 => true])->containsKeys(array(1 => 0)); // true

Parameters:

  • array<array-key>|array<TKey> $needles <p>The keys you are searching for.</p>
  • bool $recursive

Return:

  • bool <p>Returns true if all the given keys/indexes exists in the array, false otherwise.</p>

containsKeysRecursive(array $needles): bool

Check if all given needles are present in the array as key/index.

Parameters:

  • array<array-key>|array<TKey> $needles <p>The keys you are searching for.</p>

Return:

  • bool <p>Returns true if all the given keys/indexes exists in the array, false otherwise.</p>

containsValue(float|int|string $value): bool

alias: for "Arrayy->contains()"

Parameters:

  • float|int|string $value

Return:

  • bool

containsValueRecursive(float|int|string $value): bool

alias: for "Arrayy->contains($value, true)"

Parameters:

  • float|int|string $value

Return:

  • bool

containsValues(array $needles): bool

Check if all given needles are present in the array.

EXAMPLE: a([1, true])->containsValues(array(1, true)); // true

Parameters:

  • array<mixed>|array<T> $needles

Return:

  • bool <p>Returns true if all the given values exists in the array, false otherwise.</p>

count(int $mode): int

Counts all elements in an array, or something in an object.

EXAMPLE: a([-9, -8, -7, 1.32])->count(); // 4

For objects, if you have SPL installed, you can hook into count() by implementing interface {@see \Countable}. The interface has exactly one method, {@see \Countable::count()}, which returns the return value for the count() function. Please see the {@see \Array} section of the manual for a detailed explanation of how arrays are implemented and used in PHP.

Parameters:

  • int $mode [optional] If the optional mode parameter is set to COUNT_RECURSIVE (or 1), count will recursively count the array. This is particularly useful for counting all the elements of a multidimensional array. count does not detect infinite recursion.

Return:

  • `int

    The number of elements in var, which is typically an array, since anything else will have one element.

If var is not an array or an object with implemented Countable interface, 1 will be returned. There is one exception, if var is &null;, 0 will be returned.

Caution: count may return 0 for a variable that isn't set, but it may also return 0 for a variable that has been initialized with an empty array. Use isset to test if a variable is set.

`

countValues(): static

Counts all the values of an array

Parameters: nothing

Return:

  • `static

    (Immutable) An associative Arrayy-object of values from input as keys and their count as value.

`

create(mixed $data, string $iteratorClass, bool $checkPropertiesInConstructor): static

Creates an Arrayy object.

Parameters:

  • mixed $data
  • class-string<\Arrayy\ArrayyIterator> $iteratorClass
  • bool $checkPropertiesInConstructor

Return:

  • static <p>(Immutable) Returns an new instance of the Arrayy object.</p>

createByReference(array $array): $this

WARNING: Creates an Arrayy object by reference.

Parameters:

  • array<TKey, T> $array

Return:

  • $this <p>(Mutable) Return this Arrayy object.</p>

createFromArray(array $array): static

Create an new Arrayy object via JSON.

Parameters:

  • array<TKey, T> $array

Return:

  • static <p>(Immutable) Returns an new instance of the Arrayy object.</p>

createFromGeneratorFunction(callable $generatorFunction): static

Create an new instance from a callable function which will return an Generator.

Parameters:

  • callable(): \Generator<TKey, T> $generatorFunction

Return:

  • static <p>(Immutable) Returns an new instance of the Arrayy object.</p>

createFromGeneratorImmutable(\Generator $generator): static

Create an new instance filled with a copy of values from a "Generator"-object.

Parameters:

  • \Generator<TKey, T> $generator

Return:

  • static <p>(Immutable) Returns an new instance of the Arrayy object.</p>

createFromJson(string $json): static

Create an new Arrayy object via JSON.

Parameters:

  • string $json

Return:

  • static <p>(Immutable) Returns an new instance of the Arrayy object.</p>

createFromJsonMapper(string $json): $this

Parameters:

  • string $json

Return:

  • $this

createFromObject(\Traversable $object): static

Create an new instance filled with values from an object that is iterable.

Parameters:

  • \Traversable<array-key, T> $object <p>iterable object</p>

Return:

  • static <p>(Immutable) Returns an new instance of the Arrayy object.</p>

createFromObjectVars(object $object): static

Create an new instance filled with values from an object.

Parameters:

  • object $object

Return:

  • static <p>(Immutable) Returns an new instance of the Arrayy object.</p>

createFromString(string $str, string|null $delimiter, string|null $regEx): static

Create an new Arrayy object via string.

Parameters:

  • string $str <p>The input string.</p>
  • string|null $delimiter <p>The boundary string.</p>
  • string|null $regEx <p>Use the $delimiter or the $regEx, so if $pattern is null, $delimiter will be used.</p>

Return:

  • static <p>(Immutable) Returns an new instance of the Arrayy object.</p>

createFromTraversableImmutable(\Traversable $traversable, bool $use_keys): static

Create an new instance filled with a copy of values from a "Traversable"-object.

Parameters:

  • \Traversable<(array-key|TKey), T> $traversable
  • `bool $use_keys [optional]

    Whether to use the iterator element keys as index.

`

Return:

  • static <p>(Immutable) Returns an new instance of the Arrayy object.</p>

createWithRange(float|int|string $low, float|int|string $high, float|int $step): static

Create an new instance containing a range of elements.

Parameters:

  • float|int|string $low <p>First value of the sequence.</p>
  • float|int|string $high <p>The sequence is ended upon reaching the end value.</p>
  • float|int $step <p>Used as the increment between elements in the sequence.</p>

Return:

  • static <p>(Immutable) Returns an new instance of the Arrayy object.</p>

current(): false|mixed

Gets the element of the array at the current internal iterator position.

Parameters: nothing

Return:

  • false|mixed

customSortKeys(callable $function): $this

Custom sort by index via "uksort".

EXAMPLE: $callable = function ($a, $b) { if ($a == $b) { return 0; } return ($a > $b) ? 1 : -1; }; $arrayy = a(['three' => 3, 'one' => 1, 'two' => 2]); $resultArrayy = $arrayy->customSortKeys($callable); // Arrayy['one' => 1, 'three' => 3, 'two' => 2]

Parameters:

  • callable $function

Return:

  • $this <p>(Mutable) Return this Arrayy object.</p>

customSortKeysImmutable(callable $function): $this

Custom sort by index via "uksort".

Parameters:

  • callable $function

Return:

  • $this <p>(Immutable) Return this Arrayy object.</p>

customSortValues(callable $function): $this

Custom sort by value via "usort".

EXAMPLE: $callable = function ($a, $b) { if ($a == $b) { return 0; } return ($a > $b) ? 1 : -1; }; $arrayy = a(['three' => 3, 'one' => 1, 'two' => 2]); $resultArrayy = $arrayy->customSortValues($callable); // Arrayy['one' => 1, 'two' => 2, 'three' => 3]

Parameters:

  • callable $function

Return:

  • $this <p>(Mutable) Return this Arrayy object.</p>

customSortValuesImmutable(callable $function): $this

Custom sort by value via "usort".

Parameters:

  • callable $function

Return:

  • $this <p>(Immutable) Return this Arrayy object.</p>

delete(int|int[]|string|string[] $keyOrKeys): void

Delete the given key or keys.

Parameters:

  • int|int[]|string|string[] $keyOrKeys

Return:

  • void

diff(array $array): static

Return elements where the values that are only in the current array.

EXAMPLE: a([1 => 1, 2 => 2])->diff([1 => 1]); // Arrayy[2 => 2]

Parameters:

  • array<TKey, T> ...$array

Return:

  • static <p>(Immutable)</p>

diffKey(array $array): static

Return elements where the keys are only in the current array.

Parameters:

  • array<TKey, T> ...$array

Return:

  • static <p>(Immutable)</p>

diffKeyAndValue(array $array): static

Return elements where the values and keys are only in the current array.

Parameters:

  • array<TKey, T> ...$array

Return:

  • static <p>(Immutable)</p>

diffRecursive(array $array, array|\Generator|null $helperVariableForRecursion): static

Return elements where the values are only in the current multi-dimensional array.

EXAMPLE: a([1 => [1 => 1], 2 => [2 => 2]])->diffRecursive([1 => [1 => 1]]); // Arrayy[2 => [2 => 2]]

Parameters:

  • array<TKey, T> $array
  • null|array<TKey, T>|\Generator<TKey, T> $helperVariableForRecursion <p>(only for internal usage)</p>

Return:

  • static <p>(Immutable)</p>

diffReverse(array $array): static

Return elements where the values that are only in the new $array.

EXAMPLE: a([1 => 1])->diffReverse([1 => 1, 2 => 2]); // Arrayy[2 => 2]

Parameters:

  • array<TKey, T> $array

Return:

  • static <p>(Immutable)</p>

divide(): static

Divide an array into two arrays. One with keys and the other with values.

EXAMPLE: a(['a' => 1, 'b' => ''])->divide(); // Arrayy[Arrayy['a', 'b'], Arrayy[1, '']]

Parameters: nothing

Return:

  • static <p>(Immutable)</p>

each(\Closure $closure): static

Iterate over the current array and modify the array's value.

EXAMPLE: $result = A::create(); $closure = function ($value) { return ':' . $value . ':'; }; a(['foo', 'bar' => 'bis'])->each($closure); // Arrayy[':foo:', 'bar' => ':bis:']

Parameters:

  • \Closure(T = default): T|\Closure(T = default, TKey = default): T $closure

Return:

  • static <p>(Immutable)</p>

end(): false|mixed

Sets the internal iterator to the last element in the array and returns this element.

Parameters: nothing

Return:

  • false|mixed

exchangeArray(array|mixed|static $data): array

Exchange the array for another one.

Parameters:

  • `T|array<TKey, T>|self<TKey, T> $data 1. use the current array, if it's a array
  1. fallback to empty array, if there is nothing
  2. call "getArray()" on object, if there is a "Arrayy"-object
  3. call "createFromObject()" on object, if there is a "\Traversable"-object
  4. call "__toArray()" on object, if the method exists
  5. cast a string or object with "__toString()" into an array
  6. throw a "InvalidArgumentException"-Exception`

Return:

  • array

exists(\Closure $closure): bool

Check if a value is in the current array using a closure.

EXAMPLE: $callable = function ($value, $key) { return 2 === $key and 'two' === $value; }; a(['foo', 2 => 'two'])->exists($callable); // true

Parameters:

  • \Closure(T = default, TKey = default): bool $closure

Return:

  • bool <p>Returns true if the given value is found, false otherwise.</p>

fillWithDefaults(int $num, mixed $default): static

Fill the array until "$num" with "$default" values.

EXAMPLE: a(['bar'])->fillWithDefaults(3, 'foo'); // Arrayy['bar', 'foo', 'foo']

Parameters:

  • int $num
  • T $default

Return:

  • static <p>(Immutable)</p>

filter(\Closure|null $closure, int $flag): static

Find all items in an array that pass the truth test.

EXAMPLE: $closure = function ($value) { return $value % 2 !== 0; } a([1, 2, 3, 4])->filter($closure); // Arrayy[0 => 1, 2 => 3]

Parameters:

  • `null|\Closure(T = default, TKey = default): bool|\Closure(T = default): bool|\Closure(TKey = default): bool $closure [optional]

    The callback function to use

If no callback is supplied, all entries of input equal to false (see converting to boolean) will be removed.

` - `int $flag [optional]

Flag determining what arguments are sent to callback:

  • ARRAY_FILTER_USE_KEY (1) - pass key as the only argument to callback instead of the value
  • ARRAY_FILTER_USE_BOTH (2) - pass both value and key as arguments to callback instead of the value
`

Return:

  • static <p>(Immutable)</p>

filterBy(string $property, mixed $value, string|null $comparisonOp): static

Filters an array of objects (or a numeric array of associative arrays) based on the value of a particular property within that.

Parameters:

  • string $property
  • array|T $value
  • `string|null $comparisonOp

    'eq' (equals),
    'gt' (greater),
    'gte' || 'ge' (greater or equals),
    'lt' (less),
    'lte' || 'le' (less or equals),
    'ne' (not equals),
    'contains',
    'notContains',
    'newer' (via strtotime),
    'older' (via strtotime),

`

Return:

  • static <p>(Immutable)</p>

find(\Closure $closure): false|mixed

Find the first item in an array that passes the truth test, otherwise return false.

EXAMPLE: $search = 'foo'; $closure = function ($value, $key) use ($search) { return $value === $search; }; a(['foo', 'bar', 'lall'])->find($closure); // 'foo'

Parameters:

  • \Closure(T = default, TKey = default): bool $closure

Return:

  • false|mixed <p>Return false if we did not find the value.</p>

findBy(string $property, mixed $value, string $comparisonOp): static

find by .

..

EXAMPLE: $array = [ 0 => ['id' => 123, 'name' => 'foo', 'group' => 'primary', 'value' => 123456, 'when' => '2014-01-01'], 1 => ['id' => 456, 'name' => 'bar', 'group' => 'primary', 'value' => 1468, 'when' => '2014-07-15'], ]; a($array)->filterBy('name', 'foo'); // Arrayy[0 => ['id' => 123, 'name' => 'foo', 'group' => 'primary', 'value' => 123456, 'when' => '2014-01-01']]

Parameters:

  • string $property
  • array|T $value
  • string $comparisonOp

Return:

  • static <p>(Immutable)</p>

first(): mixed|null

Get the first value from the current array.

EXAMPLE: a([2 => 'foo', 3 => 'bar', 4 => 'lall'])->first(); // 'foo'

Parameters: nothing

Return:

  • mixed|null <p>Return null if there wasn't a element.</p>

firstKey(): mixed|null

Get the first key from the current array.

Parameters: nothing

Return:

  • mixed|null <p>Return null if there wasn't a element.</p>

firstsImmutable(int|null $number): static

Get the first value(s) from the current array.

And will return an empty array if there was no first entry.

EXAMPLE: a([2 => 'foo', 3 => 'bar', 4 => 'lall'])->firstsImmutable(2); // Arrayy[0 => 'foo', 1 => 'bar']

Parameters:

  • int|null $number <p>How many values you will take?</p>

Return:

  • static <p>(Immutable)</p>

firstsKeys(int|null $number): static

Get the first value(s) from the current array.

And will return an empty array if there was no first entry.

Parameters:

  • int|null $number <p>How many values you will take?</p>

Return:

  • static <p>(Immutable)</p>

firstsMutable(int|null $number): $this

Get and remove the first value(s) from the current array.

And will return an empty array if there was no first entry.

EXAMPLE: a([2 => 'foo', 3 => 'bar', 4 => 'lall'])->firstsMutable(); // 'foo'

Parameters:

  • int|null $number <p>How many values you will take?</p>

Return:

  • $this <p>(Mutable)</p>

flatten(string $delimiter, string $prepend, array|null $items): array

Flatten an array with the given character as a key delimiter.

EXAMPLE: $dot = a(['foo' => ['abc' => 'xyz', 'bar' => ['baz']]]); $flatten = $dot->flatten(); $flatten['foo.abc']; // 'xyz' $flatten['foo.bar.0']; // 'baz'

Parameters:

  • string $delimiter
  • string $prepend
  • array|null $items

Return:

  • array

flip(): static

Exchanges all keys with their associated values in an array.

EXAMPLE: a([0 => 'foo', 1 => 'bar'])->flip(); // Arrayy['foo' => 0, 'bar' => 1]

Parameters: nothing

Return:

  • static <p>(Immutable)</p>

get(int|string $key, mixed $fallback, array|null $array, bool $useByReference): mixed|static

Get a value from an array (optional using dot-notation).

EXAMPLE: $arrayy = a(['user' => ['lastname' => 'Moelleken']]); $arrayy->get('user.lastname'); // 'Moelleken' // --- $arrayy = new A(); $arrayy['user'] = ['lastname' => 'Moelleken']; $arrayy['user.firstname'] = 'Lars'; $arrayy['user']['lastname']; // Moelleken $arrayy['user.lastname']; // Moelleken $arrayy['user.firstname']; // Lars

Parameters:

  • array-key $key <p>The key to look for.</p>
  • mixed $fallback <p>Value to fallback to.</p>
  • array<array-key, mixed>|array<TKey, T> $array <p>The array to get from, if it's set to "null" we use the current array from the class.</p>
  • bool $useByReference

Return:

  • mixed|static

getAll(): array

alias: for "Arrayy->toArray()"

Parameters: nothing

Return:

  • array

getArray(bool $convertAllArrayyElements, bool $preserveKeys): array

Get the current array from the "Arrayy"-object.

alias for "toArray()"

Parameters:

  • `bool $convertAllArrayyElements

    Convert all Child-"Arrayy" objects also to arrays.

` - `bool $preserveKeys

e.g.: A generator maybe return the same key more then once, so maybe you will ignore the keys.

`

Return:

  • array

getArrayCopy(): array

Creates a copy of the ArrayyObject.

Parameters: nothing

Return:

  • array

getColumn(int|string|null $columnKey, int|string|null $indexKey): static

Returns the values from a single column of the input array, identified by the $columnKey, can be used to extract data-columns from multi-arrays.

EXAMPLE: a([['foo' => 'bar', 'id' => 1], ['foo => 'lall', 'id' => 2]])->getColumn('foo', 'id'); // Arrayy[1 => 'bar', 2 => 'lall']

INFO: Optionally, you may provide an $indexKey to index the values in the returned array by the values from the $indexKey column in the input array.

Parameters:

  • int|string|null $columnKey
  • int|string|null $indexKey

Return:

  • static <p>(Immutable)</p>

getGenerator(): Generator

Get the current array from the "Arrayy"-object as generator.

Parameters: nothing

Return:

  • \Generator

getGeneratorByReference(): Generator

Get the current array from the "Arrayy"-object as generator by reference.

Parameters: nothing

Return:

  • \Generator

getIterator(): Iterator<mixed,mixed>

Returns a new iterator, thus implementing the \Iterator interface.

EXAMPLE: a(['foo', 'bar'])->getIterator(); // ArrayyIterator['foo', 'bar']

Parameters: nothing

Return:

  • \Iterator<mixed,mixed> <p>An iterator for the values in the array.</p>

getIteratorClass(): string

Gets the iterator classname for the ArrayObject.

Parameters: nothing

Return:

  • string

getKeys(): static

alias: for "Arrayy->keys()"

Parameters: nothing

Return:

  • static <p>(Immutable)</p>

getList(bool $convertAllArrayyElements): array

Get the current array from the "Arrayy"-object as list.

alias for "toList()"

Parameters:

  • `bool $convertAllArrayyElements

    Convert all Child-"Arrayy" objects also to arrays.

`

Return:

  • array

getObject(): stdClass

Get the current array from the "Arrayy"-object as object.

Parameters: nothing

Return:

  • \stdClass

getPhpDocPropertiesFromClass():

Parameters: nothing

Return:

  • TODO: __not_detected__

getRandom(): static

alias: for "Arrayy->randomImmutable()"

Parameters: nothing

Return:

  • static <p>(Immutable)</p>

getRandomKey(): null|mixed

alias: for "Arrayy->randomKey()"

Parameters: nothing

Return:

  • null|mixed <p>Get a key/index or null if there wasn't a key/index.</p>

getRandomKeys(int $number): static

alias: for "Arrayy->randomKeys()"

Parameters:

  • int $number

Return:

  • static <p>(Immutable)</p>

getRandomValue(): null|mixed

alias: for "Arrayy->randomValue()"

Parameters: nothing

Return:

  • null|mixed <p>Get a random value or null if there wasn't a value.</p>

getRandomValues(int $number): static

alias: for "Arrayy->randomValues()"

Parameters:

  • int $number

Return:

  • static <p>(Immutable)</p>

getValues(): static

Gets all values.

Parameters: nothing

Return:

  • static <p>The values of all elements in this array, in the order they appear in the array.</p>

getValuesYield(): Generator

Gets all values via Generator.

Parameters: nothing

Return:

  • \Generator <p>The values of all elements in this array, in the order they appear in the array as Generator.</p>

group(callable|string $grouper, bool $saveKeys): static

Group values from a array according to the results of a closure.

Parameters:

  • callable|string $grouper <p>A callable function name.</p>
  • bool $saveKeys

Return:

  • static <p>(Immutable)</p>

has(mixed $key): bool

Check if an array has a given key.

Parameters:

  • null|TKey|array-key $key

Return:

  • bool

hasValue(mixed $value): bool

Check if an array has a given value.

INFO: If you need to search recursive please use contains($value, true).

Parameters:

  • T $value

Return:

  • bool

implode(string $glue, string $prefix): string

Implodes the values of this array.

EXAMPLE: a([0 => -9, 1, 2])->implode('|'); // '-9|1|2'

Parameters:

  • string $glue
  • string $prefix

Return:

  • string

implodeKeys(string $glue): string

Implodes the keys of this array.

Parameters:

  • string $glue

Return:

  • string

indexBy(int|string $key): static

Given a list and an iterate-function that returns a key for each element in the list (or a property name), returns an object with an index of each item.

Parameters:

  • array-key $key

Return:

  • static <p>(Immutable)</p>

indexOf(mixed $value): false|int|string

alias: for "Arrayy->searchIndex()"

Parameters:

  • T $value <p>The value to search for.</p>

Return:

  • false|int|string

initial(int $to): static

Get everything but the last.

.$to items.

EXAMPLE: a([2 => 'foo', 3 => 'bar', 4 => 'lall'])->initial(2); // Arrayy[0 => 'foo']

Parameters:

  • int $to

Return:

  • static <p>(Immutable)</p>

intersection(array $search, bool $keepKeys): static

Return an array with all elements found in input array.

EXAMPLE: a(['foo', 'bar'])->intersection(['bar', 'baz']); // Arrayy['bar']

Parameters:

  • array<TKey, T> $search
  • bool $keepKeys

Return:

  • static <p>(Immutable)</p>

intersectionMulti(array $array): static

Return an array with all elements found in input array.

Parameters:

  • array<array<TKey, T>> ...$array

Return:

  • static <p>(Immutable)</p>

intersects(array $search): bool

Return a boolean flag which indicates whether the two input arrays have any common elements.

EXAMPLE: a(['foo', 'bar'])->intersects(['f枚枚', 'b盲r']); // false

Parameters:

  • array<TKey, T> $search

Return:

  • bool

invoke(callable $callable, mixed $arguments): static

Invoke a function on all of an array's values.

Parameters:

  • callable(T = default, mixed ): mixed $callable
  • mixed $arguments

Return:

  • static <p>(Immutable)</p>

isAssoc(bool $recursive): bool

Check whether array is associative or not.

EXAMPLE: a(['foo' => 'bar', 2, 3])->isAssoc(); // true

Parameters:

  • bool $recursive

Return:

  • bool <p>Returns true if associative, false otherwise.</p>

isEmpty(int|int[]|string|string[]|null $keys): bool

Check if a given key or keys are empty.

Parameters:

  • int|int[]|string|string[]|null $keys

Return:

  • bool <p>Returns true if empty, false otherwise.</p>

isEqual(array $array): bool

Check if the current array is equal to the given "$array" or not.

EXAMPLE: a(['馃挬'])->isEqual(['馃挬']); // true

Parameters:

  • array<array-key, mixed> $array

Return:

  • bool

isMultiArray(): bool

Check if the current array is a multi-array.

EXAMPLE: a(['foo' => [1, 2 , 3]])->isMultiArray(); // true

Parameters: nothing

Return:

  • bool

isNumeric(): bool

Check whether array is numeric or not.

Parameters: nothing

Return:

  • bool <p>Returns true if numeric, false otherwise.</p>

isSequential(bool $recursive): bool

Check if the current array is sequential [0, 1, 2, 3, 4, 5 .

..] or not.

EXAMPLE: a([0 => 'foo', 1 => 'lall', 2 => 'foobar'])->isSequential(); // true

INFO: If the array is empty we count it as non-sequential.

Parameters:

  • bool $recursive

Return:

  • bool

jsonSerialize(): array

Parameters: nothing

Return:

  • array

key(): int|string|null

Gets the key/index of the element at the current internal iterator position.

Parameters: nothing

Return:

  • int|string|null

keyExists(int|string $key): bool

Checks if the given key exists in the provided array.

INFO: This method only use "array_key_exists()" if you want to use "dot"-notation, then you need to use "Arrayy->offsetExists()".

Parameters:

  • int|string $key the key to look for

Return:

  • bool

keys(bool $recursive, mixed|null $search_values, bool $strict): static

Get all keys from the current array.

EXAMPLE: a([1 => 'foo', 2 => 'foo2', 3 => 'bar'])->keys(); // Arrayy[1, 2, 3]

Parameters:

  • `bool $recursive [optional]

    Get all keys, also from all sub-arrays from an multi-dimensional array.

` - `null|T|T[] $search_values [optional]

If specified, then only keys containing these values are returned.

` - `bool $strict [optional]

Determines if strict comparison (===) should be used during the search.

`

Return:

  • static <p>(Immutable) An array of all the keys in input.</p>

krsort(int $sort_flags): $this

Sort an array by key in reverse order.

Parameters:

  • `int $sort_flags [optional]

    You may modify the behavior of the sort using the optional parameter sort_flags, for details see sort.

`

Return:

  • $this <p>(Mutable) Return this Arrayy object.</p>

krsortImmutable(int $sort_flags): $this

Sort an array by key in reverse order.

Parameters:

  • `int $sort_flags [optional]

    You may modify the behavior of the sort using the optional parameter sort_flags, for details see sort.

`

Return:

  • $this <p>(Immutable) Return this Arrayy object.</p>

ksort(int $sort_flags): $this

Sort the entries by key.

Parameters:

  • `int $sort_flags [optional]

    You may modify the behavior of the sort using the optional parameter sort_flags, for details see sort.

`

Return:

  • $this <p>(Mutable) Return this Arrayy object.</p>

ksortImmutable(int $sort_flags): $this

Sort the entries by key.

Parameters:

  • `int $sort_flags [optional]

    You may modify the behavior of the sort using the optional parameter sort_flags, for details see sort.

`

Return:

  • $this <p>(Immutable) Return this Arrayy object.</p>

last(): mixed|null

Get the last value from the current array.

EXAMPLE: a([2 => 'foo', 3 => 'bar', 4 => 'lall'])->last(); // 'lall'

Parameters: nothing

Return:

  • mixed|null <p>Return null if there wasn't a element.</p>

lastKey(): mixed|null

Get the last key from the current array.

Parameters: nothing

Return:

  • mixed|null <p>Return null if there wasn't a element.</p>

lastsImmutable(int|null $number): static

Get the last value(s) from the current array.

EXAMPLE: a([2 => 'foo', 3 => 'bar', 4 => 'lall'])->lasts(2); // Arrayy[0 => 'bar', 1 => 'lall']

Parameters:

  • int|null $number

Return:

  • static <p>(Immutable)</p>

lastsMutable(int|null $number): $this

Get the last value(s) from the current array.

EXAMPLE: a([2 => 'foo', 3 => 'bar', 4 => 'lall'])->lasts(2); // Arrayy[0 => 'bar', 1 => 'lall']

Parameters:

  • int|null $number

Return:

  • $this <p>(Mutable)</p>

length(int $mode): int

Count the values from the current array.

alias: for "Arrayy->count()"

Parameters:

  • int $mode

Return:

  • int

map(callable $callable, bool $useKeyAsSecondParameter, mixed $arguments): static

Apply the given function to the every element of the array, collecting the results.

EXAMPLE: a(['foo', 'Foo'])->map('mb_strtoupper'); // Arrayy['FOO', 'FOO']

Parameters:

  • callable(T , TKey = default, mixed = default): T2 $callable
  • bool $useKeyAsSecondParameter
  • mixed ...$arguments

Return:

  • static <p>(Immutable) Arrayy object with modified elements.</p>

matches(\Closure $closure): bool

Check if all items in current array match a truth test.

EXAMPLE: $closure = function ($value, $key) { return ($value % 2 === 0); }; a([2, 4, 8])->matches($closure); // true

Parameters:

  • \Closure(T = default, TKey = default): bool $closure

Return:

  • bool

matchesAny(\Closure $closure): bool

Check if any item in the current array matches a truth test.

EXAMPLE: $closure = function ($value, $key) { return ($value % 2 === 0); }; a([1, 4, 7])->matches($closure); // true

Parameters:

  • \Closure(T = default, TKey = default): bool $closure

Return:

  • bool

max(): false|float|int|string

Get the max value from an array.

EXAMPLE: a([-9, -8, -7, 1.32])->max(); // 1.32

Parameters: nothing

Return:

  • false|float|int|string <p>Will return false if there are no values.</p>

mergeAppendKeepIndex(array $array, bool $recursive): static

Merge the new $array into the current array.

  • keep key,value from the current array, also if the index is in the new $array

EXAMPLE: $array1 = [1 => 'one', 'foo' => 'bar1']; $array2 = ['foo' => 'bar2', 3 => 'three']; a($array1)->mergeAppendKeepIndex($array2); // Arrayy[1 => 'one', 'foo' => 'bar2', 3 => 'three'] // --- $array1 = [0 => 'one', 1 => 'foo']; $array2 = [0 => 'foo', 1 => 'bar2']; a($array1)->mergeAppendKeepIndex($array2); // Arrayy[0 => 'foo', 1 => 'bar2']

Parameters:

  • array<(int|TKey), T> $array
  • bool $recursive

Return:

  • static <p>(Immutable)</p>

mergeAppendNewIndex(array $array, bool $recursive): static

Merge the new $array into the current array.

  • replace duplicate assoc-keys from the current array with the key,values from the new $array
  • create new indexes

EXAMPLE: $array1 = [1 => 'one', 'foo' => 'bar1']; $array2 = ['foo' => 'bar2', 3 => 'three']; a($array1)->mergeAppendNewIndex($array2); // Arrayy[0 => 'one', 'foo' => 'bar2', 1 => 'three'] // --- $array1 = [0 => 'one', 1 => 'foo']; $array2 = [0 => 'foo', 1 => 'bar2']; a($array1)->mergeAppendNewIndex($array2); // Arrayy[0 => 'one', 1 => 'foo', 2 => 'foo', 3 => 'bar2']

Parameters:

  • array<TKey, T> $array
  • bool $recursive

Return:

  • static <p>(Immutable)</p>

mergePrependKeepIndex(array $array, bool $recursive): static

Merge the the current array into the $array.

  • use key,value from the new $array, also if the index is in the current array

EXAMPLE: $array1 = [1 => 'one', 'foo' => 'bar1']; $array2 = ['foo' => 'bar2', 3 => 'three']; a($array1)->mergePrependKeepIndex($array2); // Arrayy['foo' => 'bar1', 3 => 'three', 1 => 'one'] // --- $array1 = [0 => 'one', 1 => 'foo']; $array2 = [0 => 'foo', 1 => 'bar2']; a($array1)->mergePrependKeepIndex($array2); // Arrayy[0 => 'one', 1 => 'foo']

Parameters:

  • array<TKey, T> $array
  • bool $recursive

Return:

  • static <p>(Immutable)</p>

mergePrependNewIndex(array $array, bool $recursive): static

Merge the current array into the new $array.

  • replace duplicate assoc-keys from new $array with the key,values from the current array
  • create new indexes

EXAMPLE: $array1 = [1 => 'one', 'foo' => 'bar1']; $array2 = ['foo' => 'bar2', 3 => 'three']; a($array1)->mergePrependNewIndex($array2); // Arrayy['foo' => 'bar1', 0 => 'three', 1 => 'one'] // --- $array1 = [0 => 'one', 1 => 'foo']; $array2 = [0 => 'foo', 1 => 'bar2']; a($array1)->mergePrependNewIndex($array2); // Arrayy[0 => 'foo', 1 => 'bar2', 2 => 'one', 3 => 'foo']

Parameters:

  • array<TKey, T> $array
  • bool $recursive

Return:

  • static <p>(Immutable)</p>

meta(): ArrayyMeta|mixed|static

Parameters: nothing

Return:

  • \ArrayyMeta|mixed|static

min(): false|mixed

Get the min value from an array.

EXAMPLE: a([-9, -8, -7, 1.32])->min(); // -9

Parameters: nothing

Return:

  • false|mixed <p>Will return false if there are no values.</p>

mostUsedValue(): mixed|null

Get the most used value from the array.

Parameters: nothing

Return:

  • mixed|null <p>(Immutable) Return null if there wasn't a element.</p>

mostUsedValues(int|null $number): static

Get the most used value from the array.

Parameters:

  • int|null $number <p>How many values you will take?</p>

Return:

  • static <p>(Immutable)</p>

moveElement(int|string $from, int $to): static

Move an array element to a new index.

EXAMPLE: $arr2 = new A(['A' => 'a', 'B' => 'b', 'C' => 'c', 'D' => 'd', 'E' => 'e']); $newArr2 = $arr2->moveElement('D', 1); // Arrayy['A' => 'a', 'D' => 'd', 'B' => 'b', 'C' => 'c', 'E' => 'e']

Parameters:

  • int|string $from
  • int $to

Return:

  • static <p>(Immutable)</p>

moveElementToFirstPlace(int|string $key): static

Move an array element to the first place.

INFO: Instead of "Arrayy->moveElement()" this method will NOT loss the keys of an indexed array.

Parameters:

  • int|string $key

Return:

  • static <p>(Immutable)</p>

moveElementToLastPlace(int|string $key): static

Move an array element to the last place.

INFO: Instead of "Arrayy->moveElement()" this method will NOT loss the keys of an indexed array.

Parameters:

  • int|string $key

Return:

  • static <p>(Immutable)</p>

natcasesort(): $this

Sort an array using a case insensitive "natural order" algorithm.

Parameters: nothing

Return:

  • $this <p>(Mutable) Return this Arrayy object.</p>

natcasesortImmutable(): $this

Sort an array using a case insensitive "natural order" algorithm.

Parameters: nothing

Return:

  • $this <p>(Immutable) Return this Arrayy object.</p>

natsort(): $this

Sort entries using a "natural order" algorithm.

Parameters: nothing

Return:

  • $this <p>(Mutable) Return this Arrayy object.</p>

natsortImmutable(): $this

Sort entries using a "natural order" algorithm.

Parameters: nothing

Return:

  • $this <p>(Immutable) Return this Arrayy object.</p>

next(): false|mixed

Moves the internal iterator position to the next element and returns this element.

Parameters: nothing

Return:

  • false|mixed <p>(Mutable) Will return false if there are no values.</p>

nth(int $step, int $offset): static

Get the next nth keys and values from the array.

Parameters:

  • int $step
  • int $offset

Return:

  • static <p>(Immutable)</p>

offsetExists(bool|int|string $offset): bool

Whether or not an offset exists.

Parameters:

  • bool|int|string $offset

Return:

  • bool

offsetGet(int|string $offset): mixed

Returns the value at specified offset.

Parameters:

  • TKey $offset

Return:

  • mixed <p>Will return null if the offset did not exists.</p>

offsetSet(int|string|null $offset, mixed $value): void

Assigns a value to the specified offset + check the type.

Parameters:

  • int|string|null $offset
  • mixed $value

Return:

  • void

offsetUnset(int|string $offset): void

Unset an offset.

Parameters:

  • int|string $offset

Return:

  • void <p>(Mutable) Return nothing.</p>

only(int[]|string[] $keys): static

Get a subset of the items from the given array.

Parameters:

  • array-key[] $keys

Return:

  • static <p>(Immutable)</p>

pad(int $size, mixed $value): static

Pad array to the specified size with a given value.

Parameters:

  • int $size <p>Size of the result array.</p>
  • mixed $value <p>Empty value by default.</p>

Return:

  • static <p>(Immutable) Arrayy object padded to $size with $value.</p>

partition(\Closure $closure): array<int,static>

Partitions this array in two array according to a predicate.

Keys are preserved in the resulting array.

Parameters:

  • \Closure(T = default, TKey = default): bool $closure <p>The predicate on which to partition.</p>

Return:

  • array<int,static> <p>An array with two elements. The first element contains the array of elements where the predicate returned TRUE, the second element contains the array of elements where the predicate returned FALSE.</p>

pop(): mixed|null

Pop a specified value off the end of the current array.

Parameters: nothing

Return:

  • mixed|null <p>(Mutable) The popped element from the current array or null if the array is e.g. empty.</p>

prepend(mixed $value, mixed $key): $this

Prepend a (key) + value to the current array.

EXAMPLE: a(['f貌么' => 'b脿艡'])->prepend('foo'); // Arrayy[0 => 'foo', 'f貌么' => 'b脿艡']

Parameters:

  • T $value
  • TKey|null $key

Return:

  • $this <p>(Mutable) Return this Arrayy object, with the prepended value.</p>

prependImmutable(mixed $value, mixed $key): $this

Prepend a (key) + value to the current array.

EXAMPLE: a(['f貌么' => 'b脿艡'])->prependImmutable('foo')->getArray(); // [0 => 'foo', 'f貌么' => 'b脿艡']

Parameters:

  • T $value
  • TKey $key

Return:

  • $this <p>(Immutable) Return this Arrayy object, with the prepended value.</p>

prependToEachKey(float|int|string $suffix): static

Add a suffix to each key.

Parameters:

  • float|int|string $suffix

Return:

  • static <p>(Immutable) Return an Arrayy object, with the prepended keys.</p>

prependToEachValue(float|int|string $suffix): static

Add a suffix to each value.

Parameters:

  • float|int|string $suffix

Return:

  • static <p>(Immutable) Return an Arrayy object, with the prepended values.</p>

pull(int|int[]|string|string[]|null $keyOrKeys, mixed $fallback): mixed

Return the value of a given key and delete the key.

Parameters:

  • int|int[]|string|string[]|null $keyOrKeys
  • mixed $fallback

Return:

  • mixed

push(mixed $args): $this

Push one or more values onto the end of array at once.

Parameters:

  • array<TKey, T> ...$args

Return:

  • $this <p>(Mutable) Return this Arrayy object, with pushed elements to the end of array.</p>

randomImmutable(int|null $number): static

Get a random value from the current array.

EXAMPLE: a([1, 2, 3, 4])->randomImmutable(2); // e.g.: Arrayy[1, 4]

Parameters:

  • int|null $number <p>How many values you will take?</p>

Return:

  • static <p>(Immutable)</p>

randomKey(): null|mixed

Pick a random key/index from the keys of this array.

EXAMPLE: $arrayy = A::create([1 => 'one', 2 => 'two']); $arrayy->randomKey(); // e.g. 2

Parameters: nothing

Return:

  • null|mixed <p>Get a key/index or null if there wasn't a key/index.</p>

randomKeys(int $number): static

Pick a given number of random keys/indexes out of this array.

EXAMPLE: a([1 => 'one', 2 => 'two'])->randomKeys(); // e.g. Arrayy[1, 2]

Parameters:

  • int $number <p>The number of keys/indexes (should be <= \count($this->array))</p>

Return:

  • static <p>(Immutable)</p>

randomMutable(int|null $number): $this

Get a random value from the current array.

EXAMPLE: a([1, 2, 3, 4])->randomMutable(2); // e.g.: Arrayy[1, 4]

Parameters:

  • int|null $number <p>How many values you will take?</p>

Return:

  • $this <p>(Mutable) Return this Arrayy object.</p>

randomValue(): mixed

Pick a random value from the values of this array.

EXAMPLE: a([1 => 'one', 2 => 'two'])->randomValue(); // e.g. 'one'

Parameters: nothing

Return:

  • mixed <p>Get a random value or null if there wasn't a value.</p>

randomValues(int $number): static

Pick a given number of random values out of this array.

EXAMPLE: a([1 => 'one', 2 => 'two'])->randomValues(); // e.g. Arrayy['one', 'two']

Parameters:

  • int $number

Return:

  • static <p>(Mutable)</p>

randomWeighted(array $array, int $number):

Parameters:

  • array $array
  • int $number

Return:

  • self

reduce(callable $callable, mixed $initial): static

Reduce the current array via callable e.g. anonymous-function and return the end result.

EXAMPLE: a([1, 2, 3, 4])->reduce( function ($carry, $item) { return $carry * $item; }, 1 ); // Arrayy[24]

Parameters:

  • callable(T2 , T , TKey ): T2 $callable
  • T2 $initial

Return:

  • static <p>(Immutable)</p>

reduce_dimension(bool $unique): static

Parameters:

  • bool $unique

Return:

  • static <p>(Immutable)</p>

reindex(): $this

Create a numerically re-indexed Arrayy object.

EXAMPLE: a([2 => 1, 3 => 2])->reindex(); // Arrayy[0 => 1, 1 => 2]

Parameters: nothing

Return:

  • $this <p>(Mutable) Return this Arrayy object, with re-indexed array-elements.</p>

reject(\Closure $closure): static

Return all items that fail the truth test.

EXAMPLE: $closure = function ($value) { return $value % 2 !== 0; } a([1, 2, 3, 4])->reject($closure); // Arrayy[1 => 2, 3 => 4]

Parameters:

  • \Closure(T = default, TKey = default): bool $closure

Return:

  • static <p>(Immutable)</p>

remove(mixed $key): static

Remove a value from the current array (optional using dot-notation).

EXAMPLE: a([1 => 'bar', 'foo' => 'foo'])->remove(1); // Arrayy['foo' => 'foo']

Parameters:

  • TKey $key

Return:

  • static <p>(Mutable)</p>

removeElement(mixed $element): static

alias: for "Arrayy->removeValue()"

Parameters:

  • T $element

Return:

  • static <p>(Immutable)</p>

removeFirst(): static

Remove the first value from the current array.

EXAMPLE: a([1 => 'bar', 'foo' => 'foo'])->removeFirst(); // Arrayy['foo' => 'foo']

Parameters: nothing

Return:

  • static <p>(Immutable)</p>

removeLast(): static

Remove the last value from the current array.

EXAMPLE: a([1 => 'bar', 'foo' => 'foo'])->removeLast(); // Arrayy[1 => 'bar']

Parameters: nothing

Return:

  • static <p>(Immutable)</p>

removeValue(mixed $value): static

Removes a particular value from an array (numeric or associative).

EXAMPLE: a([1 => 'bar', 'foo' => 'foo'])->removeValue('foo'); // Arrayy[1 => 'bar']

Parameters:

  • T $value

Return:

  • static <p>(Immutable)</p>

repeat(int $times): static

Generate array of repeated arrays.

Parameters:

  • int $times <p>How many times has to be repeated.</p>

Return:

  • static <p>(Immutable)</p>

replace(mixed $oldKey, mixed $newKey, mixed $newValue): static

Replace a key with a new key/value pair.

EXAMPLE: $arrayy = a([1 => 'foo', 2 => 'foo2', 3 => 'bar']); $arrayy->replace(2, 'notfoo', 'notbar'); // Arrayy[1 => 'foo', 'notfoo' => 'notbar', 3 => 'bar']

Parameters:

  • mixed $oldKey
  • mixed $newKey
  • mixed $newValue

Return:

  • static <p>(Immutable)</p>

replaceAllKeys(int[]|string[] $keys): static

Create an array using the current array as values and the other array as keys.

EXAMPLE: $firstArray = [ 1 => 'one', 2 => 'two', 3 => 'three', ]; $secondArray = [ 'one' => 1, 1 => 'one', 2 => 2, ]; $arrayy = a($firstArray); $arrayy->replaceAllKeys($secondArray); // Arrayy[1 => "one", 'one' => "two", 2 => "three"]

Parameters:

  • array<array-key, TKey> $keys <p>An array of keys.</p>

Return:

  • `static

    (Immutable) Arrayy object with keys from the other array, empty Arrayy object if the number of elements for each array isn't equal or if the arrays are empty.

`

replaceAllValues(array $array): static

Create an array using the current array as keys and the other array as values.

EXAMPLE: $firstArray = [ 1 => 'one', 2 => 'two', 3 => 'three', ]; $secondArray = [ 'one' => 1, 1 => 'one', 2 => 2, ]; $arrayy = a($firstArray); $arrayy->replaceAllValues($secondArray); // Arrayy['one' => 1, 'two' => 'one', 'three' => 2]

Parameters:

  • array<array-key, T> $array <p>An array of values.</p>

Return:

  • `static

    (Immutable) Arrayy object with values from the other array, empty Arrayy object if the number of elements for each array isn't equal or if the arrays are empty.

`

replaceKeys(array $keys): static

Replace the keys in an array with another set.

EXAMPLE: a([1 => 'bar', 'foo' => 'foo'])->replaceKeys([1 => 2, 'foo' => 'replaced']); // Arrayy[2 => 'bar', 'replaced' => 'foo']

Parameters:

  • array<array-key, TKey> $keys <p>An array of keys matching the array's size.</p>

Return:

  • static <p>(Immutable)</p>

replaceOneValue(mixed $search, mixed $replacement): static

Replace the first matched value in an array.

EXAMPLE: $testArray = ['bar', 'foo' => 'foo', 'foobar' => 'foobar']; a($testArray)->replaceOneValue('foo', 'replaced'); // Arrayy['bar', 'foo' => 'replaced', 'foobar' => 'foobar']

Parameters:

  • mixed $search <p>The value to replace.</p>
  • mixed $replacement <p>The value to replace.</p>

Return:

  • static <p>(Immutable)</p>

replaceValues(string $search, string $replacement): static

Replace values in the current array.

EXAMPLE: $testArray = ['bar', 'foo' => 'foo', 'foobar' => 'foobar']; a($testArray)->replaceValues('foo', 'replaced'); // Arrayy['bar', 'foo' => 'replaced', 'foobar' => 'replacedbar']

Parameters:

  • string $search <p>The value to replace.</p>
  • string $replacement <p>What to replace it with.</p>

Return:

  • static <p>(Immutable)</p>

rest(int $from): static

Get the last elements from index $from until the end of this array.

EXAMPLE: a([2 => 'foo', 3 => 'bar', 4 => 'lall'])->rest(2); // Arrayy[0 => 'lall']

Parameters:

  • int $from

Return:

  • static <p>(Immutable)</p>

reverse(): $this

Return the array in the reverse order.

EXAMPLE: a([1, 2, 3])->reverse(); // self[3, 2, 1]

Parameters: nothing

Return:

  • $this <p>(Mutable) Return this Arrayy object.</p>

rsort(int $sort_flags): $this

Sort an array in reverse order.

Parameters:

  • `int $sort_flags [optional]

    You may modify the behavior of the sort using the optional parameter sort_flags, for details see sort.

`

Return:

  • $this <p>(Mutable) Return this Arrayy object.</p>

rsortImmutable(int $sort_flags): $this

Sort an array in reverse order.

Parameters:

  • `int $sort_flags [optional]

    You may modify the behavior of the sort using the optional parameter sort_flags, for details see sort.

`

Return:

  • $this <p>(Immutable) Return this Arrayy object.</p>

searchIndex(mixed $value): false|int|string

Search for the first index of the current array via $value.

EXAMPLE: a(['f貌么' => 'b脿艡', 'lall' => 'b脿艡'])->searchIndex('b脿艡'); // Arrayy[0 => 'f貌么']

Parameters:

  • T $value

Return:

  • false|int|string <p>Will return <b>FALSE</b> if the value can't be found.</p>

searchValue(mixed $index): static

Search for the value of the current array via $index.

EXAMPLE: a(['f貌么' => 'b脿艡'])->searchValue('f貌么'); // Arrayy[0 => 'b脿艡']

Parameters:

  • mixed $index

Return:

  • static <p>(Immutable) Will return a empty Arrayy if the value wasn't found.</p>

serialize(): string

Serialize the current "Arrayy"-object.

EXAMPLE: a([1, 4, 7])->serialize();

Parameters: nothing

Return:

  • string

set(string $key, mixed $value): $this

Set a value for the current array (optional using dot-notation).

EXAMPLE: $arrayy = a(['Lars' => ['lastname' => 'Moelleken']]); $arrayy->set('Lars.lastname', 'M眉ller'); // Arrayy['Lars', ['lastname' => 'M眉ller']]]

Parameters:

  • TKey $key <p>The key to set.</p>
  • T $value <p>Its value.</p>

Return:

  • $this <p>(Mutable) Return this Arrayy object.</p>

setAndGet(mixed $key, mixed $fallback): mixed

Get a value from a array and set it if it was not.

WARNING: this method only set the value, if the $key is not already set

EXAMPLE: $arrayy = a([1 => 1, 2 => 2, 3 => 3]); $arrayy->setAndGet(1, 4); // 1 $arrayy->setAndGet(0, 4); // 4

Parameters:

  • mixed $key <p>The key</p>
  • mixed $fallback <p>The default value to set if it isn't.</p>

Return:

  • mixed <p>(Mutable)</p>

setIteratorClass(string $iteratorClass): void

Sets the iterator classname for the current "Arrayy"-object.

Parameters:

  • class-string<\Arrayy\ArrayyIterator> $iteratorClass

Return:

  • void

shift(): mixed

Shifts a specified value off the beginning of array.

Parameters: nothing

Return:

  • mixed <p>(Mutable) A shifted element from the current array.</p>

shuffle(bool $secure, array|null $array): static

Shuffle the current array.

EXAMPLE: a([1 => 'bar', 'foo' => 'foo'])->shuffle(); // e.g.: Arrayy[['foo' => 'foo', 1 => 'bar']]

Parameters:

  • bool $secure <p>using a CSPRNG | @see https://paragonie.com/b/JvICXzh_jhLyt4y3</p>
  • array<TKey, T> $array [optional]

Return:

  • static <p>(Immutable)</p>

size(int $mode): int

Count the values from the current array.

alias: for "Arrayy->count()"

Parameters:

  • int $mode

Return:

  • int

sizeIs(int $size): bool

Checks whether array has exactly $size items.

Parameters:

  • int $size

Return:

  • bool

sizeIsBetween(int $fromSize, int $toSize): bool

Checks whether array has between $fromSize to $toSize items. $toSize can be smaller than $fromSize.

Parameters:

  • int $fromSize
  • int $toSize

Return:

  • bool

sizeIsGreaterThan(int $size): bool

Checks whether array has more than $size items.

Parameters:

  • int $size

Return:

  • bool

sizeIsLessThan(int $size): bool

Checks whether array has less than $size items.

Parameters:

  • int $size

Return:

  • bool

sizeRecursive(): int

Counts all elements in an array, or something in an object.

For objects, if you have SPL installed, you can hook into count() by implementing interface {@see \Countable}. The interface has exactly one method, {@see \Countable::count()}, which returns the return value for the count() function. Please see the {@see \Array} section of the manual for a detailed explanation of how arrays are implemented and used in PHP.

Parameters: nothing

Return:

  • `int

    The number of elements in var, which is typically an array, since anything else will have one element.

If var is not an array or an object with implemented Countable interface, 1 will be returned. There is one exception, if var is &null;, 0 will be returned.

Caution: count may return 0 for a variable that isn't set, but it may also return 0 for a variable that has been initialized with an empty array. Use isset to test if a variable is set.

`

slice(int $offset, int|null $length, bool $preserveKeys): static

Extract a slice of the array.

Parameters:

  • int $offset <p>Slice begin index.</p>
  • int|null $length <p>Length of the slice.</p>
  • bool $preserveKeys <p>Whether array keys are preserved or no.</p>

Return:

  • static <p>(Immutable) A slice of the original array with length $length.</p>

sort(int|string $direction, int $strategy, bool $keepKeys): static

Sort the current array and optional you can keep the keys.

EXAMPLE: a(3 => 'd', 2 => 'f', 0 => 'a')->sort(SORT_ASC, SORT_NATURAL, false); // Arrayy[0 => 'a', 1 => 'd', 2 => 'f']

Parameters:

  • int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p>
  • int $strategy <p>sort_flags => use e.g.: <strong>SORT_REGULAR</strong> (default) or <strong>SORT_NATURAL</strong></p>
  • bool $keepKeys

Return:

  • static <p>(Mutable) Return this Arrayy object.</p>

sortImmutable(int|string $direction, int $strategy, bool $keepKeys): static

Sort the current array and optional you can keep the keys.

Parameters:

  • int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p>
  • int $strategy <p>sort_flags => use e.g.: <strong>SORT_REGULAR</strong> (default) or <strong>SORT_NATURAL</strong></p>
  • bool $keepKeys

Return:

  • static <p>(Immutable) Return this Arrayy object.</p>

sortKeys(int|string $direction, int $strategy): $this

Sort the current array by key.

EXAMPLE: a([1 => 2, 0 => 1])->sortKeys(\SORT_ASC); // Arrayy[0 => 1, 1 => 2]

Parameters:

  • int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p>
  • int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or <strong>SORT_NATURAL</strong></p>

Return:

  • $this <p>(Mutable) Return this Arrayy object.</p>

sortKeysImmutable(int|string $direction, int $strategy): $this

Sort the current array by key.

Parameters:

  • int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p>
  • int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or <strong>SORT_NATURAL</strong></p>

Return:

  • $this <p>(Immutable) Return this Arrayy object.</p>

sortValueKeepIndex(int|string $direction, int $strategy): static

Sort the current array by value.

EXAMPLE: a(3 => 'd', 2 => 'f', 0 => 'a')->sortValueKeepIndex(SORT_ASC, SORT_REGULAR); // Arrayy[0 => 'a', 3 => 'd', 2 => 'f']

Parameters:

  • int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p>
  • int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or <strong>SORT_NATURAL</strong></p>

Return:

  • static <p>(Mutable)</p>

sortValueNewIndex(int|string $direction, int $strategy): static

Sort the current array by value.

EXAMPLE: a(3 => 'd', 2 => 'f', 0 => 'a')->sortValueNewIndex(SORT_ASC, SORT_NATURAL); // Arrayy[0 => 'a', 1 => 'd', 2 => 'f']

Parameters:

  • int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p>
  • int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or <strong>SORT_NATURAL</strong></p>

Return:

  • static <p>(Mutable)</p>

sorter(callable|mixed|null $sorter, int|string $direction, int $strategy): static

Sort a array by value or by a closure.

  • If the sorter is null, the array is sorted naturally.
  • Associative (string) keys will be maintained, but numeric keys will be re-indexed.

EXAMPLE: $testArray = range(1, 5); $under = a($testArray)->sorter( function ($value) { return $value % 2 === 0; } ); var_dump($under); // Arrayy[1, 3, 5, 2, 4]

Parameters:

  • callable|mixed|null $sorter
  • int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p>
  • int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or <strong>SORT_NATURAL</strong></p>

Return:

  • static <p>(Immutable)</p>

splice(int $offset, int|null $length, array $replacement): static

Parameters:

  • int $offset
  • int|null $length
  • array<array-key, T> $replacement

Return:

  • static <p>(Immutable)</p>

split(int $numberOfPieces, bool $keepKeys): static

Split an array in the given amount of pieces.

EXAMPLE: a(['a' => 1, 'b' => 2])->split(2, true); // Arrayy[['a' => 1], ['b' => 2]]

Parameters:

  • int $numberOfPieces
  • bool $keepKeys

Return:

  • static <p>(Immutable)</p>

stripEmpty(): static

Strip all empty items from the current array.

EXAMPLE: a(['a' => 1, 'b' => ''])->stripEmpty(); // Arrayy[['a' => 1]]

Parameters: nothing

Return:

  • static <p>(Immutable)</p>

swap(int|string $swapA, int|string $swapB): static

Swap two values between positions by key.

EXAMPLE: a(['a' => 1, 'b' => ''])->swap('a', 'b'); // Arrayy[['a' => '', 'b' => 1]]

Parameters:

  • int|string $swapA <p>a key in the array</p>
  • int|string $swapB <p>a key in the array</p>

Return:

  • static <p>(Immutable)</p>

toArray(bool $convertAllArrayyElements, bool $preserveKeys): array

Get the current array from the "Arrayy"-object.

alias for "getArray()"

Parameters:

  • `bool $convertAllArrayyElements

    Convert all Child-"Arrayy" objects also to arrays.

` - `bool $preserveKeys

e.g.: A generator maybe return the same key more then once, so maybe you will ignore the keys.

`

Return:

  • array

toJson(int $options, int $depth): string

Convert the current array to JSON.

EXAMPLE: a(['bar', ['foo']])->toJson(); // '["bar",{"1":"foo"}]'

Parameters:

  • int $options [optional] <p>e.g. JSON_PRETTY_PRINT</p>
  • int $depth [optional] <p>Set the maximum depth. Must be greater than zero.</p>

Return:

  • string

toList(bool $convertAllArrayyElements): array

Get the current array from the "Arrayy"-object as list.

Parameters:

  • `bool $convertAllArrayyElements

    Convert all Child-"Arrayy" objects also to arrays.

`

Return:

  • array

toPermutation(string[]|null $items, string[] $helper): static|static[]

Parameters:

  • string[]|null $items [optional]
  • string[] $helper [optional]

Return:

  • static|static[]

toString(string $separator): string

Implodes array to a string with specified separator.

Parameters:

  • string $separator [optional] <p>The element's separator.</p>

Return:

  • string <p>The string representation of array, separated by ",".</p>

uasort(callable $function): $this

Sort the entries with a user-defined comparison function and maintain key association.

Parameters:

  • callable $function

Return:

  • $this <p>(Mutable) Return this Arrayy object.</p>

uasortImmutable(callable $function): $this

Sort the entries with a user-defined comparison function and maintain key association.

Parameters:

  • callable $function

Return:

  • $this <p>(Immutable) Return this Arrayy object.</p>

uksort(callable $function): static

Sort the entries by keys using a user-defined comparison function.

Parameters:

  • callable $function

Return:

  • static <p>(Mutable) Return this Arrayy object.</p>

uksortImmutable(callable $function): static

Sort the entries by keys using a user-defined comparison function.

Parameters:

  • callable $function

Return:

  • static <p>(Immutable) Return this Arrayy object.</p>

unique(): static

alias: for "Arrayy->uniqueNewIndex()"

Parameters: nothing

Return:

  • static <p>(Mutable) Return this Arrayy object, with the appended values.</p>

uniqueKeepIndex(): $this

Return a duplicate free copy of the current array. (with the old keys)

EXAMPLE: a([2 => 1, 3 => 2, 4 => 2])->uniqueNewIndex(); // Arrayy[2 => 1, 3 => 2]

Parameters: nothing

Return:

  • $this <p>(Mutable)</p>

uniqueNewIndex(): $this

Return a duplicate free copy of the current array.

EXAMPLE: a([2 => 1, 3 => 2, 4 => 2])->uniqueNewIndex(); // Arrayy[1, 2]

Parameters: nothing

Return:

  • $this <p>(Mutable)</p>

unserialize(string $string): $this

Unserialize an string and return the instance of the "Arrayy"-class.

EXAMPLE: $serialized = a([1, 4, 7])->serialize(); a()->unserialize($serialized);

Parameters:

  • string $string

Return:

  • $this

unshift(mixed $args): $this

Prepends one or more values to the beginning of array at once.

Parameters:

  • array<TKey, T> ...$args

Return:

  • $this <p>(Mutable) Return this Arrayy object, with prepended elements to the beginning of array.</p>

validate(\Closure $closure): bool

Tests whether the given closure return something valid for all elements of this array.

Parameters:

  • \Closure(T = default, TKey = default): bool $closure the predicate

Return:

  • bool <p>TRUE, if the predicate yields TRUE for all elements, FALSE otherwise.</p>

values(): static

Get all values from a array.

EXAMPLE: $arrayy = a([1 => 'foo', 2 => 'foo2', 3 => 'bar']); $arrayyTmp->values(); // Arrayy[0 => 'foo', 1 => 'foo2', 2 => 'bar']

Parameters: nothing

Return:

  • static <p>(Immutable)</p>

walk(callable $callable, bool $recursive, mixed $userData): $this

Apply the given function to every element in the array, discarding the results.

EXAMPLE: $callable = function (&$value, $key) { $value = $key; }; $arrayy = a([1, 2, 3]); $arrayy->walk($callable); // Arrayy[0, 1, 2]

Parameters:

  • callable $callable
  • bool $recursive [optional] <p>Whether array will be walked recursively or no</p>
  • `mixed $userData [optional]

    If the optional $userData parameter is supplied, it will be passed as the third parameter to the $callable.

`

Return:

  • $this <p>(Mutable) Return this Arrayy object, with modified elements.</p>

where(string $keyOrPropertyOrMethod, mixed $value): static

Returns a collection of matching items.

Parameters:

  • string $keyOrPropertyOrMethod <p>The property or method to evaluate.</p>
  • mixed $value <p>The value to match.</p>

Return:

  • static

Support

For support and donations please visit Github | Issues | PayPal | Patreon.

For status updates and release announcements please visit Releases | Twitter | Patreon.

For professional support please contact me.

Thanks

  • Thanks to GitHub (Microsoft) for hosting the code and a good infrastructure including Issues-Managment, etc.
  • Thanks to IntelliJ as they make the best IDEs for PHP and they gave me an open source license for PhpStorm!
  • Thanks to Travis CI for being the most awesome, easiest continous integration tool out there!
  • Thanks to StyleCI for the simple but powerfull code style check.
  • Thanks to PHPStan && Psalm for relly great Static analysis tools and for discover bugs in the code!

Tests

From the project directory, tests can be ran using phpunit

License

Released under the MIT License - see LICENSE.txt for details.

GitHub

https://github.com/voku/Arrayy
Comments
  • 1. Configure Renovate

    WhiteSource Renovate

    Welcome to Renovate! This is an onboarding PR to help you understand and configure settings before regular Pull Requests begin.

    馃殾 To activate Renovate, merge this Pull Request. To disable Renovate, simply close this Pull Request unmerged.


    Detected Package Files

    • build/composer.json (composer)
    • composer.json (composer)
    • .github/workflows/ci.yml (github-actions)
    • package.json (npm)

    Configuration Summary

    Based on the default config's presets, Renovate will:

    • Start dependency updates only once this onboarding PR is merged
    • Enable Renovate Dependency Dashboard creation
    • If semantic commits detected, use semantic commit type fix for dependencies and chore for all others
    • Ignore node_modules, bower_components, vendor and various test/tests directories
    • Autodetect whether to pin dependencies or maintain ranges
    • Rate limit PR creation to a maximum of two per hour
    • Limit to maximum 10 open PRs at any time
    • Group known monorepo packages together
    • Use curated list of recommended non-monorepo package groupings
    • Fix some problems with very old Maven commons versions
    • Ignore spring cloud 1.x releases
    • Ignore http4s digest-based 1.x milestones
    • Use node versioning for @types/node
    • Limit concurrent requests to reduce load on Repology servers until we can fix this properly, see issue 10133

    馃敗 Would you like to change the way Renovate is upgrading your dependencies? Simply edit the renovate.json in this branch with your custom config and the list of Pull Requests in the "What to Expect" section below will be updated the next time Renovate runs.


    What to Expect

    With your current configuration, Renovate will create 4 Pull Requests:

    Pin dependencies
    Update actions/cache action to v2.1.7
    • Schedule: ["at any time"]
    • Branch name: renovate/actions-cache-2.x
    • Merge into: master
    • Upgrade actions/cache to v2.1.7
    Update shivammathur/setup-php action to v2.16.0
    • Schedule: ["at any time"]
    • Branch name: renovate/shivammathur-setup-php-2.x
    • Merge into: master
    • Upgrade shivammathur/setup-php to 2.16.0
    Update codecov/codecov-action action to v2
    • Schedule: ["at any time"]
    • Branch name: renovate/codecov-codecov-action-2.x
    • Merge into: master
    • Upgrade codecov/codecov-action to v2

    馃毟 Branch creation will be limited to maximum 2 per hour, so it doesn't swamp any CI resources or spam the project. See docs for prhourlylimit for details.


    鉂 Got questions? Check out Renovate's Docs, particularly the Getting Started section. If you need any further assistance then you can also request help here.


    This PR has been generated by WhiteSource Renovate. View repository job log here.


    This change is鈥Reviewable

    Reviewed by renovate[bot] at 2022-01-23 13:07
  • 2. Update shivammathur/setup-php action to v2.17.1

    WhiteSource Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | shivammathur/setup-php | action | patch | 2.17.0 -> 2.17.1 |


    Release Notes

    shivammathur/setup-php

    v2.17.1

    Compare Source

    This release is possible because of our sponsors 鉂わ笍.

    Help setup-php reach its sponsorship goals.

    Sponsor shivammathur


    • Added support for OpenSSL config on Windows. #鈥564 Now setup-php will set the environment variable OPENSSL_CONF pointing to a valid openssl.cnf file on Windows.

    • Added GitHub releases fallback URL for phing.

    • Updated version of sqlsrv and pdo_sqlsrv extensions to 5.10.0 for PHP 7.4 and above.

    • Fixed logs for symfony-cli on failure. #鈥568

    • Fixed setting an environment variable on Windows in self-hosted environments.

    • Fixed a bug in adding a directory to PATH. #鈥562

    • Fixed a minor UUOC shellcheck warning in add_tools.sh.

    • Updated Node.js dependencies.


    Thanks! @鈥媘locati for adding support for Set-OpenSSLConf 馃殌

    Follow for updates

    setup-php reddit setup-php twitter setup-php status


    Configuration

    馃搮 Schedule: At any time (no schedule defined).

    馃殾 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    馃敃 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by WhiteSource Renovate. View repository job log here.


    This change is鈥Reviewable

    Reviewed by renovate[bot] at 2022-03-01 15:55
  • 3. Upgrade to GitHub-native Dependabot

    Dependabot Preview will be shut down on August 3rd, 2021. In order to keep getting Dependabot updates, please merge this PR and migrate to GitHub-native Dependabot before then.

    Dependabot has been fully integrated into GitHub, so you no longer have to install and manage a separate app. This pull request migrates your configuration from Dependabot.com to a config file, using the new syntax. When merged, we'll swap out dependabot-preview (me) for a new dependabot app, and you'll be all set!

    With this change, you'll now use the Dependabot page in GitHub, rather than the Dependabot dashboard, to monitor your version updates, and you'll configure Dependabot through the new config file rather than a UI.

    If you've got any questions or feedback for us, please let us know by creating an issue in the dependabot/dependabot-core repository.

    Learn more about migrating to GitHub-native Dependabot

    Please note that regular @dependabot commands do not work on this pull request.


    This change is鈥Reviewable

    Reviewed by dependabot-preview[bot] at 2021-04-29 19:23
  • 4. MultiDimensional Array

    array:3 [鈻 0 => Nmap\Port {#329 鈻 -number: 22 -protocol: "tcp" -state: "open" -service: Nmap\Service {#332 鈻 -name: "ssh" -product: "OpenSSH" -version: "7.9p1 Raspbian 10" } } 1 => Nmap\Port {#324 鈻 -number: 80 -protocol: "tcp" -state: "open" -service: Nmap\Service {#334 鈻 -name: "http" -product: "Apache httpd" -version: "2.4.38" } } 2 => Nmap\Port {#330 鈻 -number: 5900 -protocol: "tcp" -state: "open" -service: Nmap\Service {#336 鈻 -name: "vnc" -product: "RealVNC Enterprise" -version: "5.3 or later" } } ]

    I have this multidimensional array.

    $arrayy = new A([$ports]);

    $arrayy->get('Nmap\Port'); // ['lastname' => 'Moelleken'] $echo = $arrayy->get('Nmap\Port.-service'); dd($echo);

    When I use this code I am getting null

    Reviewed by katesaikishore at 2020-04-06 07:51
  • 5. Update actions/upload-artifact action to v3

    WhiteSource Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | actions/upload-artifact | action | major | v2 -> v3 |


    Release Notes

    actions/upload-artifact

    v3

    Compare Source


    Configuration

    馃搮 Schedule: At any time (no schedule defined).

    馃殾 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    馃敃 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by WhiteSource Renovate. View repository job log here.


    This change is鈥Reviewable

    Reviewed by renovate[bot] at 2022-03-03 18:30
  • 6. Update actions/checkout action to v3

    WhiteSource Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | actions/checkout | action | major | v2 -> v3 |


    Release Notes

    actions/checkout

    v3

    Compare Source


    Configuration

    馃搮 Schedule: At any time (no schedule defined).

    馃殾 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    馃敃 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by WhiteSource Renovate. View repository job log here.


    This change is鈥Reviewable

    Reviewed by renovate[bot] at 2022-03-01 19:21
  • 7. Update shivammathur/setup-php action to v2.17.0

    WhiteSource Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | shivammathur/setup-php | action | minor | 2.16.0 -> 2.17.0 |


    Release Notes

    shivammathur/setup-php

    v2.17.0

    Compare Source

    This release is possible because of our sponsors 鉂わ笍.

    Help setup-php reach its sponsorship goals.

    Sponsor shivammathur


    • Added ini-file input to specify the base php.ini file. Accepts production, development or none. Docs (#鈥450, #鈥469)

    By default the production php.ini is used, you can change it to the development one, or remove it using none.

    - name: Setup PHP
      with:
        php-version: '8.1'
        ini-file: development
    
    - name: Setup PHP
      with:
        php-version: '8.1'
        tools: symfony-cli
    
    - name: Setup PHP
      with:
        php-version: '8.1'
        tools: churn
    
    • Added support for blackfire extension on PHP 8.1.
    - name: Setup PHP
      with:
        php-version: '8.1'
        extensions: blackfire
    
    • Tools pecl, phpize and php-config are now installed by default on Linux. Specifying these in tools input is no longer required.

    • The environment variable COMPOSER_NO_INTERACTION is now set to 1 by default, so using --no-interaction in composer commands is not required. (#鈥547)

    • The environment is now considered self-hosted unless the GitHub hosted environment is detected. This should prevent broken PHP installs in self-hosted environments when the runner environment variable is not specified. (#鈥554)

    • Added support to enable disabled extensions when required by tools. For this extensions are now processed before tools.

    • Added support to enable xml extension before installing other extensions using pecl. (#鈥553)

    • Speed improvements

      • Reduced the initial I/O in script creation.
      • Reduced the number of PHP calls and it now uses php-config instead.
      • Reduced number of brew calls on macOS setup.
      • Windows builds for all PHP versions are now fetched from shivammathur/php-builder-windows releases as a faster cache with windows.php.net as a fallback.
      • SSL libraries for PHP 5.3 to 5.5 on Windows are now fetched in parallel.
      • PHP builds for PHP 5.3 to 5.5 should now use cached macports builds from shivammathur/php5-darwin.
    • Added support for installing tools using composer in different scopes. This allows installing two tools with different versions of a common dependency. (#鈥549)

    • Added support to fail immediately when composer setup fails. (#鈥548)

    • Added support to parse PECL extension versions when wrongly hyphenated. (#鈥536)

    • Added support for composer phars from shivammathur/composer-cache with PHP version as now different PHP versions can have different composer versions for a release type.

    • Added setup-php.com as a fallback in addition to jsdeliver.com for script sources.

    • Fixed support for fallback sources for tools in Windows.

    • Fixed potential exponential backtracking in regex to parse extension input when installing extensions from a git repository.

    • Fixed adding sudo to self-hosted Linux environments. (#鈥555)

    • Fixed enabling disabled extensions with other extensions as dependencies. For example pecl_http, redis, etc.

    • Fixed a bug where the ini file used for enabling extensions by pecl in the scan directory was deleted when disabling extensions.

    • Fixed misconfiguration which prevented package lists from updating on Linux.

    • Fixed the fallback to install PowerShell packages using Install-Module on Windows when GitHub Releases is down. Also fixed not adding the Import-Module command to the profile when it fallbacks.

    • Fixed tools setup to not overwrite an existing tool with a broken one if it fails to set up.

    • Fixed an error when copying tools to a directory in PATH in tools setup.

    • Fixed parsing composer phars from snapshot channel for its version when is a stable version.

    • Fixed support for oci8 and pdo_oci extensions on Windows.

    • Fixed pecl_http setup.

    • Fixed restore-keys input in composer cache example in README with dependency range.

    • Fixed error in tools setup on self-hosted environments when composer's bin directory is not present.

    • Fixed tools.getLatestVersion to handle failing GitHub API call.

    • Fixed output on non-GitHub Action environments where GitHub Action specific command syntax was printed.

    • Fixed a bug where the status variable was overwritten in ppa.sh and was breaking the status output.

    • Fixed scope of variables to local in bash scripts.

    • Fixed setting extension stability in Add-Extension Function on Windows.

    • Fixed node-release workflow to add lib directory to the packages.

    • Fixed sending coverage data to codecov on pull requests.

    • Refactored utils.fetch to its own module and mocked the http module using nock for fetch tests. Now the Node.js test suite does not make any external requests.

    • Refactored setting environment variables and adding to PATH.

    • Refactored setting outputs to functions with a check to only run on GitHub Actions.

    • Refactored extension functions to add_extension.sh and add_extension.ps1.

    • Refactored the default PHP packages for self-hosted Linux environments to a config file. Also added cgi, fpm, mysql, opcache, pgsql and zip to the list.

    • Refactored Nightly PHP setup to Install-PhpNightly Function on Windows.

    • Refactored CI workflows and templates.

    • Rename common.sh to unix.sh.

    • Update security policy to specify clearly that the latest patch versions of both v1 and v2 are supported for security updates.

    • Updated Node workflows to use 16.x.

    • Updated README for the release.

    • Updated Node.js dependencies.


    Thanks! @鈥媕rfnl and @鈥媣illfa for the contributions 馃殌

    Follow for updates

    setup-php reddit setup-php twitter setup-php status


    Configuration

    馃搮 Schedule: At any time (no schedule defined).

    馃殾 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    馃敃 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by WhiteSource Renovate. View repository job log here.


    This change is鈥Reviewable

    Reviewed by renovate[bot] at 2022-02-08 14:08
  • 8. Update codecov/codecov-action action to v2

    WhiteSource Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | codecov/codecov-action | action | major | v1 -> v2 |


    Release Notes

    codecov/codecov-action

    v2

    Compare Source


    Configuration

    馃搮 Schedule: At any time (no schedule defined).

    馃殾 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    馃敃 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by WhiteSource Renovate. View repository job log here.


    This change is鈥Reviewable

    Reviewed by renovate[bot] at 2022-01-23 21:44
  • 9. Update shivammathur/setup-php action to v2.16.0

    WhiteSource Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | shivammathur/setup-php | action | minor | 2.9.0 -> 2.16.0 |


    Release Notes

    shivammathur/setup-php

    v2.16.0

    Compare Source

    This release is possible because of our sponsors. So, if your company uses setup-php, please ask them to sponsor my work.

    Sponsor shivammathur


    • PHP 8.1 is now stable (8.1.0) and marked as the latest version. 馃コ
    - name: Setup PHP 8.1
      uses: shivammathur/[email protected]
      with:
        php-version: latest
    
    • PHP 7.3 to PHP 8.1 packages have been updated to 7.3.33, 7.4.26, 8.0.13, and 8.1.0 respectively. Set the update environment variable to true for always updating to the latest patch version.
    - name: Setup PHP
      uses: shivammathur/[email protected]
      env:
        update: true
      with:
        php-version: '8.0'
    
    - name: Setup PHP
      uses: shivammathur/[email protected]
      with:
        php-version: 7.4
        extensions: intl-70.1
    
    • Add support for mailparse and xlswriter extensions on macOS using shivammathur/extensions tap.
    - name: Setup PHP
      uses: shivammathur/[email protected]
      with:
        php-version: 7.4
        extensions: mailparse, xlswriter
    
    • Fix upgrading nightly versions on self-hosted runners. Now PHP 8.2 will update to the latest build when the update environment variable is set to true.
    • Fix support for brew extensions with different package and extension name.
    • Fix support for Imagick extension on Windows. https://github.com/shivammathur/setup-php/pull/528
    • Fix error while Blackfire configuration file is opened in tool's set up on Linux.
    • Fix extension support to install extension packages from ppa:ondrej/php in php-builder builds.
    • Fix dependency support in self-hosted macOS.
    • Fix to only copy problem-matchers configs to RUNNER_TOOL_CACHE.
    • Fix support for Phalcon extension.
    • Fix CA certificate issues on windows. #鈥511, #鈥517
    • Fix to suppress error when extensions are cached on Windows.
    • Log error when wrong Xdebug version is requested as coverage driver for a PHP version. https://github.com/shivammathur/setup-php/issues/519
    • Add patch to support self-hosted environments on Debian 12 or distributions based on it.
    • Add action to limit outbound requests to known endpoints in node workflow.
    • Add links for all tools in the README. https://github.com/shivammathur/setup-php/pull/518
    • Add workflow to publish to NPM and GitHub packages. #鈥513
    • Use jest.each for extensions and install modules' tests. #鈥514, #鈥516,
    • Update Node.js dependencies.

    Thanks! @鈥媕rfnl, @鈥媕derusse, and @鈥媋neeshrelan for the contributions 馃殌

    Follow for updates

    setup-php reddit setup-php twitter setup-php status

    v2.15.0

    Compare Source

    Setup PHP depends on sponsorships. Maintaining it takes time and money especially with daily builds for upcoming PHP versions. So, if you found it helpful, please support the project.

    Sponsor shivammathur


    • PHP 5.6 to 7.2 have been rebuilt with patch for CVE-2021-21706 backported from 7.3.31.

    • PHP 7.3 to PHP 8.0 packages have been updated to 7.3.31, 7.4.24 and 8.0.11 respectively. Set the update environment variable to true for always updating to the latest patch version.

    - name: Setup PHP
      uses: shivammathur/[email protected]
      env:
        update: true
      with:
        php-version: '8.0'
    
    • Add support for the following tools:

    - name: Setup PHP
      uses: shivammathur/[email protected]
      with:
        php-version: '8.0'
        tools: phpDocumentor, parallel-lint, phpunit-polyfills
    
    - name: Setup PHP
      uses: shivammathur/[email protected]
      with:
        php-version: '8.0'
        extensions: expect, ssh2
    
    • Fix parsing PHP 8.1 version with both RC and dev suffixes in the semver notation.

    • Fix to get correct php-src git ref for nightly builds.

    • Fix version for extensions in logs when installed using PECL.

    • Fix cache support for extensions with custom support. #鈥496

    • Fix logs for extensions with custom support when cached.

    • Fix PPA setup to add/update list files in /var/lib/apt/lists. #鈥492

    • Fix typo to use correct key for phpunit in tools.functionRecord. #鈥501

    • Replace husky with simple-git-hooks.

    • Cleanup trailing whitespace in README.

    • Fix git command in format NPM script.

    • Update Node.js dependencies.


    Thanks @鈥媕rfnl for the contributions 馃殌

    Follow for updates

    setup-php reddit setup-php twitter setup-php status

    v2.14.0

    Compare Source

    • Add support for PHP 8.2. #鈥490, Docs
    • Specifying 8.2 in the php-version input will set up a nightly build of PHP 8.2.0-dev from the master branch of php/php-src.
    - name: Setup PHP 8.2
      uses: shivammathur/[email protected]
      with:
        php-version: '8.2'
    
    • Add support for the nightly alias for setting up a build from the master branch. #鈥491, Docs
    • This will also set up PHP 8.2.0-dev from the master branch of php/php-src.
    - name: Setup PHP 8.2
      uses: shivammathur/[email protected]
      with:
        php-version: nightly
    
    • Add support to disable all shared extensions. #鈥487 Docs
    • Specifying none in extensions input will now disable all shared extensions.
    • If none is specified along with other extensions then setup-php will first remove all shared extensions, and then process the other extensions in the input.
    • As part of this feature from now on, shared extensions will just be disabled, and not removed completely.

    鉂わ笍 Thanks! @鈥媠ebastianbergmann and @鈥媗ocalheinz for sponsoring this feature.

    - name: Setup PHP without any shared extensions except mbstring
      uses: shivammathur/[email protected]
      with:
        php-version: 8.0
        extensions: none, mbstring
    
    • Fix disabling extensions to identify dependent extensions using the Reflection data and disable them as well. For example, disabling PDO will also disable pdo_mysql.

    • Fix warnings in Windows when the required directory is already present.

    • Fix to identify opcache if Zend OPcache is specified in extensions input.

    • Fix Windows script to install PHP 8.2 and future nightly builds correctly.

    • Fix to parse PHP 8.1 semver version.

    • Use shivammathur/extensions tap to install vips extension on macOS.


    Internal
    • Add test cases for ini-values containing special characters to config.test.ts to avoid regression.

    • Add bugs, directories, files and types properties in package.json.

    • Add an SVG with past and present individual sponsors to the README.

    • Use commit hash from the path in URL instead of the query string for nightly builds on macOS.

    • Fix build error in install.ts after TypeScript upgrade.

    • Minor refactor in install.test.ts.

    • Refactor config and coverage test files to use jest.each.

    • Update tsconfig to generate type declarations.

    • Update documentation in the README.

    • Update versions in SECURITY.md.

    • Update Node.js dependencies.

    v2.13.0

    Compare Source

    • Added support for Debian on self-hosted environments and containers.
    • Debian 9 and above are supported in addition to existing Ubuntu support.
    • Operating systems based on these versions of Debian are also supported on a best-effort basis.
    container: debian:bullseye
    steps:
      - name: Install PHP on Debian
        uses: shivammathur/[email protected]
        with:
          php-version: '8.0'
        env:
          runner: self-hosted
    
    • Added windows-2022 to the supported OS environments.
    runs-on: windows-2022
    steps:
      - name: Install PHP
        uses: shivammathur/[email protected]
        with:
          php-version: '8.0'
    
    • Added support for phpunit-bridge and updated symfony examples to install it using setup-php.
    - name: Setup PHP with Phive
      with:
        php-version: '8.0'
        tools: phpunit-bridge
    
    • Added documentation to run multi-line PHP code in workflows. #鈥482
    - name: Setup PHP
      uses: shivammathur/[email protected]
      with:
        php-version: '8.0'
    
    - name: Run PHP code
      shell: php {0}
      run: |
        <?php
        $welcome = "Hello, world";
        echo $welcome;
    
    • Added support for extensions mongodb and yaml on macOS using shivammathur/extensions tap.
    • Added a specific phive version compatible with PHP 7.2. #鈥481
    - name: Setup PHP with Phive
      uses: shivammathur/[email protected]
      with:
        php-version: '7.2'
        tools: phive
    
    • Added --no-install-recommends to apt install commands on Linux.
    • Added support for JavaScript actions on shivammathur/node images. spc is no longer required for multi-arch workflows and normal GitHub Action syntax should work.
    container: shivammathur/node:latest-${{ matrix.arch }}
    strategy:
      matrix:
        arch: ["amd64", "i386"]
    steps:
      - name: Install PHP
        uses: shivammathur/[email protected]
        with:
          php-version: '8.0'
    
    • PHP 8.1 on Linux in shivammathur/php-builder is now built nightly with the same configuration and patches as official Debian builds of PHP.
    - name: Setup PHP 8.1
      uses: shivammathur/[email protected]
      with:
        php-version: '8.1'
    
    • Added a new flag NO_TOOLS_CACHE. The tool will be fetched from the source instead of any cache that setup-php implements when this is set to true.
    • This can be useful for maintainers to make sure a new version of their tool is used instead of the old cached version.
    • As of this release, only composer phars are cached.
    - name: Setup PHP
      uses: shivammathur/[email protected]
      env:
        NO_TOOLS_CACHE: true
      with:
        php-version: '8.0'
    
    • Removed support for Ubuntu 16.04. Please upgrade to Ubuntu 20.04 or Ubuntu 18.04 environments. #鈥452
    • Removed support for Blackfire v1. Specifying blackfire in tools will now install the latest version of Blackfire CLI v2. #鈥478
    - name: Setup PHP with Blackfire
      uses: shivammathur/[email protected]
      with:
        php-version: '8.0'
        tools: blackfire
    
    • Removed software-properties-common package from dependencies on self-hosted Linux. This package was used for adding third-party repositories(PPA). Removing this reduces self-hosted first run time from 2-3 minutes to 1-2 minutes.

    • PPAs can now be added by setup-php without any dependencies and the deprecated apt-key. It follows the Debian specification for third-party repositories.

    • Remove use of /etc/lsb-release file, /etc/os-release is used now as it has better support.

    • Fixed a bug where the status file was overwritten after PHP was set up on GitHub runners.

    • Fixed support for php-cs-fixer to parse releases.atom file and install correct latest version. #鈥485

    - name: Setup PHP with php-cs-fixer
      uses: shivammathur/[email protected]
      with:
        php-version: '8.0'
        tools: php-cs-fixer
    
    • Fixed cache support for extensions on Windows which need additional libraries.
    • Fixed permissions in composer set up on self-hosted environments. #鈥477
    • Fixed starting Blackfire service on Linux. #鈥483
    • Fixed a warning about shallow clones for Homebrew taps on macOS.
    • Fixed a warning about macOS developer mode while using brew cat.
    • In tsconfig.json set lib to ES2020 and target to ES2019 for supporting Node 12 in self-hosted runners.
    • Update Node.js dependencies.

    Thanks! @鈥媕rfnl and @鈥媗olautruche for the contributions 馃帀

    v2.12.0

    Compare Source

    • Add support to specify major or major.minor versions for tools. Docs, #鈥467
    - name: Setup PHP
      uses: shivammathur/[email protected]
      with:
        php-version: '7.4'
        tools: php-cs-fixer:3, phpunit:8.5
      env:
        COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    
    • Add a php-version output which can be used in later steps. Docs, #鈥470
    - name: Setup PHP
      id: setup-php
      uses: shivammathur/[email protected]
      with:
        php-version: '7.4'
    
    - name: Print PHP version
      run: echo ${{ steps.setup-php.outputs.php-version }}
    
    • Like Ubuntu, add PHP commit hash in PHP 8.1 (nightly) logs on Windows and macOS.
    • Use composer to install composer-require-checker. #鈥473
    • Use shivammathur/extensions tap for rdkafka extension on macOS. shivammathur/homebrew-php#鈥365
    • Support for Ubuntu 16.04 was dropped on August 1, 2021. 馃摙Announcement: #鈥452
    • Set the Firebird client version to 3.0.7 on macOS.
    • Improve grpc_php_plugin support on Ubuntu and macOS.
    • Minor fixes for self-hosted setup on Ubuntu.
    • Improve PHP setup on macOS to be more resilient to dependency version inconsistencies.
    • Fix to enable extensions disabled with phpdismod on Ubuntu. actions/virtual-environments#鈥3472
    • Fix Imagick setup with shivammathur/cache-extensions action on Windows. #鈥455
    • Fix support for OCI extensions oci8 and pdo_oci. #鈥449
    • Fix to not use system PHP on macOS.
    • Fix support for Imagick for PHP 5.3 to 5.5 on macOS.
    • Fix installing protoc on macOS.
    • Hotfix: Fix permissions of COMPOSER_HOME directory. #鈥477
    • Hotfix: Fix support for phive on PHP 7.2. #鈥481

    Internal
    • Update contributors SVG in README.md to include contributors from setup-php and all related projects.
    • Move tools set up details from tools.ts to tools.json config.
    • Improve error handling in utils.fetch and its uses.
    • Refactor tests for tools using jest.Each.
    • Update Ubuntu 16.04 warning in install.ts.
    • Set sourceMap to true in tsconfig.json.
    • Update Node.js dependencies.

    v2.11.0

    Compare Source

    • Improve cache in shivammathur/php-ubuntu for PHP 5.6 to PHP 8.0. Using cache should reduce setup-php runtime on Ubuntu when the PHP version is not installed on the runner or update: true is set from 1-2 minutes to less than 5 seconds.

    • Add support to compile and install extensions from source from any git repository, from a sub-directory in a repository, with required libraries and configuration. Refer to this guide for more details and examples. #鈥418, Closes #鈥419

    • Add support to set up composer packages using tools input. Closes #鈥442

    - name: Setup PHP with tools
      uses: shivammathur/[email protected]
      with:
        php-version: '7.4'
        tools: phpunit/phpunit
    
    • Add support to skip composer setup by specifying tools: none. Closes #鈥446
    - name: Setup PHP with no tools using composer
      uses: shivammathur/[email protected]
      with:
        php-version: '7.4'
        tools: none
    
    • Add support for different ICU versions with PHP 8.1 on Ubuntu.
    - name: Setup PHP 8.1 with ICU 69.1
      uses: shivammathur/[email protected]
      with:
        php-version: '8.1'
        extensions: intl-69.1
    
    • Improve logs for compiling extensions from source. Now this process is verbose and the logs are grouped.
    • Improve extension support.
      • Add support for pdo_firebird.
      • Improve support for geos to compile on PHP 8.0 and 8.1.
      • Fix cubrid setup on Ubuntu 16.04.
      • Fix gearman support on Ubuntu.
      • Use GitHub releases for all couchbase versions.
      • Use shivammathur/extensions tap for apcu, phalcon, psr, memcache and memcached on macOS.
      • Fix phalcon3 on Windows.
      • Revert to ppa:ondrej/ppa for phalcon3 on Ubuntu.
      • Revert pcov patch for PHP 8 on Windows as the DLL is now available on PECL.
    • Add PHP commit hash in logs on PHP 8.1 (nightly) on Ubuntu. #鈥433
    • Fix versions in logs of tools installed using composer.
    • Fix linking of old libraries on macOS.
    • Fix enabling cached extensions which have other extensions as dependencies. #鈥428
    • Fix pecl setup to avoid unnecessary callbacks.
    • Fix blackfire extension version to 1.50.0 for PHP 5.6 and below.
    • Fix composer setup on self-hosted set up. #鈥435
    • PHP 5.6 to PHP 7.2 on macOS are now built with backported security patches in shivammathur/php tap.

    Internal
    • Add fallback to Install-Module in Install-PSPackage in win32.ps1.
    • Add parameters to add_ppa function in linux.sh.
    • Do not lowercase source extension input.
    • Fix warning about ignored promise in install.ts.
    • Fix shellcheck warning in darwin.sh.
    • Refactor coverage setup.
    • Refactor regex in extension.ts.
    • Remove dotdeb support. PHP 5.4 and 5.5 are now built from source along with compatable extensions in shivammathur/php5-ubuntu.
    • Replace bintray with cdnjs as fallback to GitHub releases for fetching scripts.
    • Replace bintray in Windows script with GitHub Releases.
    • Replace bintray and use shivammathur/intl-icu GitHub releases.
    • Move patches from custom extension scripts to patches directory.
    • Switch from clover.xml to lcov.info for coverage. clover.xml has broken conditional coverage support.
    • Use add_extension_from_source for all custom supported extensions.
    • Move patches from custom extension scripts to patches directory.
    • Move add_pecl_extension to common.sh.
    • Improve switch_version in linux.sh to accept parameters.
    • Cleanup tsconfig.json.
    • Set moduleResolution to node in tsconfig.json.
    • Update year in license.
    • Update Node version to 15.x in Node workflow.
    • Update SECURITY.md.
    • Update Node.js dependencies.

    v2.10.0

    Compare Source

    • Add support to compile extensions from source. Docs (#鈥399).
    - name: Setup PHP with mongodb compiled from source
      uses: shivammathur/[email protected]
      with:
        php-version: '7.4'  
        extensions: mongodb-mongodb/[email protected]
    
    • Add support to setup Xdebug 2.x on PHP 7.2 to PHP 7.4. Docs.
    name: Setup PHP with Xdebug 2.x
    uses: shivammathur/[email protected]
    with:
      php-version: '7.4'
      coverage: xdebug2
    
    • Add support for quoted CSV in ini-values to allow directives with commas (#鈥392, #鈥405).
    - name: Setup PHP
      uses: shivammathur/[email protected]
      with:
        php-version: '8.0'
        ini-values: xdebug.mode="develop,coverage"
    
    • Add support to specify version in d.x notation. For example 5.x, 7.4 and 8.x (#鈥395).
    - name: Setup PHP 7.4
      uses: shivammathur/[email protected]
      with:
        php-version: '7.x'
    
    - name: Setup PHP
      uses: shivammathur/[email protected]
      with:
        php-version: '8.0'
        extensions: intl-68.2
    
    • Add support for pdo_firebird for all configurations.
    - name: Setup PHP
      uses: shivammathur/[email protected]
      with:
        php-version: '8.0'
        extensions: pdo_firebird
    
    • Add support for self-hosted runners on macOS ARM64 Docs.
    • Add support for blackfire on PHP 8.0.
    - name: Setup PHP with blackfire
      uses: shivammathur/[email protected]
      with:
        php-version: '8.0'
        extensions: blackfire
        tools: blackfire
    
    • Add support for pecl_http for all PHP versions on Ubuntu and macOS and PHP 7.1 to PHP 8.0 on Windows. (#鈥396)
    - name: Setup PHP with pecl_http
      uses: shivammathur/[email protected]
      with:
        php-version: '8.0'
        extensions: pecl_http
    
    • Add support for aliases for symfony-cli, vapor-cli, and wp-cli. Docs
    • Add support for couchbase extension with PHP 5.3 to PHP 5.5 on Ubuntu and macOS.
    • Fail fast on failing to setup the requested PHP version (#鈥368).
    • Fix Composer config syntax (#鈥404).
    • Fix PHP 8 on macOS after update on images.
    • Fix PDO extensions setup on Ubuntu and macOS (#鈥412).
    • Fix compiling extensions in self-hosted workflows (shivammathur/node-docker#鈥5).
    • Fix tools setup on self-hosted runners.
    • Fix pcov on PHP 8.0 on Windows (#鈥398).
    • Fix cache support for cubrid and pdo_cubrid.
    • Fix support for phalcon3 (#鈥413).
    • Improve support for PHP extensions amqp, igbinary, imap, msgpack, propro, raphf, redis and zmq on macOS.
    • Improve support for phive. Now the correct version of phive for the PHP version should be setup (#鈥366).
    • Improve fetching homebrew taps.
    • Improve PECL support. It is no longer required to specify pecl in tools input.
    • Improve regexes in extensions.ts.
    • Improve logs in Symfony examples (#鈥377).
    • Set up Codeception using Composer.
    • Change Node.js version in the workflow.
    • Update Node.js dependencies.

    Thanks @鈥媎ingo-d, @鈥媋lcaeus, @鈥媠moqadam and @鈥媑lensc for the contributions 馃帀


    Configuration

    馃搮 Schedule: At any time (no schedule defined).

    馃殾 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    馃敃 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by WhiteSource Renovate. View repository job log here.


    This change is鈥Reviewable

    Reviewed by renovate[bot] at 2022-01-23 21:44
  • 10. Update actions/cache action to v2.1.7

    WhiteSource Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | actions/cache | action | patch | v2.1.3 -> v2.1.7 |


    Release Notes

    actions/cache

    v2.1.7

    Compare Source

    Support 10GB cache upload using the latest version 1.0.8 of @actions/cache

    v2.1.6

    Compare Source

    v2.1.5

    Compare Source

    v2.1.4

    Compare Source

    • Make caching more verbose #鈥650
    • Use GNU tar on macOS if available #鈥701

    Configuration

    馃搮 Schedule: At any time (no schedule defined).

    馃殾 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    馃敃 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by WhiteSource Renovate. View repository job log here.


    This change is鈥Reviewable

    Reviewed by renovate[bot] at 2022-01-23 19:34
  • 11. Pin dependencies - autoclosed

    WhiteSource Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | gitbook-cli (source) | devDependencies | pin | ^2.1.0 -> 2.3.2 | | phpunit/phpunit (source) | require-dev | pin | ~6.0 \|\| ~7.0 \|\| ~9.0 -> 9.5.12 | | voku/php-readme-helper | require-dev | pin | ~0.6 -> 0.6.3 |

    馃搶 Important: Renovate will wait until you have merged this Pin PR before creating any upgrade PRs for the affected packages. Add the preset :preserveSemverRanges to your config if you instead don't wish to pin dependencies.


    Configuration

    馃搮 Schedule: At any time (no schedule defined).

    馃殾 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

    馃懟 Immortal: This PR will be recreated if closed unmerged. Get config help if that's undesired.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by WhiteSource Renovate. View repository job log here.


    This change is鈥Reviewable

    Reviewed by renovate[bot] at 2022-01-23 19:34
  • 12. Update codecov/codecov-action action to v3

    WhiteSource Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | codecov/codecov-action | action | major | v2 -> v3 |


    Release Notes

    codecov/codecov-action

    v3

    Compare Source


    Configuration

    馃搮 Schedule: At any time (no schedule defined).

    馃殾 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    馃敃 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by WhiteSource Renovate. View repository job log here.


    This change is鈥Reviewable

    Reviewed by renovate[bot] at 2022-04-05 17:24
  • 13. Update shivammathur/setup-php action to v2.18.1

    WhiteSource Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | shivammathur/setup-php | action | minor | 2.17.1 -> 2.18.1 |


    Release Notes

    shivammathur/setup-php

    v2.18.1

    Compare Source

    Support Ukraine

    #StandWithUkraine


    - name: Setup PHP with intl
      uses: shivammathur/[email protected]
      with:
        php-version: '8.1'
        extensions: intl-71.1
    
    • Added support for macOS Monterey (macos-12) GitHub hosted environment.

    • Added support for mcrypt extension using shivammathur/extensions tap on macOS.

    • Fixed patching brew for overwriting existing linked libraries.

    • Fixed identifying the latest protoc release.

    • Updated Node.js dependencies.


    Thanks! @鈥媕derusse for the contributions 馃殌

    Follow for updates

    setup-php reddit setup-php twitter setup-php status

    v2.18.0

    Compare Source

    Support Ukraine

    #StandWithUkraine


    • Added support for installing libraries and custom configure options for PECL extensions. #鈥575. Docs.

    • Added support for blackfire extension on PHP 8.1 on Windows.

    • Improved support for http extension on Windows and self-hosted environments.

    • Fixed installing php-dev package on self-hosted environments when missing. #鈥569

    • Fixed linking pecl ini file on self-hosted environments. #鈥569

    • Fixed copying extensions when installed using brew from its Cellar to extension directory on macOS.

    • Fixed generating extension dependency map.

    • Fixed a bug in log functions on Linux and macOS by using local variables.

    • Improved switching versions on Linux. #鈥572

    • Improved enabling default extensions by reducing PHP calls.

    • Bumped actions/checkout, actions/upload-artifact, actions/download-artifact and actions/cache version in examples and workflows to v3. #鈥571, #鈥577

    • Added PECL customization guide to README.

    • Updated Node.js dependencies.


    Thanks! @鈥媕rfnl for the contributions 馃殌

    Follow for updates

    setup-php reddit setup-php twitter setup-php status


    Configuration

    馃搮 Schedule: At any time (no schedule defined).

    馃殾 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    馃敃 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by WhiteSource Renovate. View repository job log here.


    This change is鈥Reviewable

    Reviewed by renovate[bot] at 2022-03-23 10:17
  • 14. Update actions/cache action to v3

    WhiteSource Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | actions/cache | action | major | v2.1.7 -> v3.0.2 |


    Release Notes

    actions/cache

    v3.0.2

    Compare Source

    This release adds the support for dynamic cache size cap on GHES.

    v3.0.1

    Compare Source

    • Added support for caching from GHES 3.5.
    • Fixed download issue for files > 2GB during restore.

    v3.0.0

    Compare Source

    • This change adds a minimum runner version(node12 -> node16), which can break users using an out-of-date/fork of the runner. This would be most commonly affecting users on GHES 3.3 or before, as those runners do not support node16 actions and they can use actions from github.com via github connect or manually copying the repo to their GHES instance.

    • Few dependencies and cache action usage examples have also been updated.


    Configuration

    馃搮 Schedule: At any time (no schedule defined).

    馃殾 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    馃敃 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by WhiteSource Renovate. View repository job log here.


    This change is鈥Reviewable

    Reviewed by renovate[bot] at 2022-03-21 10:14
  • 15. Validate array based on a schema

    What is this feature about (expected vs actual behaviour)?

    Provide a schema a check validity of/fix an array.

    @voku Do you happen to know a package that does this? Do you plan to implement it?

    Reviewed by szepeviktor at 2022-02-10 15:23
  • 16. Dependency Dashboard

    This issue provides visibility into Renovate updates and their statuses. Learn more

    Repository problems

    These problems occurred while renovating this repository.

    • WARN: Found renovate config warnings

    Open

    These updates have all been created already. Click a checkbox below to force a retry/rebase of any.


    • [ ] Check this box to trigger a request for Renovate to run again on this repository
    Reviewed by renovate[bot] at 2022-01-23 19:34
  • 17. Activating Open Collective

    Hi, I'm making updates for Open Collective. Either you or another core contributor signed this repository up for Open Collective. This pull request adds financial contributors from your Open Collective https://opencollective.com/Arrayy 鉂わ笍

    What it does:

    • adds a badge to show the latest number of financial contributors
    • adds a banner displaying contributors to the project on GitHub
    • adds a banner displaying all individuals contributing financially on Open Collective
    • adds a section displaying all organizations contributing financially on Open Collective, with their logo and a link to their website

    P.S: As with any pull request, feel free to comment or suggest changes.

    Thank you for your great contribution to the Open Source community. You are awesome! 馃檶 And welcome to the Open Collective community! 馃槉

    Come chat with us in the #opensource channel on https://slack.opencollective.com - great place to ask questions and share best practices with other Open Source sustainers!


    This change is鈥Reviewable

    Reviewed by monkeywithacupcake at 2019-11-15 00:00
A Collections library for PHP.

A Library of Collections for OO Programming While developing and helping others develop PHP applications I noticed the trend to use PHP's arrays in ne

May 2, 2022
Collections Abstraction library for PHP

Collections Collections Abstraction library for PHP The Collection library is one of the most useful things that many modern languages has, but for so

Dec 27, 2021
Library for (de-)serializing data of any complexity (supports JSON, and XML)

jms/serializer Introduction This library allows you to (de-)serialize data of any complexity. Currently, it supports XML and JSON. It also provides yo

May 19, 2022
:lipstick: Scalable and durable all-purpose data import library for publishing APIs and SDKs.
:lipstick: Scalable and durable all-purpose data import library for publishing APIs and SDKs.

Porter Scalable and durable data imports for publishing and consuming APIs Porter is the all-purpose PHP data importer. She fetches data from anywhere

May 6, 2022
[READ-ONLY] Collection library in CakePHP. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp

CakePHP Collection Library The collection classes provide a set of tools to manipulate arrays or Traversable objects. If you have ever used underscore

Mar 28, 2022
True asynchronous PHP I/O and HTTP without frameworks, extensions, or annoying code. Uses the accepted Fibers RFC to be implemented into PHP 8.1
True asynchronous PHP I/O and HTTP without frameworks, extensions, or annoying code. Uses the accepted Fibers RFC to be implemented into PHP 8.1

PHP Fibers - Async Examples Without External Dependencies True asynchronous PHP I/O and HTTP without frameworks, extensions, or annoying code behemoth

May 13, 2022
Map nested JSON structures onto PHP classes

JsonMapper - map nested JSON structures onto PHP classes Takes data retrieved from a JSON web service and converts them into nested object and arrays

May 13, 2022
Yet Another LINQ to Objects for PHP [Simplified BSD]

YaLinqo: Yet Another LINQ to Objects for PHP Online documentation GitHub repository Features The most complete port of .NET LINQ to PHP, with many add

May 9, 2022
`LINQ to Object` inspired DSL for PHP

Ginq Array handling in PHP? Be happy with Ginq! Ginq is a DSL that can handle arrays and iterators of PHP unified. Ginq is inspired by Linq to Object,

Apr 17, 2022
A repository with implementations of different data structures and algorithms using PHP

PHP Data Structures and Algorithms Data structure and Algorithm is always important for any programming language. PHP, being one of the most popular l

May 17, 2022
Leetcode for PHP, five questions a week and weekends are updated irregularly
Leetcode for PHP,  five questions a week and weekends are updated irregularly

鉁忥笍 Leetcode for PHP why do you have to sleep for a long time ,and naturally sleep after death 鑱旂郴 璇存槑 鐢变簬鐩墠宸ヤ綔涓昏鏄 golang,鎴戝張鏂拌捣浜嗕竴涓狶eetCode-Go-Week椤圭洰锛- Leetc

May 26, 2022
Missing data types for PHP. Highly extendable.
Missing data types for PHP. Highly extendable.

Neverending data validation can be exhausting. Either you have to validate your data over and over again in every function you use it, or you have to rely it has already been validated somewhere else and risk potential problems.

Feb 7, 2022
JsonMapper - map nested JSON structures onto PHP classes

Takes data retrieved from a JSON web service and converts them into nested object and arrays - using your own model classes.

May 10, 2021
All Algorithms implemented in Php

The Algorithms - PHP All algorithms implemented in Php (for education) These implementations are for learning purposes. They may be less efficient tha

May 22, 2022
A community driven collection of sorting algorithms in PHP

algorithms A community driven collection of sorting algorithms This repository includes a comma separated file that includes 10k numbers between 1 and

May 16, 2022
Iterators - The missing PHP iterators.

PHP Iterators Description The missing PHP iterators. Features CachingIteratorAggregate ClosureIterator: ClosureIterator(callable $callable, array $arg

May 3, 2022
PHPR or PHP Array Framework is a framework highly dependent to an array structure.

this is new repository for php-framework Introduction PHPR or PHP Array Framework is a framework highly dependent to an array structure. PHPR Framewor

Feb 12, 2022
Geographer is a PHP library that knows how any country, state or city is called in any language
Geographer is a PHP library that knows how any country, state or city is called in any language

Geographer Geographer is a PHP library that knows how any country, state or city is called in any language. Documentation on the official website Incl

May 17, 2022
Security provides an infrastructure for sophisticated authorization systems, which makes it possible to easily separate the actual authorization logic from so called user providers that hold the users credentials.

Security provides an infrastructure for sophisticated authorization systems, which makes it possible to easily separate the actual authorization logic from so called user providers that hold the users credentials. It is inspired by the Java Spring framework.

May 19, 2022