Closed ghostwriter closed 1 year ago
Thank you. Please have a look at the CS failure.
What does this PR introduce or is trying to fix? Can you please write a description?
@SenseException done, ready for review.
Thank you for clearing up the PR. It's now more understandable what you try to accomplish with the changes. Now it would help to understand "why". Did you run into memory issues or something different because of the repeated creation of the ReflectionClass instance?
No!
"lexer site:packagist.org"
AbstractLexer.php
anything else you want to know?
Feel free to reopen a similar PR when you're ready to be respectful to maintainers. In the meantime, we'll make do without your contribution.
Description
The method
getLiteral($token)
currently creates a newReflectionClass
every time it's invoked, to get the constants defined on the static class.This PR attempts to cache the first call and reuse it for subsequent calls.
Diff
once this package min support version is bumped to PHP 7.4
$constants = $constants ?? (new ReflectionClass($className))->getConstants();
can later be optimized/shortened to
$constants ??= (new ReflectionClass($className))->getConstants();