cakephp / cakephp-codesniffer

CakePHP Code Sniffer
http://cakephp.org
MIT License
238 stars 84 forks source link

CakePHP 2.0 standards with phpcs 2.x #142

Closed HaroldPutman closed 8 years ago

HaroldPutman commented 9 years ago

I tried using the CakePHP 2 coding standards by checking out release 1.0.0 of this project, but I get an exception caused by dependencies on classes from old version of phpcs. (should have checked composer.json first).

I still have to deal with some CakePHP 2.x code. Would it make sense to have a version of the CakePHP2 standards that works with newer phpcs? That looks like it might be a lot of work.

PHP Fatal error:  Uncaught exception 'PHP_CodeSniffer_Exception' with message 'Class PHP_CodeSniffer_CommentParser_FunctionCommentParser not found' in /Users/hputman/Library/cakephp2-codesniffer/CakePHP/Sniffs/Commenting/FunctionCommentSniff.php:17
Stack trace:
#0 /usr/local/Cellar/php-code-sniffer/2.3.4/CodeSniffer.php(1324): include_once()
#1 /usr/local/Cellar/php-code-sniffer/2.3.4/CodeSniffer.php(560): PHP_CodeSniffer->registerSniffs(Array, Array)
#2 /usr/local/Cellar/php-code-sniffer/2.3.4/CodeSniffer/CLI.php(818): PHP_CodeSniffer->initStandard(Array, Array)
#3 /usr/local/Cellar/php-code-sniffer/2.3.4/CodeSniffer/CLI.php(95): PHP_CodeSniffer_CLI->process()
#4 /usr/local/Cellar/php-code-sniffer/2.3.4/scripts/phpcs(25): PHP_CodeSniffer_CLI->runphpcs()
#5 {main}
  thrown in /Users/hputman/Library/cakephp2-codesniffer/CakePHP/Sniffs/Commenting/FunctionCommentSniff.php on line 17

Fatal error: Uncaught exception 'PHP_CodeSniffer_Exception' with message 'Class PHP_CodeSniffer_CommentParser_FunctionCommentParser not found' in /Users/hputman/Library/cakephp2-codesniffer/CakePHP/Sniffs/Commenting/FunctionCommentSniff.php:17
Stack trace:
#0 /usr/local/Cellar/php-code-sniffer/2.3.4/CodeSniffer.php(1324): include_once()
#1 /usr/local/Cellar/php-code-sniffer/2.3.4/CodeSniffer.php(560): PHP_CodeSniffer->registerSniffs(Array, Array)
#2 /usr/local/Cellar/php-code-sniffer/2.3.4/CodeSniffer/CLI.php(818): PHP_CodeSniffer->initStandard(Array, Array)
#3 /usr/local/Cellar/php-code-sniffer/2.3.4/CodeSniffer/CLI.php(95): PHP_CodeSniffer_CLI->process()
#4 /usr/local/Cellar/php-code-sniffer/2.3.4/scripts/phpcs(25): PHP_CodeSniffer_CLI->runphpcs()
#5 {main}
  thrown in /Users/hputman/Library/cakephp2-codesniffer/CakePHP/Sniffs/Commenting/FunctionCommentSniff.php on line 17
ravage84 commented 9 years ago

Sure it would make sense, but as you already pointed it out: It might be [hell of] a lot work :smirk_cat:

Until there is a phpcs 2.x compatible version of the CakePHP 2.x CS, I recommend you to use Composer to manage the phpcs 1.5.x dependency for your 2.x applications. Works well for me, at least.

markstory commented 9 years ago

Yes its a pile of work which is why it has not been done. I agree with @ravage84 and that you should use composer to manage dependencies.