antonioribeiro / laravelcs

Laravel PHP_CodeSniffer
BSD 3-Clause "New" or "Revised" License
234 stars 32 forks source link

Getting an error when trying to run #2

Closed jwalton512 closed 9 years ago

jwalton512 commented 9 years ago

I installed globally via composer

Getting the error below when I try to run with Laravel Standard

ERROR: the "~/.composer/vendor/pragmarx/laravelcs/Standards/Laravel" coding standard is not installed. The installed coding standards are MySource, PEAR, PHPCS, PSR1, PSR2, Squiz and Zend

Just running phpcs works fine.

antonioribeiro commented 9 years ago

Check if you have a folder ~/.composer/vendor/pragmarx/laravelcs

On Linux/Mac:

ls -la  ~/.composer/vendor/pragmarx/laravelcs
jwalton512 commented 9 years ago

Yep, that directory is there -- here are a few pertinent results:

➜  ~  ls -lah ~/.composer/vendor/pragmarx/laravelcs
total 24
drwxr-xr-x   7 jason  staff   238B Dec  9 07:57 .
drwxr-xr-x   3 jason  staff   102B Dec  9 07:57 ..
drwxr-xr-x  15 jason  staff   510B Dec  9 07:57 .git
-rw-r--r--   1 jason  staff   1.5K Dec  9 07:57 LICENSE
drwxr-xr-x   4 jason  staff   136B Dec  9 07:57 Standards
-rw-r--r--   1 jason  staff   455B Dec  9 07:57 composer.json
-rw-r--r--   1 jason  staff   2.7K Dec  9 07:57 readme.md
➜  ~  phpcs ~/Development/laravel-framework/src/Illuminate/Cache/Console/CacheTableCommand.php

FILE: ...nt/laravel-framework/src/Illuminate/Cache/Console/CacheTableCommand.php
--------------------------------------------------------------------------------
FOUND 98 ERRORS AFFECTING 60 LINES
--------------------------------------------------------------------------------
  1 | ERROR | [ ] Missing file doc comment
  7 | ERROR | [ ] Missing class doc comment
  7 | ERROR | [x] Opening brace of a class must be on the line after the
    |       |     definition

... shortened for brevity
➜  ~  phpcs --standard=~/.composer/vendor/pragmarx/laravelcs/Standards/Laravel ~/Development/laravel-framework/src/Illuminate/Cache/Console/CacheTableCommand.php
ERROR: the "~/.composer/vendor/pragmarx/laravelcs/Standards/Laravel" coding standard is not installed. The installed coding standards are MySource, PEAR, PHPCS, PSR1, PSR2, Squiz and Zend
antonioribeiro commented 9 years ago

That was tough. Looks like PHP_CodeSniffer doesn't accept standards inside hidden folders like ~/.composer, so copying it to /tmp worked:

cp -a ~/.composer/vendor/pragmarx/laravelcs /tmp
phpcs -v --standard=/tmp/laravelcs/Standards/Laravel/ /tmp/laravelcs/Standards/TestFiles/Filesystem.php

Now I just have to fix this... :(

/cc @mvpasarel

antonioribeiro commented 9 years ago

Looks like they knew & fixed it:

http://pear.php.net/package/PHP_CodeSniffer/download/All

This should work on 2.0.0RC2, but I have 2.0.0 (stable) and it's not.

antonioribeiro commented 9 years ago

Not sure if it was fixed here or not: https://github.com/squizlabs/PHP_CodeSniffer/issues/254

mvpasarel commented 9 years ago

Hmm... The problem seems to be from the ~/ because I actually tested it with /Users/mvpasarel/.composer/... and is working with .composer hidden directory.

I can change the readme to use the full path only.

@xsbeats Can you try with the full path please?

antonioribeiro commented 9 years ago

You're right! I'll change it. Thanks.

mvpasarel commented 9 years ago

While you're there, I have a typo as well at Usage wih, please change that too. Thanks.

antonioribeiro commented 9 years ago

Done and done.

You can run it using:

phpcs -v --standard=$HOME/.composer/vendor/pragmarx/laravelcs/Standards/Laravel /path/to/folder/or/file
antonioribeiro commented 9 years ago

I also opened an issue on CodeSniffer: https://github.com/squizlabs/PHP_CodeSniffer/issues/353, they should use realpath() to convert those paths before start to traverse them...

antonioribeiro commented 9 years ago

I also created a pull request to fix it on CodeSniffer: https://github.com/squizlabs/PHP_CodeSniffer/pull/354/files

jwalton512 commented 9 years ago

thanks @antonioribeiro @mvpasarel. working great now!