BetterReflection

:crystal_ball: Better Reflection is a reflection API that aims to improve and provide more features than PHP's built-in reflection API.

  • Owner: Roave/BetterReflection
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

Better Reflection

Build Status
Scrutinizer Code Quality
Code Coverage
Type Coverage
Latest Stable Version
License

Better Reflection is a reflection API that aims to improve and provide more features than PHP's built-in
reflection API.

Why is it better?

  • You can reflect on classes that are not already loaded, without loading them
  • Ability to reflect on classes directly from a string of PHP code
  • Better Reflection analyses the DocBlocks (using phpdocumentor/type-resolver)
  • Reflecting directly on closures
  • Ability to extract AST from methods and functions
  • Ability to return AST representation of a class or function
  • Fetch return type declaration and parameter type declarations in PHP 7 code
  • Change or remove PHP 7 parameter type and return type declarations from methods and functions
  • Change the body of a function or method to do something different
  • Moar stuff coming soon!

Be sure to read more in the feature documentation.

Installation

Require using composer:

$ composer require roave/better-reflection

Usage

<?php

use Roave\BetterReflection\BetterReflection;

$classInfo = (new BetterReflection())
    ->classReflector()
    ->reflect(\Foo\Bar\MyClass::class);

Documentation

Upgrading

Please refer to the Upgrade Documentation documentation to see what is required to upgrade your installed
BetterReflection version.

Limitations

  • PHP cannot autoload functions, therefore we cannot statically reflect functions

License

This package is released under the MIT license.

Contributing

If you wish to contribute to the project, please read the CONTRIBUTING notes.

Main metrics

Overview
Name With OwnerRoave/BetterReflection
Primary LanguagePHP
Program languagePHP (Language Count: 2)
Platform
License:MIT License
所有者活动
Created At2015-06-04 11:02:42
Pushed At2025-06-10 06:08:08
Last Commit At
Release Count113
Last Release Name6.59.0 (Posted on 2025-05-27 21:39:32)
First Release Name0.1.0 (Posted on 2015-11-02 23:02:43)
用户参与
Stargazers Count1.2k
Watchers Count27
Fork Count136
Commits Count4.3k
Has Issues Enabled
Issues Count308
Issue Open Count12
Pull Requests Count1008
Pull Requests Open Count8
Pull Requests Close Count185
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private