diff --git a/.scrutinizer.yml b/.scrutinizer.yml deleted file mode 100644 index 59efb70..0000000 --- a/.scrutinizer.yml +++ /dev/null @@ -1,34 +0,0 @@ -before_commands: - - "composer install --no-dev --prefer-source" - -tools: - external_code_coverage: - timeout: 1200 - php_code_coverage: - enabled: true - php_code_sniffer: - enabled: true - config: - standard: PSR2 - filter: - paths: ["src/*"] - php_cpd: - enabled: true - excluded_dirs: ["docs", "examples", "tests", "vendor"] - php_cs_fixer: - enabled: true - config: - level: all - filter: - paths: ["src/*"] - php_loc: - enabled: true - excluded_dirs: ["docs", "examples", "tests", "vendor"] - php_pdepend: - enabled: true - excluded_dirs: ["docs", "examples", "tests", "vendor"] - php_analyzer: - enabled: true - filter: - paths: ["src/*"] - sensiolabs_security_checker: true diff --git a/LICENSE b/LICENSE index f0c04f3..d95fa70 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2015-2024 Alexander Lisachenko +Copyright (c) 2026 Alexander Lisachenko Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index c2e3fe1..8887b21 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,30 @@ Parser Reflection API Library ----------------- -This library is **deprecated**. Please use [BetterReflection](https://github.com/Roave/BetterReflection). -Parser 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. +## ๐Ÿ” Static Code Analysis Meets Reflection -This library can be used for analysing the source code; for automatic proxy creation and much more. +**Parser Reflection API** brings the power of PHP's Reflection API to static code analysis. Built on top of [nikic/php-parser](https://github.com/nikic/PHP-Parser), this library lets you introspect classes, methods, and properties **without ever loading them into memory**. -[![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) -[![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) +### โœจ Key Features + +๐Ÿง  **Pure AST-Based Reflection** + +Forget autoloading. This library parses your PHP source files directly into an Abstract Syntax Tree (AST) and extracts reflection data from the syntax itself โ€” no `include`, no `require`, no side effects. Analyze classes without bootstrapping your entire application. Perfect for static analyzers, code generators, documentation tools, and IDE plugins. + +### Why Use It? + +- ๐Ÿ“Š **Source code analysis** โ€” inspect structure without executing anything +- ๐Ÿงช **Safe introspection** โ€” avoid triggering constructors or static initializers +- ๐Ÿ”Œ **Drop-in compatible** โ€” extends native `\ReflectionClass`, `\ReflectionMethod`, etc. + +![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/goaop/parser-reflection/phpunit.yml?branch=master) +![PHPStan Badge](https://img.shields.io/badge/PHPStan-level%2010-brightgreen.svg?style=flat&link=https%3A%2F%2Fphpstan.org%2Fuser-guide%2Frule-levels) +[![GitHub release](https://img.shields.io/github/release/goaop/parser-reflection.svg)](https://github.com/goaop/parser-reflection/releases/latest) [![Total Downloads](https://img.shields.io/packagist/dt/goaop/parser-reflection.svg)](https://packagist.org/packages/goaop/parser-reflection) [![Daily Downloads](https://img.shields.io/packagist/dd/goaop/parser-reflection.svg)](https://packagist.org/packages/goaop/parser-reflection) -[![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) -[![PHP Version](https://img.shields.io/badge/php-%3E%3D%208.2-8892BF.svg)](https://php.net/) +[![PHP Version](https://img.shields.io/badge/php-%3E%3D%208.4-8892BF.svg)](https://php.net/) [![License](https://img.shields.io/packagist/l/goaop/parser-reflection.svg)](https://packagist.org/packages/goaop/parser-reflection) +[![Sponsor](https://img.shields.io/badge/Sponsor-โค๏ธ-lightgray?style=flat&logo=github)](https://github.com/sponsors/lisachenko) Installation ------------ @@ -79,6 +91,32 @@ How it works? To understand how library works let's look at what happens during the call to the `new \Go\ParserReflection\ReflectionClass(SomeClass::class)` +```text +โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” +โ”‚ ReflectionClass โ”‚ +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ + โ”‚ asks for AST node + โ–ผ +โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” +โ”‚ ReflectionEngine โ”‚ +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ + โ”‚ locates file + โ–ผ +โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” +โ”‚ ComposerLocator โ”‚ โ”€โ”€โ–บ Composer autoloader +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ + โ”‚ parses file + โ–ผ +โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” +โ”‚ nikic/php-parser โ”‚ โ”€โ”€โ–บ Returns AST +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ + โ”‚ wraps nodes + โ–ผ +โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” +โ”‚ Reflection Objects โ”‚ +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ +``` + * `\Go\ParserReflection\ReflectionClass` asks reflection engine to give an AST node for the given class name * Reflection engine asks a locator to locate a filename for the given class * `ComposerLocator` instance asks the Composer to find a filename for the given class and returns this result back to the reflection engine diff --git a/nitpick.json b/nitpick.json deleted file mode 100644 index f8c1a40..0000000 --- a/nitpick.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "ignore": [ - "src/*", - "tests/*", - "docs/*" - ] -} diff --git a/rector.php b/rector.php deleted file mode 100644 index 3f28e74..0000000 --- a/rector.php +++ /dev/null @@ -1,32 +0,0 @@ -withPaths([ - __DIR__ . '/src', - __DIR__ . '/tests', - ]) - // uncomment to reach your current PHP version - // ->withPhpSets() - ->withRules([ - AddVoidReturnTypeWhereNoReturnRector::class, - RemoveUselessParamTagRector::class, - RemoveUselessReturnTagRector::class, - PublicConstantVisibilityRector::class, - ClosureToArrowFunctionRector::class, - ]) - ->withSets([ - PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES, - PHPUnitSetList::PHPUNIT_CODE_QUALITY, - PhpParserSetList::PHP_PARSER_50 - ]);