Skip to content

Commit a416ab2

Browse files
authored
Merge pull request #11 from infocyph/feature/improvement-25
Feature/improvement 25
2 parents e01607e + 8f3a0bc commit a416ab2

45 files changed

Lines changed: 4210 additions & 2198 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2

.gitattributes

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.editorconfig export-ignore
2+
.gitignore export-ignore
13
tests export-ignore
24
docs export-ignore
35
.github export-ignore
@@ -7,5 +9,7 @@ phpunit.xml export-ignore
79
pint.json export-ignore
810
rector.php export-ignore
911
.gitattributes export-ignore
12+
psalm.xml export-ignore
13+
pest.xml export-ignore
1014

11-
* text eol=lf
15+
* text eol=lf

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @abmmhasan
1+
* @abmmhasan

.github/dependabot.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version: 2
22
updates:
3-
- package-ecosystem: "composer" # See documentation for possible values
4-
directory: "/" # Location of package manifests
3+
- package-ecosystem: "composer"
4+
directory: "/"
55
schedule:
6-
interval: "daily"
6+
interval: "weekly"

.github/workflows/build.yml

Lines changed: 69 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,34 @@ on:
44
schedule:
55
- cron: '0 0 * * 0'
66
push:
7-
branches: [ '*' ]
7+
branches: [ "main", "master" ]
88
pull_request:
9-
branches: [ "main", "master", "develop" ]
9+
branches: [ "main", "master", "develop", "development" ]
1010

1111
jobs:
12+
prepare:
13+
name: Prepare CI matrix
14+
runs-on: ubuntu-latest
15+
outputs:
16+
php_versions: ${{ steps.matrix.outputs.php_versions }}
17+
dependency_versions: ${{ steps.matrix.outputs.dependency_versions }}
18+
steps:
19+
- name: Define shared matrix values
20+
id: matrix
21+
run: |
22+
echo 'php_versions=["8.3","8.4","8.5"]' >> "$GITHUB_OUTPUT"
23+
echo 'dependency_versions=["prefer-lowest","prefer-stable"]' >> "$GITHUB_OUTPUT"
24+
1225
run:
26+
needs: prepare
1327
runs-on: ${{ matrix.operating-system }}
1428
strategy:
1529
matrix:
1630
operating-system: [ ubuntu-latest ]
17-
php-versions: [ '8.2', '8.3', '8.4' ]
18-
dependency-version: [ prefer-lowest, prefer-stable ]
31+
php-versions: ${{ fromJson(needs.prepare.outputs.php_versions) }}
32+
dependency-version: ${{ fromJson(needs.prepare.outputs.dependency_versions) }}
1933

20-
name: PHP ${{ matrix.php-versions }} - ${{ matrix.operating-system }} - ${{ matrix.dependency-version }}
34+
name: Code Analysis - PHP ${{ matrix.php-versions }} - ${{ matrix.dependency-version }}
2135
steps:
2236
- name: Checkout
2337
uses: actions/checkout@v4
@@ -35,11 +49,56 @@ jobs:
3549
- name: Validate Composer
3650
run: composer validate --strict
3751

52+
- name: Resolve dependencies (${{ matrix.dependency-version }})
53+
run: composer update --no-interaction --prefer-dist --no-progress --${{ matrix.dependency-version }}
54+
55+
- name: Test
56+
run: |
57+
composer test:code
58+
composer test:lint
59+
composer test:refactor
60+
# Skip Psalm on prefer-lowest: older transitive amphp versions can trigger PHP 8.4+ deprecations at startup.
61+
if [ "${{ matrix.dependency-version }}" != "prefer-lowest" ]; then
62+
composer test:security
63+
fi
64+
65+
analyze:
66+
needs: prepare
67+
name: Security Analysis - PHP ${{ matrix.php-versions }}
68+
runs-on: ubuntu-latest
69+
strategy:
70+
matrix:
71+
php-versions: ${{ fromJson(needs.prepare.outputs.php_versions) }}
72+
permissions:
73+
security-events: write
74+
actions: read
75+
contents: read
76+
77+
steps:
78+
- name: Checkout repository
79+
uses: actions/checkout@v4
80+
81+
- name: Setup PHP
82+
uses: shivammathur/setup-php@v2
83+
with:
84+
php-version: ${{ matrix.php-versions }}
85+
tools: composer:v2
86+
3887
- name: Install dependencies
39-
run: composer install --no-interaction --prefer-dist --optimize-autoloader
88+
run: composer install --no-interaction --prefer-dist --no-progress
4089

41-
- name: Package Audit
42-
run: composer audit
90+
- name: Composer Audit (CVE check)
91+
run: composer audit --no-interaction
4392

44-
- name: Test
45-
run: composer tests
93+
# Run Psalm (Deep Taint Analysis)
94+
- name: Run Psalm Security Scan
95+
run: |
96+
php ./vendor/bin/psalm --config=psalm.xml --security-analysis --threads=1 --report=psalm-results.sarif || true
97+
continue-on-error: true
98+
99+
- name: Upload Psalm Results
100+
uses: github/codeql-action/upload-sarif@v4
101+
with:
102+
sarif_file: psalm-results.sarif
103+
category: "psalm-${{ matrix.php-versions }}"
104+
if: always() && hashFiles('psalm-results.sarif') != ''

.gitignore

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,13 @@ test.php
66
composer.lock
77
git-story_media
88
*~
9-
diffs.txt
9+
*.txt
10+
!docs/requirements.txt
11+
.windsurf
12+
.vscode
13+
.phpunit.cache
14+
var
15+
*.patch
16+
patch.php
17+
.psalm-cache
18+
AI_CONTEXT.md

.readthedocs.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: 2
2+
3+
build:
4+
os: ubuntu-24.04
5+
tools:
6+
python: "3.13"
7+
8+
python:
9+
install:
10+
- requirements: docs/requirements.txt
11+
12+
sphinx:
13+
configuration: docs/conf.py
14+
15+
formats:
16+
- pdf
17+
- epub
18+

README.md

Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,23 @@
77
![Packagist Version](https://img.shields.io/packagist/v/infocyph/arraykit)
88
![Packagist PHP Version](https://img.shields.io/packagist/dependency-v/infocyph/arraykit/php)
99
![GitHub Code Size](https://img.shields.io/github/languages/code-size/infocyph/arraykit)
10+
[![Documentation](https://img.shields.io/badge/Documentation-ArrayKit-blue?logo=readthedocs&logoColor=white)](https://docs.infocyph.com/projects/arraykit/)
1011

11-
**ArrayKit** is a modern **PHP 8.2+** library for elegant, high-performance **array manipulation**, **dot notation
12+
**ArrayKit** is a modern **PHP 8.4+** library for elegant, high-performance **array manipulation**, **dot notation
1213
utilities**, **dynamic configuration**, **hookable collections**, and more.
1314
From shallow single arrays to deeply nested data structures — **ArrayKit** provides a fluent, reliable toolkit for
1415
real-world PHP projects.
1516

16-
---
17-
1817
## 📦 Features at a Glance
1918

20-
**Single-Dimensional Helpers**
21-
**Multi-Dimensional Helpers**
22-
**Dot Notation Get/Set/Flatten**
23-
**Dynamic Config with Hooks**
24-
**Collection & Hooked Collection**
25-
**Traits for DTO & Hooking**
26-
**Pipeline for Collection Ops**
27-
**Global Helpers (`functions.php`)**
28-
29-
---
19+
- **Single-Dimensional Helpers**
20+
- **Multi-Dimensional Helpers**
21+
- **Dot Notation Get/Set/Flatten**
22+
- **Dynamic Config with Hooks**
23+
- **Collection & Hooked Collection**
24+
- **Traits for DTO & Hooking**
25+
- **Pipeline for Collection Ops**
26+
- **Global Helpers (`functions.php`)**
3027

3128
## 📚 Modules
3229

@@ -39,17 +36,14 @@ real-world PHP projects.
3936
| **DotNotation** | Get/set/remove values using dot keys; flatten & expand nested arrays with dot keys. |
4037
| **BaseArrayHelper** | Internal shared base for consistent API across helpers. |
4138

42-
---
43-
4439
### ➤ Config System
4540

4641
| Class | Description |
4742
|---------------------|---------------------------------------------------------------------------------------------------------------------|
48-
| **Config** | Immutable dot-access configuration loader. |
43+
| **Config** | Dot-access configuration loader. |
4944
| **DynamicConfig** | Extends `Config` with **on-get/on-set hooks** to transform values dynamically (e.g., encrypt/decrypt, auto-format). |
5045
| **BaseConfigTrait** | Shared config logic. |
5146

52-
---
5347

5448
### ➤ Collections
5549

@@ -60,7 +54,6 @@ real-world PHP projects.
6054
| **Pipeline** | Functional-style pipeline for chaining operations on collections. |
6155
| **BaseCollectionTrait** | Shared collection behavior. |
6256

63-
---
6457

6558
### ➤ Traits
6659

@@ -69,30 +62,25 @@ real-world PHP projects.
6962
| **HookTrait** | Generic hook system for on-get/on-set callbacks. Used by `DynamicConfig` & `HookedCollection`. |
7063
| **DTOTrait** | Utility trait for DTO-like behavior: populate, extract, cast arrays/objects easily. |
7164

72-
---
7365

7466
### ➤ Global Helpers
7567

7668
| File | Description |
7769
|-------------------|------------------------------------------------------------|
7870
| **functions.php** | Global shortcut functions for frequent array/config tasks. |
7971

80-
---
8172

8273
## ✅ Requirements
8374

84-
* **PHP 8.2** or higher
75+
* **PHP 8.4** or higher
8576

86-
---
8777

8878
## ⚡ Installation
8979

9080
```bash
9181
composer require infocyph/arraykit
9282
```
9383

94-
---
95-
9684
## 🚀 Quick Examples
9785

9886
### 🔹 Single-Dimensional Helpers
@@ -112,8 +100,6 @@ $dupes = ArraySingle::duplicates($list); // [2]
112100
$page = ArraySingle::paginate($list, page:1, perPage:2); // [1, 2]
113101
```
114102

115-
---
116-
117103
### 🔹 Multi-Dimensional Helpers
118104

119105
```php
@@ -134,8 +120,6 @@ $depth = ArrayMulti::depth($data); // 3
134120
$sorted = ArrayMulti::sortRecursive($data);
135121
```
136122

137-
---
138-
139123
### 🔹 Dot Notation
140124

141125
```php
@@ -156,8 +140,6 @@ $flat = DotNotation::flatten($user);
156140
// [ 'profile.name' => 'Alice', 'profile.email' => '[email protected]' ]
157141
```
158142

159-
---
160-
161143
### 🔹 Dynamic Config with Hooks
162144

163145
```php
@@ -179,8 +161,6 @@ $config->set('auth.password', 'secret123');
179161
$hashed = $config->get('auth.password');
180162
```
181163

182-
---
183-
184164
### 🔹 Hooked Collection
185165

186166
```php
@@ -200,8 +180,6 @@ $collection['role'] = 'admin';
200180
echo $collection['role']; // Role: admin
201181
```
202182

203-
---
204-
205183
### 🔹 DTO Trait Example
206184

207185
```php
@@ -219,14 +197,10 @@ $user->fromArray(['name' => 'Alice', 'email' => '[email protected]']);
219197
$array = $user->toArray();
220198
```
221199

222-
---
223-
224200
## 🤝 Support
225201

226202
Have a bug or feature idea? Please [open an issue](https://github.com/infocyph/arraykit/issues).
227203

228-
---
229-
230204
## 📄 License
231205

232206
Licensed under the **MIT License** — use it freely for personal or commercial projects. See [LICENSE](LICENSE) for

0 commit comments

Comments
 (0)