Search code examples
phpphpcodesniffer

Ignore code snippets in PHP_CodeSniffer


It is possible to ignore some parts of code from a php file when it's analyzed by PHP_CodeSniffer?


Solution

  • Yes it is possible with @codingStandardsIgnoreStart and @codingStandardsIgnoreEnd annotations

    <?php
    some_code();
    // @codingStandardsIgnoreStart
    this_will_be_ignored();
    // @codingStandardsIgnoreEnd
    some_other_code();
    

    It is also described in the documentation.