phug-php / phug

Phug - The Pug Template Engine for PHP
https://phug.selfbuild.fr
MIT License
62 stars 3 forks source link

Inconsistent error message when calling undefined closure #18

Closed char101 closed 6 years ago

char101 commented 6 years ago

Hello,

= f()

PHP Fatal error: Uncaught Error: Call to undefined function f()

= $f()

PHP Fatal error: Uncaught Error: Function name must be a string

kylekatarnls commented 6 years ago

Because in PHP $f() call a closure from a variable, while f() call a declared function.

It's exactly what happen if you try to execute this both codes in a PHP file. Except if you use the jsphpize (pug-php with JS expressionLanguage = 'js', or install the extension in Phug), we do not parse the code inside expressions/codes else. We generate PHP file and give it to PHP. There is no added value to catch and rewrite each PHP possible error.

Does this pose a problem to the use?

char101 commented 6 years ago

No, it is not a problem for me, I only thought that it could pose some confusion for some people. I realize now that pug does not have a function call syntax (other than mixin call) only PHP expression syntax. So whatever error in the expression comes from PHP.