[Templating] fix logic regarding template references and many phpdoc