Closed flashios09 closed 7 years ago
Hi @flashios09
I think that error is a parse error from the phpcs because maybe you are using an older PHP version within Sublime Text.
Parse error: parse error, expecting `'&'' or `"variable (T_VARIABLE)"' in /Volumes/Data/Sites/hotelas/vendor/cakephp/cakephp/src/I18n/functions.php on line 26
So you may want to set this configuration setting:
"phpcs_php_path": "/path/to/your/php",
On your terminal do which php
and put that path in the config within Sublime Text. See if that works for you
@benmatselby thanks for your reply
I'm sure it's not php version/path problem because it was working before updating the framework yesterday.
I don't use phpcs linter php -l
, even if i activate the phpcs linter and force the phpcs_php_path it always display the same parse error:
Parse error: parse error, expecting
'&'' or "variable (T_VARIABLE)"' in /Volumes/Data/Sites/hotelas/vendor/cakephp/cakephp/src/I18n/functions.php on line 26
Take a look at this:
[Phpcs] Project files:
[Phpcs] Current: /Volumes/Data/Sites/hotelas/hotelas.sublime-project
[Phpcs] Last Known: None
[Phpcs] Project files have changed, commence the reload
[Phpcs] /Volumes/Data/Sites/hotelas/vendor/bin/phpcbf /Volumes/Data/Sites/hotelas/vendor/cakephp/cakephp/src/I18n/functions.php --standard=CakePHP -n
[Phpcs] /Volumes/Data/Sites/hotelas/vendor/bin/phpcbf /Volumes/Data/Sites/hotelas/vendor/cakephp/cakephp/src/I18n/functions.php --standard=CakePHP -n
[Phpcs] cwd: /Users/flashios09
[Phpcs]
Parse error: parse error, expecting `'&'' or `"variable (T_VARIABLE)"' in /Volumes/Data/Sites/hotelas/vendor/cakephp/cakephp/src/I18n/functions.php on line 26
[Phpcs] /usr/local/bin/php -l -d display_errors=On /Volumes/Data/Sites/hotelas/vendor/cakephp/cakephp/src/I18n/functions.php
[Phpcs] /usr/local/bin/php -l -d display_errors=On /Volumes/Data/Sites/hotelas/vendor/cakephp/cakephp/src/I18n/functions.php
[Phpcs] cwd: /Users/flashios09
[Phpcs] No syntax errors detected in /Volumes/Data/Sites/hotelas/vendor/cakephp/cakephp/src/I18n/functions.php
[Phpcs] /Volumes/Data/Sites/hotelas/vendor/bin/phpcs --report=checkstyle --standard=CakePHP -n /Volumes/Data/Sites/hotelas/vendor/cakephp/cakephp/src/I18n/functions.php
[Phpcs] /Volumes/Data/Sites/hotelas/vendor/bin/phpcs --report=checkstyle --standard=CakePHP -n /Volumes/Data/Sites/hotelas/vendor/cakephp/cakephp/src/I18n/functions.php
[Phpcs] cwd: /Volumes/Data/Sites/hotelas/vendor/cakephp/cakephp/src/I18n
[Phpcs]
Parse error: parse error, expecting `'&'' or `"variable (T_VARIABLE)"' in /Volumes/Data/Sites/hotelas/vendor/cakephp/cakephp/src/I18n/functions.php on line 26
The debug says there is no syntax errors in the functions.php file, plus the parse error that block phpcs appears before the php -l
cmd, it appears with phpcbf
cmd.
Yesterday when i tried to do some debug to phpcs.py file and tried this:
if proc.stdout:
data = proc.communicate()[0]
pprint(data)
it give me this in the console:
b'\nParse error: parse error, expecting `\'&\'\' or `"variable (T_VARIABLE)"\' in /Volumes/Data/Sites/hotelas/vendor/cakephp/cakephp/src/I18n/functions.php on line 26\n'
So get this error from somewhere, i don't know what subprocess.Popen(...)
then proc.communicate()[0]
do but i'm sure it's blocked at the first error and i don't know how to do clear cache or erase the file that stock all the errors before re-send it to sublime text.
PS:
It complains about this function __($singular, ...$args)
in functions.php file so if i fix it by removing the ...
-> function __($singular, $args)
, it will change the message to this:
Parse error: parse error, expecting `'&'' or `"variable (T_VARIABLE)"' in /Volumes/Data/Sites/hotelas/vendor/cakephp/cakephp/src/I18n/functions.php on line 51
It moves to the second error(same error for him the ...
), if i fix all the errors by removing ...
, it works again in my main files TssController.php
What i haven't understand is why phpcs/phpcbf complains about ...
and try to parse syntax errors !
Hi @flashios09
What happens when you run
/Volumes/Data/Sites/hotelas/vendor/bin/phpcbf /Volumes/Data/Sites/hotelas/vendor/cakephp/cakephp/src/I18n/functions.php --standard=CakePHP -n
In your terminal?
What i haven't understand is why phpcs/phpcbf complains about ... and try to parse syntax errors !
Because you may be using two different versions of PHP. One that supports Varadics and the one that doesn't (http://php.net/manual/en/migration56.new-features.php)
The PHP version will depend on the PATH, and Sublime Text does not use the one defined in your Terminal, which is why you may need to set phpcs_commands_to_php_prefix
as well maybe. See documentation here (http://benmatselby.github.io/sublime-phpcs/)
@benmatselby thanks for your time
Yes it's about the php version, i installed php 7.1 via brew and updated the PATH that's why if i run the same command on terminal it works but in sublime text it's says parse error ...
I re-updated the PATH to use the default installed php 5.5.38 and now on terminal i have the parse error ...
too.
Before the functions.php file doesn't have the ...$args
notation so that's why sublime text doesn't complaint about it, the updated functions.php version use this notation.
I tried to force the phpcs_php_path
like this:
"phpcs_php_path": "/usr/local/bin/php"
but this doesn't solve the problem :(
php 5.5.38 bin -> /usr/bin/php
php 7.1 bin -> /usr/local/bin/php
you may need to set
phpcs_commands_to_php_prefix
as well maybe
I read the doc but i didn't understand what is the value that i have to use for this key, even on your nix-all-commands-example
i can't find this key. Can you tell me please ?
Thanks
PS: I fix this by overriding the php bin:
sudo cp /usr/local/Cellar/php71/7.1.0_11/bin /usr/bin/
Now /usr/bin/php
and /usr/local/bin/php
use the same php 7.1.0 and sublime text phpcs works again.
BTW i fixed the cs warnings on your phpcs.py
, i can do a PR if you want ;)
Hi @flashios09
I read the doc but i didn't understand what is the value that i have to use for this key, even on your nix-all-commands-example i can't find this key. Can you tell me please ?
// We want the fixer to be run through the php application
"phpcs_commands_to_php_prefix": ["Fixer"],
This is an array and can be "Sniffer".. Not entirely sure that will work, as that is usually when using Phar files. Glad it is working now, and I will close the issue
Hi @benmatselby, First of all thanks for this awesome sublime text plugin. Sublime PhpCS was working for me until i upgrade my CakePHP framework today, i activated the debug and this what i get:
If i tried the same cmd on terminal:
I have this:
So i'm sure that's not a config problem but i didn't understand why he try to fix this file
/Volumes/Data/Sites/hotelas/vendor/cakephp/cakephp/src/I18n/functions.php
instead of the current one/Volumes/Data/Sites/hotelas/src/Controller/TssController.php
I tried also to take a look at the
phpcs.py
file and do some debug via the pprint function(i'm pretty novice to python) and i think that the problem come from the line 172:It's like he always blocked at an error from the another file and i don't know how to restart python(i'm using Python 2.7 on Mac OS El Capitan) or clear the console/cache(maybe it's a problem of cache/console)