sajadsdi/php-reflection

Tools for get class reflection

1.0.0 2023-12-07 01:26 UTC

This package is auto-updated.

Last update: 2024-09-21 04:05:52 UTC


README

The PHP Reflection library provides a set of tools for performing class reflection in PHP. It allows you to retrieve information about classes, properties, methods, and constants using PHP's built-in reflection capabilities.

Installation

You can install the PHP Reflection library via Composer. Run the following command in your project directory:

composer require sajadsdi/php-reflection

Usage

To use the Reflections library, follow these steps:

  1. Import the Reflections class into your PHP file:
use Sajadsdi\PhpReflection\Reflections;
  1. Create an instance of the Reflections class (use singleton for better performance):
$reflections = new Reflections();

3.0. Perform class reflection:

$class = new MyClass();
$reflectionClass = $reflections->reflection($class);

//or
$reflectionClass = $reflections->reflection(MyClass::class);

3.1.Retrieve properties, methods, or constants:

$properties = $reflections->properties(MyClass::class);
$methods = $reflections->methods(MyClass::class);
$constants = $reflections->constants(MyClass::class);

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the GitHub repository.

License

This library is open-source and released under the MIT License. See the LICENSE file for more information.

Credits

The PHP Reflection library is developed and maintained by SajaD SaeeDi.

Feel free to use this library in your projects and enjoy the power of class reflection in PHP!