-
Notifications
You must be signed in to change notification settings - Fork 1
Implement ParameterAttributeCollector #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
/** | ||
* @return array<TransientTargetMethodParameter> | ||
*/ | ||
public function collectAttributes(\ReflectionFunctionAbstract $reflectionFunctionAbstract): array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have build this collector on ReflectionFunctionAbstract
, so we can easily add support for function parameters
public const CACHE_DIR = '.composer-attribute-collector'; | ||
public const VERSION_MAJOR = 2; | ||
public const VERSION_MINOR = 0; | ||
public const VERSION_MINOR = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use new version to make sure a fresh attributes.php
is generated and we don't need to invalide existing caches in tests.
attributes.php
in consuming projects currently don't have a cache key or similar
// classes | ||
$targetClassesCode, | ||
// methods | ||
$targetMethodsCode, | ||
// properties | ||
$targetPropertiesCode, | ||
// method parameters | ||
$targetMethodParametersCode, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added comments to ease reading of the attributes.php
Pull Request Test Coverage Report for Build 15401669993Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Looking forward to see this finished.
The PHP-Parser implementation will be verified by having tests succeed on PHP 7.4. Just beware - because of new $attribute(...$args)
, it cannot work with named arguments, so you can test it only with positional arguments like #[Foo(1, 2, 3)]
.
In phpstan-src this problem is avoided by downgrading named arguments to positional arguments even inside attributes.
while working on the php-parser based parts, I realized that atm this packages relies on runtime reflection, which means I cannot reflect on a class which uses hooked properties when on PHP 8.3 or lower. do you agree that we need ondrejmirtes/better-reflection as a dependency to make it work with static reflection instead? |
No, I don't want to complicate this with more dependencies. We don't need support for property hooks now, you can omit it. |
cannot be emulated via runtime reflection on PHP < 8.4
do you have a cs-fixer arround to fix the build? otherwise I think its good to go |
Try running |
here we go |
Thank you! |
This is what your work allows us to do now: phpstan/phpstan-src#4042 |
nice. while porting this PR to the upstream, I found a bug. will fix in a moment |
strike that.. it was a upstream only bug because of bad merge conflicts |
opening a first draft so we can discuss directions