{"id":15578342,"url":"https://github.com/goaop/parser-reflection","last_synced_at":"2025-04-14T08:53:09.006Z","repository":{"id":1935284,"uuid":"45357981","full_name":"goaop/parser-reflection","owner":"goaop","description":"Parser Reflection API - Provides source code analysis without loading classes into the PHP memory","archived":false,"fork":false,"pushed_at":"2024-12-12T22:43:53.000Z","size":480,"stargazers_count":100,"open_issues_count":9,"forks_count":50,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-30T15:36:57.644Z","etag":null,"topics":["ast","parser-reflection","php","php-parser","reflection"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/goaop.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["lisachenko"]}},"created_at":"2015-11-01T21:20:21.000Z","updated_at":"2025-01-31T11:35:00.000Z","dependencies_parsed_at":"2024-02-04T12:38:15.477Z","dependency_job_id":"29665600-ae62-4477-be47-cdb4c570ad11","html_url":"https://github.com/goaop/parser-reflection","commit_stats":{"total_commits":387,"total_committers":18,"mean_commits":21.5,"dds":0.2687338501291989,"last_synced_commit":"9c9bee019c76398f396ed673b6d7602b92a74a55"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goaop%2Fparser-reflection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goaop%2Fparser-reflection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goaop%2Fparser-reflection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goaop%2Fparser-reflection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/goaop","download_url":"https://codeload.github.com/goaop/parser-reflection/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247415793,"owners_count":20935383,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ast","parser-reflection","php","php-parser","reflection"],"created_at":"2024-10-02T19:09:17.834Z","updated_at":"2025-04-14T08:53:08.987Z","avatar_url":"https://github.com/goaop.png","language":"PHP","readme":"Parser Reflection API Library\n-----------------\nThis library is **deprecated**. Please use [BetterReflection](https://github.com/Roave/BetterReflection).\n\nParser Reflection API library provides a set of classes that extend original internal Reflection classes, but powered by [PHP-Parser](https://github.com/nikic/PHP-Parser) library thus allowing to create a reflection instance without loading classes into the memory.\n\nThis library can be used for analysing the source code; for automatic proxy creation and much more.\n\n[![Build Status](https://scrutinizer-ci.com/g/goaop/parser-reflection/badges/build.png?b=master)](https://scrutinizer-ci.com/g/goaop/parser-reflection/build-status/master)\n[![Code Coverage](https://scrutinizer-ci.com/g/goaop/parser-reflection/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/goaop/parser-reflection/?branch=master)\n[![Total Downloads](https://img.shields.io/packagist/dt/goaop/parser-reflection.svg)](https://packagist.org/packages/goaop/parser-reflection)\n[![Daily Downloads](https://img.shields.io/packagist/dd/goaop/parser-reflection.svg)](https://packagist.org/packages/goaop/parser-reflection)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/goaop/parser-reflection/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/goaop/parser-reflection/?branch=master)\n[![PHP Version](https://img.shields.io/badge/php-%3E%3D%208.2-8892BF.svg)](https://php.net/)\n[![License](https://img.shields.io/packagist/l/goaop/parser-reflection.svg)](https://packagist.org/packages/goaop/parser-reflection)\n\nInstallation\n------------\n\nLibrary can be installed with Composer. Installation is quite easy:\n\n```bash\n$ composer require goaop/parser-reflection\n```\n\nComposer will install the library to your project's `vendor/goaop/parser-reflection` directory.\n\nUsage\n------------\n\n### Initialization\n\nPrior to the first use library can be optionally initialized. If you use Composer for installing packages and loading classes, \nthen you shouldn't worry about initialization, library will be initialized automatically.\n\nIf project uses a custom autoloader then you should follow the next steps:\n\n1. Create a new class that implements `\\Go\\ParserReflection\\LocatorInterface`\n2. Create an instance of that class and pass it to the `ReflectionEngine::init()` method for initial configuration\n\n### Reflecting concrete classes/methods/properties without loading them\n\nJust use `Go\\ParserReflection` package reflection classes like traditional ones:\n\n```php\n$parsedClass = new \\Go\\ParserReflection\\ReflectionClass(SomeClass::class);\nvar_dump($parsedClass-\u003egetMethods());\n\n$parsedMethod = new \\Go\\ParserReflection\\ReflectionMethod(SomeClass::class, 'someMethod');\necho (string)$parsedMethod;\n```\n\nOr you can use an additional classes [`ReflectionFile`][0] and [`ReflectionFileNamespace`][1] to analyse a raw PHP files:\n\n```php\n$parsedFile     = new \\Go\\ParserReflection\\ReflectionFile('SomeClass.php');\n$fileNameSpaces = $parsedFile-\u003egetFileNamespaces();\n// We can iterate over namespaces in the file\nforeach ($fileNameSpaces as $namespace) {\n    $classes = $namespace-\u003egetClasses();\n    // Iterate over the classes in the namespace\n    foreach ($classes as $class) {\n        echo \"Found class: \", $class-\u003egetName(), PHP_EOL;\n        // Now let's show all methods in the class\n        foreach ($class-\u003egetMethods() as $method) {\n            echo \"Found class method: \", $class-\u003egetName(), '::', $method-\u003egetName(), PHP_EOL;\n        }\n        \n        // ...all properties in the class\n        foreach ($class-\u003egetProperties() as $property) {\n            echo \"Found class property: \", $class-\u003egetName(), '-\u003e', $property-\u003egetName(), PHP_EOL;\n        }\n    }\n}\n```\n\nHow it works?\n------------\n\nTo understand how library works let's look at what happens during the call to the `new \\Go\\ParserReflection\\ReflectionClass(SomeClass::class)`\n\n * `\\Go\\ParserReflection\\ReflectionClass` asks reflection engine to give an AST node for the given class name\n * Reflection engine asks a locator to locate a filename for the given class\n * `ComposerLocator` instance asks the Composer to find a filename for the given class and returns this result back to the reflection engine\n * Reflection engine loads the content of file and passes it to the [PHP-Parser](https://github.com/nikic/PHP-Parser) for tokenization and processing\n * PHP-Parser returns an AST (Abstract Syntax Tree)\n * Reflection engine then analyse this AST to extract specific nodes and wrap them into corresponding reflection classes.\n\nCompatibility\n------------\n\nAll parser reflection classes extend PHP internal reflection classes, this means that you can use `\\Go\\ParserReflection\\ReflectionClass` instance in any place that asks for `\\ReflectionClass` instance. All reflection methods should be compatible with original ones, providing an  except methods that requires object manipulation, such as `invoke()`, `invokeArgs()`, `setAccessible()`, etc. These methods will trigger the process of class loading and switching to the internal reflection.\n\n[0]: docs/reflection_file.md\n[1]: docs/reflection_file_namespace.md\n","funding_links":["https://github.com/sponsors/lisachenko"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoaop%2Fparser-reflection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoaop%2Fparser-reflection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoaop%2Fparser-reflection/lists"}