php-gettext / PHP-Scanner

PHP code scanner for gettext
MIT License
14 stars 5 forks source link

Variables in Scanner #17

Open EvilBozkurt opened 1 month ago

EvilBozkurt commented 1 month ago

I can translate _($variable) this way with gettext and there are no errors. So far, no problem. But it causes this problem in the scanner. How can I prevent this? I am getting this error


<!--StartFragment-->
<b>Fatal error</b>:  Uncaught Exception: Invalid gettext function in Templates/default/header_breadcrumb.php:182. Some required arguments are not valid in C:\xampp\htdocs\testpanel\vendor\gettext\gettext\src\Scanner\CodeScanner.php:148
--
  | Stack trace:
  | #0 C:\xampp\htdocs\testpanel\vendor\gettext\gettext\src\Scanner\FunctionsHandlersTrait.php(15): Gettext\Scanner\CodeScanner-&gt;checkFunction(Object(Gettext\Scanner\ParsedFunction), 1)
  | #1 [internal function]: Gettext\Scanner\PhpScanner-&gt;gettext(Object(Gettext\Scanner\ParsedFunction))
  | #2 C:\xampp\htdocs\testpanel\vendor\gettext\gettext\src\Scanner\CodeScanner.php(81): call_user_func(Array, Object(Gettext\Scanner\ParsedFunction))
  | #3 C:\xampp\htdocs\testpanel\vendor\gettext\gettext\src\Scanner\CodeScanner.php(67): Gettext\Scanner\CodeScanner-&gt;handleFunction(Object(Gettext\Scanner\ParsedFunction))
  | #4 C:\xampp\htdocs\testpanel\vendor\gettext\gettext\src\Scanner\Scanner.php(45): Gettext\Scanner\CodeScanner-&gt;scanString('&lt;!doctype html&gt;...', 'Templates/defau...')
  | #5 C:\xampp\htdocs\testpanel\Templates\default\admin\language.php(41): Gettext\Scanner\Scanner-&gt;scanFile('Templates/defau...')
  | #6 C:\xampp\htdocs\testpanel\index.php(2028): require('C:\\xampp\\htdocs...')
  | #7 C:\xampp\htdocs\testpanel\index.php(2857): {closure}()
  | #8 {main}
  | thrown in <b>C:\xampp\htdocs\testpanel\vendor\gettext\gettext\src\Scanner\CodeScanner.php</b> on line <b>148</b><br />

<!--EndFragment-->
oscarotero commented 4 weeks ago

You can use the $scanner->ignoreInvalidFunctions() option to ignore them instead throw an exception.