nayjest/manipulator
Fast, lightweight PHP object manipulation helpers—like symfony/property-access but simpler (~300 LOC) and no reflection. Instantiate classes, set public properties, and assign values via setters from arrays (snake/camel case), with optional property creation.
Use Case Alignment:
collect() and Arr helpers suffice for arrays, this package may still offer advantages for method-aware operations or immutable object modifications (e.g., hydrating objects from API responses).symfony/property-access or league/arrayobjects remain viable but unaddressed by this package. Justification for adoption should still focus on specific gaps (e.g., handling magic methods like __get/__set or recursive object structures).Laravel 10+ Compatibility:
minor bugfix in v3.1.1 does not address PHP 8.0+ compatibility, so backward incompatibilities (e.g., ReflectionClass changes, strict typing) may still exist.minor bugfix suggests no breaking changes, but the lack of transparency about the fix’s nature (e.g., PHP version support, edge-case handling) introduces uncertainty.minor bugfix does not indicate a shift in this trajectory.ReflectionProperty changes, constructor property promotion).unserialize or unsafe property access).deepMerge recursion). Deep operations may still pose risks for large objects.minor bugfix does not reduce this burden.minor bugfix?
collect(), Arr) or modern libraries (symfony/property-access). If no unique value is added, reconsider.symfony/property-access) if adopted.collect()->merge() or array_merge_recursive().array_merge for Manipulator::merge).ReflectionClass calls).// Polyfill for PHP 8.0+ strict types (if needed)
if (!method_exists(\ReflectionProperty::class, 'getType')) {
// Fallback logic for older PHP versions
}
serialize()/unserialize() in caches).ReflectionClass or clone.collect() for specific cases).ReflectionClass changes).deepMerge").symfony/property-access).xdebug, Reflection).Manipulator::deepClone() fails, trace through ReflectionClass and __clone() magic methods.deepMerge) could hit stack limits for large objects.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| PHP version incompatibility | Runtime errors (e.g., E_DEPRECATED) |
Polyfills, PHP 8.0+ testing. |
Circular reference in deepMerge |
Infinite loop, memory exhaustion | Add cycle detection (e.g., track object IDs). |
| Unsafe property access | Security risks (e.g., __wakeup) |
Whitelist allowed properties/methods. |
| Package abandonment | No future fixes | Fork and maintain internally. |
// Merge two user objects (with arrays and custom methods)
$merged = Manipulator::merge($user1, $user2);
How can I help you explore Laravel packages today?