eviweb / fuelphp-phpcs

PHP Code Sniffer standard for Fuel PHP
MIT License
27 stars 12 forks source link

Broke with PHP_CodeSniffer #9

Closed tete2soja closed 5 years ago

tete2soja commented 5 years ago

Hello,

I'm really happy to find it to check my fuelPHP project. But, we can't run your rules set with PHP_CodeSniffer because something seems change in the base code. Can you update or tell me which version I can use to run the ruleset without errors ?

PHP Fatal error:  Uncaught Error: Class 'PHP_CodeSniffer_Exception' not found in /usr/share/pear/PHP/CodeSniffer/src/Standards/FuelPHP/Sniffs/NamingConventions/ConciseUnderscoredVariableNameSniff.php:16
Stack trace:
#0 /usr/share/pear/PHP/CodeSniffer/autoload.php(167): include()
#1 /usr/share/pear/PHP/CodeSniffer/src/Ruleset.php(1129): PHP_CodeSniffer\Autoload::loadFile('/usr/share/pear...')
#2 /usr/share/pear/PHP/CodeSniffer/src/Ruleset.php(217): PHP_CodeSniffer\Ruleset->registerSniffs(Array, Array, Array)
#3 /usr/share/pear/PHP/CodeSniffer/src/Runner.php(294): PHP_CodeSniffer\Ruleset->__construct(Object(PHP_CodeSniffer\Config))
#4 /usr/share/pear/PHP/CodeSniffer/src/Runner.php(70): PHP_CodeSniffer\Runner->init()
#5 /usr/bin/phpcs(18): PHP_CodeSniffer\Runner->runPHPCS()
#6 {main}
  thrown in /usr/share/pear/PHP/CodeSniffer/src/Standards/FuelPHP/Sniffs/NamingConventions/ConciseUnderscoredVariableNameSniff.php on line 16

Thanks in advance :heart:

eviweb commented 5 years ago

Hi @Darkitty, thanks for reporting. I missed to specify the PHP Code Sniffer version, it's done now and fixed in v1.0.8. For your information the current supported PHP Code Sniffer version is 2.x. The correct PHP Code Sniffer version is locally installed when using the composer installation way, which I hardly recommend. Please refer to README. Don't hesitate to come back if something remains broken. Best regards

tete2soja commented 5 years ago

Hi,

Perfect. I use the 2.9.0 of phpcs and works perfectly :heart: (pear install PHP_CodeSniffer-2.9.0)

jonnyijapan commented 5 years ago

I think you should put the 2.9.x requirement in the readme - I couldn't install using composer or any other method due to other issues - installing 2.9.2 of phpcs manually worked. https://github.com/squizlabs/PHP_CodeSniffer/releases/tag/2.9.2

eviweb commented 5 years ago

hi @jonnyijapan, thanks for reporting and the suggestion. PHPCS requirement is now added to the readme. May you please explain what was going wrong with the composer install ? thanks

jonnyijapan commented 5 years ago

Composer.json has php 5.x something as a requirement. I have 7.x on my Mac and don't think I will change that really.

eviweb commented 5 years ago

composer.json has PHP version 5.3.3 as minimal version. I also run PHP 7.x and don't encounter any issue. I'm surprised. So if you get some time to give me more details about error messages, I would appreciate. Thanks

jonnyijapan commented 5 years ago

Since I tried adding using my Mac having php 7 it failed out because php version is set to 5 in composer.json. I think that was the error, from what I remember. I guess if I ran the install on the actual service environment it might have worked. However phpcs should not be in production environments for that matter.(?)

Got it working by manually installing phpcs however.

A side note is that it seems like it would be nice if this standard could support the latest phpcs (3.x). The beautifier and/or related extension for vscode seems to have some problems and I suspect it might be because of not using the latest phpcs/beautifier version.

eviweb commented 5 years ago

Hi @jonnyijapan thanks for the precision and the suggestion. Unfortunately, I currently have no time to work on this enhancement. I opened an issue #10 as a reminder, but feel free to contribute ;)