pragmarx/ia-arr
Illuminate\Support\Arr extracted from Laravel, repackaged as a framework-agnostic PHP library. Provides the full set of Arr helpers under the IlluminateAgnostic\Arr namespace to avoid conflicts, usable in any project (including Laravel).
Pros:
Illuminate\Support\Arr functionality, offering a drop-in replacement for array manipulation utilities (e.g., Arr::get(), Arr::set(), Arr::pull()).IlluminateAgnostic\Arr) prevents conflicts with Laravel’s built-in Arr helper, making it ideal for non-Laravel PHP projects or Laravel apps requiring customization.Arr helpers.Cons:
Str or Collection).Arr::forget()) may behave differently in non-Laravel contexts due to missing Laravel-specific dependencies (e.g., Collection).Non-Laravel Projects:
symfony/var-dumper for debugging).Arr::forget() may fail if the underlying array is not traversable (e.g., objects without __get()).Collection integration (e.g., Arr::wrap() assumes arrays).Laravel Projects:
Arr via namespace aliasing (e.g., use Arr as LaravelArr).Arr in unit tests without polluting the global namespace.Arr::dot()) may differ subtly from Laravel’s implementation if they rely on Laravel’s Str or Collection classes.Arr extensively.| Risk Area | Assessment | Mitigation Strategy |
|---|---|---|
| API Stability | Minor risk: Follows Laravel’s 5.5–5.6 API but lacks long-term backward compatibility guarantees. | Pin to a specific version (e.g., v5.6.3) and monitor Laravel’s Arr changes. |
| Dependency Conflicts | Low risk: Only symfony/var-dumper is required. |
Use Composer’s replace or conflict directives if needed. |
| Performance | Negligible: Pure PHP implementation with no external calls. | Benchmark critical paths if used in high-throughput systems. |
| Testing | Medium risk: Test coverage is good (~80%), but edge cases (e.g., non-array inputs) may exist. | Write integration tests for custom array structures. |
| Future Maintenance | Medium risk: Abandonware risk (last release 2024-10-05, no dependents). | Fork or maintain a patched version if critical. |
| PHP Version Support | High risk: PHP 7.0–7.3 is outdated. | Use a PHP 8.x-compatible fork (e.g., spatie/array) if needed. |
Arr directly?
Collection integration, dot notation with Str)?spatie/array, php-array utilities) that better fit the roadmap?Arr (if used in a Laravel project)?ArrayAccess) that need validation?Arr::get(), Arr::set()).Collection methods, dot notation with Str).spatie/array or custom implementations).Arr.Arr methods used in the codebase (e.g., get, set, forget, dot).Arr usage with IlluminateAgnostic\Arr and test.// config/app.php
'aliases' => [
'Arr' => IlluminateAgnostic\Arr\Support\Arr::class,
];
IlluminateAgnostic\Arr\Arr::get()) to avoid conflicts.get, has, only).set, pull, forget) after validation.Arr for critical paths.| Feature | Compatibility Notes |
|---|---|
Laravel Arr API |
90%+ compatible with Laravel 5.5–5.6. Some methods may behave differently. |
| Non-array inputs | Methods like Arr::get() may throw errors on objects without __get(). |
| PHP 8.x | Not officially supported; may require polyfills for named arguments. |
| Laravel Collections | Arr::wrap() assumes arrays; may fail on Collection inputs. |
| Dot notation | Limited to basic cases (no Str integration for path normalization). |
Arr::get(), Arr::set(), Arr::has().Arr::pull(), Arr::forget(), Arr::prepend().Arr::dot(), Arr::undot() (if used).Str).Arr in favor of the agnostic version.symfony/var-dumper only).Arr::forget() on objects).How can I help you explore Laravel packages today?