Open moon0326 opened 9 years ago
Can you provide more context from the log please in the console, and also supply your phpcs settings.
Hello,
Here's the full log
[Phpcs] Project files:
[Phpcs] Current: None
[Phpcs] Last Known: None
[Phpcs] No project file defined, therefore skipping reload
[Phpcs] /Users/moonkuykyong/.composer/vendor/bin/php-cs-fixer fix /Users/moonkuykyong/Code//app/Modules/User/OAuthPasswordGrantVerifier.php --verbose
[Phpcs] /Users/moonkuykyong/.composer/vendor/bin/php-cs-fixer fix /Users/moonkuykyong/Code//app/Modules/User/OAuthPasswordGrantVerifier.php --verbose
[Phpcs] cwd: /Users/moonkuykyong
[Phpcs] I
Legend: ?-unknown, I-invalid file syntax, file ignored, .-no changes, F-fixed, E-error
Fixed all files in 0.012 seconds, 4.750 MB memory used
[Phpcs] /Applications/MAMP/bin/php/php5.5.18/bin/php -l -d display_errors=On /Users/moonkuykyong/Code/app/Modules/User/OAuthPasswordGrantVerifier.php
[Phpcs] /Applications/MAMP/bin/php/php5.5.18/bin/php -l -d display_errors=On /Users/moonkuykyong/Code/app/Modules/User/OAuthPasswordGrantVerifier.php
[Phpcs] cwd: /Users/moonkuykyong
[Phpcs] No syntax errors detected in /Users/moonkuykyong/Code/hue-auth/app/Modules/User/OAuthPasswordGrantVerifier.php
[Phpcs] /Applications/MAMP/bin/php/php5.5.18/bin/phpcs --report=checkstyle -n --standard=PSR2 /Users/moonkuykyong/Code/app/Modules/User/OAuthPasswordGrantVerifier.php
[Phpcs] /Applications/MAMP/bin/php/php5.5.18/bin/phpcs --report=checkstyle -n --standard=PSR2 /Users/moonkuykyong/Code/app/Modules/User/OAuthPasswordGrantVerifier.php
[Phpcs] cwd: /Users/moonkuykyong
[Phpcs] <?xml version="1.0" encoding="UTF-8"?>
<checkstyle version="2.3.2">
<file name="/Users/moonkuykyong/Code/app/Modules/User/OAuthPasswordGrantVerifier.php">
<error line="48" column="23" severity="error" message="Expected 1 newline after opening brace; 2 found" source="Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace"/>
</file>
</checkstyle>
[Phpcs] Linter found 0 errors
[Phpcs] Sniffer found 1 errors
and this is my config
{
"show_debug": true,
"phpcs_executable_path": "/Applications/MAMP/bin/php/php5.5.18/bin/phpcs",
"php_cs_fixer_on_save": true,
"phpcs_execute_on_save": true,
"php_cs_fixer_executable_path": "/Users/moonkuykyong/.composer/vendor/bin/php-cs-fixer",
"phpcs_php_path": "/Applications/MAMP/bin/php/php5.5.18/bin/php",
"phpcs_show_quick_panel": false,
"phpcs_show_errors_on_save": true,
}
I'm a little stumped here as this is working for me:
[Phpcs] Project files:
[Phpcs] Current: /Users/ben/Documents/sublime-projects/development.sublime-project
[Phpcs] Last Known: /Users/ben/Documents/sublime-projects/development.sublime-project
[Phpcs] Project files are the same, skipping reload
[Phpcs] /Users/ben/.composer/vendor/bin/php-cs-fixer fix /Users/Ben/git/external/trello-cli/src/TrelloCli/Command/ListBoardsCommand.php --verbose
[Phpcs] /Users/ben/.composer/vendor/bin/php-cs-fixer fix /Users/Ben/git/external/trello-cli/src/TrelloCli/Command/ListBoardsCommand.php --verbose
[Phpcs] cwd: /Users/ben
[Phpcs] F
Legend: ?-unknown, I-invalid file syntax, file ignored, .-no changes, F-fixed, E-error
1) /Users/Ben/git/external/trello-cli/src/TrelloCli/Command/ListBoardsCommand.php (blankline_after_open_tag, concat_without_spaces, multiple_use, phpdoc_short_description, no_empty_lines_after_phpdocs, single_blank_line_before_namespace, unused_use, braces)
Fixed all files in 0.209 seconds, 6.000 MB memory used
What version of php-ca-fixer are you using? I'm using 1.9
Is this Sublime Text 3 btw?
@benmatselby
Same here. It's been working just fine for me. It just stopped working a few days ago.
I'm using php-cs-fixer 1.9 and I'm on Sublime Text 3.
It works just fine from the terminal.
Hi @moon0326
Anything to do with the double / in the path?
Also, it's nothing related to line endings or the encoding of the file is it?
@benmatselby That's my mistake. There was a dir name between / and /. I removed it since it's a company project. In the actual log, the path is correct.
I don't think it has anything to do with file encoding since it works when I run the exact command (copy and paste) from the terminal manually.
I think I've figured out what is wrong here. This happens when your PHP file contains newer PHP syntax than what's available in the version of PHP that php-cs-fixer
is running on. For example, on my system if I use the new ClassName::class
feature in PHP (available since PHP 5.5), I'll get the invalid file syntax
response. This is because my system (OSX Mavericks) has PHP 5.4 installed by default. Now, I do all my development on PHP 5.6 (installed with Homebrew), but for some reason this plugin still runs php-cs-fixer
on PHP 5.4 (the system default).
I've tried to append the full path to my PHP 5.6 install in the configuration (php_cs_fixer_executable_path
), but that resulted in other errors. I think this plugin simply needs a php_cs_fixer_php_path
option, which is appended before running php-cs-fixer
.
@reinink You can do this already by setting the phpcs_commands_to_php_prefix
config item. Please see https://github.com/benmatselby/sublime-phpcs/blob/master/example-settings/windows-7-phpcs-fixer-linter.example as an example..
If you define the array in there, it will then prefix the PHP path to it.
Hey Ben, thanks, but it's still not working. Are you sure it adds it to the php-cs-fixer
command as well? I just tried, and enabled the console and I got:
[Phpcs] /Users/jonathan/.composer/vendor/bin/php-cs-fixer fix /Users/jonathan/Sites/subhub/api/tests/Absences/Services/SubFinderTest.php --verbose --level=psr2 --fixers=strict,strict_param,ordered_use,multiline_spaces_before_semicolon,short_array_syntax,concat_without_spaces,double_arrow_multiline_whitespaces,duplicate_semicolon,empty_return,extra_empty_lines,include,multiline_array_trailing_comma,namespace_no_leading_whitespace,new_with_braces,object_operator,operators_spaces,phpdoc_params,remove_leading_slash_use,remove_lines_between_uses,return,single_array_no_trailing_comma,spaces_before_semicolon,spaces_cast,standardize_not_equal,ternary_spaces,unused_use,whitespacy_lines
[Phpcs] /Users/jonathan/.composer/vendor/bin/php-cs-fixer fix /Users/jonathan/Sites/subhub/api/tests/Absences/Services/SubFinderTest.php --verbose --level=psr2 --fixers=strict,strict_param,ordered_use,multiline_spaces_before_semicolon,short_array_syntax,concat_without_spaces,double_arrow_multiline_whitespaces,duplicate_semicolon,empty_return,extra_empty_lines,include,multiline_array_trailing_comma,namespace_no_leading_whitespace,new_with_braces,object_operator,operators_spaces,phpdoc_params,remove_leading_slash_use,remove_lines_between_uses,return,single_array_no_trailing_comma,spaces_before_semicolon,spaces_cast,standardize_not_equal,ternary_spaces,unused_use,whitespacy_lines
[Phpcs] cwd: /Users/jonathan
[Phpcs] I
Legend: ?-unknown, I-invalid file syntax, file ignored, .-no changes, F-fixed, E-error
What I'm looking for is:
/usr/local/opt/php55/bin/php /Users/jonathan/.composer/vendor/bin/php-cs-fixer fix /Users/jonathan/Sites/subhub/api/tests/Absences/Services/SubFinderTest.php --verbose --level=psr2 --fixers=strict,strict_param,ordered_use,multiline_spaces_before_semicolon,short_array_syntax,concat_without_spaces,double_arrow_multiline_whitespaces,duplicate_semicolon,empty_return,extra_empty_lines,include,multiline_array_trailing_comma,namespace_no_leading_whitespace,new_with_braces,object_operator,operators_spaces,phpdoc_params,remove_leading_slash_use,remove_lines_between_uses,return,single_array_no_trailing_comma,spaces_before_semicolon,spaces_cast,standardize_not_equal,ternary_spaces,unused_use,whitespacy_lines
Any ideas?
@reinink
Just checked on my install (at a machine now).
You need to define
"phpcs_commands_to_php_prefix": ["Fixer"],
"phpcs_php_prefix_path": "/usr/local/opt/php55/bin/php"
In your config.
This is on Line 250 of the plugin
Just ran this on my machine:
[Phpcs] /usr/local/opt/php56/bin/php /Users/ben/.composer/vendor/bin/php-cs-fixer fix /Users/Ben/git/external/trello-cli/src/TrelloCli/Command/LabelCardsCommand.php --verbose
@reinink Did this resolve it for you?
Yes and no. Been meaning to do more testing, but haven't had a chance yet.
It did in fact add "/usr/local/opt/php55/bin/php" before the command, which is what I wanted. But, much to my disappointment, it did not resolve the original issue. So now I'm really puzzled. Only thing I can think is that simple putting "/usr/local/opt/php55/bin/php" before the "php-cs-fixer" may not actually make php-cs-fixer run on that version of PHP.
So yeah, more testing required yet.
I have the same issue in ST3, using php and php-cs-fixer binaries installed by Homebrew on OS X.
Initial problem:
[Phpcs] Fixer
[Phpcs] /usr/local/bin/php-cs-fixer fix /Users/myuser/path/to/MyFile.php --verbose --config-file=/Users/myuser/path/to/.php_cs
[Phpcs] /usr/local/bin/php-cs-fixer fix /Users/myuser/path/to/MyFile.php --verbose --config-file=/Users/myuser/path/to/.php_cs
[Phpcs] cwd: /Users/myuser
[Phpcs] Loaded config from "/Users/myuser/path/to/.php_cs"
I
Legend: ?-unknown, I-invalid file syntax, file ignored, .-no changes, F-fixed, E-error
Fixed all files in 0.084 seconds, 5.500 MB memory used
The same command run from the command line finishes without any problem.
After prepending php settings as suggested:
[Phpcs] Fixer
[Phpcs] /usr/local/bin/php /usr/local/bin/php-cs-fixer fix /Users/myname/path/to/MyFile.php --verbose --config-file=/Users/myname/path/to/.php_cs
[Phpcs] /usr/local/bin/php /usr/local/bin/php-cs-fixer fix /Users/myname/path/to/MyFile.php --verbose --config-file=/Users/myname/path/to/.php_cs
[Phpcs] cwd: /Users/myname
[Phpcs]
/usr/bin/env php -d allow_url_fopen=On -d detect_unicode=Off /usr/local/Cellar/php-cs-fixer/1.10/libexec/php-cs-fixer.phar $*
Some more info
$ php -v
PHP 5.6.14 (cli) (built: Oct 3 2015 14:46:59)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
$ /usr/bin/php -v
PHP 5.5.29 (cli) (built: Sep 6 2015 20:20:34)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
$ php-cs-fixer --version
PHP CS Fixer version 1.10 by Fabien Potencier
I too have this exact same issue. When I call the fixer from Sublime Text 3, I get a
[Phpcs] Fixer
[Phpcs] C:\Program Files\php\php.exe C:\Program Files\php\pear\php-cs-fixer.phar fix C:\class_user.php --verbose --level=psr2
[Phpcs] C:\Program Files\php\php.exe C:\Program Files\php\pear\php-cs-fixer.phar fix C:\class_user.php --verbose --level=psr2
[Phpcs] cwd: C:\Users\pilger
[Phpcs] I
Legend: ?-unknown, I-invalid file syntax, file ignored, .-no changes, F-fixed, E-error
And when I paste the exact same command [Phpcs] gave me on console, only adding some quotes to admit the spaces on the path, like: "C:\Program Files\php\php.exe" "C:\Program Files\php\pear\php-cs-fixer.phar" fix C:\class_user.php --verbose --level=psr2
, the file gets fixed just fine:
C:\Program Files\php>"C:\Program Files\php\php.exe" "C:\Program Files\php\pear\php-cs-fixer.phar" fix C:\class_user.php --verbose --level=psr2
F
Legend: ?-unknown, I-invalid file syntax, file ignored, .-no changes, F-fixed, E-error
1) C:\class_user.php (psr0, braces)
Fixed all files in 0.210 seconds, 6.000 MB memory used
What do I need to provide in order to help solving this?
From "159 closed :
Thanks Ben
I figured out that
"php_cs_fixer_executable_path": "C:\\wamp\\tools\\php-cs-fixer.**phar**"
, and not .bat.
So I changed to
"php_cs_fixer_executable_path": "C:\\wamp\\tools\\php-cs-fixer.bat",
Then after running php cs fixer, I get that in the console :+1:
[Phpcs] Fixer [Phpcs] C:\wamp\bin\php\php5.5.12\php.exe C:\wamp\tools\php-cs-fixer.bat fix E:\Users\Denis\Documents\AW\Astuces&Technique\PrestaShop\Modules nouveaux\Gift List Pro\ps1.7x\100_blockgiftlistpro_v1.700\blockgiftlistpro\managewishlistdetailDD-TEST.php --verbose [Phpcs] C:\wamp\bin\php\php5.5.12\php.exe C:\wamp\tools\php-cs-fixer.bat fix E:\Users\Denis\Documents\AW\Astuces&Technique\PrestaShop\Modules nouveaux\Gift List Pro\ps1.7x\100_blockgiftlistpro_v1.700\blockgiftlistpro\managewishlistdetailDD-TEST.php --verbose [Phpcs] cwd: E:\Users\Denis [Phpcs] "C:\wamp\bin\php\php5.5.12\php.exe" "C:\wamp\tools\php-cs-fixer.phar" %*
And that's all. Nothing happens. Do you have any idea of the reason ?
Looking forward to hearing from you, Regards Denis
Hi,
I noticed my php-cs-fixer stopped working. I've enabled show_debug and looked at the log messages.
When I copy and paste the same command from the console to my terminal, it works just fine.
I've checked my php path and all the configurations and they look just fine.
Where should I look?