[Templating] fix logic regarding template references and many phpdocs