kokororin / vscode-phpfmt

Integrates phpfmt into VS Code
https://marketplace.visualstudio.com/items?itemName=kokororin.vscode-phpfmt
BSD 3-Clause "New" or "Revised" License
129 stars 30 forks source link

Error: Call to undefined function token_get_all() #58

Closed paviad closed 5 years ago

paviad commented 5 years ago

I just installed this extension and it failed to format. I ran the command manually and this is what I got:

>php "C:\Users\user\.vscode\extensions\kokororin.vscode-phpfmt-1.0.30\node_modules\phpfmt\fmt.phar" --psr2 --indent_with_space=4 index.php

Warning: Use of undefined constant T_WHITESPACE - assumed 'T_WHITESPACE' (this will throw an Error in a future version of PHP) in phar://C:/Users/user/.vscode/extensions/kokororin.vscode-phpfmt-1.0.30/node_modules/phpfmt/fmt.phar/fmt.stub.php on line 3042

Warning: Use of undefined constant T_COMMENT - assumed 'T_COMMENT' (this will throw an Error in a future version of PHP) in phar://C:/Users/user/.vscode/extensions/kokororin.vscode-phpfmt-1.0.30/node_modules/phpfmt/fmt.phar/fmt.stub.php on line 3042

Warning: Use of undefined constant T_DOC_COMMENT - assumed 'T_DOC_COMMENT' (this will throw an Error in a future version of PHP) in phar://C:/Users/user/.vscode/extensions/kokororin.vscode-phpfmt-1.0.30/node_modules/phpfmt/fmt.phar/fmt.stub.php on line 3042Formatting ....
Fatal error: Uncaught Error: Call to undefined function token_get_all() in phar://C:/Users/user/.vscode/extensions/kokororin.vscode-phpfmt-1.0.30/node_modules/phpfmt/fmt.phar/fmt.stub.php:3147
Stack trace:
#0 phar://C:/Users/user/.vscode/extensions/kokororin.vscode-phpfmt-1.0.30/node_modules/phpfmt/fmt.phar/fmt.stub.php(3116): BaseCodeFormatter->getFoundTokens('<?php\r\n/**\r\n * ...')
#1 phar://C:/Users/user/.vscode/extensions/kokororin.vscode-phpfmt-1.0.30/node_modules/phpfmt/fmt.phar/fmt.stub.php(14088): BaseCodeFormatter->formatCode('<?php\r\n/**\r\n * ...')
#2 C:\Users\user\.vscode\extensions\kokororin.vscode-phpfmt-1.0.30\node_modules\phpfmt\fmt.phar(10): include('phar://C:/Users...')
#3 {main}  thrown in phar://C:/Users/user/.vscode/extensions/kokororin.vscode-phpfmt-1.0.30/node_modules/phpfmt/fmt.phar/fmt.stub.php on line 3147

Any help would be appreciated.

kokororin commented 5 years ago

You probably don't have the tokenizer extension available or enabled.

paviad commented 5 years ago

Thanks, it turns out my installation of php was damaged. Reinstalled and everything is working.