fsi/reflection
Optimized Reflection for PHP 5.3 that caches ReflectionClass/Method/Property objects via factory() so they’re never created twice. Returned methods/properties are pre-set accessible for private/protected access; some uncached operations throw exceptions.
Illuminate\Container, Eloquent, or custom DI containers). Laravel’s reliance on reflection for service resolution, dynamic properties, and testing makes this a high-value optimization for legacy systems (PHP 5.3–5.6) or performance-critical paths.setAccessible() calls) and preventing accidental reflection object leaks. This aligns well with Laravel’s emphasis on maintainable, opinionated code.app()->reflector()).ReflectionClass/ReflectionMethod directly in controllers, middleware, or service providers) would require massive refactoring. Tools like PHPStan or Rector could automate factory adoption, but edge cases (e.g., dynamic class names) may need manual handling.laravel-debugbar, spatie/laravel-activitylog, or doctrine/dbal may use reflection internally. Testing is critical to avoid silent failures.setAccessible() could break tests if private properties/methods are unexpectedly modified.if (class_exists('FSi\Reflection\ReflectionClass'))) to allow gradual adoption.ReflectionFunctionAbstract::getClosureThis()). This could lead to inconsistent performance gains in complex use cases.Model::getMorphClass()) to validate memory savings.class_alias() or eval() calls.ReflectionCache, phpstan/phpdoc-parser) that could replace this in the long term?Illuminate\Container, Eloquent, Testing\TestCase).ReflectionFactory trait) to minimize disruption?Container::getReflectionClass() to speed up service resolution.Model::getMorphClass() or dynamic property access in polymorphic relationships.laravel-aspect) or custom proxies.grep -r "new Reflection" app/ to identify all reflection instantiations.ReflectionFactory facade to abstract factories (e.g., ReflectionFactory::classFor('App\Models\User')).new ReflectionClass() with ReflectionClass::factory().$$className or eval()-generated classes).disallow_new_reflection_classes).php:5.6-apache).opcache or configuring it to avoid conflicts with reflection caching.doctrine/orm, symfony/property-access) may fail with factory exceptions.static or a global cache).ServiceProvider boot methods).createMock()) only after core functionality is stable.How can I help you explore Laravel packages today?