- What is sebastian/object-enumerator used for?
- It provides a single Enumerator::enumerate() method that walks arrays and object graphs and returns every referenced object, including nested ones. It is a single-purpose utility from the PHPUnit toolchain and is useful for programmatic deep inspection, graph-shape assertions, leak checks, serialization analysis, or internal inspector commands. It is not intended for readable debugging output.
- How do I install sebastian/object-enumerator in a Laravel project?
- Use composer require --dev sebastian/object-enumerator only when you have a direct call site. In many Laravel projects it is already present transitively through sebastian/comparator and phpunit/phpunit. Installing it explicitly converts an implicit dependency into a declared dev dependency; it adds no service provider or configuration.
- Is sebastian/object-enumerator Laravel-specific or framework-agnostic?
- It is framework-agnostic and has no service provider, configuration, or Laravel coupling. That makes it trivially compatible with Laravel 10, 11, and 12, but also irrelevant to MVC, domain, or service-layer code. Treat it as test and tooling infrastructure rather than application architecture.
- Do I need to require sebastian/object-enumerator if I already use PHPUnit or Pest?
- Usually no: PHPUnit and Pest pull it in through sebastian/comparator, so it is likely already in vendor/. Check composer show sebastian/object-enumerator and composer.lock before adding it. Promote it to an explicit require-dev entry only if your code directly calls Enumerator::enumerate().
- Which Laravel versions support sebastian/object-enumerator?
- There is no Laravel version constraint because the package has no Laravel coupling. Compatibility depends on the PHP version supported by the installed object-enumerator release and on your PHPUnit or Pest version. Laravel 10, 11, and 12 do not introduce any package-specific integration requirements.
- Does sebastian/object-enumerator support PHP 8.2 and PHP 8.3?
- The release notes for 7.0.0 and 8.0.0 contain wording about PHP 8.2 and PHP 8.3 that must be checked against the installed composer.json require constraint. Across sebastian packages this phrasing often indicates a minimum PHP version floor, but do not assume it. Verify the constraint for each CI matrix PHP version before planning an upgrade.
- Can I use sebastian/object-enumerator in production Laravel code?
- It should be dev-only with zero production call sites. Use require-dev and call it from test helpers or CI-only artisan commands, not from controllers, jobs, or domain services. For human debugging, dump() and VarDumper are better; this package is for programmatic enumeration.
- How does sebastian/object-enumerator handle cycles in object graphs?
- The enumerator is described as cycle-safe and returns each referenced object without looping forever on circular references. It performs depth-first traversal with no depth cap, predicate, or result limit. Large hydrated Eloquent graphs or container dumps can therefore be slow and memory-hungry, so scope inputs carefully.
- What are alternatives to sebastian/object-enumerator for inspecting objects in Laravel?
- Use VarDumper or dump() for readable debugging, json_encode for simple serializable data, Arr:: helpers for array-only work, and spl_object_id when you only need identity tracking. Choose object-enumerator when you need identity-level, cycle-safe traversal of nested object graphs. It is not a replacement for a full profiler or memory analyzer.
- How should I test or maintain a Laravel wrapper around sebastian/object-enumerator?
- If you add a wrapper, keep it in tests/ or a CI-only command and cover it with a small fixture containing nested arrays and circular object references. Declare sebastian/object-enumerator as require-dev and let PHPUnit or Pest drive its version rather than pinning it independently. Avoid a production wrapper, document the named caller, and re-check the PHP constraint on each PHP or PHPUnit major upgrade.