Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php namespace PHP_CodeSniffer\Tests\Core; use PHP_CodeSniffer\Config; use PHP_CodeSniff..

Decoded Output download

<?php
 namespace PHP_CodeSniffer\Tests\Core; use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Files\DummyFile; use PHPUnit\Framework\TestCase; class ErrorSuppressionTest extends TestCase { public function testSuppressError($before, $after, $expectedErrors = 0) { static $config, $ruleset; if (isset($config, $ruleset) === false) { $config = new Config(); $config->standards = array("Generic"); $config->sniffs = array("Generic.PHP.LowerCaseConstant"); $ruleset = new Ruleset($config); } $content = "<?php " . PHP_EOL . $before . "$var = FALSE;" . PHP_EOL . $after; $file = new DummyFile($content, $ruleset, $config); $file->process(); $this->assertSame($expectedErrors, $file->getErrorCount()); $this->assertCount($expectedErrors, $file->getErrors()); } public function dataSuppressError() { return array("no suppression" => array("before" => '', "after" => '', "expectedErrors" => 1), "disable/enable: slash comment" => array("before" => "// phpcs:disable" . PHP_EOL, "after" => "// phpcs:enable"), "disable/enable: multi-line slash comment, tab indented" => array("before" => "\x9" . "// For reasons" . PHP_EOL . "\x9" . "// phpcs:disable" . PHP_EOL . "\x9", "after" => "\x9" . "// phpcs:enable"), "disable/enable: slash comment, with @" => array("before" => "// @phpcs:disable" . PHP_EOL, "after" => "// @phpcs:enable"), "disable/enable: slash comment, mixed case" => array("before" => "// PHPCS:Disable" . PHP_EOL, "after" => "// pHPcs:enabLE"), "disable/enable: hash comment" => array("before" => "# phpcs:disable" . PHP_EOL, "after" => "# phpcs:enable"), "disable/enable: multi-line hash comment, tab indented" => array("before" => "	" . "# For reasons" . PHP_EOL . "	" . "# phpcs:disable" . PHP_EOL . "	", "after" => "\x9" . "# phpcs:enable"), "disable/enable: hash comment, with @" => array("before" => "# @phpcs:disable" . PHP_EOL, "after" => "# @phpcs:enable"), "disable/enable: hash comment, mixed case" => array("before" => "# PHPCS:Disable" . PHP_EOL, "after" => "# pHPcs:enabLE"), "disable/enable: star comment" => array("before" => "/* phpcs:disable */" . PHP_EOL, "after" => "/* phpcs:enable */"), "disable/enable: multi-line star comment" => array("before" => "/*" . PHP_EOL . " phpcs:disable" . PHP_EOL . " */" . PHP_EOL, "after" => "/*" . PHP_EOL . " phpcs:enable" . PHP_EOL . " */"), "disable/enable: multi-line star comment, each line starred" => array("before" => "/*" . PHP_EOL . " * phpcs:disable" . PHP_EOL . " */" . PHP_EOL, "after" => "/*" . PHP_EOL . " * phpcs:enable" . PHP_EOL . " */"), "disable/enable: multi-line star comment, each line starred, tab indented" => array("before" => "\x9" . "/*" . PHP_EOL . "\x9" . " * phpcs:disable" . PHP_EOL . "	" . " */" . PHP_EOL . "\x9", "after" => "\x9" . "/*" . PHP_EOL . " * phpcs:enable" . PHP_EOL . " */"), "disable/enable: single line docblock comment" => array("before" => "/** phpcs:disable */" . PHP_EOL, "after" => "/** phpcs:enable */"), "old style: slash comment" => array("before" => "// @codingStandardsIgnoreStart" . PHP_EOL, "after" => "// @codingStandardsIgnoreEnd"), "old style: star comment" => array("before" => "/* @codingStandardsIgnoreStart */" . PHP_EOL, "after" => "/* @codingStandardsIgnoreEnd */"), "old style: multi-line star comment" => array("before" => "/*" . PHP_EOL . " @codingStandardsIgnoreStart" . PHP_EOL . " */" . PHP_EOL, "after" => "/*" . PHP_EOL . " @codingStandardsIgnoreEnd" . PHP_EOL . " */"), "old style: single line docblock comment" => array("before" => "/** @codingStandardsIgnoreStart */" . PHP_EOL, "after" => "/** @codingStandardsIgnoreEnd */")); } public function testSuppressSomeErrors($before, $between, $expectedErrors = 1) { static $config, $ruleset; if (isset($config, $ruleset) === false) { $config = new Config(); $config->standards = array("Generic"); $config->sniffs = array("Generic.PHP.LowerCaseConstant"); $ruleset = new Ruleset($config); } $content = "<?php
{$before}\xa$var = FALSE;
{$between}
$var = TRUE;"; $file = new DummyFile($content, $ruleset, $config); $file->process(); $this->assertSame($expectedErrors, $file->getErrorCount()); $this->assertCount($expectedErrors, $file->getErrors()); } public function dataSuppressSomeErrors() { return array("no suppression" => array("before" => '', "between" => '', "expectedErrors" => 2), "disable/enable: slash comment" => array("before" => "// phpcs:disable", "between" => "// phpcs:enable"), "disable/enable: slash comment, with @" => array("before" => "// @phpcs:disable", "between" => "// @phpcs:enable"), "disable/enable: hash comment" => array("before" => "# phpcs:disable", "between" => "# phpcs:enable"), "disable/enable: hash comment, with @" => array("before" => "# @phpcs:disable", "between" => "# @phpcs:enable"), "disable/enable: single line docblock comment" => array("before" => "/** phpcs:disable */", "between" => "/** phpcs:enable */"), "old style: slash comment" => array("before" => "// @codingStandardsIgnoreStart", "between" => "// @codingStandardsIgnoreEnd"), "old style: single line docblock comment" => array("before" => "/** @codingStandardsIgnoreStart */", "between" => "/** @codingStandardsIgnoreEnd */")); } public function testSuppressWarning($before, $after, $expectedWarnings = 0) { static $config, $ruleset; if (isset($config, $ruleset) === false) { $config = new Config(); $config->standards = array("Generic"); $config->sniffs = array("Generic.Commenting.Todo"); $ruleset = new Ruleset($config); } $content = "<?php
{$before}\xa//TODO: write some code.\xa{$after}"; $file = new DummyFile($content, $ruleset, $config); $file->process(); $this->assertSame($expectedWarnings, $file->getWarningCount()); $this->assertCount($expectedWarnings, $file->getWarnings()); } public function dataSuppressWarning() { return array("no suppression" => array("before" => '', "after" => '', "expectedWarnings" => 1), "disable/enable: slash comment" => array("before" => "// phpcs:disable", "after" => "// phpcs:enable"), "disable/enable: slash comment, with @" => array("before" => "// @phpcs:disable", "after" => "// @phpcs:enable"), "disable/enable: single line docblock comment" => array("before" => "/** phpcs:disable */", "after" => "/** phpcs:enable */"), "old style: slash comment" => array("before" => "// @codingStandardsIgnoreStart", "after" => "// @codingStandardsIgnoreEnd"), "old style: single line docblock comment" => array("before" => "/** @codingStandardsIgnoreStart */", "after" => "/** @codingStandardsIgnoreEnd */")); } public function testSuppressLine($before, $after = '', $expectedErrors = 1) { static $config, $ruleset; if (isset($config, $ruleset) === false) { $config = new Config(); $config->standards = array("Generic"); $config->sniffs = array("Generic.PHP.LowerCaseConstant"); $ruleset = new Ruleset($config); } $content = "<?php
{$before}\xa$var = FALSE;{$after}\xa$var = FALSE;"; $file = new DummyFile($content, $ruleset, $config); $file->process(); $this->assertSame($expectedErrors, $file->getErrorCount()); $this->assertCount($expectedErrors, $file->getErrors()); } public function dataSuppressLine() { return array("no suppression" => array("before" => '', "after" => '', "expectedErrors" => 2), "ignore: line before, slash comment" => array("before" => "// phpcs:ignore"), "ignore: line before, slash comment, with @" => array("before" => "// @phpcs:ignore"), "ignore: line before, hash comment" => array("before" => "# phpcs:ignore"), "ignore: line before, hash comment, with @" => array("before" => "# @phpcs:ignore"), "ignore: line before, star comment" => array("before" => "/* phpcs:ignore */"), "ignore: line before, star comment, with @" => array("before" => "/* @phpcs:ignore */"), "ignore: end of line, slash comment" => array("before" => '', "after" => " // phpcs:ignore"), "ignore: end of line, slash comment, with @" => array("before" => '', "after" => " // @phpcs:ignore"), "ignore: end of line, hash comment" => array("before" => '', "after" => " # phpcs:ignore"), "ignore: end of line, hash comment, with @" => array("before" => '', "after" => " # @phpcs:ignore"), "old style: line before, slash comment" => array("before" => "// @codingStandardsIgnoreLine"), "old style: end of line, slash comment" => array("before" => '', "after" => " // @codingStandardsIgnoreLine")); } public function testSuppressLineMidLine() { $config = new Config(); $config->standards = array("Generic"); $config->sniffs = array("Generic.PHP.LowerCaseConstant"); $ruleset = new Ruleset($config); $content = "<?php " . PHP_EOL . "$var = FALSE; /* @phpcs:ignore */ $var = FALSE;"; $file = new DummyFile($content, $ruleset, $config); $file->process(); $this->assertSame(0, $file->getErrorCount()); $this->assertCount(0, $file->getErrors()); } public function testSuppressLineWithinDocblock() { $config = new Config(); $config->standards = array("Generic"); $config->sniffs = array("Generic.Files.LineLength"); $ruleset = new Ruleset($config); $comment = str_repeat("a ", 50); $content = "<?php\xa/**\xa * Comment here
 * @phpcs:ignore
 * {$comment}\xa */"; $file = new DummyFile($content, $ruleset, $config); $file->process(); $this->assertSame(0, $file->getErrorCount()); $this->assertCount(0, $file->getErrors()); } public function testNestedSuppressLine($before, $after) { static $config, $ruleset; if (isset($config, $ruleset) === false) { $config = new Config(); $config->standards = array("Generic"); $config->sniffs = array("Generic.PHP.LowerCaseConstant"); $ruleset = new Ruleset($config); } $content = "<?php
{$before}\xa$var = FALSE;
$var = TRUE;
{$after}"; $file = new DummyFile($content, $ruleset, $config); $file->process(); $this->assertSame(0, $file->getErrorCount()); $this->assertCount(0, $file->getErrors()); } public function dataNestedSuppressLine() { return array("disable/enable: slash comment, no single line suppression" => array("before" => "// phpcs:disable", "after" => "// phpcs:enable"), "disable/enable: slash comment, with @, no single line suppression" => array("before" => "// @phpcs:disable", "after" => "// @phpcs:enable"), "disable/enable: hash comment, no single line suppression" => array("before" => "# phpcs:disable", "after" => "# phpcs:enable"), "old style: slash comment, no single line suppression" => array("before" => "// @codingStandardsIgnoreStart", "after" => "// @codingStandardsIgnoreEnd"), "disable/enable: slash comment, next line nested single line suppression" => array("before" => "// phpcs:disable" . PHP_EOL . "// phpcs:ignore", "after" => "// phpcs:enable"), "disable/enable: slash comment, with @, next line nested single line suppression" => array("before" => "// @phpcs:disable" . PHP_EOL . "// @phpcs:ignore", "after" => "// @phpcs:enable"), "disable/enable: hash comment, next line nested single line suppression" => array("before" => "# @phpcs:disable" . PHP_EOL . "# @phpcs:ignore", "after" => "# @phpcs:enable"), "old style: slash comment, next line nested single line suppression" => array("before" => "// @codingStandardsIgnoreStart" . PHP_EOL . "// @codingStandardsIgnoreLine", "after" => "// @codingStandardsIgnoreEnd")); } public function testSuppressScope($before, $after, $expectedErrors = 0) { static $config, $ruleset; if (isset($config, $ruleset) === false) { $config = new Config(); $config->standards = array("PEAR"); $config->sniffs = array("PEAR.Functions.FunctionDeclaration"); $ruleset = new Ruleset($config); } $content = "<?php " . PHP_EOL . $before . "$var = FALSE;" . $after . PHP_EOL . "$var = FALSE;"; $content = "<?php\xaclass MyClass() {
    {$before}
    function myFunction() {\xa        {$after}
        $this->foo();\xa    }\xa}"; $file = new DummyFile($content, $ruleset, $config); $file->process(); $this->assertSame($expectedErrors, $file->getErrorCount()); $this->assertCount($expectedErrors, $file->getErrors()); } public function dataSuppressScope() { return array("no suppression" => array("before" => '', "after" => '', "expectedErrors" => 1), "disable/enable: slash comment" => array("before" => "//phpcs:disable", "after" => "//phpcs:enable"), "disable/enable: slash comment, with @" => array("before" => "//@phpcs:disable", "after" => "//@phpcs:enable"), "disable/enable: hash comment" => array("before" => "#phpcs:disable", "after" => "#phpcs:enable"), "disable/enable: single line docblock comment" => array("before" => "/** phpcs:disable */", "after" => "/** phpcs:enable */"), "disable/enable: single line docblock comment, with @" => array("before" => "/** @phpcs:disable */", "after" => "/** @phpcs:enable */"), "old style: start/end, slash comment" => array("before" => "//@codingStandardsIgnoreStart", "after" => "//@codingStandardsIgnoreEnd"), "old style: start/end, single line docblock comment" => array("before" => "/** @codingStandardsIgnoreStart */", "after" => "/** @codingStandardsIgnoreEnd */")); } public function testSuppressFile($before, $after = '', $expectedWarnings = 0) { static $config, $ruleset; if (isset($config, $ruleset) === false) { $config = new Config(); $config->standards = array("Generic"); $config->sniffs = array("Generic.Commenting.Todo"); $ruleset = new Ruleset($config); } $content = "<?php\xa{$before}
class MyClass {}\xa$foo = new MyClass();
//TODO: write some code\xa{$after}"; $file = new DummyFile($content, $ruleset, $config); $file->process(); $this->assertSame($expectedWarnings, $file->getWarningCount()); $this->assertCount($expectedWarnings, $file->getWarnings()); } public function dataSuppressFile() { return array("no suppression" => array("before" => '', "after" => '', "expectedErrors" => 1), "ignoreFile: start of file, slash comment" => array("before" => "// phpcs:ignoreFile"), "ignoreFile: start of file, slash comment, with @" => array("before" => "// @phpcs:ignoreFile"), "ignoreFile: start of file, slash comment, mixed case" => array("before" => "// PHPCS:Ignorefile"), "ignoreFile: start of file, hash comment" => array("before" => "# phpcs:ignoreFile"), "ignoreFile: start of file, hash comment, with @" => array("before" => "# @phpcs:ignoreFile"), "ignoreFile: start of file, single-line star comment" => array("before" => "/* phpcs:ignoreFile */"), "ignoreFile: start of file, multi-line star comment" => array("before" => "/*" . PHP_EOL . " phpcs:ignoreFile" . PHP_EOL . " */"), "ignoreFile: start of file, single-line docblock comment" => array("before" => "/** phpcs:ignoreFile */"), "ignoreFile: late comment, slash comment" => array("before" => '', "after" => "// phpcs:ignoreFile"), "old style: start of file, slash comment" => array("before" => "// @codingStandardsIgnoreFile"), "old style: start of file, single-line star comment" => array("before" => "/* @codingStandardsIgnoreFile */"), "old style: start of file, multi-line star comment" => array("before" => "/*" . PHP_EOL . " @codingStandardsIgnoreFile" . PHP_EOL . " */"), "old style: start of file, single-line docblock comment" => array("before" => "/** @codingStandardsIgnoreFile */"), "old style: late comment, slash comment" => array("before" => '', "after" => "// @codingStandardsIgnoreFile")); } public function testDisableSelected($before, $expectedErrors = 0, $expectedWarnings = 0) { static $config, $ruleset; if (isset($config, $ruleset) === false) { $config = new Config(); $config->standards = array("Generic"); $config->sniffs = array("Generic.PHP.LowerCaseConstant", "Generic.Commenting.Todo"); $ruleset = new Ruleset($config); } $content = "<?php\xa{$before}\xa$var = FALSE;\xa//TODO: write some code"; $file = new DummyFile($content, $ruleset, $config); $file->process(); $this->assertSame($expectedErrors, $file->getErrorCount()); $this->assertCount($expectedErrors, $file->getErrors()); $this->assertSame($expectedWarnings, $file->getWarningCount()); $this->assertCount($expectedWarnings, $file->getWarnings()); } public function dataDisableSelected() { return array("disable: single sniff" => array("before" => "// phpcs:disable Generic.Commenting.Todo", "expectedErrors" => 1), "disable: single sniff with reason" => array("before" => "# phpcs:disable Generic.Commenting.Todo -- for reasons", "expectedErrors" => 1), "disable: single sniff, docblock" => array("before" => "/**" . PHP_EOL . " * phpcs:disable Generic.Commenting.Todo" . PHP_EOL . " */ ", "expectedErrors" => 1), "disable: single sniff, docblock, with @" => array("before" => "/**" . PHP_EOL . " * @phpcs:disable Generic.Commenting.Todo" . PHP_EOL . " */ ", "expectedErrors" => 1), "disable: multiple sniffs in one comment" => array("before" => "// phpcs:disable Generic.Commenting.Todo,Generic.PHP.LowerCaseConstant"), "disable: multiple sniff in multiple comments" => array("before" => "// phpcs:disable Generic.Commenting.Todo" . PHP_EOL . "// phpcs:disable Generic.PHP.LowerCaseConstant"), "disable: complete category" => array("before" => "// phpcs:disable Generic.Commenting", "expectedErrors" => 1), "disable: whole standard" => array("before" => "// phpcs:disable Generic"), "disable: single errorcode" => array("before" => "# @phpcs:disable Generic.Commenting.Todo.TaskFound", "expectedErrors" => 1), "disable: single errorcode and a category" => array("before" => "// phpcs:disable Generic.PHP.LowerCaseConstant.Found,Generic.Commenting"), "disable: wrong error code and category" => array("before" => "/**" . PHP_EOL . " * phpcs:disable Generic.PHP.LowerCaseConstant.Upper,Generic.Comments" . PHP_EOL . " */ ", "expectedErrors" => 1, "expectedWarnings" => 1), "disable: wrong category, docblock" => array("before" => "/**" . PHP_EOL . " * phpcs:disable Generic.Files" . PHP_EOL . " */ ", "expectedErrors" => 1, "expectedWarnings" => 1), "disable: wrong category, docblock, with @" => array("before" => "/**" . PHP_EOL . " * @phpcs:disable Generic.Files" . PHP_EOL . " */ ", "expectedErrors" => 1, "expectedWarnings" => 1)); } public function testEnableSelected($code, $expectedErrors, $expectedWarnings) { static $config, $ruleset; if (isset($config, $ruleset) === false) { $config = new Config(); $config->standards = array("Generic"); $config->sniffs = array("Generic.PHP.LowerCaseConstant", "Generic.Commenting.Todo"); $ruleset = new Ruleset($config); } $content = "<?php " . $code; $file = new DummyFile($content, $ruleset, $config); $file->process(); $this->assertSame($expectedErrors, $file->getErrorCount()); $this->assertCount($expectedErrors, $file->getErrors()); $this->assertSame($expectedWarnings, $file->getWarningCount()); $this->assertCount($expectedWarnings, $file->getWarnings()); } public function dataEnableSelected() { return array("disable/enable: a single sniff" => array("code" => "\xa                    // phpcs:disable Generic.Commenting.Todo
                    $var = FALSE;
                    //TODO: write some code\xa                    // phpcs:enable Generic.Commenting.Todo\xa                    //TODO: write some code", "expectedErrors" => 1, "expectedWarnings" => 1), "disable/enable: multiple sniffs" => array("code" => "\xa                    // phpcs:disable Generic.Commenting.Todo,Generic.PHP.LowerCaseConstant\xa                    $var = FALSE;
                    //TODO: write some code
                    // phpcs:enable Generic.Commenting.Todo,Generic.PHP.LowerCaseConstant\xa                    //TODO: write some code\xa                    $var = FALSE;", "expectedErrors" => 1, "expectedWarnings" => 1), "disable: multiple sniffs; enable: one" => array("code" => "
                    # phpcs:disable Generic.Commenting.Todo,Generic.PHP.LowerCaseConstant\xa                    $var = FALSE;\xa                    //TODO: write some code\xa                    # phpcs:enable Generic.Commenting.Todo\xa                    //TODO: write some code\xa                    $var = FALSE;", "expectedErrors" => 0, "expectedWarnings" => 1), "disable/enable: complete category" => array("code" => "
                    // phpcs:disable Generic.Commenting\xa                    $var = FALSE;
                    //TODO: write some code\xa                    // phpcs:enable Generic.Commenting\xa                    //TODO: write some code", "expectedErrors" => 1, "expectedWarnings" => 1), "disable/enable: whole standard" => array("code" => "
                    // phpcs:disable Generic
                    $var = FALSE;\xa                    //TODO: write some code\xa                    // phpcs:enable Generic\xa                    //TODO: write some code", "expectedErrors" => 0, "expectedWarnings" => 1), "disable: whole standard; enable: category from the standard" => array("code" => "
                    // phpcs:disable Generic
                    $var = FALSE;
                    //TODO: write some code
                    // phpcs:enable Generic.Commenting
                    //TODO: write some code", "expectedErrors" => 0, "expectedWarnings" => 1), "disable: a category; enable: the whole standard containing the category" => array("code" => "
                    # phpcs:disable Generic.Commenting\xa                    $var = FALSE;\xa                    //TODO: write some code
                    # phpcs:enable Generic
                    //TODO: write some code", "expectedErrors" => 1, "expectedWarnings" => 1), "disable: single sniff; enable: the category containing the sniff" => array("code" => "
                    // phpcs:disable Generic.Commenting.Todo
                    $var = FALSE;\xa                    //TODO: write some code\xa                    // phpcs:enable Generic.Commenting\xa                    //TODO: write some code", "expectedErrors" => 1, "expectedWarnings" => 1), "disable: whole standard; enable: single sniff from the standard" => array("code" => "\xa                    // phpcs:disable Generic\xa                    $var = FALSE;
                    //TODO: write some code
                    // phpcs:enable Generic.Commenting.Todo\xa                    //TODO: write some code", "expectedErrors" => 0, "expectedWarnings" => 1), "disable: whole standard; enable: single sniff from the standard; disable: that same sniff; enable: everything" => array("code" => "\xa                    // phpcs:disable Generic
                    $var = FALSE;
                    //TODO: write some code\xa                    // phpcs:enable Generic.Commenting.Todo
                    //TODO: write some code
                    // phpcs:disable Generic.Commenting.Todo\xa                    //TODO: write some code
                    // phpcs:enable
                    //TODO: write some code", "expectedErrors" => 0, "expectedWarnings" => 2), "disable: whole standard; enable: single sniff from the standard; enable: other sniff from the standard" => array("code" => "
                    // phpcs:disable Generic
                    $var = FALSE;\xa                    //TODO: write some code\xa                    // phpcs:enable Generic.Commenting.Todo\xa                    //TODO: write some code\xa                    $var = FALSE;
                    // phpcs:enable Generic.PHP.LowerCaseConstant
                    //TODO: write some code
                    $var = FALSE;", "expectedErrors" => 1, "expectedWarnings" => 2)); } public function testIgnoreSelected($before, $expectedErrors, $expectedWarnings) { static $config, $ruleset; if (isset($config, $ruleset) === false) { $config = new Config(); $config->standards = array("Generic"); $config->sniffs = array("Generic.PHP.LowerCaseConstant", "Generic.Commenting.Todo"); $ruleset = new Ruleset($config); } $content = "<?php\xa{$before}
$var = FALSE; //TODO: write some code
$var = FALSE; //TODO: write some code"; $file = new DummyFile($content, $ruleset, $config); $file->process(); $this->assertSame($expectedErrors, $file->getErrorCount()); $this->assertCount($expectedErrors, $file->getErrors()); $this->assertSame($expectedWarnings, $file->getWarningCount()); $this->assertCount($expectedWarnings, $file->getWarnings()); } public function dataIgnoreSelected() { return array("no suppression" => array("before" => '', "expectedErrors" => 2, "expectedWarnings" => 2), "ignore: single sniff" => array("before" => "// phpcs:ignore Generic.Commenting.Todo", "expectedErrors" => 2, "expectedWarnings" => 1), "ignore: multiple sniffs" => array("before" => "// phpcs:ignore Generic.Commenting.Todo,Generic.PHP.LowerCaseConstant", "expectedErrors" => 1, "expectedWarnings" => 1), "disable: single sniff; ignore: single sniff" => array("before" => "// phpcs:disable Generic.Commenting.Todo" . PHP_EOL . "// phpcs:ignore Generic.PHP.LowerCaseConstant", "expectedErrors" => 1, "expectedWarnings" => 0), "ignore: category of sniffs" => array("before" => "# phpcs:ignore Generic.Commenting", "expectedErrors" => 2, "expectedWarnings" => 1), "ignore: whole standard" => array("before" => "// phpcs:ignore Generic", "expectedErrors" => 1, "expectedWarnings" => 1)); } public function testCommenting($code, $expectedErrors, $expectedWarnings) { static $config, $ruleset; if (isset($config, $ruleset) === false) { $config = new Config(); $config->standards = array("Generic"); $config->sniffs = array("Generic.PHP.LowerCaseConstant", "Generic.Commenting.Todo"); $ruleset = new Ruleset($config); } $content = "<?php " . $code; $file = new DummyFile($content, $ruleset, $config); $file->process(); $this->assertSame($expectedErrors, $file->getErrorCount()); $this->assertCount($expectedErrors, $file->getErrors()); $this->assertSame($expectedWarnings, $file->getWarningCount()); $this->assertCount($expectedWarnings, $file->getWarnings()); } public function dataCommenting() { return array("ignore: single sniff" => array("code" => "
                    // phpcs:ignore Generic.Commenting.Todo -- Because reasons\xa                    $var = FALSE; //TODO: write some code\xa                    $var = FALSE; //TODO: write some code", "expectedErrors" => 2, "expectedWarnings" => 1), "disable: single sniff; enable: same sniff - test whitespace handling around reason delimiter" => array("code" => "\xa                    // phpcs:disable Generic.Commenting.Todo --Because reasons
                    $var = FALSE;\xa                    //TODO: write some code\xa                    // phpcs:enable Generic.Commenting.Todo   --  Because reasons\xa                    //TODO: write some code", "expectedErrors" => 1, "expectedWarnings" => 1), "disable: single sniff, multi-line comment" => array("code" => "
                    /*
                        Disable some checks\xa                        phpcs:disable Generic.Commenting.Todo\xa                    */
                    $var = FALSE;
                    //TODO: write some code", "expectedErrors" => 1, "expectedWarnings" => 0), "ignore: single sniff, multi-line slash comment" => array("code" => "
                    // Turn off a check for the next line of code.
                    // phpcs:ignore Generic.Commenting.Todo\xa                    $var = FALSE; //TODO: write some code\xa                    $var = FALSE; //TODO: write some code", "expectedErrors" => 2, "expectedWarnings" => 1), "enable before disable, sniff not in standard" => array("code" => "\xa                    // phpcs:enable Generic.PHP.NoSilencedErrors -- Because reasons\xa                    $var = @delete( $filename );\xa                    ", "expectedErrors" => 0, "expectedWarnings" => 0)); } } ?>

Did this file decode correctly?

Original Code

<?php
 namespace PHP_CodeSniffer\Tests\Core; use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Files\DummyFile; use PHPUnit\Framework\TestCase; class ErrorSuppressionTest extends TestCase { public function testSuppressError($before, $after, $expectedErrors = 0) { static $config, $ruleset; if (isset($config, $ruleset) === false) { $config = new Config(); $config->standards = array("\107\145\156\x65\x72\151\x63"); $config->sniffs = array("\x47\145\x6e\145\162\x69\x63\56\120\x48\120\x2e\x4c\x6f\x77\145\x72\103\141\x73\x65\103\157\x6e\163\x74\x61\156\x74"); $ruleset = new Ruleset($config); } $content = "\x3c\x3f\x70\150\x70\x20" . PHP_EOL . $before . "\44\166\141\162\40\x3d\40\106\101\114\x53\105\73" . PHP_EOL . $after; $file = new DummyFile($content, $ruleset, $config); $file->process(); $this->assertSame($expectedErrors, $file->getErrorCount()); $this->assertCount($expectedErrors, $file->getErrors()); } public function dataSuppressError() { return array("\x6e\157\40\x73\x75\160\x70\x72\x65\x73\163\x69\157\x6e" => array("\142\145\x66\157\x72\x65" => '', "\x61\146\164\x65\162" => '', "\145\x78\160\x65\143\x74\145\x64\x45\162\162\157\x72\x73" => 1), "\x64\151\x73\x61\142\x6c\x65\x2f\145\x6e\141\x62\x6c\145\72\40\x73\x6c\141\x73\x68\x20\143\157\155\155\x65\156\x74" => array("\x62\145\x66\157\x72\x65" => "\57\x2f\40\160\x68\x70\143\x73\72\x64\151\x73\141\142\x6c\145" . PHP_EOL, "\141\x66\164\145\162" => "\x2f\x2f\40\160\x68\160\143\163\72\145\156\141\x62\x6c\x65"), "\x64\x69\163\141\x62\154\145\57\x65\156\x61\142\154\x65\x3a\40\x6d\x75\154\x74\151\55\x6c\151\x6e\x65\x20\163\x6c\141\163\150\x20\143\157\155\x6d\x65\156\164\x2c\x20\x74\x61\x62\40\151\156\144\x65\x6e\x74\145\144" => array("\142\x65\146\x6f\162\x65" => "\x9" . "\x2f\x2f\x20\x46\x6f\x72\x20\x72\x65\141\x73\157\x6e\163" . PHP_EOL . "\x9" . "\x2f\57\40\x70\x68\160\x63\x73\x3a\x64\151\163\141\x62\x6c\x65" . PHP_EOL . "\x9", "\141\x66\x74\x65\162" => "\x9" . "\57\57\40\x70\x68\160\x63\x73\x3a\x65\x6e\141\142\x6c\x65"), "\144\151\x73\x61\142\154\x65\57\x65\156\141\142\154\145\72\40\x73\x6c\141\163\150\x20\143\157\x6d\x6d\145\156\164\x2c\x20\x77\x69\x74\x68\40\100" => array("\142\x65\146\x6f\x72\145" => "\x2f\57\40\100\x70\150\x70\143\x73\72\144\x69\x73\141\142\x6c\145" . PHP_EOL, "\x61\x66\164\145\162" => "\57\57\40\100\x70\x68\x70\143\x73\x3a\145\x6e\x61\x62\x6c\145"), "\144\x69\x73\141\x62\154\x65\x2f\145\156\x61\142\x6c\145\72\40\x73\x6c\x61\163\x68\40\x63\157\155\x6d\145\x6e\x74\x2c\40\x6d\x69\x78\x65\144\40\143\x61\x73\x65" => array("\x62\145\146\157\162\x65" => "\57\x2f\40\120\x48\120\103\x53\72\104\151\x73\141\142\x6c\145" . PHP_EOL, "\141\146\164\x65\162" => "\x2f\x2f\40\x70\110\x50\x63\x73\72\x65\156\x61\142\x4c\105"), "\x64\151\x73\x61\142\154\x65\57\x65\156\x61\x62\154\x65\x3a\x20\x68\x61\163\150\x20\143\x6f\x6d\x6d\145\156\x74" => array("\142\145\146\x6f\x72\x65" => "\43\x20\160\x68\x70\x63\x73\72\144\151\163\141\142\x6c\145" . PHP_EOL, "\141\146\x74\x65\162" => "\43\40\x70\x68\x70\x63\x73\72\145\x6e\141\x62\154\x65"), "\144\x69\x73\141\x62\154\x65\x2f\x65\156\x61\x62\154\x65\72\40\x6d\x75\x6c\x74\x69\x2d\x6c\151\156\145\x20\x68\x61\x73\150\40\x63\157\155\155\145\x6e\164\54\40\x74\141\142\40\x69\x6e\x64\145\x6e\164\x65\x64" => array("\x62\145\146\x6f\162\x65" => "\11" . "\x23\40\x46\x6f\162\40\162\145\141\163\x6f\x6e\163" . PHP_EOL . "\11" . "\43\x20\x70\150\160\x63\x73\x3a\144\x69\163\141\142\154\x65" . PHP_EOL . "\11", "\141\x66\164\x65\x72" => "\x9" . "\x23\40\160\150\x70\143\163\x3a\145\x6e\141\142\154\145"), "\x64\151\x73\141\x62\x6c\x65\x2f\145\156\141\x62\x6c\x65\x3a\40\150\x61\163\x68\x20\143\157\155\x6d\x65\156\x74\x2c\40\167\x69\164\150\40\x40" => array("\142\145\x66\157\162\145" => "\43\40\x40\160\x68\x70\143\x73\x3a\144\151\163\141\x62\x6c\145" . PHP_EOL, "\141\x66\x74\145\162" => "\43\40\x40\160\x68\x70\143\x73\x3a\x65\x6e\141\x62\154\145"), "\144\151\x73\141\x62\x6c\145\57\x65\156\x61\x62\154\x65\x3a\40\x68\x61\x73\x68\x20\143\x6f\155\x6d\x65\x6e\164\54\x20\155\x69\170\145\x64\40\x63\141\163\x65" => array("\142\145\x66\157\x72\145" => "\x23\40\x50\110\x50\103\x53\x3a\104\x69\163\x61\142\x6c\x65" . PHP_EOL, "\x61\146\164\145\162" => "\x23\x20\160\x48\120\x63\x73\72\x65\156\141\x62\x4c\x45"), "\x64\151\163\x61\x62\154\145\x2f\x65\156\141\x62\154\x65\x3a\x20\163\x74\141\162\x20\x63\x6f\155\x6d\x65\x6e\x74" => array("\x62\145\146\x6f\x72\x65" => "\x2f\52\x20\160\x68\160\x63\163\72\x64\x69\x73\141\x62\154\x65\40\52\x2f" . PHP_EOL, "\x61\146\164\145\x72" => "\57\x2a\40\x70\150\x70\143\163\72\145\156\141\142\x6c\x65\40\52\57"), "\x64\151\163\141\x62\154\145\57\145\x6e\x61\142\154\x65\x3a\40\155\165\x6c\x74\151\x2d\154\151\x6e\145\x20\163\x74\x61\162\40\143\157\155\155\x65\156\x74" => array("\142\x65\x66\157\x72\145" => "\x2f\x2a" . PHP_EOL . "\x20\x70\x68\x70\x63\163\72\144\x69\163\141\x62\x6c\145" . PHP_EOL . "\x20\52\57" . PHP_EOL, "\141\x66\164\145\x72" => "\x2f\52" . PHP_EOL . "\x20\x70\x68\x70\x63\x73\x3a\145\x6e\x61\142\x6c\145" . PHP_EOL . "\x20\52\57"), "\144\151\163\x61\142\154\x65\57\x65\156\x61\x62\x6c\145\72\x20\155\165\x6c\164\151\55\154\x69\x6e\x65\40\x73\164\141\x72\x20\143\x6f\x6d\155\x65\x6e\164\54\x20\145\141\x63\x68\x20\154\151\x6e\145\x20\x73\x74\x61\162\162\x65\144" => array("\142\x65\x66\x6f\x72\x65" => "\57\52" . PHP_EOL . "\40\x2a\x20\x70\x68\x70\143\163\72\x64\151\163\141\142\x6c\145" . PHP_EOL . "\x20\52\x2f" . PHP_EOL, "\141\x66\x74\145\x72" => "\x2f\x2a" . PHP_EOL . "\40\52\40\x70\x68\x70\143\x73\72\145\x6e\141\142\154\x65" . PHP_EOL . "\40\52\57"), "\144\151\x73\141\x62\154\145\x2f\x65\156\x61\x62\154\x65\72\40\155\165\154\164\151\55\x6c\151\156\x65\40\x73\x74\141\162\40\x63\157\x6d\155\x65\156\164\x2c\x20\x65\141\x63\150\x20\154\151\x6e\x65\40\163\164\141\x72\162\x65\x64\54\x20\x74\x61\142\40\x69\156\144\x65\156\x74\145\144" => array("\142\x65\x66\x6f\162\145" => "\x9" . "\57\52" . PHP_EOL . "\x9" . "\40\52\40\160\x68\160\x63\163\x3a\x64\151\x73\x61\142\x6c\145" . PHP_EOL . "\11" . "\x20\52\x2f" . PHP_EOL . "\x9", "\141\146\x74\x65\x72" => "\x9" . "\57\52" . PHP_EOL . "\40\x2a\x20\160\x68\160\x63\x73\x3a\145\x6e\141\x62\x6c\x65" . PHP_EOL . "\x20\x2a\x2f"), "\144\x69\x73\141\x62\154\x65\57\145\156\x61\142\154\x65\72\x20\x73\151\x6e\x67\154\x65\40\154\x69\x6e\145\x20\x64\157\143\x62\154\x6f\x63\x6b\40\x63\157\x6d\155\x65\156\164" => array("\142\x65\x66\157\162\x65" => "\57\52\x2a\x20\x70\x68\160\143\x73\x3a\144\151\x73\141\x62\x6c\x65\40\52\x2f" . PHP_EOL, "\x61\x66\164\x65\x72" => "\57\52\52\x20\160\x68\x70\x63\x73\x3a\145\156\141\x62\154\x65\40\x2a\57"), "\x6f\154\x64\x20\163\x74\171\x6c\145\x3a\x20\x73\154\x61\163\150\x20\143\157\x6d\155\x65\156\x74" => array("\x62\x65\146\x6f\x72\145" => "\x2f\x2f\40\100\143\157\144\x69\156\x67\x53\x74\141\156\144\141\162\x64\163\x49\147\x6e\157\162\x65\123\164\141\x72\x74" . PHP_EOL, "\141\146\x74\x65\x72" => "\x2f\x2f\x20\x40\x63\157\144\151\156\147\123\164\x61\x6e\144\x61\162\x64\163\111\x67\156\157\162\x65\x45\x6e\144"), "\157\154\144\x20\163\x74\x79\154\145\x3a\x20\163\164\141\x72\40\143\x6f\x6d\155\x65\156\x74" => array("\142\x65\x66\x6f\162\145" => "\57\x2a\x20\100\143\157\x64\151\x6e\147\x53\164\141\156\x64\x61\x72\x64\163\x49\147\x6e\157\x72\145\x53\164\141\162\x74\x20\52\57" . PHP_EOL, "\x61\146\164\x65\x72" => "\57\52\x20\100\143\157\x64\151\x6e\147\123\x74\x61\156\144\x61\162\x64\163\111\147\x6e\x6f\x72\145\x45\x6e\144\40\x2a\x2f"), "\157\154\x64\40\x73\x74\171\x6c\145\x3a\40\155\165\154\x74\151\55\154\x69\x6e\145\40\x73\164\141\162\40\143\x6f\x6d\x6d\145\x6e\164" => array("\142\145\146\157\x72\145" => "\57\x2a" . PHP_EOL . "\x20\100\143\x6f\144\x69\x6e\x67\x53\164\x61\x6e\144\141\162\144\163\111\147\x6e\157\162\x65\123\x74\x61\x72\x74" . PHP_EOL . "\40\52\57" . PHP_EOL, "\x61\146\x74\x65\x72" => "\x2f\x2a" . PHP_EOL . "\x20\x40\x63\x6f\144\151\x6e\147\123\x74\141\x6e\144\141\162\144\163\x49\x67\156\x6f\x72\145\x45\156\x64" . PHP_EOL . "\x20\52\x2f"), "\x6f\x6c\x64\40\x73\x74\171\154\x65\72\x20\x73\151\x6e\x67\x6c\x65\40\x6c\151\x6e\x65\40\144\x6f\143\x62\154\157\143\153\x20\x63\x6f\155\x6d\x65\156\x74" => array("\x62\x65\146\x6f\x72\x65" => "\x2f\x2a\x2a\x20\x40\x63\x6f\144\151\x6e\147\123\x74\x61\x6e\x64\141\162\x64\163\111\x67\x6e\x6f\162\145\123\164\x61\x72\x74\40\52\57" . PHP_EOL, "\x61\x66\x74\x65\162" => "\57\x2a\x2a\x20\100\x63\157\144\x69\156\x67\123\164\x61\156\144\141\162\144\x73\x49\147\x6e\x6f\x72\145\105\x6e\144\40\52\57")); } public function testSuppressSomeErrors($before, $between, $expectedErrors = 1) { static $config, $ruleset; if (isset($config, $ruleset) === false) { $config = new Config(); $config->standards = array("\107\145\x6e\145\162\151\143"); $config->sniffs = array("\107\x65\x6e\x65\162\x69\143\56\120\110\120\x2e\114\x6f\x77\x65\162\103\141\x73\145\x43\x6f\x6e\163\164\141\x6e\x74"); $ruleset = new Ruleset($config); } $content = "\74\77\160\x68\x70\12{$before}\xa\x24\166\141\162\x20\75\40\x46\101\114\x53\105\73\12{$between}\12\x24\166\141\x72\x20\75\40\x54\122\125\x45\73"; $file = new DummyFile($content, $ruleset, $config); $file->process(); $this->assertSame($expectedErrors, $file->getErrorCount()); $this->assertCount($expectedErrors, $file->getErrors()); } public function dataSuppressSomeErrors() { return array("\x6e\x6f\40\x73\x75\x70\x70\162\x65\x73\x73\151\x6f\156" => array("\142\x65\x66\x6f\162\x65" => '', "\x62\145\x74\167\x65\x65\x6e" => '', "\x65\170\160\145\x63\164\145\x64\105\x72\162\x6f\162\x73" => 2), "\x64\151\x73\x61\142\x6c\145\57\x65\156\x61\142\154\x65\72\40\x73\x6c\141\x73\150\x20\143\157\x6d\155\145\x6e\164" => array("\142\x65\146\157\x72\x65" => "\57\57\x20\x70\x68\160\143\x73\72\x64\x69\x73\x61\142\154\145", "\x62\x65\164\x77\x65\145\x6e" => "\x2f\x2f\x20\x70\x68\160\143\163\72\145\x6e\141\x62\x6c\145"), "\x64\151\163\141\142\x6c\145\x2f\x65\x6e\141\x62\154\x65\x3a\x20\x73\154\x61\x73\x68\40\143\x6f\x6d\x6d\145\156\x74\x2c\40\167\x69\x74\x68\40\x40" => array("\x62\x65\146\157\162\145" => "\x2f\57\x20\x40\160\150\160\x63\163\72\144\151\163\141\142\x6c\145", "\142\x65\164\x77\145\145\156" => "\57\x2f\40\x40\160\150\x70\x63\x73\x3a\145\x6e\141\x62\x6c\145"), "\x64\x69\163\x61\x62\154\x65\x2f\x65\x6e\x61\x62\x6c\x65\72\x20\x68\x61\x73\x68\40\x63\x6f\x6d\x6d\145\x6e\x74" => array("\142\145\146\157\162\145" => "\43\x20\x70\150\160\x63\x73\72\x64\x69\163\x61\x62\154\145", "\x62\x65\164\167\145\x65\156" => "\x23\x20\160\x68\160\143\x73\x3a\145\x6e\141\142\154\x65"), "\144\151\163\x61\142\154\145\x2f\x65\156\141\x62\x6c\x65\72\40\x68\141\x73\x68\x20\x63\x6f\155\155\145\x6e\x74\54\x20\167\x69\x74\150\x20\x40" => array("\142\x65\146\x6f\162\145" => "\x23\40\x40\160\x68\160\143\163\72\x64\x69\x73\141\142\x6c\145", "\x62\145\x74\167\145\145\x6e" => "\43\x20\x40\160\x68\x70\143\163\72\x65\x6e\x61\x62\154\x65"), "\144\151\x73\x61\142\154\145\57\x65\x6e\x61\142\x6c\x65\x3a\x20\x73\151\x6e\147\x6c\x65\40\154\151\x6e\145\x20\x64\x6f\x63\142\x6c\157\143\x6b\x20\143\157\x6d\155\x65\156\164" => array("\142\x65\x66\157\162\x65" => "\x2f\x2a\x2a\x20\160\150\160\x63\x73\x3a\x64\x69\163\x61\142\x6c\x65\40\52\57", "\x62\x65\164\167\x65\145\156" => "\x2f\x2a\52\40\x70\150\160\x63\x73\x3a\x65\156\141\x62\x6c\x65\40\52\57"), "\157\154\x64\40\x73\164\x79\x6c\145\x3a\40\163\x6c\141\163\150\40\143\x6f\155\155\x65\156\164" => array("\142\145\x66\157\x72\145" => "\57\57\40\100\x63\157\144\x69\156\x67\x53\x74\x61\x6e\x64\x61\162\x64\163\x49\x67\156\x6f\162\x65\123\x74\141\162\164", "\142\x65\x74\167\x65\x65\156" => "\x2f\x2f\40\x40\x63\x6f\144\151\x6e\x67\123\164\141\156\144\141\162\x64\163\x49\x67\156\x6f\x72\145\x45\156\x64"), "\157\154\144\x20\x73\164\171\x6c\145\72\40\163\151\156\147\x6c\145\40\x6c\151\x6e\x65\x20\x64\157\143\x62\154\157\x63\153\40\x63\157\x6d\x6d\x65\x6e\164" => array("\142\x65\146\x6f\x72\x65" => "\x2f\52\x2a\40\100\143\x6f\144\151\x6e\147\123\164\x61\x6e\144\141\162\x64\163\111\x67\156\x6f\162\145\x53\x74\x61\x72\164\40\x2a\57", "\142\x65\164\167\x65\x65\x6e" => "\x2f\x2a\x2a\x20\100\x63\157\144\x69\x6e\x67\x53\164\141\156\144\x61\162\144\163\111\147\x6e\x6f\x72\145\x45\x6e\144\x20\52\57")); } public function testSuppressWarning($before, $after, $expectedWarnings = 0) { static $config, $ruleset; if (isset($config, $ruleset) === false) { $config = new Config(); $config->standards = array("\107\145\x6e\x65\162\x69\x63"); $config->sniffs = array("\x47\x65\156\x65\162\x69\143\x2e\103\157\155\155\145\156\x74\x69\x6e\x67\56\124\157\144\x6f"); $ruleset = new Ruleset($config); } $content = "\74\77\x70\x68\160\12{$before}\xa\x2f\x2f\x54\x4f\104\117\x3a\40\167\162\x69\164\x65\40\163\x6f\x6d\145\x20\x63\x6f\144\x65\56\xa{$after}"; $file = new DummyFile($content, $ruleset, $config); $file->process(); $this->assertSame($expectedWarnings, $file->getWarningCount()); $this->assertCount($expectedWarnings, $file->getWarnings()); } public function dataSuppressWarning() { return array("\156\157\40\x73\x75\x70\x70\162\145\x73\x73\151\x6f\156" => array("\142\x65\x66\157\x72\145" => '', "\141\146\164\x65\x72" => '', "\x65\170\160\x65\x63\x74\x65\x64\127\x61\162\x6e\151\x6e\x67\163" => 1), "\144\151\163\x61\x62\x6c\145\57\x65\x6e\141\x62\154\x65\72\40\x73\154\x61\x73\x68\x20\143\157\x6d\155\145\156\164" => array("\x62\x65\x66\x6f\162\145" => "\x2f\57\40\160\x68\160\x63\163\72\x64\151\163\141\142\x6c\145", "\x61\146\x74\x65\162" => "\x2f\57\40\160\150\x70\x63\163\x3a\145\x6e\x61\142\154\x65"), "\x64\x69\163\141\x62\x6c\x65\x2f\x65\x6e\x61\142\154\x65\72\40\163\x6c\x61\163\x68\x20\x63\157\155\x6d\x65\x6e\x74\54\x20\167\x69\x74\150\40\x40" => array("\142\x65\146\x6f\x72\x65" => "\57\x2f\x20\x40\x70\150\x70\143\163\x3a\x64\x69\x73\141\x62\154\145", "\141\146\164\x65\162" => "\57\x2f\40\100\x70\x68\160\143\x73\72\x65\156\141\142\x6c\x65"), "\144\x69\163\x61\142\154\145\x2f\x65\x6e\x61\142\154\145\x3a\x20\163\x69\156\147\x6c\145\40\x6c\151\156\x65\40\x64\x6f\x63\x62\154\157\x63\153\x20\x63\157\155\155\x65\x6e\164" => array("\x62\145\x66\x6f\x72\145" => "\x2f\52\52\40\160\150\x70\x63\x73\72\x64\151\163\141\x62\x6c\145\40\52\57", "\141\x66\164\145\x72" => "\57\x2a\x2a\40\160\150\160\x63\163\x3a\145\x6e\141\142\x6c\145\x20\x2a\x2f"), "\157\154\144\40\163\x74\171\154\145\72\40\163\154\141\163\x68\40\x63\x6f\x6d\x6d\145\x6e\x74" => array("\x62\x65\146\157\162\145" => "\x2f\x2f\40\100\x63\157\144\151\x6e\x67\123\164\141\x6e\x64\x61\x72\144\x73\x49\147\x6e\x6f\162\145\x53\x74\x61\162\x74", "\141\146\x74\145\162" => "\x2f\57\x20\100\143\157\x64\151\x6e\x67\123\x74\141\x6e\144\x61\x72\144\x73\x49\x67\156\x6f\x72\x65\x45\156\x64"), "\157\154\144\40\163\x74\171\x6c\x65\72\40\163\x69\156\147\154\145\x20\x6c\151\156\x65\x20\144\157\x63\142\154\x6f\x63\x6b\x20\143\157\155\155\145\156\x74" => array("\142\x65\x66\157\162\x65" => "\x2f\x2a\x2a\40\x40\x63\157\144\x69\156\147\x53\164\x61\x6e\x64\x61\x72\144\163\x49\147\156\x6f\162\145\x53\164\x61\162\x74\40\52\57", "\x61\x66\x74\x65\162" => "\57\52\x2a\x20\100\x63\157\144\x69\x6e\147\x53\x74\x61\x6e\x64\141\162\144\163\111\147\x6e\157\162\x65\x45\156\144\x20\x2a\x2f")); } public function testSuppressLine($before, $after = '', $expectedErrors = 1) { static $config, $ruleset; if (isset($config, $ruleset) === false) { $config = new Config(); $config->standards = array("\x47\145\156\x65\x72\151\143"); $config->sniffs = array("\x47\145\156\145\162\151\x63\x2e\120\110\120\x2e\114\x6f\x77\145\162\103\141\163\x65\103\157\156\x73\164\141\x6e\x74"); $ruleset = new Ruleset($config); } $content = "\74\x3f\x70\x68\x70\12{$before}\xa\44\x76\x61\162\40\x3d\40\x46\x41\x4c\123\105\73{$after}\xa\x24\x76\141\162\40\75\40\x46\x41\114\123\105\73"; $file = new DummyFile($content, $ruleset, $config); $file->process(); $this->assertSame($expectedErrors, $file->getErrorCount()); $this->assertCount($expectedErrors, $file->getErrors()); } public function dataSuppressLine() { return array("\156\x6f\40\x73\165\x70\x70\x72\x65\163\163\x69\157\156" => array("\x62\145\146\157\x72\x65" => '', "\x61\x66\x74\x65\x72" => '', "\145\x78\160\145\x63\x74\145\x64\105\162\x72\x6f\x72\163" => 2), "\151\x67\x6e\157\162\x65\72\40\x6c\151\x6e\145\40\142\x65\x66\x6f\x72\145\54\40\163\154\x61\163\150\x20\143\157\x6d\155\145\156\x74" => array("\142\x65\146\x6f\162\x65" => "\57\x2f\40\x70\x68\160\x63\163\72\151\x67\x6e\157\162\145"), "\x69\147\156\x6f\x72\x65\72\x20\x6c\x69\156\x65\x20\x62\x65\x66\x6f\x72\145\54\x20\163\154\141\163\150\x20\143\x6f\x6d\x6d\145\156\x74\54\x20\x77\151\x74\x68\x20\x40" => array("\142\x65\x66\157\x72\145" => "\x2f\x2f\40\100\160\x68\x70\x63\163\x3a\x69\147\156\157\162\x65"), "\x69\x67\x6e\x6f\x72\145\72\x20\x6c\151\x6e\x65\40\142\x65\x66\x6f\162\145\54\x20\x68\141\163\150\x20\143\157\x6d\155\x65\156\164" => array("\142\x65\x66\x6f\162\x65" => "\x23\x20\x70\x68\160\143\163\72\x69\147\156\157\162\145"), "\151\147\156\157\162\x65\72\x20\x6c\x69\x6e\145\40\142\x65\x66\157\x72\x65\54\40\x68\x61\163\150\x20\x63\x6f\x6d\x6d\145\x6e\x74\x2c\40\167\151\x74\150\40\100" => array("\142\x65\146\157\x72\x65" => "\43\x20\x40\x70\150\x70\x63\163\x3a\x69\147\156\157\x72\145"), "\151\x67\x6e\x6f\162\145\x3a\x20\154\151\156\x65\x20\142\145\x66\x6f\162\x65\x2c\x20\x73\164\141\162\40\x63\x6f\x6d\x6d\x65\156\164" => array("\x62\145\146\x6f\x72\145" => "\x2f\52\40\x70\x68\160\143\x73\x3a\x69\147\156\157\162\x65\40\52\57"), "\151\147\x6e\x6f\162\x65\72\x20\154\151\x6e\x65\40\142\145\146\x6f\x72\x65\x2c\40\x73\164\141\162\x20\143\157\155\x6d\145\156\x74\54\x20\x77\151\164\x68\40\x40" => array("\x62\x65\146\x6f\x72\x65" => "\x2f\52\x20\x40\160\x68\x70\143\163\x3a\151\x67\156\x6f\x72\x65\40\52\x2f"), "\151\147\x6e\x6f\162\x65\x3a\40\x65\156\x64\40\157\x66\40\154\x69\156\x65\x2c\40\x73\154\x61\163\150\40\x63\157\x6d\155\145\156\x74" => array("\x62\x65\x66\157\x72\145" => '', "\141\146\164\145\x72" => "\40\x2f\x2f\40\160\150\160\x63\163\72\x69\147\x6e\x6f\162\145"), "\x69\x67\156\x6f\x72\145\72\x20\x65\x6e\144\x20\157\x66\x20\x6c\x69\x6e\x65\x2c\40\163\154\x61\x73\150\40\x63\157\155\x6d\145\156\164\54\x20\x77\x69\x74\x68\40\x40" => array("\142\x65\x66\157\162\145" => '', "\x61\146\x74\x65\162" => "\40\x2f\57\x20\x40\x70\x68\x70\x63\x73\72\151\147\156\x6f\162\x65"), "\151\147\156\x6f\x72\145\72\x20\145\x6e\x64\40\157\146\40\x6c\x69\156\x65\54\40\150\x61\163\x68\x20\143\x6f\155\x6d\145\156\164" => array("\x62\x65\x66\x6f\162\145" => '', "\x61\146\x74\145\162" => "\x20\43\40\160\x68\x70\x63\x73\72\151\147\156\157\162\145"), "\x69\147\156\157\x72\x65\x3a\40\x65\x6e\x64\x20\x6f\x66\x20\x6c\151\x6e\145\x2c\40\150\x61\163\x68\40\143\x6f\x6d\155\x65\156\x74\x2c\40\167\151\164\x68\40\x40" => array("\x62\x65\x66\x6f\162\145" => '', "\x61\x66\x74\145\162" => "\x20\43\x20\x40\x70\x68\x70\x63\x73\72\151\147\156\x6f\x72\x65"), "\157\154\x64\40\163\x74\x79\154\x65\72\40\154\x69\156\x65\40\142\x65\x66\157\x72\x65\x2c\x20\x73\154\x61\x73\150\x20\x63\x6f\x6d\155\145\156\164" => array("\x62\x65\146\x6f\x72\145" => "\x2f\x2f\x20\x40\143\x6f\x64\151\156\147\123\x74\141\156\144\141\162\144\x73\x49\147\x6e\x6f\x72\145\x4c\x69\x6e\x65"), "\157\x6c\144\x20\x73\x74\x79\x6c\x65\72\40\145\156\144\x20\x6f\x66\x20\x6c\x69\156\x65\54\x20\163\x6c\141\163\150\x20\x63\x6f\155\155\145\x6e\164" => array("\142\145\146\157\162\145" => '', "\x61\146\164\x65\162" => "\40\x2f\x2f\40\x40\143\157\144\x69\156\147\123\x74\141\x6e\x64\141\x72\144\163\x49\147\156\157\162\x65\114\151\156\145")); } public function testSuppressLineMidLine() { $config = new Config(); $config->standards = array("\107\145\156\x65\x72\151\x63"); $config->sniffs = array("\107\145\x6e\x65\162\x69\x63\56\120\110\x50\x2e\114\157\x77\145\162\x43\x61\163\x65\x43\157\x6e\163\x74\x61\156\x74"); $ruleset = new Ruleset($config); $content = "\74\77\x70\x68\x70\40" . PHP_EOL . "\x24\x76\141\162\40\75\x20\x46\x41\x4c\123\105\x3b\x20\57\52\40\x40\x70\150\160\143\163\72\151\147\156\x6f\x72\x65\40\52\57\x20\44\166\x61\x72\40\x3d\40\x46\x41\114\x53\105\x3b"; $file = new DummyFile($content, $ruleset, $config); $file->process(); $this->assertSame(0, $file->getErrorCount()); $this->assertCount(0, $file->getErrors()); } public function testSuppressLineWithinDocblock() { $config = new Config(); $config->standards = array("\x47\145\x6e\145\x72\x69\143"); $config->sniffs = array("\107\x65\156\x65\x72\151\x63\x2e\106\x69\x6c\145\163\56\114\151\156\x65\114\145\x6e\x67\164\x68"); $ruleset = new Ruleset($config); $comment = str_repeat("\x61\40", 50); $content = "\x3c\x3f\160\x68\x70\xa\57\52\x2a\xa\40\x2a\x20\103\x6f\155\x6d\x65\156\164\40\x68\x65\x72\145\12\x20\x2a\40\100\x70\150\160\x63\163\72\151\147\156\157\x72\x65\12\40\52\x20{$comment}\xa\x20\52\57"; $file = new DummyFile($content, $ruleset, $config); $file->process(); $this->assertSame(0, $file->getErrorCount()); $this->assertCount(0, $file->getErrors()); } public function testNestedSuppressLine($before, $after) { static $config, $ruleset; if (isset($config, $ruleset) === false) { $config = new Config(); $config->standards = array("\x47\145\156\x65\x72\x69\x63"); $config->sniffs = array("\x47\145\156\145\x72\x69\x63\x2e\x50\110\x50\56\x4c\x6f\167\x65\x72\103\141\x73\145\x43\157\156\x73\x74\x61\156\164"); $ruleset = new Ruleset($config); } $content = "\74\x3f\160\x68\x70\12{$before}\xa\44\x76\141\162\40\x3d\x20\x46\x41\x4c\123\105\73\12\44\x76\x61\162\40\x3d\x20\x54\122\x55\x45\73\12{$after}"; $file = new DummyFile($content, $ruleset, $config); $file->process(); $this->assertSame(0, $file->getErrorCount()); $this->assertCount(0, $file->getErrors()); } public function dataNestedSuppressLine() { return array("\144\x69\x73\141\142\154\x65\57\145\156\x61\x62\x6c\145\x3a\x20\x73\x6c\x61\x73\150\x20\x63\x6f\155\x6d\145\156\x74\x2c\x20\x6e\x6f\40\x73\151\x6e\147\154\x65\40\154\151\x6e\x65\x20\x73\165\x70\x70\162\145\x73\x73\x69\157\156" => array("\x62\x65\x66\x6f\x72\145" => "\57\x2f\x20\x70\x68\x70\143\x73\72\x64\x69\x73\x61\142\x6c\x65", "\x61\146\x74\145\x72" => "\x2f\x2f\40\160\x68\x70\143\163\x3a\145\x6e\x61\x62\154\145"), "\144\x69\x73\141\142\x6c\145\57\145\156\x61\x62\154\145\x3a\40\x73\x6c\141\163\150\x20\x63\157\x6d\x6d\145\156\x74\x2c\x20\x77\151\164\x68\40\x40\x2c\40\x6e\157\x20\x73\x69\x6e\147\154\145\x20\154\151\x6e\x65\x20\163\165\160\x70\x72\x65\x73\163\x69\x6f\156" => array("\x62\145\146\157\x72\145" => "\x2f\x2f\x20\x40\160\x68\160\x63\163\x3a\x64\x69\163\141\142\x6c\145", "\x61\x66\164\145\162" => "\57\x2f\x20\100\160\x68\x70\143\163\72\145\x6e\x61\x62\x6c\145"), "\144\x69\163\141\142\x6c\x65\x2f\x65\x6e\x61\x62\154\145\72\40\150\141\x73\x68\x20\x63\x6f\x6d\x6d\x65\x6e\x74\54\x20\156\x6f\40\x73\x69\x6e\147\x6c\145\40\x6c\x69\156\x65\x20\x73\165\x70\160\162\145\x73\163\x69\157\156" => array("\x62\145\146\x6f\162\145" => "\43\x20\x70\150\160\x63\x73\72\144\x69\x73\x61\142\154\145", "\141\146\x74\x65\162" => "\43\40\160\x68\x70\x63\x73\72\x65\x6e\x61\x62\154\x65"), "\157\x6c\144\x20\163\164\171\154\x65\72\x20\163\154\141\163\x68\x20\x63\x6f\155\x6d\x65\156\x74\x2c\x20\156\x6f\40\x73\x69\x6e\147\154\145\40\x6c\x69\x6e\145\x20\163\165\160\x70\162\145\x73\163\151\x6f\x6e" => array("\x62\145\x66\157\x72\x65" => "\57\x2f\x20\100\143\157\x64\151\156\x67\123\x74\x61\x6e\144\141\x72\144\163\111\147\156\x6f\162\x65\x53\164\141\x72\164", "\x61\146\164\145\x72" => "\x2f\57\40\100\x63\157\144\x69\x6e\x67\x53\x74\x61\156\x64\x61\x72\144\x73\x49\x67\x6e\157\162\x65\x45\x6e\144"), "\x64\151\163\141\x62\x6c\x65\x2f\x65\x6e\141\142\x6c\145\72\x20\x73\x6c\x61\163\x68\x20\143\157\155\155\145\156\164\x2c\x20\156\145\x78\x74\40\154\151\x6e\x65\40\x6e\145\x73\164\x65\x64\40\x73\151\x6e\x67\x6c\x65\x20\154\151\x6e\145\40\x73\x75\160\160\x72\x65\x73\x73\x69\157\156" => array("\142\145\x66\157\162\145" => "\x2f\57\x20\160\150\x70\143\x73\72\144\151\x73\x61\142\154\145" . PHP_EOL . "\x2f\x2f\x20\160\150\x70\x63\x73\x3a\151\x67\x6e\157\x72\145", "\x61\146\x74\x65\162" => "\x2f\x2f\40\x70\x68\160\x63\163\x3a\145\156\x61\142\x6c\x65"), "\144\151\x73\x61\142\x6c\145\57\x65\156\141\142\x6c\145\72\40\x73\154\141\x73\150\x20\143\x6f\x6d\x6d\145\x6e\x74\54\x20\167\x69\x74\x68\x20\100\x2c\40\x6e\145\170\x74\40\x6c\x69\156\x65\40\x6e\x65\163\x74\145\144\x20\163\151\x6e\x67\154\145\40\x6c\x69\x6e\x65\40\163\x75\x70\160\x72\x65\x73\163\x69\157\x6e" => array("\x62\x65\x66\157\162\145" => "\57\x2f\40\100\x70\150\x70\x63\x73\x3a\144\x69\x73\x61\142\154\145" . PHP_EOL . "\57\x2f\x20\100\160\150\x70\143\163\72\x69\x67\156\x6f\x72\x65", "\141\x66\x74\x65\x72" => "\x2f\x2f\x20\100\160\x68\x70\143\163\72\145\156\141\142\154\145"), "\144\x69\x73\141\x62\x6c\x65\x2f\145\156\141\x62\x6c\145\x3a\x20\x68\141\163\150\40\x63\x6f\155\155\x65\156\x74\x2c\x20\156\x65\170\164\x20\154\x69\x6e\145\x20\156\x65\163\164\x65\x64\40\x73\x69\x6e\x67\154\x65\x20\x6c\151\156\x65\40\163\x75\160\160\x72\145\x73\163\x69\x6f\156" => array("\x62\x65\146\x6f\162\x65" => "\43\x20\x40\x70\150\x70\x63\163\x3a\x64\151\x73\141\142\154\145" . PHP_EOL . "\x23\x20\100\160\150\160\143\x73\72\x69\147\x6e\x6f\162\x65", "\141\x66\x74\145\x72" => "\x23\40\100\x70\150\x70\x63\x73\72\x65\156\x61\142\x6c\145"), "\x6f\x6c\x64\x20\163\164\171\154\145\x3a\40\163\x6c\141\x73\x68\40\x63\157\155\x6d\145\x6e\x74\x2c\x20\x6e\x65\x78\x74\x20\154\151\x6e\145\40\156\145\163\x74\145\x64\x20\x73\x69\x6e\147\154\x65\40\154\151\156\x65\x20\163\x75\x70\160\162\145\x73\x73\x69\157\156" => array("\x62\x65\146\x6f\162\x65" => "\57\x2f\40\x40\143\157\x64\x69\x6e\x67\123\x74\141\x6e\x64\x61\x72\144\x73\x49\147\x6e\x6f\x72\x65\123\x74\x61\162\164" . PHP_EOL . "\x2f\57\x20\100\143\157\x64\151\x6e\147\123\x74\141\156\x64\x61\x72\144\x73\111\147\156\157\162\x65\x4c\151\156\x65", "\x61\146\x74\145\162" => "\x2f\x2f\40\100\x63\x6f\x64\151\x6e\147\x53\x74\141\156\144\141\x72\144\x73\x49\x67\156\157\162\x65\105\x6e\144")); } public function testSuppressScope($before, $after, $expectedErrors = 0) { static $config, $ruleset; if (isset($config, $ruleset) === false) { $config = new Config(); $config->standards = array("\120\105\x41\122"); $config->sniffs = array("\120\105\101\x52\x2e\x46\x75\x6e\x63\x74\151\157\156\x73\56\x46\x75\156\143\164\x69\157\156\104\145\143\154\x61\162\141\164\x69\157\156"); $ruleset = new Ruleset($config); } $content = "\74\77\x70\x68\160\x20" . PHP_EOL . $before . "\44\x76\141\x72\40\75\x20\106\101\114\x53\105\73" . $after . PHP_EOL . "\x24\x76\x61\162\40\75\40\x46\101\114\123\105\73"; $content = "\x3c\x3f\x70\x68\x70\xa\143\x6c\x61\x73\x73\x20\x4d\171\103\154\141\163\163\x28\x29\40\x7b\12\x20\40\40\40{$before}\12\40\x20\x20\40\146\x75\156\x63\x74\151\157\156\x20\x6d\171\106\165\x6e\x63\x74\x69\x6f\156\x28\x29\40\173\xa\x20\x20\x20\40\40\40\40\x20{$after}\12\x20\40\40\40\x20\40\40\40\44\164\150\151\163\55\76\x66\157\157\50\x29\73\xa\40\x20\40\x20\x7d\xa\x7d"; $file = new DummyFile($content, $ruleset, $config); $file->process(); $this->assertSame($expectedErrors, $file->getErrorCount()); $this->assertCount($expectedErrors, $file->getErrors()); } public function dataSuppressScope() { return array("\156\x6f\x20\x73\x75\160\160\162\x65\163\x73\x69\x6f\x6e" => array("\142\x65\x66\x6f\162\x65" => '', "\x61\146\x74\x65\x72" => '', "\x65\170\x70\145\x63\x74\x65\144\105\x72\x72\x6f\162\x73" => 1), "\x64\151\x73\141\x62\x6c\145\57\x65\156\141\x62\x6c\x65\72\x20\163\154\141\x73\150\40\143\157\x6d\155\x65\156\164" => array("\x62\x65\146\157\162\x65" => "\x2f\57\160\150\x70\x63\x73\x3a\144\151\163\x61\x62\154\x65", "\141\146\x74\145\x72" => "\x2f\57\x70\150\x70\143\163\72\145\156\x61\x62\154\145"), "\144\151\163\x61\142\x6c\x65\57\145\156\x61\142\154\x65\x3a\40\163\154\141\x73\x68\x20\143\x6f\155\155\x65\x6e\x74\54\x20\x77\x69\x74\x68\40\100" => array("\x62\x65\x66\157\162\x65" => "\57\57\100\x70\x68\x70\x63\x73\72\144\x69\163\141\142\x6c\x65", "\141\x66\x74\x65\x72" => "\57\x2f\x40\160\x68\x70\x63\x73\x3a\x65\156\x61\142\154\145"), "\x64\x69\x73\141\x62\154\x65\x2f\145\x6e\x61\x62\x6c\x65\72\x20\x68\141\x73\x68\40\143\157\x6d\x6d\x65\156\x74" => array("\x62\145\146\x6f\x72\x65" => "\43\160\x68\x70\x63\163\x3a\144\151\x73\x61\x62\154\x65", "\x61\x66\x74\145\162" => "\x23\x70\150\160\x63\x73\72\145\156\141\x62\x6c\145"), "\144\x69\163\x61\x62\x6c\x65\57\145\x6e\141\x62\154\x65\x3a\40\163\x69\156\147\x6c\145\x20\x6c\151\x6e\145\40\144\157\143\142\x6c\157\x63\x6b\x20\x63\x6f\155\155\x65\156\164" => array("\x62\145\146\x6f\x72\145" => "\x2f\x2a\x2a\x20\x70\150\x70\143\x73\72\144\x69\x73\141\142\154\x65\x20\x2a\x2f", "\141\146\x74\145\162" => "\57\x2a\52\40\160\x68\x70\143\x73\x3a\145\156\x61\x62\154\145\x20\52\x2f"), "\144\151\x73\x61\142\x6c\145\57\x65\x6e\x61\x62\154\x65\x3a\40\163\151\x6e\x67\154\145\40\x6c\151\156\x65\40\144\157\143\x62\x6c\x6f\x63\153\x20\143\x6f\x6d\155\x65\x6e\x74\54\x20\167\x69\x74\x68\x20\100" => array("\x62\145\146\157\162\x65" => "\57\52\x2a\40\100\x70\150\x70\x63\163\x3a\144\x69\x73\x61\x62\x6c\x65\40\52\57", "\141\x66\164\145\162" => "\57\x2a\52\x20\x40\x70\x68\160\143\163\72\x65\x6e\x61\x62\154\x65\40\x2a\57"), "\157\154\x64\x20\163\x74\x79\x6c\x65\72\40\x73\x74\141\162\x74\x2f\x65\156\144\x2c\x20\x73\x6c\141\x73\150\x20\x63\157\155\x6d\x65\x6e\x74" => array("\142\145\146\x6f\162\145" => "\57\57\x40\143\x6f\x64\151\x6e\147\123\x74\x61\156\144\x61\x72\144\163\x49\x67\x6e\x6f\x72\x65\x53\164\x61\162\164", "\x61\x66\x74\145\x72" => "\57\x2f\100\x63\x6f\x64\151\156\x67\123\x74\141\156\144\x61\x72\144\163\111\147\x6e\x6f\162\x65\105\x6e\x64"), "\x6f\154\144\40\163\x74\x79\x6c\x65\72\x20\x73\164\x61\x72\x74\x2f\145\156\x64\x2c\40\163\x69\x6e\147\x6c\145\x20\154\151\x6e\145\x20\x64\x6f\x63\x62\154\157\x63\x6b\40\143\x6f\155\155\145\156\x74" => array("\142\x65\146\x6f\x72\145" => "\x2f\x2a\x2a\40\100\143\157\144\x69\156\147\123\164\141\x6e\x64\141\x72\x64\x73\111\x67\x6e\157\162\145\123\x74\x61\162\x74\40\52\x2f", "\x61\x66\164\x65\162" => "\x2f\52\52\40\x40\143\157\144\x69\156\147\123\x74\x61\x6e\x64\141\162\144\x73\111\x67\x6e\x6f\x72\145\105\156\144\40\x2a\x2f")); } public function testSuppressFile($before, $after = '', $expectedWarnings = 0) { static $config, $ruleset; if (isset($config, $ruleset) === false) { $config = new Config(); $config->standards = array("\107\x65\x6e\x65\162\x69\x63"); $config->sniffs = array("\107\x65\x6e\x65\162\151\x63\x2e\x43\x6f\x6d\x6d\x65\156\x74\151\x6e\x67\56\x54\157\x64\157"); $ruleset = new Ruleset($config); } $content = "\74\77\160\x68\160\xa{$before}\12\143\x6c\x61\163\163\x20\x4d\171\x43\x6c\141\163\x73\40\x7b\x7d\xa\x24\146\x6f\157\x20\75\40\x6e\x65\167\x20\115\171\x43\x6c\x61\163\x73\50\x29\x3b\12\57\57\124\x4f\x44\117\x3a\40\167\162\151\164\145\x20\x73\157\155\x65\40\143\x6f\x64\145\xa{$after}"; $file = new DummyFile($content, $ruleset, $config); $file->process(); $this->assertSame($expectedWarnings, $file->getWarningCount()); $this->assertCount($expectedWarnings, $file->getWarnings()); } public function dataSuppressFile() { return array("\156\x6f\x20\163\x75\x70\x70\x72\x65\163\x73\x69\157\156" => array("\x62\x65\146\x6f\162\x65" => '', "\x61\146\x74\x65\162" => '', "\x65\x78\x70\145\x63\x74\x65\144\x45\162\x72\157\162\163" => 1), "\151\x67\x6e\157\162\145\x46\151\x6c\x65\72\x20\x73\x74\x61\x72\164\40\157\x66\x20\x66\x69\x6c\x65\54\40\163\154\x61\163\x68\40\x63\x6f\x6d\x6d\145\156\164" => array("\142\145\x66\x6f\x72\x65" => "\57\x2f\x20\160\150\x70\x63\x73\x3a\x69\147\156\x6f\162\145\106\x69\154\145"), "\151\147\156\157\162\145\106\151\x6c\145\x3a\x20\163\164\x61\162\x74\40\x6f\146\x20\146\151\x6c\145\x2c\40\x73\x6c\141\163\150\40\x63\157\155\x6d\x65\156\164\54\40\167\x69\x74\x68\40\x40" => array("\142\145\x66\157\162\x65" => "\57\57\40\x40\160\150\160\x63\163\72\151\147\x6e\x6f\x72\x65\x46\x69\154\x65"), "\x69\x67\x6e\x6f\x72\145\x46\x69\x6c\x65\x3a\40\x73\x74\x61\162\x74\x20\x6f\146\x20\x66\x69\154\145\54\x20\x73\154\x61\163\150\40\x63\157\155\x6d\145\x6e\164\54\40\x6d\x69\x78\x65\x64\40\x63\141\x73\x65" => array("\x62\x65\146\157\162\145" => "\x2f\x2f\x20\120\110\x50\103\x53\72\111\x67\156\157\x72\x65\146\151\x6c\145"), "\151\147\x6e\x6f\x72\x65\x46\x69\154\145\x3a\40\x73\164\141\x72\164\x20\157\146\40\146\x69\154\145\54\40\150\x61\x73\150\x20\x63\x6f\x6d\155\x65\x6e\164" => array("\x62\145\x66\x6f\x72\145" => "\43\x20\x70\150\160\143\x73\72\151\x67\156\x6f\162\x65\x46\x69\154\145"), "\x69\147\x6e\x6f\162\145\106\x69\x6c\x65\x3a\x20\163\x74\141\162\x74\40\157\146\40\146\x69\x6c\x65\54\x20\150\x61\163\150\x20\x63\x6f\155\155\145\x6e\x74\x2c\x20\167\151\164\x68\40\100" => array("\x62\x65\146\x6f\x72\145" => "\43\40\x40\x70\150\x70\143\163\x3a\151\147\x6e\x6f\x72\145\106\x69\x6c\145"), "\151\x67\156\157\x72\x65\x46\x69\154\x65\x3a\40\x73\x74\x61\162\164\40\157\146\40\x66\151\154\145\54\40\x73\x69\x6e\147\154\145\x2d\x6c\151\156\145\x20\163\x74\141\x72\x20\x63\x6f\x6d\x6d\x65\x6e\164" => array("\x62\x65\x66\x6f\x72\145" => "\57\x2a\40\x70\150\160\x63\163\72\x69\147\156\x6f\x72\x65\x46\151\x6c\145\x20\52\57"), "\151\x67\x6e\x6f\162\145\x46\x69\x6c\x65\x3a\40\163\164\x61\162\164\40\x6f\146\x20\146\151\154\145\x2c\40\x6d\x75\154\164\x69\x2d\x6c\x69\156\145\x20\x73\x74\141\162\40\143\157\155\155\x65\x6e\164" => array("\142\145\x66\x6f\x72\145" => "\x2f\52" . PHP_EOL . "\40\160\x68\x70\x63\163\72\151\x67\x6e\x6f\162\x65\x46\x69\154\x65" . PHP_EOL . "\x20\52\x2f"), "\x69\x67\x6e\x6f\162\x65\x46\151\154\x65\x3a\40\163\x74\x61\162\x74\x20\157\x66\x20\x66\x69\x6c\145\54\x20\x73\x69\156\x67\154\x65\x2d\154\151\156\145\x20\x64\x6f\x63\142\154\157\143\153\40\143\x6f\x6d\155\145\x6e\x74" => array("\x62\x65\146\x6f\x72\145" => "\57\x2a\52\40\160\150\x70\143\163\72\x69\x67\x6e\157\x72\x65\x46\x69\x6c\145\40\52\x2f"), "\151\147\156\157\162\145\106\151\154\x65\72\x20\x6c\x61\x74\145\x20\143\x6f\x6d\x6d\x65\156\x74\x2c\x20\x73\154\x61\163\150\40\x63\157\155\x6d\145\x6e\164" => array("\x62\145\x66\157\x72\145" => '', "\x61\146\x74\x65\x72" => "\57\57\40\x70\150\x70\x63\163\x3a\x69\x67\156\x6f\x72\145\106\151\154\x65"), "\x6f\x6c\x64\x20\x73\x74\x79\154\145\x3a\40\163\x74\141\162\164\40\x6f\146\x20\x66\x69\x6c\x65\x2c\x20\x73\154\141\163\150\40\143\x6f\x6d\155\145\x6e\164" => array("\x62\x65\146\157\162\x65" => "\x2f\x2f\x20\100\x63\157\x64\x69\156\147\x53\164\141\x6e\x64\141\162\x64\163\x49\147\156\x6f\x72\x65\106\151\x6c\x65"), "\x6f\154\x64\40\163\164\x79\x6c\x65\x3a\40\x73\164\x61\162\164\40\x6f\x66\40\146\151\x6c\x65\x2c\x20\163\151\156\x67\x6c\145\55\x6c\151\156\145\40\x73\x74\x61\162\40\x63\157\155\155\145\x6e\x74" => array("\x62\145\146\157\x72\145" => "\57\52\40\100\143\157\x64\151\x6e\147\x53\164\141\156\x64\x61\x72\144\163\111\147\x6e\157\162\x65\106\x69\x6c\145\x20\52\x2f"), "\157\154\144\40\x73\x74\x79\154\145\72\x20\x73\x74\x61\x72\x74\40\157\x66\x20\x66\x69\154\x65\54\x20\x6d\165\154\x74\151\x2d\x6c\151\x6e\145\x20\163\x74\141\x72\40\143\x6f\x6d\155\x65\x6e\x74" => array("\x62\x65\146\x6f\x72\x65" => "\57\52" . PHP_EOL . "\x20\x40\143\157\144\x69\x6e\x67\x53\164\141\156\144\141\162\x64\163\x49\x67\156\157\162\145\x46\x69\154\x65" . PHP_EOL . "\x20\x2a\x2f"), "\157\154\x64\x20\163\x74\171\x6c\x65\x3a\x20\163\x74\141\x72\164\x20\157\146\40\146\x69\x6c\x65\x2c\40\x73\x69\x6e\x67\154\145\x2d\x6c\x69\156\x65\x20\x64\157\143\x62\x6c\157\143\x6b\40\143\x6f\x6d\x6d\x65\156\x74" => array("\x62\145\x66\x6f\162\x65" => "\57\52\52\x20\x40\143\157\x64\151\156\x67\x53\x74\141\156\x64\x61\x72\x64\163\111\147\156\157\162\145\x46\151\x6c\145\40\x2a\57"), "\x6f\x6c\x64\x20\x73\x74\171\x6c\145\72\x20\154\x61\x74\145\x20\143\157\x6d\155\x65\156\x74\x2c\x20\163\154\141\163\150\40\143\157\x6d\x6d\x65\x6e\164" => array("\142\145\146\x6f\x72\145" => '', "\x61\x66\164\x65\x72" => "\57\x2f\x20\100\143\x6f\x64\x69\156\x67\x53\x74\x61\x6e\144\x61\x72\x64\x73\x49\147\156\x6f\x72\x65\106\151\x6c\145")); } public function testDisableSelected($before, $expectedErrors = 0, $expectedWarnings = 0) { static $config, $ruleset; if (isset($config, $ruleset) === false) { $config = new Config(); $config->standards = array("\107\145\156\x65\162\x69\143"); $config->sniffs = array("\107\x65\156\x65\162\151\x63\x2e\x50\110\120\x2e\114\157\x77\145\x72\103\141\163\x65\103\x6f\x6e\x73\164\141\156\164", "\x47\x65\x6e\x65\x72\151\143\x2e\103\x6f\x6d\x6d\145\x6e\164\x69\156\147\56\x54\x6f\144\157"); $ruleset = new Ruleset($config); } $content = "\74\77\160\150\x70\xa{$before}\xa\44\x76\141\x72\x20\x3d\x20\106\x41\x4c\x53\105\x3b\xa\57\x2f\124\x4f\x44\117\x3a\x20\x77\162\x69\164\x65\x20\163\x6f\x6d\145\40\143\157\144\x65"; $file = new DummyFile($content, $ruleset, $config); $file->process(); $this->assertSame($expectedErrors, $file->getErrorCount()); $this->assertCount($expectedErrors, $file->getErrors()); $this->assertSame($expectedWarnings, $file->getWarningCount()); $this->assertCount($expectedWarnings, $file->getWarnings()); } public function dataDisableSelected() { return array("\144\151\x73\141\142\x6c\x65\x3a\x20\163\151\x6e\147\x6c\145\40\163\156\151\x66\x66" => array("\x62\145\x66\157\162\145" => "\x2f\x2f\40\160\x68\160\x63\163\x3a\144\x69\x73\141\x62\x6c\145\40\x47\145\x6e\145\162\151\x63\x2e\x43\157\x6d\155\x65\x6e\x74\151\x6e\147\56\x54\157\144\157", "\x65\170\160\145\143\x74\x65\x64\105\x72\162\157\x72\x73" => 1), "\144\x69\x73\141\x62\154\x65\72\40\x73\151\x6e\x67\x6c\145\40\x73\156\151\x66\146\x20\167\x69\x74\x68\40\162\x65\x61\163\157\156" => array("\x62\x65\x66\157\162\145" => "\43\40\160\x68\160\143\163\x3a\x64\x69\x73\x61\x62\154\x65\40\107\145\x6e\145\162\151\143\x2e\x43\x6f\155\x6d\x65\156\164\x69\x6e\x67\x2e\x54\x6f\144\157\x20\x2d\55\x20\146\157\162\x20\162\x65\x61\x73\157\x6e\x73", "\145\x78\160\x65\143\x74\x65\144\x45\x72\x72\157\162\163" => 1), "\144\151\163\x61\142\154\145\72\40\x73\151\x6e\x67\x6c\x65\40\x73\x6e\151\146\146\54\40\144\x6f\143\x62\154\x6f\x63\153" => array("\x62\145\146\157\x72\x65" => "\57\52\52" . PHP_EOL . "\40\x2a\x20\160\150\x70\143\x73\x3a\x64\151\x73\x61\142\x6c\145\40\107\145\x6e\145\x72\151\143\x2e\103\157\x6d\x6d\x65\x6e\164\151\x6e\147\x2e\x54\x6f\x64\157" . PHP_EOL . "\40\x2a\x2f\40", "\x65\x78\x70\145\x63\x74\x65\144\x45\x72\x72\x6f\x72\163" => 1), "\144\x69\163\141\142\154\145\72\40\163\151\x6e\147\154\145\x20\x73\156\x69\x66\146\x2c\40\x64\157\x63\142\154\157\143\x6b\x2c\40\167\x69\164\x68\40\100" => array("\142\x65\x66\157\162\145" => "\57\x2a\x2a" . PHP_EOL . "\40\x2a\x20\x40\x70\x68\160\x63\x73\x3a\144\151\163\141\142\154\x65\40\107\145\156\145\x72\151\143\56\103\x6f\x6d\155\x65\x6e\164\x69\156\x67\56\124\x6f\x64\157" . PHP_EOL . "\x20\52\57\40", "\x65\x78\x70\145\143\x74\145\x64\105\162\162\x6f\162\x73" => 1), "\144\x69\163\141\142\154\x65\x3a\40\x6d\x75\154\164\x69\x70\154\x65\40\163\156\x69\146\x66\163\x20\151\x6e\40\157\156\145\40\x63\157\155\x6d\145\x6e\164" => array("\x62\x65\146\x6f\162\145" => "\57\x2f\40\x70\x68\x70\143\163\x3a\144\x69\163\141\142\x6c\145\x20\x47\145\156\145\x72\x69\x63\x2e\103\x6f\155\x6d\145\156\164\151\156\147\56\x54\157\144\x6f\x2c\107\x65\156\x65\x72\x69\x63\56\x50\110\x50\x2e\x4c\x6f\x77\x65\162\x43\x61\x73\x65\x43\157\x6e\x73\x74\141\x6e\164"), "\x64\x69\163\x61\142\x6c\145\72\40\x6d\x75\154\164\x69\160\154\x65\40\x73\156\151\146\146\40\151\156\40\x6d\x75\x6c\164\151\160\154\145\x20\x63\x6f\155\155\x65\156\164\163" => array("\142\145\x66\x6f\162\145" => "\x2f\57\x20\x70\150\160\x63\x73\72\144\x69\163\x61\142\154\x65\40\x47\145\x6e\x65\x72\x69\x63\x2e\103\157\155\155\145\x6e\x74\x69\x6e\x67\x2e\124\x6f\x64\157" . PHP_EOL . "\x2f\x2f\40\x70\150\x70\x63\163\x3a\x64\x69\x73\141\x62\x6c\x65\x20\x47\145\x6e\145\162\151\x63\56\x50\x48\x50\x2e\114\x6f\167\x65\x72\103\x61\163\x65\103\157\156\x73\x74\x61\x6e\x74"), "\x64\x69\x73\x61\142\154\145\72\x20\143\157\155\160\154\x65\164\145\x20\143\141\164\145\x67\157\162\171" => array("\142\145\x66\157\x72\145" => "\57\x2f\40\160\150\160\x63\163\x3a\144\x69\x73\141\142\154\145\x20\107\x65\x6e\x65\x72\151\x63\x2e\103\x6f\x6d\x6d\x65\x6e\x74\x69\156\147", "\x65\170\160\145\x63\164\145\144\x45\162\x72\157\162\163" => 1), "\144\151\163\141\x62\x6c\145\x3a\x20\x77\x68\x6f\x6c\x65\x20\163\164\141\156\x64\x61\162\x64" => array("\x62\145\146\157\x72\x65" => "\x2f\57\x20\160\150\x70\x63\163\x3a\x64\x69\x73\141\x62\x6c\x65\x20\x47\x65\x6e\x65\162\151\143"), "\x64\151\x73\141\142\x6c\x65\72\40\x73\x69\156\147\x6c\145\40\x65\162\162\157\162\143\157\x64\145" => array("\x62\145\x66\157\x72\145" => "\43\40\100\x70\x68\x70\143\x73\72\x64\x69\163\x61\142\x6c\x65\x20\107\145\156\145\x72\x69\143\x2e\103\157\x6d\155\x65\156\x74\151\156\147\56\124\x6f\x64\x6f\56\x54\x61\x73\x6b\x46\x6f\x75\x6e\144", "\145\x78\x70\x65\x63\164\x65\x64\x45\162\x72\157\x72\x73" => 1), "\x64\151\163\x61\x62\x6c\145\x3a\40\x73\x69\x6e\147\154\x65\x20\x65\x72\162\x6f\162\x63\x6f\144\145\x20\141\156\144\x20\x61\x20\x63\141\x74\x65\147\157\x72\x79" => array("\142\x65\x66\x6f\162\x65" => "\x2f\57\x20\160\150\x70\x63\x73\72\144\x69\163\x61\142\154\145\40\x47\x65\x6e\x65\162\151\143\56\x50\x48\120\x2e\114\x6f\167\145\x72\103\x61\163\145\x43\157\x6e\163\164\141\x6e\x74\x2e\106\157\165\156\144\54\x47\x65\156\145\162\151\x63\56\x43\157\155\155\145\156\164\x69\156\x67"), "\x64\x69\163\x61\142\154\x65\72\x20\x77\x72\157\x6e\147\40\x65\162\162\157\x72\40\143\157\x64\145\40\141\x6e\x64\40\143\x61\x74\x65\147\x6f\162\171" => array("\142\145\146\x6f\162\x65" => "\x2f\x2a\x2a" . PHP_EOL . "\40\52\x20\x70\x68\x70\143\x73\72\x64\x69\x73\141\142\154\x65\40\107\x65\x6e\x65\162\151\x63\56\120\110\x50\x2e\114\x6f\x77\x65\x72\x43\x61\163\145\x43\x6f\156\x73\164\141\156\x74\x2e\x55\160\160\145\162\x2c\107\x65\x6e\x65\162\x69\143\x2e\103\x6f\x6d\x6d\145\156\x74\163" . PHP_EOL . "\x20\52\57\x20", "\x65\170\160\x65\143\164\145\144\x45\x72\x72\x6f\x72\163" => 1, "\145\170\x70\145\143\164\x65\x64\127\141\x72\x6e\151\x6e\147\163" => 1), "\144\x69\x73\x61\x62\154\145\72\40\x77\x72\x6f\156\147\40\x63\141\x74\x65\147\157\162\171\x2c\40\144\x6f\x63\x62\154\157\x63\x6b" => array("\142\x65\146\x6f\x72\x65" => "\57\x2a\52" . PHP_EOL . "\40\52\x20\160\150\x70\143\163\72\x64\x69\163\x61\x62\154\145\40\107\145\x6e\145\x72\x69\143\56\106\151\x6c\145\163" . PHP_EOL . "\x20\x2a\57\x20", "\x65\170\x70\145\x63\164\145\144\x45\162\x72\157\x72\163" => 1, "\x65\170\x70\145\143\164\145\144\x57\x61\162\156\151\156\x67\x73" => 1), "\144\151\163\141\142\x6c\145\x3a\40\x77\x72\157\x6e\x67\x20\143\141\x74\x65\x67\157\x72\x79\x2c\x20\144\x6f\x63\x62\x6c\x6f\x63\153\x2c\40\167\x69\164\150\x20\x40" => array("\x62\145\146\157\x72\x65" => "\x2f\x2a\52" . PHP_EOL . "\40\x2a\x20\x40\160\x68\160\143\163\x3a\144\x69\163\141\x62\154\x65\x20\x47\145\156\145\x72\151\x63\56\x46\151\154\145\163" . PHP_EOL . "\x20\x2a\x2f\40", "\x65\x78\x70\145\x63\164\145\144\105\162\x72\x6f\x72\x73" => 1, "\x65\170\x70\x65\143\164\x65\x64\127\141\x72\156\151\x6e\147\163" => 1)); } public function testEnableSelected($code, $expectedErrors, $expectedWarnings) { static $config, $ruleset; if (isset($config, $ruleset) === false) { $config = new Config(); $config->standards = array("\x47\145\156\145\x72\x69\143"); $config->sniffs = array("\107\145\x6e\145\x72\x69\x63\56\120\x48\x50\56\114\x6f\167\x65\x72\103\x61\163\x65\x43\x6f\156\x73\164\x61\156\x74", "\x47\145\x6e\145\x72\x69\143\56\103\157\155\155\x65\156\164\151\156\147\x2e\124\x6f\x64\x6f"); $ruleset = new Ruleset($config); } $content = "\x3c\x3f\160\150\160\x20" . $code; $file = new DummyFile($content, $ruleset, $config); $file->process(); $this->assertSame($expectedErrors, $file->getErrorCount()); $this->assertCount($expectedErrors, $file->getErrors()); $this->assertSame($expectedWarnings, $file->getWarningCount()); $this->assertCount($expectedWarnings, $file->getWarnings()); } public function dataEnableSelected() { return array("\144\x69\163\141\142\154\145\57\x65\x6e\141\142\154\x65\x3a\x20\141\x20\x73\151\156\147\154\x65\x20\163\x6e\151\x66\146" => array("\143\x6f\x64\x65" => "\xa\40\x20\40\40\x20\x20\x20\40\40\40\x20\40\x20\x20\x20\40\x20\x20\40\40\x2f\x2f\x20\160\x68\x70\x63\x73\72\x64\x69\163\x61\142\154\145\x20\107\x65\x6e\145\x72\x69\143\56\103\157\155\x6d\145\x6e\x74\x69\156\147\x2e\x54\157\144\157\12\40\x20\x20\x20\40\x20\40\x20\40\x20\40\40\40\x20\x20\x20\x20\x20\x20\40\44\166\x61\x72\40\75\x20\x46\x41\114\x53\x45\73\12\40\40\x20\x20\x20\40\40\x20\40\40\40\x20\40\40\x20\40\x20\40\40\40\57\x2f\x54\117\104\117\72\x20\167\x72\151\164\145\x20\163\157\x6d\x65\40\x63\x6f\144\x65\xa\x20\x20\40\x20\40\40\40\40\40\40\40\x20\x20\x20\x20\40\40\40\40\40\57\57\x20\x70\150\x70\x63\163\72\145\156\x61\x62\x6c\145\x20\107\x65\156\x65\x72\151\143\56\103\157\155\x6d\145\156\164\151\x6e\147\56\x54\157\x64\157\xa\40\x20\x20\x20\x20\40\x20\40\x20\x20\40\x20\x20\x20\x20\x20\x20\40\40\40\x2f\57\124\117\104\x4f\72\40\x77\x72\x69\x74\145\40\163\x6f\x6d\145\x20\143\157\x64\x65", "\x65\170\160\x65\143\164\145\144\x45\x72\x72\157\x72\x73" => 1, "\145\170\160\145\x63\x74\x65\144\x57\141\x72\x6e\151\156\x67\163" => 1), "\x64\151\x73\141\142\x6c\145\x2f\145\156\x61\142\154\145\x3a\x20\155\x75\x6c\x74\x69\x70\x6c\145\x20\163\x6e\151\146\x66\x73" => array("\x63\157\144\145" => "\xa\x20\40\x20\x20\x20\40\x20\40\x20\x20\40\40\x20\x20\x20\40\x20\x20\40\x20\57\x2f\x20\x70\150\160\x63\x73\72\144\x69\163\x61\x62\x6c\145\x20\x47\x65\x6e\x65\162\151\143\x2e\x43\x6f\155\x6d\145\156\x74\x69\x6e\x67\x2e\124\157\x64\x6f\54\107\x65\x6e\145\x72\151\x63\56\x50\x48\x50\x2e\114\157\x77\x65\162\x43\x61\163\145\x43\x6f\x6e\163\x74\141\x6e\164\xa\40\x20\x20\40\40\x20\x20\40\40\40\40\40\x20\x20\40\x20\40\x20\x20\x20\44\166\x61\162\40\x3d\x20\106\101\x4c\123\x45\73\12\40\x20\x20\x20\40\x20\x20\x20\40\40\40\x20\40\x20\x20\40\x20\40\x20\x20\57\x2f\124\x4f\104\117\72\40\167\x72\x69\x74\x65\x20\163\x6f\x6d\145\40\143\x6f\144\145\12\40\x20\40\40\x20\40\40\40\x20\40\x20\x20\x20\40\x20\40\x20\40\40\x20\x2f\x2f\x20\160\150\160\143\x73\72\x65\x6e\141\142\154\x65\40\107\145\156\145\162\151\x63\56\103\x6f\x6d\x6d\145\156\164\x69\x6e\147\56\124\157\x64\x6f\54\x47\x65\x6e\x65\162\x69\x63\x2e\x50\x48\x50\x2e\x4c\157\167\x65\162\103\x61\163\x65\103\x6f\x6e\x73\164\x61\156\x74\xa\x20\x20\x20\40\40\40\40\40\40\40\40\40\40\40\40\40\40\40\x20\x20\57\57\124\x4f\104\117\x3a\x20\167\162\x69\x74\x65\40\163\x6f\x6d\x65\40\x63\157\144\145\xa\40\x20\x20\x20\40\40\40\x20\40\40\x20\x20\x20\x20\40\40\x20\40\40\x20\44\166\x61\162\40\x3d\x20\x46\101\x4c\x53\105\73", "\x65\x78\x70\145\143\164\x65\x64\x45\162\x72\157\x72\163" => 1, "\145\170\x70\x65\x63\164\145\x64\127\x61\x72\156\151\x6e\147\163" => 1), "\144\151\x73\141\x62\x6c\145\x3a\x20\x6d\165\x6c\164\151\x70\154\145\x20\x73\x6e\x69\146\146\x73\x3b\40\145\x6e\x61\142\x6c\x65\72\x20\157\156\x65" => array("\x63\157\144\145" => "\12\40\x20\x20\x20\40\40\40\40\x20\40\40\40\40\40\40\40\40\x20\x20\40\43\40\x70\150\160\143\163\x3a\144\151\163\x61\x62\154\145\x20\x47\x65\156\145\162\x69\143\x2e\103\x6f\x6d\x6d\145\156\x74\x69\156\x67\56\124\x6f\x64\157\54\107\x65\156\x65\162\151\x63\56\x50\x48\x50\x2e\114\157\x77\145\162\103\141\x73\145\x43\157\156\163\164\x61\x6e\164\xa\40\40\40\x20\40\40\x20\40\x20\40\x20\x20\40\x20\x20\40\x20\40\40\x20\x24\x76\x61\x72\x20\x3d\x20\106\x41\x4c\x53\105\x3b\xa\40\40\x20\x20\40\x20\40\x20\40\40\40\x20\x20\x20\40\x20\40\40\x20\40\57\x2f\x54\117\x44\117\x3a\40\167\162\x69\x74\145\x20\x73\157\155\145\x20\143\157\x64\x65\xa\x20\40\40\40\x20\x20\x20\x20\40\40\x20\40\x20\x20\x20\40\40\40\x20\x20\43\40\x70\150\x70\x63\163\72\145\156\x61\x62\x6c\x65\40\x47\x65\156\x65\x72\151\x63\x2e\103\x6f\155\x6d\x65\x6e\x74\151\156\x67\56\124\x6f\x64\157\xa\x20\x20\x20\40\x20\x20\40\40\x20\40\40\x20\40\x20\x20\40\x20\x20\x20\40\x2f\57\x54\117\x44\117\72\x20\167\162\x69\164\x65\x20\163\x6f\x6d\x65\40\x63\x6f\x64\x65\xa\40\x20\x20\40\40\x20\x20\40\40\x20\40\40\40\x20\40\40\40\40\x20\x20\x24\x76\x61\162\x20\75\40\x46\101\x4c\123\105\x3b", "\145\x78\160\x65\143\x74\145\x64\105\162\x72\157\x72\163" => 0, "\x65\170\x70\145\143\x74\x65\144\127\x61\x72\156\x69\156\x67\163" => 1), "\x64\151\x73\x61\x62\x6c\x65\x2f\x65\156\x61\142\154\145\x3a\40\x63\157\155\160\x6c\x65\164\145\40\x63\x61\x74\145\147\157\162\171" => array("\x63\157\144\x65" => "\12\40\x20\x20\x20\40\40\40\x20\40\40\40\40\40\40\x20\x20\40\x20\40\x20\x2f\x2f\40\160\150\160\143\163\72\x64\x69\163\x61\x62\154\x65\40\x47\x65\x6e\x65\x72\x69\x63\56\103\x6f\155\155\145\x6e\164\x69\156\147\xa\40\x20\x20\40\40\x20\40\40\40\x20\40\40\x20\40\x20\x20\40\x20\40\40\44\166\x61\162\x20\75\40\x46\x41\x4c\x53\105\x3b\12\x20\40\x20\x20\x20\40\40\40\x20\40\40\x20\x20\x20\x20\40\x20\x20\x20\x20\57\57\124\x4f\104\x4f\72\40\167\162\x69\x74\x65\x20\x73\157\x6d\145\x20\143\x6f\144\x65\xa\40\40\x20\40\40\x20\x20\40\x20\40\40\x20\40\40\x20\40\40\40\40\x20\x2f\57\40\160\150\x70\143\163\72\145\156\141\142\x6c\x65\40\107\145\156\145\x72\151\143\56\103\157\155\155\x65\156\x74\151\156\x67\xa\x20\x20\40\x20\x20\x20\x20\x20\x20\40\40\x20\40\40\x20\40\40\x20\x20\x20\x2f\57\x54\117\104\117\x3a\x20\167\162\x69\164\145\x20\163\x6f\x6d\x65\40\x63\157\x64\x65", "\145\x78\x70\x65\143\164\145\x64\x45\162\162\x6f\162\x73" => 1, "\145\x78\160\145\x63\x74\x65\144\127\x61\162\156\x69\x6e\147\163" => 1), "\x64\x69\163\x61\142\154\x65\57\x65\156\x61\142\x6c\145\x3a\40\167\x68\157\x6c\x65\40\x73\x74\141\x6e\144\141\x72\144" => array("\x63\x6f\x64\145" => "\12\40\x20\x20\x20\40\40\40\40\x20\x20\x20\40\40\40\x20\x20\x20\40\40\40\x2f\x2f\x20\x70\x68\160\x63\x73\72\x64\x69\163\x61\x62\x6c\145\40\107\145\x6e\x65\162\151\143\12\40\x20\x20\40\40\40\40\x20\40\x20\x20\x20\x20\40\x20\x20\x20\x20\x20\x20\44\x76\141\162\x20\x3d\40\106\101\x4c\123\105\73\xa\40\x20\x20\x20\40\40\x20\x20\40\x20\40\40\x20\x20\40\40\40\40\40\x20\x2f\57\124\117\104\x4f\x3a\x20\167\x72\x69\x74\145\x20\x73\x6f\155\x65\40\143\x6f\x64\145\xa\x20\40\x20\x20\x20\x20\x20\40\40\40\40\40\x20\40\40\x20\40\x20\40\40\57\57\40\x70\x68\x70\x63\163\x3a\x65\x6e\x61\142\x6c\x65\x20\107\145\156\x65\162\x69\143\xa\x20\40\40\x20\40\40\x20\40\x20\x20\x20\40\40\40\40\40\40\40\x20\x20\x2f\x2f\124\x4f\x44\x4f\72\x20\167\x72\151\x74\145\x20\163\x6f\155\145\x20\x63\157\x64\145", "\145\170\160\x65\x63\164\145\x64\105\x72\x72\157\x72\x73" => 0, "\145\170\x70\145\x63\x74\145\x64\127\x61\x72\156\151\156\x67\163" => 1), "\144\151\163\141\x62\154\145\x3a\x20\167\150\x6f\x6c\145\40\x73\x74\141\156\144\141\162\144\x3b\40\145\156\141\142\x6c\x65\x3a\x20\x63\x61\x74\145\147\x6f\x72\171\x20\146\162\157\x6d\40\164\150\145\x20\x73\x74\141\x6e\x64\x61\x72\144" => array("\x63\157\144\x65" => "\12\x20\x20\40\40\x20\40\x20\x20\x20\40\x20\x20\40\x20\40\x20\x20\40\40\x20\x2f\57\40\160\150\160\x63\x73\x3a\144\x69\163\141\x62\154\145\40\107\145\x6e\145\162\151\x63\12\x20\40\40\x20\x20\40\40\40\x20\x20\40\x20\x20\x20\x20\40\40\40\x20\x20\44\166\141\162\x20\75\x20\x46\101\x4c\x53\x45\x3b\12\40\40\40\40\x20\40\x20\x20\x20\x20\x20\40\40\x20\x20\40\40\x20\x20\x20\x2f\57\x54\x4f\104\117\x3a\40\x77\162\151\164\x65\x20\x73\157\x6d\x65\40\x63\157\x64\x65\12\40\x20\40\x20\40\40\x20\x20\x20\x20\x20\40\40\40\40\x20\40\40\40\x20\x2f\57\x20\x70\x68\160\143\163\x3a\145\x6e\x61\x62\154\145\x20\107\x65\x6e\x65\162\151\x63\x2e\103\157\155\155\x65\156\164\151\156\x67\12\40\x20\40\40\40\40\x20\40\x20\x20\40\40\40\x20\x20\x20\x20\40\40\x20\57\57\124\117\104\117\x3a\x20\x77\162\x69\164\145\40\x73\x6f\x6d\145\40\x63\x6f\144\145", "\x65\x78\x70\x65\143\164\x65\x64\105\162\162\x6f\x72\163" => 0, "\x65\x78\160\x65\143\164\145\x64\127\x61\162\156\151\x6e\x67\x73" => 1), "\x64\x69\x73\x61\x62\x6c\145\72\40\x61\40\x63\141\x74\145\x67\x6f\162\x79\73\x20\145\156\x61\142\x6c\x65\72\x20\x74\150\x65\x20\x77\x68\x6f\154\145\x20\x73\x74\x61\x6e\x64\141\x72\x64\x20\x63\x6f\156\x74\141\x69\x6e\151\156\x67\40\x74\150\x65\x20\x63\x61\164\145\147\157\162\171" => array("\x63\x6f\x64\x65" => "\12\40\40\x20\40\40\40\40\40\40\x20\x20\x20\40\x20\40\40\40\x20\x20\x20\43\40\160\x68\x70\x63\x73\72\x64\151\x73\141\x62\154\145\40\x47\x65\x6e\145\162\151\x63\56\x43\157\155\x6d\145\156\164\151\156\147\xa\x20\40\x20\x20\40\x20\x20\40\x20\40\40\40\40\40\40\40\x20\x20\x20\40\44\166\x61\162\x20\75\x20\106\x41\114\x53\x45\73\xa\x20\x20\x20\40\40\x20\40\x20\40\40\x20\40\x20\x20\40\x20\40\40\x20\x20\57\57\x54\x4f\x44\117\x3a\x20\167\162\151\x74\x65\x20\x73\157\155\145\40\143\x6f\144\x65\12\40\40\x20\x20\x20\x20\40\40\x20\x20\x20\40\x20\40\x20\x20\x20\40\x20\40\43\x20\160\x68\x70\x63\163\72\145\156\141\x62\x6c\x65\40\x47\x65\x6e\145\162\151\x63\12\40\40\40\x20\40\40\40\x20\x20\x20\40\40\x20\40\x20\x20\40\x20\40\x20\x2f\57\124\117\104\117\x3a\40\x77\x72\151\164\145\40\163\x6f\x6d\145\x20\x63\x6f\144\145", "\x65\x78\160\x65\x63\164\145\x64\x45\162\x72\157\x72\x73" => 1, "\145\170\160\x65\x63\x74\x65\144\127\141\162\x6e\151\156\147\163" => 1), "\x64\x69\163\x61\142\x6c\145\x3a\x20\x73\x69\x6e\147\x6c\x65\40\x73\156\151\146\x66\73\40\145\156\141\142\154\145\72\x20\x74\150\145\40\x63\141\164\145\147\x6f\162\171\x20\143\157\x6e\x74\141\151\x6e\151\x6e\147\x20\x74\x68\145\40\x73\156\151\146\x66" => array("\x63\157\144\x65" => "\12\x20\40\x20\40\40\40\x20\40\x20\40\40\40\40\x20\40\x20\40\x20\40\x20\57\57\x20\x70\150\160\x63\163\72\144\x69\163\x61\x62\154\x65\x20\x47\x65\x6e\x65\x72\x69\143\x2e\x43\x6f\x6d\x6d\145\156\164\x69\156\x67\x2e\x54\157\x64\157\12\x20\40\x20\x20\x20\40\40\40\40\x20\40\x20\x20\40\40\x20\40\x20\x20\x20\x24\x76\x61\162\x20\x3d\40\x46\x41\114\123\x45\x3b\xa\40\x20\x20\x20\x20\40\40\40\40\40\40\40\x20\40\40\40\x20\40\40\40\57\x2f\x54\x4f\104\x4f\x3a\40\167\x72\151\x74\x65\x20\163\157\x6d\x65\x20\x63\x6f\144\145\xa\x20\40\x20\x20\x20\40\x20\x20\x20\40\x20\x20\40\x20\x20\x20\x20\x20\x20\40\x2f\x2f\40\x70\x68\x70\x63\163\x3a\145\x6e\141\x62\x6c\x65\x20\x47\145\156\145\162\x69\143\56\x43\x6f\x6d\155\x65\x6e\164\151\156\x67\xa\40\40\40\x20\x20\40\x20\x20\x20\x20\40\x20\x20\x20\x20\40\x20\40\40\40\57\57\x54\117\104\117\72\40\167\162\151\x74\145\x20\163\157\x6d\x65\x20\x63\157\x64\145", "\x65\170\x70\145\x63\x74\145\144\105\162\162\x6f\162\163" => 1, "\145\x78\x70\x65\143\x74\145\x64\x57\141\162\156\x69\x6e\x67\163" => 1), "\144\151\x73\141\x62\154\x65\x3a\40\167\150\157\154\x65\40\163\x74\141\x6e\144\141\x72\144\73\x20\x65\156\x61\142\154\145\72\40\163\151\x6e\x67\x6c\145\40\x73\156\151\x66\146\40\x66\x72\157\x6d\40\x74\150\x65\40\163\164\141\156\x64\x61\x72\x64" => array("\x63\157\144\x65" => "\xa\x20\x20\40\40\x20\x20\40\x20\40\x20\40\x20\40\40\x20\40\40\x20\40\40\x2f\57\x20\160\x68\x70\x63\163\x3a\144\151\x73\x61\x62\154\x65\x20\107\x65\x6e\145\x72\151\x63\xa\40\x20\x20\40\40\40\x20\x20\x20\x20\x20\x20\x20\x20\x20\40\x20\x20\x20\x20\x24\x76\141\162\40\x3d\40\x46\101\114\123\105\x3b\12\x20\x20\40\x20\x20\x20\x20\x20\40\40\40\40\x20\40\x20\40\x20\x20\x20\40\57\x2f\124\x4f\x44\x4f\x3a\40\167\162\151\x74\145\40\x73\x6f\155\x65\40\x63\x6f\144\x65\12\x20\40\40\x20\x20\40\40\x20\40\40\x20\40\40\x20\x20\40\x20\40\x20\x20\57\x2f\x20\x70\x68\160\x63\x73\72\x65\x6e\x61\142\154\145\40\x47\145\156\145\162\151\143\x2e\x43\x6f\155\x6d\x65\156\164\151\x6e\x67\x2e\x54\x6f\x64\x6f\xa\40\x20\40\x20\40\40\x20\40\x20\40\x20\x20\40\x20\40\40\x20\x20\x20\40\x2f\57\124\117\104\117\x3a\x20\167\162\x69\164\x65\x20\163\157\x6d\145\x20\x63\x6f\144\x65", "\x65\170\160\x65\x63\164\145\x64\x45\162\x72\157\162\x73" => 0, "\x65\x78\160\145\x63\x74\x65\144\127\x61\162\x6e\x69\x6e\x67\x73" => 1), "\144\151\x73\141\x62\x6c\x65\72\40\x77\x68\x6f\154\145\40\163\164\x61\x6e\x64\141\162\x64\x3b\x20\145\x6e\141\142\154\145\72\x20\163\151\x6e\x67\154\x65\x20\163\156\151\x66\146\x20\x66\x72\x6f\x6d\x20\164\150\145\40\163\x74\141\x6e\144\141\x72\144\x3b\40\144\151\x73\x61\142\x6c\145\x3a\x20\164\150\x61\164\40\163\x61\155\145\40\163\156\151\x66\x66\x3b\x20\x65\x6e\141\142\154\x65\72\40\145\x76\145\162\x79\x74\150\x69\x6e\x67" => array("\x63\x6f\144\145" => "\xa\40\40\x20\x20\40\40\x20\40\40\x20\x20\40\x20\x20\40\40\40\x20\40\40\x2f\57\40\x70\150\160\x63\163\x3a\144\x69\163\x61\142\x6c\145\40\107\145\156\x65\162\x69\x63\12\x20\40\x20\x20\x20\40\x20\40\x20\40\40\x20\40\x20\40\40\40\40\x20\40\44\166\x61\x72\x20\x3d\x20\106\x41\x4c\x53\x45\73\12\x20\40\40\40\x20\40\40\40\x20\x20\x20\40\40\40\40\40\40\40\40\x20\x2f\x2f\124\x4f\x44\117\72\x20\167\x72\x69\164\x65\x20\x73\x6f\x6d\145\40\x63\157\x64\x65\xa\x20\40\40\40\x20\x20\40\40\x20\40\x20\40\40\40\x20\x20\x20\x20\40\x20\57\x2f\x20\160\150\x70\143\x73\72\145\156\x61\x62\x6c\145\x20\x47\x65\156\145\162\x69\143\x2e\x43\x6f\155\155\x65\156\x74\x69\156\x67\x2e\x54\157\x64\157\12\40\x20\40\40\x20\x20\40\40\x20\x20\40\x20\x20\x20\40\x20\40\x20\x20\40\x2f\x2f\x54\x4f\x44\117\72\x20\x77\x72\151\164\x65\x20\x73\x6f\x6d\145\40\143\157\144\145\12\x20\x20\x20\40\40\x20\40\x20\40\x20\x20\x20\40\40\40\x20\40\x20\40\x20\57\x2f\x20\x70\x68\x70\143\163\72\144\x69\x73\141\142\154\x65\40\107\x65\x6e\x65\x72\x69\143\56\x43\x6f\x6d\155\x65\156\164\x69\156\x67\56\x54\x6f\144\157\xa\40\x20\40\40\x20\x20\x20\x20\x20\x20\x20\40\x20\40\40\x20\40\x20\40\40\57\x2f\x54\117\104\x4f\72\x20\167\162\x69\164\x65\40\163\x6f\x6d\x65\40\x63\157\x64\x65\12\40\x20\40\x20\40\x20\x20\40\40\x20\x20\x20\40\40\x20\40\x20\x20\40\40\57\x2f\40\x70\x68\160\x63\163\72\x65\x6e\141\x62\154\145\12\x20\x20\x20\40\40\40\40\x20\x20\40\40\x20\x20\40\x20\40\x20\40\x20\40\57\x2f\124\117\104\117\72\x20\x77\x72\151\x74\145\x20\x73\x6f\x6d\145\x20\143\x6f\144\145", "\145\170\160\x65\143\164\x65\144\105\x72\x72\157\162\163" => 0, "\145\x78\160\145\143\x74\145\144\127\141\x72\156\151\x6e\147\x73" => 2), "\144\151\x73\x61\142\154\x65\x3a\40\167\x68\157\154\x65\x20\163\x74\141\156\x64\141\162\144\x3b\40\x65\x6e\x61\x62\154\x65\x3a\x20\x73\151\x6e\x67\x6c\x65\40\163\156\x69\x66\x66\40\146\162\x6f\155\x20\164\150\145\40\163\164\x61\156\144\141\x72\144\73\40\x65\x6e\x61\142\154\145\72\40\x6f\164\x68\x65\162\x20\x73\x6e\151\x66\x66\x20\x66\x72\x6f\x6d\x20\164\150\145\40\x73\x74\141\x6e\144\x61\162\144" => array("\x63\157\144\145" => "\12\40\x20\40\x20\40\40\x20\40\x20\x20\40\40\x20\40\40\40\40\x20\x20\40\x2f\57\40\x70\150\x70\143\x73\72\144\151\x73\x61\142\154\145\x20\107\145\x6e\x65\162\151\x63\12\40\40\40\x20\x20\x20\x20\40\x20\x20\40\40\x20\40\x20\40\40\x20\40\x20\44\x76\141\x72\x20\75\40\x46\x41\x4c\x53\105\x3b\xa\x20\x20\x20\40\40\x20\40\40\x20\40\x20\x20\x20\x20\x20\40\40\40\x20\x20\x2f\57\124\x4f\x44\117\72\x20\x77\162\x69\x74\x65\x20\x73\157\155\145\40\143\157\x64\145\xa\40\40\x20\40\40\40\40\x20\40\40\40\x20\x20\x20\40\40\x20\x20\x20\x20\x2f\x2f\x20\160\150\x70\143\x73\72\x65\156\x61\142\154\145\40\x47\x65\x6e\x65\162\x69\143\56\x43\157\x6d\x6d\x65\x6e\164\151\x6e\x67\56\x54\x6f\x64\x6f\xa\x20\40\40\40\x20\x20\x20\40\x20\x20\x20\40\x20\x20\40\x20\x20\40\x20\x20\57\57\124\x4f\104\117\72\x20\x77\162\x69\164\x65\40\163\157\155\145\40\143\x6f\144\145\xa\40\x20\40\40\x20\40\x20\40\40\x20\x20\40\40\40\40\x20\40\40\40\x20\x24\x76\x61\162\40\75\x20\x46\x41\x4c\123\x45\73\12\x20\40\x20\x20\40\x20\40\x20\x20\x20\x20\x20\x20\x20\x20\x20\40\x20\x20\x20\57\x2f\40\x70\150\x70\143\x73\x3a\145\x6e\x61\x62\154\x65\x20\x47\145\x6e\145\x72\x69\x63\x2e\x50\x48\x50\56\114\157\x77\145\x72\x43\141\x73\145\x43\x6f\156\x73\x74\141\x6e\164\12\40\x20\x20\40\x20\x20\40\x20\40\x20\40\x20\40\40\40\x20\40\x20\x20\x20\x2f\57\124\117\104\117\x3a\40\167\162\151\164\145\x20\163\157\x6d\145\x20\x63\157\144\x65\12\x20\40\x20\40\40\x20\40\40\40\40\x20\x20\x20\x20\40\40\x20\x20\x20\x20\x24\166\141\162\x20\x3d\40\x46\x41\x4c\123\x45\x3b", "\x65\x78\160\145\143\x74\145\144\105\x72\x72\x6f\162\163" => 1, "\x65\170\x70\x65\x63\164\145\x64\x57\141\162\156\x69\156\147\163" => 2)); } public function testIgnoreSelected($before, $expectedErrors, $expectedWarnings) { static $config, $ruleset; if (isset($config, $ruleset) === false) { $config = new Config(); $config->standards = array("\x47\145\x6e\145\162\x69\x63"); $config->sniffs = array("\x47\145\156\145\162\x69\x63\56\120\x48\x50\x2e\x4c\x6f\167\x65\x72\x43\141\163\145\103\x6f\x6e\163\x74\141\x6e\x74", "\107\x65\156\145\162\x69\143\x2e\103\157\x6d\155\145\156\164\151\x6e\x67\x2e\124\x6f\x64\157"); $ruleset = new Ruleset($config); } $content = "\74\x3f\160\150\x70\xa{$before}\12\44\166\141\162\40\x3d\x20\106\x41\114\123\105\x3b\40\57\57\x54\x4f\104\117\72\40\167\162\151\164\145\40\163\157\x6d\x65\40\143\157\x64\145\12\x24\166\141\162\40\x3d\40\x46\101\114\x53\x45\73\40\57\57\124\x4f\104\x4f\72\x20\167\162\151\164\145\x20\x73\157\x6d\x65\x20\143\x6f\144\145"; $file = new DummyFile($content, $ruleset, $config); $file->process(); $this->assertSame($expectedErrors, $file->getErrorCount()); $this->assertCount($expectedErrors, $file->getErrors()); $this->assertSame($expectedWarnings, $file->getWarningCount()); $this->assertCount($expectedWarnings, $file->getWarnings()); } public function dataIgnoreSelected() { return array("\156\x6f\x20\x73\x75\160\x70\x72\x65\163\x73\151\157\x6e" => array("\x62\x65\146\x6f\x72\x65" => '', "\145\x78\x70\x65\x63\x74\x65\x64\x45\162\162\x6f\x72\163" => 2, "\145\170\x70\145\143\x74\x65\144\127\x61\162\156\151\x6e\147\x73" => 2), "\151\x67\156\157\162\x65\72\40\163\151\156\x67\x6c\145\40\163\156\x69\x66\x66" => array("\142\145\x66\x6f\162\145" => "\x2f\x2f\40\x70\x68\160\143\x73\x3a\x69\147\x6e\x6f\x72\x65\x20\x47\x65\156\145\162\151\x63\56\103\157\155\x6d\x65\156\x74\x69\x6e\147\x2e\124\x6f\x64\x6f", "\x65\170\x70\x65\143\x74\x65\144\x45\x72\162\x6f\162\163" => 2, "\x65\170\160\x65\143\164\x65\x64\x57\x61\x72\x6e\x69\x6e\147\x73" => 1), "\x69\147\156\157\x72\145\x3a\40\155\x75\x6c\x74\151\x70\x6c\145\40\163\156\151\x66\146\163" => array("\x62\x65\x66\157\162\145" => "\x2f\57\x20\x70\150\160\143\163\x3a\151\147\x6e\x6f\x72\145\40\x47\145\x6e\x65\x72\x69\143\56\103\157\155\x6d\x65\156\x74\x69\x6e\x67\56\x54\x6f\144\x6f\x2c\x47\145\x6e\145\162\x69\x63\56\x50\110\x50\x2e\114\157\167\x65\162\103\141\x73\x65\x43\157\x6e\x73\x74\x61\156\164", "\x65\x78\160\x65\x63\164\x65\x64\105\x72\x72\x6f\162\163" => 1, "\x65\x78\160\145\143\x74\145\x64\127\x61\x72\x6e\x69\x6e\x67\x73" => 1), "\x64\151\163\x61\142\x6c\x65\72\40\x73\x69\156\x67\154\x65\40\x73\x6e\x69\146\x66\x3b\40\151\147\156\157\162\145\x3a\x20\163\x69\156\147\154\145\x20\x73\x6e\151\146\x66" => array("\142\145\x66\x6f\162\x65" => "\x2f\57\x20\160\150\160\143\163\72\144\151\163\x61\142\154\145\40\x47\145\156\145\x72\151\143\x2e\x43\x6f\155\155\145\156\x74\151\156\x67\x2e\x54\157\x64\x6f" . PHP_EOL . "\x2f\57\40\x70\150\160\143\163\x3a\x69\x67\x6e\157\x72\145\40\x47\x65\x6e\x65\x72\151\x63\x2e\120\110\x50\56\x4c\x6f\167\145\162\x43\x61\163\x65\x43\157\x6e\x73\x74\x61\156\164", "\145\170\x70\145\x63\x74\145\144\105\x72\162\x6f\162\x73" => 1, "\145\x78\x70\145\x63\x74\145\x64\127\141\x72\156\151\x6e\147\x73" => 0), "\x69\147\156\x6f\162\x65\72\x20\x63\141\x74\x65\147\157\162\171\40\x6f\x66\40\x73\156\x69\x66\146\x73" => array("\x62\145\146\x6f\x72\x65" => "\x23\40\160\x68\x70\x63\x73\x3a\x69\x67\x6e\x6f\x72\145\x20\x47\145\156\145\x72\151\x63\x2e\x43\157\x6d\x6d\145\x6e\x74\151\156\147", "\145\x78\x70\x65\143\164\145\144\105\x72\162\157\x72\x73" => 2, "\x65\170\x70\x65\x63\x74\145\144\127\141\x72\x6e\151\x6e\x67\x73" => 1), "\151\x67\x6e\x6f\x72\145\72\x20\x77\x68\157\x6c\145\x20\163\164\x61\156\x64\x61\x72\144" => array("\x62\x65\x66\x6f\x72\145" => "\57\57\x20\x70\150\160\143\163\x3a\151\147\x6e\157\x72\x65\x20\x47\145\156\145\x72\x69\x63", "\x65\170\160\145\x63\164\x65\144\105\x72\162\157\162\x73" => 1, "\145\x78\x70\145\143\164\145\x64\x57\141\162\x6e\x69\156\147\163" => 1)); } public function testCommenting($code, $expectedErrors, $expectedWarnings) { static $config, $ruleset; if (isset($config, $ruleset) === false) { $config = new Config(); $config->standards = array("\107\145\156\145\x72\151\143"); $config->sniffs = array("\107\145\x6e\145\162\151\143\x2e\120\110\120\56\114\x6f\x77\145\162\x43\x61\x73\145\103\x6f\x6e\163\164\x61\x6e\164", "\x47\145\156\x65\162\x69\x63\56\x43\157\x6d\155\x65\x6e\x74\x69\x6e\147\56\124\x6f\144\157"); $ruleset = new Ruleset($config); } $content = "\74\x3f\x70\x68\x70\40" . $code; $file = new DummyFile($content, $ruleset, $config); $file->process(); $this->assertSame($expectedErrors, $file->getErrorCount()); $this->assertCount($expectedErrors, $file->getErrors()); $this->assertSame($expectedWarnings, $file->getWarningCount()); $this->assertCount($expectedWarnings, $file->getWarnings()); } public function dataCommenting() { return array("\151\x67\x6e\157\162\145\x3a\40\163\x69\156\x67\x6c\x65\40\163\x6e\x69\x66\146" => array("\x63\157\x64\145" => "\12\40\40\x20\40\x20\x20\x20\x20\x20\40\40\x20\40\x20\x20\x20\x20\x20\x20\40\57\57\40\x70\150\x70\143\x73\72\151\147\156\157\x72\145\40\x47\145\156\x65\x72\x69\x63\56\x43\157\x6d\155\x65\x6e\x74\x69\156\147\56\x54\x6f\144\x6f\x20\x2d\55\40\x42\x65\x63\x61\165\x73\x65\40\x72\x65\x61\x73\x6f\156\163\xa\40\x20\40\40\x20\x20\x20\40\x20\40\40\x20\40\x20\40\40\40\x20\40\40\x24\x76\141\162\40\x3d\x20\x46\101\x4c\123\105\x3b\x20\x2f\57\x54\117\104\117\72\40\x77\x72\x69\x74\x65\40\x73\x6f\x6d\x65\x20\x63\157\x64\x65\xa\40\x20\x20\40\40\x20\x20\x20\x20\40\x20\40\40\40\40\x20\40\40\x20\x20\44\x76\141\162\x20\75\40\106\x41\114\123\x45\73\x20\57\57\x54\117\104\117\x3a\x20\167\x72\x69\164\x65\40\163\x6f\155\145\x20\x63\x6f\x64\x65", "\145\170\x70\x65\143\x74\x65\x64\x45\x72\162\157\162\x73" => 2, "\145\x78\x70\145\143\x74\x65\144\127\x61\162\x6e\151\156\147\x73" => 1), "\144\x69\163\x61\142\154\x65\x3a\40\163\x69\156\147\x6c\145\x20\163\x6e\x69\x66\x66\x3b\40\x65\156\141\142\154\145\72\40\x73\x61\x6d\x65\x20\x73\156\151\x66\146\40\55\x20\164\145\163\164\40\167\x68\x69\164\145\163\x70\141\143\x65\40\150\141\156\x64\154\x69\x6e\147\40\x61\x72\x6f\165\156\144\40\162\145\x61\x73\x6f\156\40\x64\145\x6c\x69\x6d\x69\x74\145\162" => array("\x63\157\144\x65" => "\xa\x20\40\x20\x20\40\x20\40\40\x20\40\40\x20\x20\x20\40\40\40\40\40\40\57\57\40\160\x68\160\x63\x73\x3a\x64\151\x73\141\142\x6c\x65\40\107\145\x6e\145\x72\151\143\56\x43\157\155\155\145\156\x74\151\x6e\x67\56\124\157\x64\x6f\40\55\x2d\x42\x65\x63\141\x75\163\x65\x20\162\145\x61\x73\x6f\x6e\163\12\x20\x20\40\40\40\x20\x20\40\40\x20\x20\x20\x20\x20\x20\x20\x20\40\40\40\x24\166\141\162\x20\75\40\106\101\114\123\105\x3b\xa\x20\40\40\x20\x20\x20\x20\x20\x20\x20\x20\40\40\40\40\x20\40\x20\40\40\x2f\x2f\124\x4f\x44\117\x3a\40\x77\x72\151\164\145\x20\x73\x6f\x6d\x65\x20\143\157\144\145\xa\40\x20\40\x20\x20\x20\x20\x20\x20\x20\40\x20\x20\x20\40\x20\40\40\x20\40\x2f\x2f\x20\160\x68\160\x63\163\72\x65\x6e\x61\x62\154\145\40\x47\145\156\x65\162\151\x63\56\103\157\x6d\x6d\145\x6e\164\151\x6e\x67\x2e\124\157\144\x6f\40\40\x20\x2d\55\x20\x20\102\x65\143\x61\165\x73\x65\40\x72\x65\x61\163\157\x6e\163\xa\40\40\x20\x20\x20\x20\x20\40\x20\x20\40\40\x20\40\40\40\40\x20\x20\x20\x2f\x2f\x54\x4f\104\x4f\x3a\x20\167\x72\151\x74\x65\x20\163\157\155\x65\40\143\x6f\144\x65", "\145\170\x70\145\143\164\145\x64\105\x72\162\157\162\163" => 1, "\145\x78\160\145\143\x74\145\144\127\x61\x72\x6e\x69\x6e\147\x73" => 1), "\144\x69\163\x61\142\x6c\x65\72\40\x73\x69\156\x67\x6c\145\x20\x73\156\x69\146\146\x2c\40\155\165\x6c\x74\151\x2d\x6c\151\156\x65\x20\x63\x6f\x6d\x6d\145\156\164" => array("\143\x6f\x64\x65" => "\12\x20\40\x20\40\x20\x20\x20\40\40\x20\x20\40\x20\x20\x20\x20\x20\x20\x20\40\x2f\52\12\40\40\x20\x20\x20\40\x20\x20\x20\x20\40\x20\40\40\x20\x20\x20\40\40\40\40\40\40\x20\104\151\x73\x61\x62\x6c\x65\40\163\157\x6d\x65\x20\143\x68\145\143\x6b\163\xa\x20\40\40\x20\40\40\40\40\x20\40\40\40\40\x20\40\x20\x20\40\x20\x20\40\x20\40\x20\x70\150\x70\143\163\72\144\x69\163\x61\x62\x6c\x65\x20\x47\x65\156\x65\x72\151\143\x2e\103\x6f\155\x6d\145\x6e\164\151\x6e\147\x2e\x54\157\144\157\xa\x20\40\40\40\40\40\x20\40\x20\x20\x20\40\x20\x20\x20\40\40\40\x20\x20\x2a\57\12\40\40\40\40\40\40\x20\40\x20\x20\40\x20\x20\x20\40\x20\40\x20\x20\40\44\166\141\x72\x20\x3d\40\x46\x41\x4c\123\x45\x3b\12\x20\40\x20\40\x20\x20\x20\40\x20\40\40\x20\x20\x20\x20\40\40\x20\40\x20\57\x2f\x54\117\x44\117\72\x20\167\162\151\164\145\x20\x73\x6f\155\145\x20\143\157\144\x65", "\145\170\160\145\143\x74\x65\x64\105\x72\x72\157\162\163" => 1, "\145\x78\x70\145\x63\164\x65\144\x57\x61\162\x6e\x69\x6e\x67\x73" => 0), "\x69\x67\x6e\x6f\162\x65\x3a\40\163\x69\156\x67\x6c\x65\x20\x73\x6e\x69\x66\146\x2c\40\x6d\x75\154\x74\x69\55\x6c\x69\x6e\x65\40\163\154\x61\x73\150\40\143\157\x6d\155\145\156\164" => array("\143\157\144\145" => "\12\x20\x20\x20\x20\x20\x20\40\40\x20\x20\x20\40\40\x20\40\x20\40\x20\x20\x20\x2f\57\x20\x54\165\x72\x6e\x20\157\146\146\x20\x61\x20\143\150\145\x63\153\x20\146\x6f\162\40\164\150\x65\40\156\145\170\x74\x20\154\x69\156\145\x20\157\x66\40\x63\x6f\x64\x65\56\12\40\40\x20\40\x20\40\40\40\x20\40\x20\40\40\x20\x20\40\x20\40\40\x20\x2f\x2f\x20\x70\150\160\143\163\x3a\x69\147\156\x6f\162\x65\40\x47\145\156\145\162\x69\143\x2e\103\157\x6d\155\x65\156\x74\x69\x6e\x67\56\x54\157\x64\x6f\xa\40\40\x20\x20\x20\40\40\40\x20\40\40\40\40\40\40\x20\x20\40\x20\x20\44\x76\141\x72\x20\x3d\x20\x46\101\114\123\105\x3b\40\x2f\57\124\x4f\104\117\72\40\x77\162\151\164\145\40\163\x6f\x6d\x65\x20\x63\157\144\145\xa\40\40\40\x20\x20\x20\40\40\x20\40\x20\x20\40\40\x20\x20\x20\40\40\40\44\166\x61\162\x20\x3d\40\x46\x41\114\x53\105\x3b\40\57\57\124\117\104\x4f\72\x20\x77\162\x69\x74\x65\x20\x73\157\x6d\x65\40\143\x6f\144\145", "\145\x78\x70\x65\143\x74\x65\x64\105\x72\x72\157\162\x73" => 2, "\x65\x78\x70\145\143\x74\x65\144\x57\x61\x72\156\151\x6e\147\x73" => 1), "\x65\x6e\x61\142\154\145\x20\x62\x65\146\x6f\162\x65\x20\144\x69\163\x61\142\154\x65\x2c\x20\163\x6e\151\x66\x66\40\156\157\x74\x20\x69\x6e\x20\163\x74\141\156\x64\141\x72\x64" => array("\x63\157\x64\x65" => "\xa\40\40\40\x20\40\x20\40\40\40\40\40\x20\x20\40\x20\40\x20\x20\40\x20\57\57\40\x70\150\160\x63\163\x3a\x65\x6e\x61\142\154\145\40\107\x65\x6e\145\162\x69\143\56\120\x48\120\56\116\157\x53\151\154\x65\x6e\x63\x65\144\x45\x72\x72\157\x72\163\x20\55\x2d\x20\102\145\143\x61\165\x73\x65\40\162\145\x61\x73\x6f\156\x73\xa\x20\40\40\40\40\40\x20\40\40\40\40\40\x20\40\40\40\x20\x20\40\x20\44\x76\x61\x72\40\x3d\40\x40\144\145\154\145\x74\x65\50\40\x24\x66\x69\x6c\x65\156\x61\x6d\x65\40\51\x3b\xa\40\40\40\x20\40\40\x20\x20\x20\x20\x20\x20\40\40\40\40\x20\x20\x20\40", "\x65\x78\160\145\143\164\x65\144\105\162\162\157\x72\x73" => 0, "\145\x78\160\145\143\164\145\144\x57\x61\162\x6e\x69\x6e\147\x73" => 0)); } }

Function Calls

None

Variables

None

Stats

MD5 b5f62fe382d5c637333ab205f008a32f
Eval Count 0
Decode Time 105 ms