Question

On our CI servers we run PHP codesniffer and phpmd. Some of issues raised are false-positive. How can I disable certain parts of PHP file to be analysed by those (as @SupressWarning(...) in Java) ? Thanks!

Was it helpful?

Solution

Taken from the documentation. First hit after doing a Google search for disable parts of a file codesniffer php

Ignoring parts of a file using comments


$xmlPackage = new XMLPackage;
// @codingStandardsIgnoreStart
$xmlPackage['error_code'] = get_default_error_code_value();
// @codingStandardsIgnoreEnd
$xmlPackage->send();

http://pear.php.net/manual/en/package.php.php-codesniffer.advanced-usage.php

Is this what you mean?

As for PHP-MD...

http://phpmd.org/documentation/suppress-warnings.html

Two clicks from

http://phpmd.org/

I'm not normally the kind to say this, but it would be much quicker for you if you read the documentation (which it seems you did, as I edited this answer!)

OTHER TIPS

For PHPMD it is: @SuppressWarnings(PHPMD) @SuppressWarnings(PHPMD.UnusedLocalVariable)

http://phpmd.org/documentation/suppress-warnings.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top