generator
generator copied to clipboard
Ignore inaccessible class child nodes
Based on the idea that was voiced in https://github.com/szepeviktor/phpstan-wordpress/issues/99#issuecomment-1112996660
It should be safe to not include private constants/properties/methods of classes. And if the class is final, protected ones can be ignored too IMO.
Fyi this only makes the wordpress-stubs around 0.1M smaller, so it won't change much in regard to parsing performance there.
What do you think?
What do you think?
I think this could be resolved in PHPStan. BTW PHPStan is written in PHP so it is not expected to be as fast as C code.
The current maintenance effort is over my personal max.
the performance problems should be fixed in phpstan for sure. this PR was meant to just clean up the stubs a bit further which is not really related and makes sense anyways IMO. it could also be made configurable with a "include_inaccessible_class_nodes" config (a couple of lines more I already prepared).
but it's also fine to keep it as it is of course, this is your stubs generator :) but maybe you also want to remove the "PR welcome" message from the README then.
Martin! We were forced to fork this project as we had problems. https://github.com/php-stubs/generator/commits/master
Stubs could be modified here: https://github.com/php-stubs/wordpress-stubs/blob/master/visitor.php#L37
I'll merge this as soon as any other person is complaining about private methods.
Okay?
- if you want to remove a node I think you have to do this via
leaveNodeinstead, see https://github.com/nikic/PHP-Parser/blob/v4.13.2/lib/PhpParser/NodeVisitor.php#L45 - sure, that's fine! feel free to keep it open, or also just close it if you want. I also don't have a problem if you say you don't need/want this :)
To be honest I do not know what will happen by this PR. Thousands use WP core stubs!
Actually this generator is a highly unstable project. I do not dare to touch it!!! I'm not a businessman nor a developer, I sit here at home and think. For me theory is not practice.
You must be brave enough to touch daily work of thousands.
@herndlm Have you seen the actual diff?
164 insertions(+), 2959 deletions(-)
I briefly scrolled through it, yeah. Was looking fine to me. But please let's not argue over this, if it's too risky then it shall not be touched and over :) or, as you suggested, work can be continued if more people want/need this.
I would be in favour of removing these inaccessible nodes by default. Perhaps with a config flag to not exclude them in cases where they are needed?
If it breaks anybody's code then they can ask Viktor for a refund.
with a config flag
Let's do this.
rebased on master and added the config change I had apparently lying around since May :D
Thank you!
Does --help talk about include_inaccessible_class_nodes?
I realized that what I pushed was not ready yet, now it is, including the help adaption.
but let me add a test case for that, sorry :) UPDATE: now I'm ok with it
Thank you.
Released as https://github.com/php-stubs/generator/releases/tag/v0.8.3
Nice one