Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Better Reflection Laravel Package

roave/better-reflection

Enhanced PHP reflection for static analysis: reflect classes without loading them, from PHP code strings or closures, extract AST from functions/methods, and read type declarations and docblocks. Feature-rich but slower than native reflection.

View on GitHub
Deep Wiki
Context7

Using Types

When you have a ReflectionParameter, you can determine types in the following ways:

class MyClass
{
    /**
     * [@param](https://github.com/param) array $myParameter
     */
    public function myMethod(array $myParameter = [])
    {
        // ... stuff ...
    }
}
<?php

use Roave\BetterReflection\BetterReflection;

$classInfo     = (new BetterReflection())->reflector()->reflectClass('MyClass');
$methodInfo    = $classInfo->getMethod('myMethod');
$parameterInfo = $methodInfo->getParameter('myParameter');

// Will fetch the language hint
var_dump($parameterInfo->getType());

ReflectionParameter->getType()

This is compatible with the PHP 7 reflection API, and will return a \Roave\BetterReflection\Reflection\ReflectionType instance.

ReflectionFunction->getReturnType() and ReflectionMethod->getReturnType()

This is compatible with the PHP 7 reflection API, and will return a \Roave\BetterReflection\Reflection\ReflectionType instance.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope