php-generator
php-generator copied to clipboard
feat: add wrapping of global function with existing check
- bug fix / new feature?
- feature
- BC break? yes/no
- no
- doc PR: nette/docs#???
- can be done if merged
I'm generating a lot of helper methods recently, but I have the need to wrap them into a function exist check. It is kinda duplicated if done manually, so I want it to be part of the generation itself. The code style may differ a lot from the code style of the project, feel free to adjust it
The flag indicating that a function should be wrapped in a condition does not logically belong to the GlobalFunction class but is rather a concern of the Printer.
If you need to wrap all functions in a file this way, it can be easily handled with a single switch in Printer. However, if the wrapping needs to be selective, the implementation would naturally be more complex.