raphhh/trex-reflection
Lightweight PHP reflection helper focused on analyzing types, classes and members with a cleaner API than native Reflection. Great for tooling, static analysis, and code generation tasks—extract signatures, docblocks, visibility, and metadata with minimal boilerplate.
This package provides lightweight, utility-focused reflection helpers—ideal for inspecting classes, methods, properties, and attributes (annotations) in a more expressive, chainable way. Since it hasn’t been updated since 2020, assume PHP ≤8.0 compatibility (no native attributes support for newer PHP). Start by installing via Composer:
composer require raphhh/trex-reflection
The entry point is typically \Trex\Reflection\ReflectionHelper, offering static methods like forClass(), forMethod(), forProperty() to build fluent reflection objects. Your first use case might be safely retrieving docblock annotations (e.g., @var, custom @SWG\Property) without writing preg_match or ReflectionMethod::getDocComment() boilerplate.
ReflectionHelper::forClass(MyClass::class)->getMethods()->filterByVisibility('public') to chain operations.@Route("/api/users") from docblocks using getMethodDocblockAnnotation('route', $method)—useful for custom routing, serialization, or validation layers.@var annotations:
$type = ReflectionHelper::forProperty($object, 'name')->getDocblockType();
PhpDocParser or nikic/php-parser if you need modern metadata handling.@var, @param) are not verified—invalid or missing tags return null or defaults silently. Always validate assumptions with hasDocblock() first.getMethodAttributes() as a wrapper around ReflectionMethod::getAttributes().forClass()->getPropertiesWithDocblocks()) in hot loops—cache results or delegate to builder classes.How can I help you explore Laravel packages today?