php-generator icon indicating copy to clipboard operation
php-generator copied to clipboard

feat: add wrapping of global function with existing check

Open Katalam opened this issue 11 months ago • 1 comments

  • 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

Katalam avatar Feb 14 '25 11:02 Katalam

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.

dg avatar Feb 17 '25 16:02 dg