Releases: Roave/BetterReflection
3.5.0
This release introduces support for ReflectionConstant
, adds support
for PHP 7.4 typed properties,
and replaces the internal class stubbing mechanisms with direct hits to
the installed JetBrains stubs. In addition to that, parent::class
, self::class
and static::class
are now correctly evaluated to the target class name.
Total issues resolved: 13
- 444:
self::class
,parent::class
andstatic::class
are not correctly resolved into their corresponding strings thanks to @Ocramius - 465: Fix
.gitignore
format for Windows environments thanks to @kukulich - 466: Correct PHPUnit MockObject class names as per PHPUnit 8+ thanks to @kukulich
- 467: Tests for source stubbers thanks to @kukulich
- 469: Refactor SourceLocators to no longer depend on CoreReflection thanks to @theofidry
- 470: PhpInternalSourceLocator is not based on internal reflection anymore thanks to @kukulich
- 471: Added ReflectionConstant thanks to @kukulich
- 472: Fixed resolving self::, static:: and parent:: as property or constant values thanks to @kukulich
- 473: Added support for PHP 7.4 typed properties thanks to @kukulich
- 474: Run tests on PHP 7.4 thanks to @kukulich
- 475: Bump phpunit/phpunit from 8.1.3 to 8.1.5 thanks to @dependabot-preview[bot]
- 476: Bump phpdocumentor/reflection-docblock from 4.3.0 to 4.3.1 thanks to @dependabot-preview[bot]
- 477: Bump nikic/php-parser from 4.2.1 to 4.2.2 thanks to @dependabot-preview[bot]
3.4.0
This release drops support for PHP 7.1 and introduces major performance improvements
when inspecting sources of projects that use composer.json
as main dependency tracking
mechanism.
Specifically, following utilities have been introduced to aid in inspecting project
sources:
Roave\BetterReflection\SourceLocator\Type\Composer\Factory\MakeLocatorForComposerJsonAndInstalledJson
- if
you need to inspect project and dependenciesRoave\BetterReflection\SourceLocator\Type\Composer\Factory\MakeLocatorForComposerJson
- if you only want to
inspect project sourcesRoave\BetterReflection\SourceLocator\Type\Composer\Factory\MakeLocatorForInstalledJson
- if you only want
to inspect project dependencies
To use them, please follow the usage documentation examples, such as following:
<?php
use Roave\BetterReflection\BetterReflection;
use Roave\BetterReflection\Reflector\ClassReflector;
use Roave\BetterReflection\SourceLocator\Type\AggregateSourceLocator;
use Roave\BetterReflection\SourceLocator\Type\PhpInternalSourceLocator;
use Roave\BetterReflection\SourceLocator\Type\Composer\Factory\MakeLocatorForComposerJsonAndInstalledJson;
$astLocator = (new BetterReflection())->astLocator();
$reflector = new ClassReflector(new AggregateSourceLocator([
(new MakeLocatorForComposerJsonAndInstalledJson)('path/to/the/project', $astLocator),
new PhpInternalSourceLocator($astLocator)
]));
$classes = $reflector->getAllClasses();
Total issues resolved: 4
- 442: Add a source locator that can detect
"autoload"
and"autoload-dev"
when given a composer schema definition from either acomposer.json
or acomposer.lock
thanks to @Ocramius - 461: Composer-specific source locator builder thanks to @Ocramius
- 463: Updated some build dependencies thanks to @kukulich
- 464: AppVeyor is dead, long live Travis thanks to @kukulich
3.3.0
This release replaces the internal source locator provided by
this package with the more updated and widely used class and
function definitions by jetbrains/phpstorm-stubs
, allowing
for quicker updates and more community-based internal symbol
reflection synchronisation.
Total issues resolved: 4
3.2.0
This release introduces PHP 7.3 support, reduces the exported package size,
and improves the overall code quality of the package through updated coding
style conventions.
Total issues resolved: 6
- 440: Test failures under PHP 7.3 thanks to @Majkl578
- 450: PHP_Parser v4 introduces a
string
type declaration on a parameter, breaking PHP 7.1 installations thanks to @Ocramius - 451: Remove .idea from .gitignore thanks to @Majkl578
- 452: Upgrade to Doctrine CS 5.0 thanks to @Majkl578
- 453: export-ignores, appveyor.yml -> .appveyor.yml thanks to @Majkl578
- 455: PHP 7.3 stub and PHP-Parser compatibility thanks to @paxal
3.1.1
This release fixes an incompatibility between ext-reflection
and roave/better-reflection
in which ReflectionClass#getConstructor()
led to an exception rather than a null
return value in case of
constructors being missing.
Total issues resolved: 1
3.1.0
This release hardens the AutoloadSourceLocator
to allow for multiple PSR-4
paths to be crawled for class existence.
Also, it is now possible to alter reflection instances to set the function/method
docBlocks while monkey-patching code.
Total issues resolved: 7
- 384:
AutoloadSourceLocator
uses the wrong directory thanks to @oqq - 425: Better exception messages and assertions for unrecognized class constant fetch expressions thanks to @Ocramius
- 431: #430 Add ability to specify doc comment for the functions thanks to @funivan
- 433: Fixed error on anonymous classes with interfaces thanks to @prisis
- 435: Return of the PHPStan thanks to @kukulich
- 436: Updated to PHPStan 0.10.1 thanks to @kukulich
- 437: Fixing AutoloadSourceLocator when multiple PSR-0/4 directories are possible thanks to @moufmouf
3.0.0
This release improves the performance and reliability of the library, which is now
fully working with PHP 7.2 and newer nikic/php-parser
releases.
Some BC breaks had to be performed:
- 389: Throw
ReflectionException
when a property is not found thanks to @muglug - 391: Adapter method
ReflectionClass#getProperty()
throw an exception when a property doesn't exist thanks to @kukulich - 415: Improved
ReflectionType
API so that a target reflection class can directly be retrieved, removed existing named constructor thanks to @Ocramius
Total issues resolved: 23
- 381: rename
$myMethod
to$myParameter
as expected bygetParameter('myParameter')
thanks to @tobemedia - 382: [TYPO\ Minimal grammar correction in Exception message thanks to @afoeder
- 389: Throw
ReflectionException
when a property is not found thanks to @muglug - 391: Adapter method
ReflectionClass#getProperty()
throw an exception when a property doesn't exist thanks to @kukulich - 392: Disallow build failures on PHP 7.2 thanks to @kukulich
- 393: Updated to
doctrine/coding-standard
2.0 thanks to @kukulich - 394: Fix issues found by static analysis thanks to @muglug
- 395: Updated to
doctrine/coding-standard
2.1 thanks to @kukulich - 400: Updated PHPUnit and PHPStan dependencies thanks to @kukulich
- 403: Use HTTPS instead of HTTP when referencing external documentation thanks to @carusogabriel
- 404: Account for case insensitivity thanks to @theofidry
- 405: Corrected typos in variable names and docblocks thanks to @ntzm
- 406: Remove useless
final
keyword from theprivate
methodReflectionFunctionAbstract#loadStaticParser()
thanks to @ntzm - 410: Updated to
nikic/PHP-Parser
4.x thanks to @kukulich - 411:
ReflectionClass#isInstantiable()
should reportfalse
forprivate
constructors thanks to @UFOMelkor - 412:
ReflectionClass::isInstantiable()
now reportsfalse
in case of inaccessible constructors thanks to @kukulich - 415: Improved
ReflectionType
API so that a target reflection class can directly be retrieved, removed existing named constructor thanks to @Ocramius - 418: Updated to
doctrine/coding-standard
4.0 thanks to @kukulich - 420: Tidied docs and simply removed weasel words thanks to @GeeH
- 421: PHP 7.2 build is failing thanks to @asgrim
- 422: Corrected build failures caused by
ext/date-time
upgrades in PHP 7.2 thanks to @kukulich - 423: Add
vimeo/psalm
to the build and fixed detected static analysis issues that were detected by it thanks to @muglug - 424: Fixed build failure caused by incorrectly formatted inline IDE hints thanks to @kukulich
2.0.2
Total issues resolved: 2
2.0.1
This release fixes constraint incompatibilities with PHP 7.1.0, newer PHP 7.1.11 UConverter
API
and a type error raised when attempting to fetch the AST nodes of an interface's method.
Total issues resolved: 5
- 372: Added missing parent::setUp() in tests thanks to @kukulich
- 376: Incorrect PHP version constraint thanks to @nikic
- 377: composer: allow PHP 7.1 thanks to @TomasVotruba
- 379: Return empty ast for interface method body thanks to @codeliner
- 380: #379
UConverter#getAliases($name)
is not an optional parameter anymore as per latest PHP releases thanks to @Ocramius
2.0.0
This major release is a massive rework of the internal implementation details
of BetterReflection.
Improvements
Version 2.0.0 provides a massive performance boost when using the
new Roave\BetterReflection\BetterReflection
kernel as an entry point
for using the library.
The minimum supported PHP version is now 7.1.0
, which allows for
a much cleaner API definition: we added nullable hints to our own
API wherever applicable.
The compatibility with the ext-reflection
API is also almost complete, excluding some scenarios that would
forcefully require class autoloading.
Among the many new implemented features, we now support:
- Property/Method accessors
- Start/End line analysis for defined symbols
- PHP 7.1 nullable types
- PHP 7.1
iterable
type declarations - PHP 7.2
object
type declarations - PHP 7.1
const
visibility support - Monkey-patching classes on the fly via hijacked autoloader
- Immediate/inherited constants/methods/properties lookup
- PHP 4.x constructor detection
- Constant expression value resolution
- Closure reflection
- Anonymous class reflection
- Internal class parameter default value reflection (through stubs)
- Retrieving AST nodes for each reflection
BC Breaks
Most of the generally used API was not touched, but a lot of internal
components were completely rewritten to address design and performance
issues. Please make sure that you read
the upgrade notes.
Total issues resolved: 138
- 14: Implement accessors without instantiating thanks to @asgrim
- 20: Validate identifier name in Identifier value object thanks to @asgrim
- 68: Add getColumn everywhere to complement getStartLine/getEndLine thanks to @asgrim
- 94: Improve
__toString()
functionality internally thanks to @asgrim - 98: Find a way to decrease complexity of compileBinaryOperator method thanks to @asgrim
- 103: ReflectionClass getMethods() and getProperties() do not filter thanks to @asgrim
- 131: Make Better Reflection faster thanks to @asgrim
- 152:
ClosureSourceLocator#locateIdentifiersByType()
- investigate implementation thanks to @asgrim - 169: Investigate upgrading to
phpdocumentor/reflection-docblock 3.1
thanks to @asgrim - 202: Review PHP 7.1 feature: nullable types thanks to @asgrim
- 204: Review PHP 7.1 feature: Class constant visibility modifiers thanks to @asgrim
- 205: Autoload interruption for dynamic monkey patching thanks to @asgrim
- 216: Autoload interruption for monkey patching thanks to @asgrim
- 217: Update our code for API changes in PHP-Parser thanks to @asgrim
- 218: Upgrade phpdocumentor reflection docblock thanks to @asgrim
- 219: Check compatibility with PHP 7.2 thanks to @asgrim
- 220: Fixed issues found by static analysis thanks to @ondrejmirtes
- 221: Upgrade minimum version to PHP 7.0 thanks to @asgrim
- 223: Add vendor prefix to namespaces thanks to @asgrim
- 225: Fixed function reflector doc thanks to @dantleech
- 226: Require minimum of PHP 7, enabling tests on PHP 7.1 thanks to @asgrim
- 227: Prefix namespaces with Roave thanks to @asgrim
- 228: Implement internal parsing of closures thanks to @asgrim
- 229: getDocBlockTypes() causes error when no docblock is present thanks to @dantleech
- 231: Inherited properties not returned by getProperties thanks to @dantleech
- 235:
LocatedSource#__construct()
should accept empty string as $source thanks to @asgrim - 236: Fix exception being thrown in AutoloadSourceLocator thanks to @asgrim
- 238: LocatedSource now allows empty strings as source code thanks to @asgrim
- 240: ReflectionParameter doesn't resolve parameter type
self
thanks to @malukenho - 241: Fix
self
andparent
hinted ReflectionParameter class reference thanks to @malukenho - 242: Support for the PHP 7.1
iterable
type thanks to @Ocramius - 243:
ReflectionType#__toString()
should NOT prepend backslashes to class/interface types thanks to @Ocramius - 244: Fix for #243:
ReflectionType
(string)
cast should not prepend backslash to class and interface types thanks to @Ocramius - 246: Fixed class constant value fetch when constant is declared in parent thanks to @janlanger
- 250: Types with no doc block thanks to @marcosh
- 251: Retrieve all functions in SourceLocator scope thanks to @marcosh
- 252: get all functions available in SourceLocator scope thanks to @marcosh
- 253: Usage: fix DirectoriesSourceLocator usage thanks to @TomasVotruba
- 254: README: drop unstable dependencies reference thanks to @TomasVotruba
- 255: create ReflectionParameter from closure thanks to @marcosh
- 256: create reflection parameter from closure thanks to @marcosh
- 257: Possible unused code path thanks to @asgrim
- 258: PHP 7.1 updates thanks to @asgrim
- 259: [Docs] Usage: drop SingleDirectorySourceLocator thanks to @TomasVotruba
- 260: [Docs] Usage - add FunctionReflector getAllFunctions() example thanks to @TomasVotruba
- 263: Support PHP4-style constructors? thanks to @asgrim
- 264: ReflectionMethod::isDestructor is case insensitive thanks to @asgrim
- 266: get file name of unlocated source could be null thanks to @marcosh
- 267: Testing that class constant visibility works thanks to @asgrim
- 268: Ensure locateFunctionByName returns ?string always thanks to @asgrim
- 269: Added case insensitivity to isConstructor and isDestructor methods thanks to @asgrim
- 271: getProperties returns inherited properties thanks to @marcosh
- 272: Added test cases for ?nullable and iterable types in PHP 7.1 thanks to @asgrim
- 273: [docs] example2.php - flip fallen space from the bottom thanks to @TomasVotruba
- 274: [failing-test] Namespaced Trait fails to be resolved thanks to @TomasVotruba
- 275: Filter get methods and properties thanks to @marcosh
- 277: [demo] add getAllClasses() examples, ref #276 thanks to @TomasVotruba
- 278: object immediate properties includes runtime properties thanks to @marcosh
- 279: Reflect on instances of anonymous classes thanks to @marcosh
- 280: [NodeCompiler] add support for
__DIR__
thanks to @TomasVotruba - 281: [PHP7.1] ::getReflectionConstant() and ::getReflectionConstants() support thanks to @POPSuL
- 282: [PHP 7.1] Add support for ReflectionClassConstant (#281) thanks to @POPSuL
- 284: fixed improper docblock retrieval thanks to @vlastavesely
- [285: FindReflectionOnLine cannot be...