Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
0417594
chore: target Runwire 4.0.1 and extend compatibility matrix
abmmhasan Nov 27, 2026
c9c4e73
fix: replace deprecated PHP locale sorting with explicit collation
abmmhasan Nov 27, 2026
85c7e17
fix: describe delegated collection and facade contracts and type thei…
abmmhasan Nov 27, 2026
db5681a
fix: document exception boundaries and correct runtime type contracts
abmmhasan Nov 27, 2026
6adb92d
fix: validate benchmark outputs and type regression fixtures
abmmhasan Nov 27, 2026
747557c
fix: type feature callbacks and guard regression resources
abmmhasan Nov 27, 2026
2f9eb8c
fix: address follow-up analyzer review and formatting findings
abmmhasan Nov 27, 2026
d56fa80
fix: validate regression fixture shapes and simplify worker checks
abmmhasan Nov 27, 2026
4bb8448
ci: document PHP 8.6 support and pin complete QA matrix
abmmhasan Nov 27, 2026
e409205
fix: resolve residual PHPStan contracts and PHP 8.6 test deprecation
abmmhasan Nov 27, 2026
a97382c
fix: complete source exception and public API contracts
abmmhasan Nov 27, 2026
0fdb90c
fix: preserve public numeric operations and repair analyzer fixtures
abmmhasan Nov 27, 2026
e11fa5c
fix: simplify enum resolution and close residual QA findings
abmmhasan Nov 27, 2026
664b315
fix: propagate exception contracts and align formatter rules
abmmhasan Nov 27, 2026
d7cb995
fix: preserve numeric precision and clarify callback result contracts
abmmhasan Nov 27, 2026
0a43360
fix: guard namespace reads and consolidate strict fingerprint paths
abmmhasan Nov 27, 2026
87fc33c
fix: harden benchmark fixtures and complete test and exception contracts
abmmhasan Nov 27, 2026
c6b743a
fix: detect repeated nulls and preserve DTO fixture contracts
abmmhasan Nov 27, 2026
1bc273c
fix: complete remaining exception and reflection contracts
abmmhasan Nov 27, 2026
f51ef6d
fix: bootstrap benchmark workers from the trusted parent runner
abmmhasan Nov 27, 2026
f071bcf
Complete exception contracts across configuration and lazy traversal …
abmmhasan Nov 27, 2026
767e923
Finish collection exception propagation and correct benchmark factory…
abmmhasan Nov 27, 2026
a3b6a08
Use secure default shuffle and full-width deterministic random engine
abmmhasan Nov 27, 2026
e08e7dd
Describe shared value type for reference restoration
abmmhasan Nov 27, 2026
92b2bb9
fix: complete collection and global helper exception contracts
abmmhasan Nov 27, 2026
f47762b
fix: document exception on magic collection setter
abmmhasan Nov 27, 2026
27e87ee
docs: align release migration and runtime behavior with ArrayKit 5.4
abmmhasan Nov 27, 2026
011f836
docs: correct release notes heading underline
abmmhasan Nov 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ body:
id: php_version
attributes:
label: PHP version
placeholder: e.g. 8.4.13
placeholder: e.g. 8.6.0
validations:
required: true

Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/ci_failure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ body:
id: php_version
attributes:
label: PHP version
placeholder: e.g. 8.4.13
placeholder: e.g. 8.6.0
validations:
required: true

Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/question.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ body:
attributes:
label: Environment
description: Include package, PHP, Composer, OS, extensions or CI details only when relevant.
placeholder: Package 2.4.1, PHP 8.4, Composer 2.9, Ubuntu 24.04...
placeholder: Package 2.4.1, PHP 8.6, Composer 2.9, Ubuntu 24.04...

- type: textarea
id: additional
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/regression_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ body:
attributes:
label: Environment details
description: PHP version, Composer version, OS, CI provider (if relevant).
placeholder: PHP 8.3, Composer 2.9, Ubuntu 24.04...
placeholder: PHP 8.6, Composer 2.9, Ubuntu 24.04...
validations:
required: true
24 changes: 15 additions & 9 deletions .github/workflows/security-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
pull_request:
branches: [ "main", "master", "develop", "development" ]

concurrency:
group: arraykit-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true

jobs:
release:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
Expand All @@ -22,6 +26,8 @@ jobs:
if: github.event_name != 'push' || !startsWith(github.ref, 'refs/tags/')
uses: infocyph/phpforge/.github/workflows/security-standards.yml@main
with:
php_versions: '["8.4","8.5","8.6"]'
php_extensions: 'intl'
integration_services: '[]'
service_topologies: '{}'
benchmark_composer_script: "benchmark:representative"
Expand Down Expand Up @@ -51,13 +57,13 @@ jobs:

runwire-compat:
if: github.event_name != 'push' || !startsWith(github.ref, 'refs/tags/')
name: "Runwire 3.0 / PHP ${{ matrix.php }}"
name: "Runwire 4.0.1 / PHP ${{ matrix.php }}"
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
php: ["8.4", "8.5"]
php: ["8.4", "8.5", "8.6"]
env:
XDEBUG_MODE: off
steps:
Expand All @@ -67,11 +73,11 @@ jobs:
with:
php-version: ${{ matrix.php }}
tools: composer:v2
extensions: opcache
extensions: opcache, intl
ini-values: opcache.enable_cli=1
coverage: none
- name: Install exact Runwire 3.0
run: composer require --dev "infocyph/runwire:3.0.0" --no-interaction --prefer-dist --no-progress
- name: Install exact Runwire 4.0.1
run: composer require --dev "infocyph/runwire:4.0.1" --no-interaction --prefer-dist --no-progress
- name: Exercise lazy pipeline and host-owned coroutine lifecycle
run: >-
php vendor/bin/pest
Expand All @@ -81,7 +87,7 @@ jobs:
tests/Feature/Release530BatchETest.php
tests/Feature/Release530ReviewRegressionTest.php
tests/Feature/Release530BatchFTest.php
- name: Exercise persistent worker with Runwire 3.0
- name: Exercise persistent worker with Runwire 4.0.1
if: matrix.php == '8.5'
run: |
mkdir -p build
Expand All @@ -92,11 +98,11 @@ jobs:
--max-growth-mb=16 \
--report=build/runwire-worker-soak.json \
-- php -d opcache.enable_cli=1 tests/Support/release530-persistent-worker.php
- name: Upload Runwire 3.0 worker-soak report
- name: Upload Runwire 4.0.1 worker-soak report
if: always() && matrix.php == '8.5' && hashFiles('build/runwire-worker-soak.json') != ''
uses: actions/upload-artifact@v7
with:
name: runwire-3.0-php-${{ matrix.php }}-worker-soak
name: runwire-4.0.1-php-${{ matrix.php }}-worker-soak
path: build/runwire-worker-soak.json
if-no-files-found: error
retention-days: 61
Expand All @@ -115,7 +121,7 @@ jobs:
with:
php-version: "8.5"
tools: composer:v2
extensions: opcache
extensions: opcache, intl
ini-values: opcache.enable_cli=1
coverage: none
- name: Install acceptance dependencies
Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,12 @@ configuration or object models.

## Requirements

* **PHP 8.4** or higher
* **PHP 8.4** or higher (CI matrix: PHP 8.4, 8.5 and 8.6)
* **ext-filter**, **ext-hash** and **ext-tokenizer**

Runwire is optional. ArrayKit 5.3.2 qualifies its passed-instance lazy-runtime integration against `infocyph/runwire` 3.0 on PHP 8.4 and 8.5; ordinary ArrayKit installation has no Runwire runtime dependency.
`ext-intl` is optional; it is required for locale-aware sorting outside the C/POSIX collation locale.

Runwire is optional. The 5.4 release line targets `infocyph/runwire` `^4.0.1`, with exact 4.0.1 integration tested on PHP 8.4, 8.5 and 8.6. Ordinary ArrayKit installation has no Runwire runtime dependency.


## Installation
Expand Down Expand Up @@ -160,6 +163,10 @@ $flatZero = ArrayMulti::flatten($data, 0); // [[1, 2], [3, [4, 5]]]
$flatOne = ArrayMulti::flatten($data, 1); // [1, 2, 3, [4, 5]]

// Multi-column and query helpers
$rows = [
['status' => 'active', 'created_at' => '2026-01-01', 'email' => 'alice@example.com', 'role' => 'admin'],
['status' => 'inactive', 'created_at' => '2026-01-02', 'email' => 'bob@example.com', 'role' => 'editor'],
];
$sortedMany = ArrayMulti::sortByMany($rows, [
['status', 'asc'],
['created_at', 'desc'],
Expand All @@ -168,7 +175,7 @@ $active = ArrayMulti::whereStartsWith($rows, 'status', 'act', false);
$match = ArrayMulti::whereLike($rows, 'email', '%@example.com');
$first = ArrayMulti::firstWhereIn($rows, 'role', ['admin', 'editor']);
$uniqueUsers = ArrayMulti::uniqueBy($rows, 'email');
$dupeUsers = ArrayMulti::duplicatesBy($rows, fn ($row) => strtolower((string) ($row['email'] ?? '')));
$dupeUsers = ArrayMulti::duplicatesBy($rows, 'email');

// Collapse one level
$collapsed = ArrayMulti::collapse($data); // [1, 2, 3, [4, 5]]
Expand Down Expand Up @@ -305,6 +312,9 @@ $host = $config->get('db.host');

- `ArrayMulti::flatten($array, 0)` keeps top-level values unchanged; `1` flattens one level; `INF` fully flattens.
- `ArraySingle::avg()`, `sum()`, `isPositive()`, and `isNegative()` only consider numeric values (non-numeric values are ignored).
- `ArraySingle::duplicates($values, true)` reports repeated `null` without conflating it with `false`, `0` or `''`.
- Use `ArrayMulti::SORT_LOCALE` for locale-aware sorting instead of PHP's deprecated locale flag; non-C collation uses ICU and may differ from libc.
- Unseeded `ArraySingle::shuffle()` uses secure randomness; seeded shuffles are reproducible but their exact order changed with the new engine.
- `ArraySingle::paginate()` requires `page >= 1` and `perPage >= 1` (throws `InvalidArgumentException` otherwise).
- Callback-based row helpers (`ArrayMulti::sortBy()`, `sum()`, `maxBy()`, `minBy()`) support `($row, $key)`.
- `DotNotation` treats existing `null` keys/properties as present (does not fall back to defaults).
Expand Down
42 changes: 36 additions & 6 deletions benchmarks/ArrayMultiBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
use PhpBench\Attributes\ParamProviders;
use PhpBench\Attributes\Revs;

/**
* PhpBench discovers this benchmark through its attributes.
* @api
*/
#[Revs(1)]
#[Iterations(3)]
#[BeforeMethods('setUp')]
Expand Down Expand Up @@ -42,6 +46,9 @@ public function setUp(array $params): void
$this->needles = range(0, $params['needles'] - 1);
}

/**
* @throws \InvalidArgumentException
*/
public function benchCountBy(): void
{
ArrayMulti::countBy($this->rows, 'group');
Expand All @@ -57,34 +64,53 @@ public function benchFlatten(): void
ArrayMulti::flatten($this->rows);
}

/**
* @throws \InvalidArgumentException
*/
public function benchGroupBy(): void
{
ArrayMulti::groupBy($this->rows, 'group');
}

/**
* @throws \InvalidArgumentException
*/
public function benchKeyBy(): void
{
ArrayMulti::keyBy($this->rows, 'id');
}

public function benchKeyByNative(): void
/** @return array<array-key, mixed> */
public function benchKeyByNative(): array
{
$result = [];
foreach ($this->rows as $row) {
$result[$row['id']] = $row;
}

return $result;
}

public function benchPluck(): void
/**
* @return array<array-key, mixed>
* @throws \InvalidArgumentException
*/
public function benchPluck(): array
{
ArrayMulti::pluck($this->rows, 'score', 'id');
return ArrayMulti::pluck($this->rows, 'score', 'id');
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
}

/**
* @throws \RuntimeException
*/
public function benchSortBy(): void
{
ArrayMulti::sortBy($this->rows, 'score', true, SORT_NUMERIC);
}

/**
* @throws \RuntimeException
*/
public function benchSortByMany(): void
{
ArrayMulti::sortByMany($this->rows, [
Expand All @@ -103,24 +129,28 @@ public function benchUniqueByStrict(): void
ArrayMulti::uniqueBy($this->rows, 'derived', true);
}

public function benchWhere(): void
/** @return array<array-key, mixed> */
public function benchWhere(): array
{
ArrayMulti::where($this->rows, 'score', '>=', 500);
return ArrayMulti::where($this->rows, 'score', '>=', 500);
}

public function benchWhereIn(): void
{
ArrayMulti::whereIn($this->rows, 'score', $this->needles, true);
}

public function benchWhereInNative(): void
/** @return array<array-key, mixed> */
public function benchWhereInNative(): array
{
$result = [];
foreach ($this->rows as $key => $row) {
if (in_array($row['score'], $this->needles, true)) {
$result[$key] = $row;
}
}

return $result;
}

public function benchWhereNotIn(): void
Expand Down
31 changes: 23 additions & 8 deletions benchmarks/ArraySingleBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
use PhpBench\Attributes\ParamProviders;
use PhpBench\Attributes\Revs;

/**
* PhpBench discovers this benchmark through its attributes.
* @api
*/
#[Revs(1)]
#[Iterations(3)]
#[BeforeMethods('setUp')]
Expand Down Expand Up @@ -41,6 +45,7 @@ public function setUp(array $params): void
$this->needles = array_slice($this->data, 0, min(100, $params['size']));
}

/** @param array{size:int} $params */
public function benchContains(array $params): void
{
ArraySingle::contains($this->data, $params['size'] - 1, true);
Expand All @@ -51,14 +56,16 @@ public function benchContainsAll(): void
ArraySingle::containsAll($this->data, $this->needles, true);
}

/** @param array{size:int} $params */
public function benchContainsAny(array $params): void
{
ArraySingle::containsAny($this->data, [$params['size'], $this->needles[0]], true);
}

public function benchContainsNative(array $params): void
/** @param array{size:int} $params */
public function benchContainsNative(array $params): bool
{
in_array($params['size'] - 1, $this->data, true);
return in_array($params['size'] - 1, $this->data, true);
}

public function benchDiff(): void
Expand All @@ -76,29 +83,37 @@ public function benchMap(): void
ArraySingle::map($this->data, static fn(int $value): int => $value + 1);
}

public function benchMapArrayMap(): void
/** @return array<array-key, mixed> */
public function benchMapArrayMap(): array
{
array_map(static fn(int $value): int => $value + 1, $this->data);
return array_map(static fn(int $value): int => $value + 1, $this->data);
}

public function benchMapForeach(): void
/** @return array<array-key, mixed> */
public function benchMapForeach(): array
{
$result = [];
foreach ($this->data as $key => $value) {
$result[$key] = $value + 1;
}

return $result;
}

public function benchMedian(): void
{
ArraySingle::median($this->data);
}

public function benchMode(): void
/** @return array<array-key, mixed> */
public function benchMode(): array
{
ArraySingle::mode($this->data);
return ArraySingle::mode($this->data);
}

/**
* @throws \InvalidArgumentException
*/
public function benchNth(): void
{
ArraySingle::nth($this->data, 10, 3);
Expand Down Expand Up @@ -144,7 +159,7 @@ public function benchWhere(): void
ArraySingle::where($this->keyed, static fn(int $value): bool => ($value % 2) === 0);
}

/** @return array<string, array{size:int}> */
/** @return array<int|string, array{size:int}> */
public function provideSizes(): array
{
return [
Expand Down
Loading