Search by

raxos / reflection

basmilius

Reflection utilities used in Raxos.

3.2.0 2026-10-02 17:11 UTC

This package is auto-updated.

Last update: 2026-10-03 12:06:00 UTC


README

Bas Milius

Raxos Reflection

Typed wrappers around PHP reflection for classes, members, parameters, functions and types.

Documentation | Packagist | Raxos

  • Class hierarchy, attribute and member inspection.
  • Nullable, literal, union and intersection type handling, including DNF types.
  • Generators of reflector objects and callable invocation helpers.

Installation

Requires PHP 8.5 or later. Composer checks the remaining package and extension dependencies declared in composer.json.

composer require "raxos/reflection:^3.2"

Usage

<?php
declare(strict_types=1);

use function Raxos\Reflection\reflect;

require __DIR__ . '/vendor/autoload.php';

final readonly class Product
{
    public function __construct(public int $id, public string $name) {}
}

$class = reflect(Product::class);

foreach ($class->getPublicProperties() as $property) {
    echo $property->getName() . ': ' . $property->getType()->getName() . PHP_EOL;
}

getMethod() and getProperty() return null for missing members. Untyped parameters resolve to mixed; internal functions may return false for their source filename.

Documentation

Testing

Run this library's Pest suite from the Raxos workspace:

git clone --recurse-submodules https://github.com/basmilius/raxos.git
cd raxos
composer install
vendor/bin/pest --testsuite=reflection

See Testing Raxos for PHP extensions, integration services and coverage commands. The library's Tests workflow also runs in GitHub Actions.

License

MIT. Copyright (c) 2017 - present Bas Milius.