php-stubs / generator

Generate stubs from any PHP code for IDE completion and static analysis.
https://packagist.org/packages/php-stubs/generator
MIT License
52 stars 11 forks source link

How to override phpdocs #23

Closed criskell closed 1 year ago

criskell commented 1 year ago

When I am generating the stub, I would like to modify the PHPDoc of a specific method of a specific class.

Would it be possible?

szepeviktor commented 1 year ago

Thank you for asking @criskell!

👋🏻

You may modify the implementation in WP stubs. https://github.com/php-stubs/wordpress-stubs/blob/9da4e91a9dce4faf64f3f943f523c624626b59a5/visitor.php#L236

https://github.com/php-stubs/generator/blob/bf758105124218225d59e698913ac852ee7d79c7/src/GenerateStubsCommand.php#L62

szepeviktor commented 1 year ago

sed is a simpler alternative.

https://github.com/php-stubs/wordpress-stubs/blob/9da4e91a9dce4faf64f3f943f523c624626b59a5/generate.sh#L37-L70

criskell commented 1 year ago

I got it using sed's idea, thanks!

maybe it would be nice to have a functionality to merge stubs files?

so I wouldn't need to use sed, I would only use PHP

szepeviktor commented 1 year ago

It is very easy. Add those changes before generating stubs. The generator can handle duplicated functions.