Jump to content

Trouble with PrestaShop standard for PHP CodeSniffer?


hostjars

Recommended Posts

I'd really like to utilize the validator when creating addons for PrestaShop.

Following the instructions (http://doc.prestashop.com/display/PS15/Coding+Standards#CodingStandards-PhpStormintegration), I've downloaded the zip from  https://github.com/PrestaShop/PrestaShop-norm-validator, and placed the contents in Codesniffer's /Standards folder. I specified the path to the phpcs executable and set PrestaShop as the standard. Both in phpstorm and command-line, I get the following error:

PHP Fatal error:  Cannot redeclare class Prestashop_Sniffs_CodeAnalysis_DisallowSizeFunctionsInLoopsSniff in /usr/share/php/PHP/CodeSniffer/Standards/PrestaShop/Sniffs/CodeAnalysis/DisallowSizeFunctionsInLoopsSniff.php on line 54

When I use "phpcs -i" command line, I see PrestaShop installed in the list of coding standards; so not sure what the problem is. Anyone experience this error before and found a solution?

Thanks in advance for your help!
 

Link to comment
Share on other sites

  • 11 months later...

Hello Hostjars,

 

Just to let you know that we also get some troubles with the CodeSniffer standard. The Prestashop patterns are written and tested with a specific release of CodeSniffer and you may get troubles if you are not using the same version than developpers.

 

You can ask for git changes onto the git repository but this require advance testing with several codesniffer versions.

Link to comment
Share on other sites

As an exemple, here is one easy fix error that we get with 2.0.0 of CodeSniffer :

PHP Fatal error:  Access level to Prestashop_Sniffs_PHP_DeprecatedFunctionsSniff::$forbiddenFunctions must be public (as in class Generic_Sniffs_PHP_ForbiddenFunctionsSniff) in /usr/share/php/PHP/CodeSniffer/Standards/Prestashop/Sniffs/PHP/DeprecatedFunctionsSniff.php on line 59

You can easily fix it by replacing the "protected" keyword by "public" keyword on the specified line

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...