Closed jcloutz closed 9 years ago
@jcloutz Can you please set show_debug = true, and then paste in the different commands from the console please. This just shells out the commands to php-cs-fixer, so we need to see what is running underneath
Thanks
I figured out what is happening.
Laravel 5 places everything in the app/
folder but declares the App
namespace for autoloading purposes in the composer.json file.
"autoload": {
"psr-4": {
"App\\": "app/",
}
}
It looks like PHP CS Fixer doesn't take the composer.json file into account and is altering the namespace to match the file path.
[Phpcs] Linter found 0 errors
[Phpcs] Sniffer found 0 errors
[Phpcs] Project files:
[Phpcs] Current: None
[Phpcs] Last Known: None
[Phpcs] No project file defined, therefore skipping reload
[Phpcs] /usr/local/bin/php-cs-fixer fix /Users/jeremyc/develop/eve-mrp/app/Models/Blueprint.php --verbose
[Phpcs] /usr/local/bin/php-cs-fixer fix /Users/jeremyc/develop/eve-mrp/app/Models/Blueprint.php --verbose
[Phpcs] cwd: /Users/jeremyc
[Phpcs] F
Legend: ?-unknown, I-invalid file syntax, file ignored, .-no changes, F-fixed, E-error
1) /Users/jeremyc/develop/eve-mrp/app/Models/Blueprint.php (psr0)
Fixed all files in 0.213 seconds, 5.750 MB memory used
[Phpcs] /usr/bin/php -l -d display_errors=On /Users/jeremyc/develop/eve-mrp/app/Models/Blueprint.php
[Phpcs] /usr/bin/php -l -d display_errors=On /Users/jeremyc/develop/eve-mrp/app/Models/Blueprint.php
[Phpcs] cwd: /Users/jeremyc
[Phpcs] No syntax errors detected in /Users/jeremyc/develop/eve-mrp/app/Models/Blueprint.php
[Phpcs] /Users/jeremyc/pear/bin/phpcs --report=checkstyle -n --standard=PSR2 /Users/jeremyc/develop/eve-mrp/app/Models/Blueprint.php
[Phpcs] /Users/jeremyc/pear/bin/phpcs --report=checkstyle -n --standard=PSR2 /Users/jeremyc/develop/eve-mrp/app/Models/Blueprint.php
[Phpcs] cwd: /Users/jeremyc
[Phpcs] <?xml version="1.0" encoding="UTF-8"?>
<checkstyle version="2.3.2">
</checkstyle>
[Phpcs] Linter found 0 errors
[Phpcs] Sniffer found 0 errors
reloading /Users/jeremyc/develop/eve-mrp/app/Models/Blueprint.php
@jcloutz Can we close this down then please?
Yeah, I ended up just changing the namespace path to uppercase.
I fixed this in Vim by adding --fixers=-psr0 (please note the minus sign before psr0). Maybe that will work for you in Sublime.
Building off of @olimorris 's tip, just add this to the phpcs.sublime-settings file (Preferences -> Package Settings -> PHP Code Sniffer -> Settings - User):
"php_cs_fixer_additional_args": { "--fixers": "-psr0" },
And to fix in Atom, based on @olimorris's advice, simply add -psr0
to the Fixers input for pfefferle/atom-php-cs-fixer and your namespaces will be safe!
I am having a very strange issue when using
"php_cs_fixer_on_save": true
. When I save a class file the namespace is automatically lowercased for some reason. For instanceIs converted to
This only happens when php_cs_fixer_on_save is true. If i right click the folder and run it from the context menu it is it doesn't effect the capitalization, and same goes for running php-ca-fixer from the command line.
It may be an issue with php-cs-fixer itself but I cannot duplicate it unless I am using sublime-phpcs.