Tags: kswzr/BetterReflection
Tags
This release introduces support for `ReflectionConstant`, adds support for PHP 7.4 [typed properties](https://wiki.php.net/rfc/typed_properties_v2), 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` and `static::class` are not correctly resolved into their corresponding strings](Roave#444) thanks to @Ocramius - [465: Fix `.gitignore` format for Windows environments](Roave#465) thanks to @kukulich - [466: Correct PHPUnit MockObject class names as per PHPUnit 8+](Roave#466) thanks to @kukulich - [467: Tests for source stubbers](Roave#467) thanks to @kukulich - [469: Refactor SourceLocators to no longer depend on CoreReflection](Roave#469) thanks to @theofidry - [470: PhpInternalSourceLocator is not based on internal reflection anymore](Roave#470) thanks to @kukulich - [471: Added ReflectionConstant](Roave#471) thanks to @kukulich - [472: Fixed resolving self::, static:: and parent:: as property or constant values](Roave#472) thanks to @kukulich - [473: Added support for PHP 7.4 typed properties ](Roave#473) thanks to @kukulich - [474: Run tests on PHP 7.4](Roave#474) thanks to @kukulich - [475: Bump phpunit/phpunit from 8.1.3 to 8.1.5](Roave#475) thanks to @dependabot-preview[bot] - [476: Bump phpdocumentor/reflection-docblock from 4.3.0 to 4.3.1](Roave#476) thanks to @dependabot-preview[bot] - [477: Bump nikic/php-parser from 4.2.1 to 4.2.2](Roave#477) thanks to @dependabot-preview[bot]
This release drops support for PHP 7.1 and introduces major performan… …ce 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 dependencies * `Roave\BetterReflection\SourceLocator\Type\Composer\Factory\MakeLocatorForComposerJson` - if you only want to inspect project sources * `Roave\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 <?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 a `composer.json` or a `composer.lock`](Roave#442) thanks to @Ocramius - [461: Composer-specific source locator builder](Roave#461) thanks to @Ocramius - [463: Updated some build dependencies](Roave#463) thanks to @kukulich - [464: AppVeyor is dead, long live Travis](Roave#464) thanks to @kukulich
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** - [373: Source stubber based on `jetbrains/phpstorm-stubs`](Roave#373) thanks to @kukulich - [458: Update usage.md](Roave#458) thanks to @panosru - [460: Better highlighting for code snippets in `README.md`](Roave#460) thanks to @phpdev - [462: Use Null Coalesce Operator](Roave#462) thanks to @carusogabriel
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](Roave#440) thanks to @Majkl578 - [450: PHP&Roave#95;Parser v4 introduces a `string` type declaration on a parameter, breaking PHP 7.1 installations](Roave#450) thanks to @Ocramius - [451: Remove .idea from .gitignore](Roave#451) thanks to @Majkl578 - [452: Upgrade to Doctrine CS 5.0](Roave#452) thanks to @Majkl578 - [453: export-ignores, appveyor.yml -> .appveyor.yml ](Roave#453) thanks to @Majkl578 - [455: PHP 7.3 stub and PHP-Parser compatibility](Roave#455) thanks to @paxal
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** - [439: Adapter's ReflectionClass::getConstructor() returns null when no constructor exists](Roave#439) thanks to @lookyman
This release hardens the `AutoloadSourceLocator` to allow for multipl… …e 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](Roave#384) thanks to @oqq - [425: Better exception messages and assertions for unrecognized class constant fetch expressions](Roave#425) thanks to @Ocramius - [431: Roave#430 Add ability to specify doc comment for the functions](Roave#431) thanks to @funivan - [433: Fixed error on anonymous classes with interfaces](Roave#433) thanks to @prisis - [435: Return of the PHPStan](Roave#435) thanks to @kukulich - [436: Updated to PHPStan 0.10.1](Roave#436) thanks to @kukulich - [437: Fixing AutoloadSourceLocator when multiple PSR-0/4 directories are possible](Roave#437) thanks to @moufmouf
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](Roave#389) thanks to @muglug - [391: Adapter method `ReflectionClass#getProperty()` throw an exception when a property doesn't exist](Roave#391) thanks to @kukulich - [415: Improved `ReflectionType` API so that a target reflection class can directly be retrieved, removed existing named constructor](Roave#415) thanks to @Ocramius Total issues resolved: **23** - [381: rename `$myMethod` to `$myParameter` as expected by `getParameter('myParameter')`](Roave#381) thanks to @tobemedia - [382: &Roave#91;TYPO&Roave#92; Minimal grammar correction in Exception message](Roave#382) thanks to @afoeder - [389: Throw `ReflectionException` when a property is not found](Roave#389) thanks to @muglug - [391: Adapter method `ReflectionClass#getProperty()` throw an exception when a property doesn't exist](Roave#391) thanks to @kukulich - [392: Disallow build failures on PHP 7.2](Roave#392) thanks to @kukulich - [393: Updated to `doctrine/coding-standard` 2.0](Roave#393) thanks to @kukulich - [394: Fix issues found by static analysis](Roave#394) thanks to @muglug - [395: Updated to `doctrine/coding-standard` 2.1](Roave#395) thanks to @kukulich - [400: Updated PHPUnit and PHPStan dependencies](Roave#400) thanks to @kukulich - [403: Use HTTPS instead of HTTP when referencing external documentation](Roave#403) thanks to @carusogabriel - [404: Account for case insensitivity](Roave#404) thanks to @theofidry - [405: Corrected typos in variable names and docblocks](Roave#405) thanks to @ntzm - [406: Remove useless `final` keyword from the `private` method `ReflectionFunctionAbstract#loadStaticParser()` ](Roave#406) thanks to @ntzm - [410: Updated to `nikic/PHP-Parser` 4.x ](Roave#410) thanks to @kukulich - [411: `ReflectionClass#isInstantiable()` should report `false` for `private` constructors](Roave#411) thanks to @UFOMelkor - [412: `ReflectionClass::isInstantiable()` now reports `false` in case of inaccessible constructors](Roave#412) thanks to @kukulich - [415: Improved `ReflectionType` API so that a target reflection class can directly be retrieved, removed existing named constructor](Roave#415) thanks to @Ocramius - [418: Updated to `doctrine/coding-standard` 4.0](Roave#418) thanks to @kukulich - [420: Tidied docs and simply removed weasel words](Roave#420) thanks to @GeeH - [421: PHP 7.2 build is failing](Roave#421) thanks to @asgrim - [422: Corrected build failures caused by `ext/date-time` upgrades in PHP 7.2](Roave#422) thanks to @kukulich - [423: Add `vimeo/psalm` to the build and fixed detected static analysis issues that were detected by it](Roave#423) thanks to @muglug - [424: Fixed build failure caused by incorrectly formatted inline IDE hints](Roave#424) thanks to @kukulich
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](Roave#372) thanks to @kukulich - [376: Incorrect PHP version constraint](Roave#376) thanks to @nikic - [377: composer: allow PHP 7.1](Roave#377) thanks to @TomasVotruba - [379: Return empty ast for interface method body](Roave#379) thanks to @codeliner - [380: Roave#379 `UConverter#getAliases($name)` is not an optional parameter anymore as per latest PHP releases](Roave#380) thanks to @Ocramius
This major release is a massive rework of the internal implementation… … details of BetterReflection. 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`](https://github.com/Roave/BetterReflection/blob/2.0.0/docs/compatibility.md) 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 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](https://github.com/Roave/BetterReflection/blob/2.0.0/UPGRADE.md#200). Total issues resolved: **138** - [14: Implement accessors without instantiating](Roave#14) thanks to @asgrim - [20: Validate identifier name in Identifier value object](Roave#20) thanks to @asgrim - [68: Add getColumn everywhere to complement getStartLine/getEndLine](Roave#68) thanks to @asgrim - [94: Improve `__toString()` functionality internally](Roave#94) thanks to @asgrim - [98: Find a way to decrease complexity of compileBinaryOperator method](Roave#98) thanks to @asgrim - [103: ReflectionClass getMethods() and getProperties() do not filter](Roave#103) thanks to @asgrim - [131: Make Better Reflection faster](Roave#131) thanks to @asgrim - [152: `ClosureSourceLocator#locateIdentifiersByType()` - investigate implementation](Roave#152) thanks to @asgrim - [169: Investigate upgrading to `phpdocumentor/reflection-docblock 3.1`](Roave#169) thanks to @asgrim - [202: Review PHP 7.1 feature: nullable types](Roave#202) thanks to @asgrim - [204: Review PHP 7.1 feature: Class constant visibility modifiers](Roave#204) thanks to @asgrim - [205: Autoload interruption for dynamic monkey patching](Roave#205) thanks to @asgrim - [216: Autoload interruption for monkey patching](Roave#216) thanks to @asgrim - [217: Update our code for API changes in PHP-Parser](Roave#217) thanks to @asgrim - [218: Upgrade phpdocumentor reflection docblock](Roave#218) thanks to @asgrim - [219: Check compatibility with PHP 7.2](Roave#219) thanks to @asgrim - [220: Fixed issues found by static analysis](Roave#220) thanks to @ondrejmirtes - [221: Upgrade minimum version to PHP 7.0](Roave#221) thanks to @asgrim - [223: Add vendor prefix to namespaces](Roave#223) thanks to @asgrim - [225: Fixed function reflector doc](Roave#225) thanks to @dantleech - [226: Require minimum of PHP 7, enabling tests on PHP 7.1](Roave#226) thanks to @asgrim - [227: Prefix namespaces with Roave](Roave#227) thanks to @asgrim - [228: Implement internal parsing of closures](Roave#228) thanks to @asgrim - [229: getDocBlockTypes() causes error when no docblock is present](Roave#229) thanks to @dantleech - [231: Inherited properties not returned by getProperties](Roave#231) thanks to @dantleech - [235: `LocatedSource#__construct()` should accept empty string as $source](Roave#235) thanks to @asgrim - [236: Fix exception being thrown in AutoloadSourceLocator](Roave#236) thanks to @asgrim - [238: LocatedSource now allows empty strings as source code](Roave#238) thanks to @asgrim - [240: ReflectionParameter doesn't resolve parameter type `self`](Roave#240) thanks to @malukenho - [241: Fix `self` and `parent` hinted ReflectionParameter class reference](Roave#241) thanks to @malukenho - [242: Support for the PHP 7.1 `iterable` type](Roave#242) thanks to @Ocramius - [243: `ReflectionType#__toString()` should NOT prepend backslashes to class/interface types](Roave#243) thanks to @Ocramius - [244: Fix for Roave#243: `ReflectionType` `(string)` cast should not prepend backslash to class and interface types](Roave#244) thanks to @Ocramius - [246: Fixed class constant value fetch when constant is declared in parent](Roave#246) thanks to @janlanger - [250: Types with no doc block](Roave#250) thanks to @marcosh - [251: Retrieve all functions in SourceLocator scope](Roave#251) thanks to @marcosh - [252: get all functions available in SourceLocator scope](Roave#252) thanks to @marcosh - [253: Usage: fix DirectoriesSourceLocator usage](Roave#253) thanks to @TomasVotruba - [254: README: drop unstable dependencies reference](Roave#254) thanks to @TomasVotruba - [255: create ReflectionParameter from closure](Roave#255) thanks to @marcosh - [256: create reflection parameter from closure](Roave#256) thanks to @marcosh - [257: Possible unused code path](Roave#257) thanks to @asgrim - [258: PHP 7.1 updates](Roave#258) thanks to @asgrim - [259: [Docs] Usage: drop SingleDirectorySourceLocator](Roave#259) thanks to @TomasVotruba - [260: [Docs] Usage - add FunctionReflector getAllFunctions() example](Roave#260) thanks to @TomasVotruba - [263: Support PHP4-style constructors?](Roave#263) thanks to @asgrim - [264: ReflectionMethod::isDestructor is case insensitive](Roave#264) thanks to @asgrim - [266: get file name of unlocated source could be null](Roave#266) thanks to @marcosh - [267: Testing that class constant visibility works](Roave#267) thanks to @asgrim - [268: Ensure locateFunctionByName returns ?string always](Roave#268) thanks to @asgrim - [269: Added case insensitivity to isConstructor and isDestructor methods](Roave#269) thanks to @asgrim - [271: getProperties returns inherited properties](Roave#271) thanks to @marcosh - [272: Added test cases for ?nullable and iterable types in PHP 7.1](Roave#272) thanks to @asgrim - [273: [docs] example2.php - flip fallen space from the bottom](Roave#273) thanks to @TomasVotruba - [274: [failing-test] Namespaced Trait fails to be resolved](Roave#274) thanks to @TomasVotruba - [275: Filter get methods and properties](Roave#275) thanks to @marcosh - [277: [demo] add getAllClasses() examples, ref Roave#276](Roave#277) thanks to @TomasVotruba - [278: object immediate properties includes runtime properties](Roave#278) thanks to @marcosh - [279: Reflect on instances of anonymous classes](Roave#279) thanks to @marcosh - [280: [NodeCompiler] add support for `__DIR__`](Roave#280) thanks to @TomasVotruba - [281: [PHP7.1] ::getReflectionConstant() and ::getReflectionConstants() support](Roave#281) thanks to @POPSuL - [282: [PHP 7.1] Add support for ReflectionClassConstant (Roave#281)](Roave#282) thanks to @POPSuL - [284: fixed improper docblock retrieval](Roave#284) thanks to @vlastavesely - [285: FindReflectionOnLine cannot be configured to load dependencies](Roave#285) thanks to @moufmouf - [286: Make FindReflectionOnline more configurable](Roave#286) thanks to @moufmouf - [287: Remove namespace BC shim](Roave#287) thanks to @asgrim - [288: added ReflectionProperty::getDefaultValueAsString()](Roave#288) thanks to @vlastavesely - [290: Documentation fix regarding new Roave namespace](Roave#290) thanks to @moufmouf - [291: Added support for getStart/EndLine() for ReflectionClassConstant and ReflectionProperty](Roave#291) thanks to @POPSuL - [293: getDefaultValueAsString removals/deprecation](Roave#293) thanks to @asgrim - [294: Support for PHP 7.2's `object` hint](Roave#294) thanks to @Ocramius - [296: ReflectionParameter::parseDefaultValueNode() - case insensitive check of TRUE, FALSE and NULL](Roave#296) thanks to @vlastavesely - [297: ReflectionParameter: return full name if default value is class' constant](Roave#297) thanks to @vlastavesely - [298: CompileNodeToValue: added support for `__CLASS__` magic const](Roave#298) thanks to @vlastavesely - [300: Support for anonymous classes](Roave#300) thanks to @kukulich - [301: Fixed travis.yml - no PHP 7.0 support already](Roave#301) thanks to @kukulich - [302: ReflectionClass::getConstants() and ::getReflectionConstants() should return inherited constants](Roave#302) thanks to @kukulich - [303: Added missing `getReturnType` functionality to adapters](Roave#303) thanks to @kukulich - [304: Adapters API is not consistent with internal reflection](Roave#304) thanks to @kukulich - [305: Fixed almost all tests on Windows](Roave#305) thanks to @kukulich - [306: Adding appveyor config to test on windows](Roave#306) thanks to @Ocramius - [307: Removed dead code that skipped tests for older PHP versions](Roave#307) thanks to @kukulich - [308: Improve AppVeyor build setup to include more extensions](Roave#308) thanks to @kukulich - [309: Use `PhpParser\ParserFactory` with `PREFER_PHP7` parser everywhere](Roave#309) thanks to @kukulich - [311: `declare(strict_types=1)` everywhere](Roave#311) thanks to @kukulich - [313: Adapters are more compatible with internal reflections](Roave#313) thanks to @kukulich - [314: Internal functions are to be used with `\` (FQN)](Roave#314) thanks to @kukulich - [315: Adding type hints to closures](Roave#315) thanks to @kukulich - [316: PHPStan integration (Level 5 with exclusions) and CI stages](Roave#316) thanks to @Ocramius - [317: Incompatibility between `ReflectionClass#newInstance()` on PHP 7.1 vs PHP 7.2](Roave#317) thanks to @Ocramius - [318: Roave#317 locking onto PHP 7.1 due to reflection API changes that cannot be made compatible with both versions](Roave#318) thanks to @Ocramius - [319: Remowing workarounds used in pre-php-7 code to catch any exception that isn't a `Throwable`](Roave#319) thanks to @Ocramius - [320: Support for PHP4 style constructors](Roave#320) thanks to @kukulich - [321: ClosureSourceLocator improvements](Roave#321) thanks to @kukulich - [322: Implemented `getStartColumn()` and `getEndColumn()` methods](Roave#322) thanks to @kukulich - [323: Method isSubclassOf() of ReflectionClass adapter should check also implemented interfaces to be compatible with internal reflection](Roave#323) thanks to @kukulich - [324: Method getFileName() of adapters should return false where no filename to be compatible with internal reflection](Roave#324) thanks to @kukulich - [325: Class with name "Scalar" is not resolved right](Roave#325) thanks to @kukulich - [327: Property from Trait should have actual class as declaring class](Roave#327) thanks to @kukulich - [328: Coding standard](Roave#328) thanks to @kukulich - [329: More coding standard checks](Roave#329) thanks to @kukulich - [330: Adapters compatibility for properties and methods from traits](Roave#330) thanks to @kukulich - [331: Used `PhpParser\NodeVisitor\NameResolver` to simplify code](Roave#331) thanks to @kukulich - [332: Added missing documentation of `AnonymousClassObjectSourceLocator`](Roave#332) thanks to @kukulich - [333: `PhpParser\BuilderFactory` instead of `Zend\Code\Generator\ClassGenerator` in the `SourceStubber`](Roave#333) thanks to @kukulich - [334: Update phpdocumentor/reflection-docblock](Roave#334) thanks to @asgrim - [335: Self and parent are not builtin types in internal reflection](Roave#335) thanks to @kukulich - [336: Fixes of bugs introduced in Roave#331](Roave#336) thanks to @kukulich - [337: BetterReflection entry-point class](Roave#337) thanks to @Ocramius - [338: Memoize parsing and symbol detection: improves performance by removing repeated I/O and parsing](Roave#338) thanks to @Ocramius - [340: Fixed AppVeyor badge](Roave#340) thanks to @kukulich - [341: Check if identifier name is valid](Roave#341) thanks to @kukulich - [342: ReflectionClass::newInstance() and ReflectionObject::newInstance() compatibility in all PHP versions](Roave#342) thanks to @kukulich - [343: Implemented ReflectionProperty::setAccessible(), getValue() and setValue() and ReflectionClass::getStaticProperties()](Roave#343) thanks to @kukulich - [344: Fixed stubs searching](Roave#344) thanks to @kukulich - [345: Introduced PHPBench with sample benchmark](Roave#345) thanks to @dantleech - [346: Avoid repeated source parsing when trying to analyse docblock types](Roave#346) thanks to @Ocramius - [347: FindTypeFromAst dropped in Roave#331 with no upgrade path](Roave#347) thanks to @asgrim - [348: Migrate BC Breaks documentation to migration path docs](Roave#348) thanks to @Ocramius - [349: Improved SourceStubber trait tests](Roave#349) thanks to @kukulich - [350: Implement `ReflectionClass#getExtensionName()`](Roave#350) thanks to @kukulich - [351: ReflectionClass::implementsInterface() stopped working](Roave#351) thanks to @TomasVotruba - [352: Cleanup: generic type/static analysis fixes](Roave#352) thanks to @Ocramius - [353: Roave#351 verify stub implemented interfaces and extended classes](Roave#353) thanks to @Ocramius - [354: Implemented ReflectionMethod::getClosure()](Roave#354) thanks to @kukulich - [355: Implemented ReflectionMethod::invoke(), invokeArgs() and setAccessible()](Roave#355) thanks to @kukulich - [356: Replacing internal `assertObject` return type with `object`, removing therefore the implicit upcast](Roave#356) thanks to @Ocramius - [357: Implemented missing functions in ReflectionFunction](Roave#357) thanks to @kukulich - [358: Mark `*::createFromNode` methods as `@internal`](Roave#358) thanks to @asgrim - [359: Roave#334 bump `phpdocumentor/reflection-docblock` dependency version](Roave#359) thanks to @Ocramius - [360: Mark `*::createFromNode` methods as `@internal` to indicate they…](Roave#360) thanks to @marcomenzel - [361: String casting improvements](Roave#361) thanks to @kukulich - [362: AppVeyor configuration tuning](Roave#362) thanks to @kukulich - [363: Fixed infinite recursion in CompileNodeToValue](Roave#363) thanks to @kukulich - [364: Not all constants defined with const keyword are detected](Roave#364) thanks to @kukulich - [366: Fixed detection of all constants and properties defined by one keyword](Roave#366) thanks to @kukulich - [367: Added `Closure::fromCallable()` to stubs](Roave#367) thanks to @kukulich - [368: Improved `PhpInternalSourceLocator` test and `Closure` stub](Roave#368) thanks to @kukulich - [369: Added `SlevomatCodingStandard.ControlStructures.RequireYodaComparison`](Roave#369) thanks to @kukulich - [370: Added `ReflectionParameter::getAst()`](Roave#370) thanks to @kukulich
PreviousNext