orisai/reflection-meta

PHP reflection in more reliable and deterministic way - for declarative engines

1.0.1 2024-06-21 10:25 UTC

This package is auto-updated.

Last update: 2024-09-21 11:09:51 UTC


README

Orisai
Reflection Meta

PHP reflection in more reliable and deterministic way - for declarative engines

📄 Check out our documentation.

💸 If you like Orisai, please make a donation. Thank you!

use Orisai\ReflectionMeta\Structure\StructureBuilder;
use Orisai\ReflectionMeta\Structure\StructureFlattener;
use Orisai\ReflectionMeta\Structure\StructureGrouper;
use ReflectionClass;

$reflector = new ReflectionClass(ExampleClass::class);
$hierarchy = StructureBuilder::build($reflector);
$list = StructureFlattener::flatten($hierarchy);
$group = StructureGrouper::group($list);

var_dump($group);
/*
StructureGroup(
	classes: [
		ClassStructure(ParentInterface),
		ClassStructure(ParentTrait),
		ClassStructure(ParentClass),
		ClassStructure(ExampleInterface),
		ClassStructure(ExampleTrait),
		ClassStructure(ExampleClass),
	],
	constants: [
		'::publicConstName' => [
			ConstantStructure(ExampleInterface, 'publicConstName'),
		],
		'::protectedConstName' => [
			ConstantStructure(ParentClass, 'protectedConstName'),
			ConstantStructure(ExampleClass, 'protectedConstName'),
		],
		'ParentClass::privateConstName' => [
			ConstantStructure(ParentClass, 'privateConstName'),
		],
	],
	properties: [
		'::publicPropertyName' => [
			PropertyStructure(ExampleClass, 'publicPropertyName'),
		],
		// ...
	],
	methods: [
		// ...
	],
)
*/