nette / php-generator

🐘 Generates neat PHP code for you. Supports new PHP 8.3 features.
https://doc.nette.org/php-generator
Other
2.11k stars 138 forks source link

Toggle for resolving of class names when using withBodyFrom functionality #85

Closed wikando-km closed 3 years ago

wikando-km commented 3 years ago

In order to create a class from an existing file and move it to another location with another namespace, it was necessary to be able to disable the replacing of class names in function bodies with fully qualified versions, and rather relying on correct use statements.

Also made the change in the most harmless way so nothing breaks :crossed_fingers:

Hope this is a valuable addition :)

dg commented 3 years ago

That's great, thanks. Could you add a test?

wikando-km commented 3 years ago

Yes! Will do it when I have more time :)

dg commented 3 years ago

I totally understand the first commit with the replacing of class names inside the function bodies, this is of course useful and I merged it.

But I don't understand the point of the second commit. On the one hand it goes against type resolving in the Printer, and anyway it would have to be done differently, because the last segment of the class name might not be sufficient, for example in the case of class Foo extends SubName\Bar.