diff --git a/.cspell.json b/.cspell.json index a495f45094..afdc28e1ab 100644 --- a/.cspell.json +++ b/.cspell.json @@ -3,8 +3,8 @@ "dictionaries": ["php"], "allowCompoundWords": true, "ignorePaths": [ - "src/Standards/*/Tests/*/*.{inc,js,css}", - "src/Standards/*/Tests/*/*.{inc,js,css}.fixed" + "src/Standards/*/Tests/*/*.inc", + "src/Standards/*/Tests/*/*.inc.fixed" ], "ignoreRegExpList": ["email", "^\\s+\\*\\s+@(author|copyright)\\s+.*$"], "words": [ @@ -28,9 +28,7 @@ "dnumber", "docblock", "encapsed", - "gjslint", "groupid", - "gsjlint", "hashbang", "heredoc", "hgblame", diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 20b695a36b..46b303311e 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -265,8 +265,6 @@ To help you with this, a number of convenience scripts are available: which will be placed in a `build/coverage-html` subdirectory. * `composer build` will build the phpcs.phar and phpcbf.phar files. -N.B.: You can ignore any skipped tests as these are for external tools. - ### Writing Tests diff --git a/.github/workflows/quicktest.yml b/.github/workflows/quicktest.yml index f76f8a2508..6bee46b36a 100644 --- a/.github/workflows/quicktest.yml +++ b/.github/workflows/quicktest.yml @@ -20,7 +20,7 @@ concurrency: jobs: #### QUICK TEST #### # This is a much quicker test run which only runs the unit tests against the low/medium/high - # supported PHP versions and skips the PHAR test and the tests for external JS/CSS tooling. + # supported PHP versions and skips the PHAR test. # These are basically the same builds as in the Test->Coverage workflow, but then without doing # the code-coverage. quicktest: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6c25ae69fb..a09c8dd92f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -189,21 +189,6 @@ jobs: - name: "DEBUG: show libxml loaded version (php)" run: php -r 'echo "libxml loaded version = ", LIBXML_LOADED_VERSION, PHP_EOL;' - # This action also handles the caching of the dependencies. - - name: Set up node - if: ${{ matrix.custom_ini == false }} - uses: actions/setup-node@v4 - with: - node-version: '20' - - - name: Install external tools used in tests - if: ${{ matrix.custom_ini == false }} - run: > - npm install -g --fund false - csslint - eslint - jshint - # Install dependencies and handle caching in one go. # @link https://github.com/marketplace/actions/install-php-dependencies-with-composer - name: Install Composer dependencies @@ -291,21 +276,6 @@ jobs: ini-values: error_reporting=-1, display_errors=On${{ steps.set_ini.outputs.PHP_INI }} coverage: xdebug - # This action also handles the caching of the dependencies. - - name: Set up node - if: ${{ matrix.custom_ini == false }} - uses: actions/setup-node@v4 - with: - node-version: '20' - - - name: Install external tools used in tests - if: ${{ matrix.custom_ini == false }} - run: > - npm install -g --fund false - csslint - eslint - jshint - # Install dependencies and handle caching in one go. # @link https://github.com/marketplace/actions/install-php-dependencies-with-composer - name: Install Composer dependencies diff --git a/README.md b/README.md index f5c7b132fa..ec500d8575 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ ## About -PHP_CodeSniffer is a set of two PHP scripts; the main `phpcs` script that tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard, and a second `phpcbf` script to automatically correct coding standard violations. PHP_CodeSniffer is an essential development tool that ensures your code remains clean and consistent. +PHP_CodeSniffer is a set of two PHP scripts; the main `phpcs` script that tokenizes PHP files to detect violations of a defined coding standard, and a second `phpcbf` script to automatically correct coding standard violations. PHP_CodeSniffer is an essential development tool that ensures your code remains clean and consistent. ## Requirements diff --git a/composer.json b/composer.json index 8e05c30d38..9de761e07b 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "squizlabs/php_codesniffer", - "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "description": "PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.", "license": "BSD-3-Clause", "type": "library", "keywords": [ diff --git a/phpcs.xml.dist b/phpcs.xml.dist index d7f885554c..0a0545c5bb 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -9,8 +9,8 @@ src tests - */src/Standards/*/Tests/*\.(inc|css|js)$ - */tests/Core/*/*\.(inc|css|js)$ + */src/Standards/*/Tests/*\.inc$ + */tests/Core/*/*\.inc$ */tests/Core/*/Fixtures/*\.php$ diff --git a/src/Config.php b/src/Config.php index 07edf811de..3ae1f78a9b 100644 --- a/src/Config.php +++ b/src/Config.php @@ -64,8 +64,11 @@ * @property string $stdinPath The path to use for content passed on STDIN. * @property bool $trackTime Whether or not to track sniff run time. * - * @property array $extensions File extensions that should be checked, and what tokenizer to use. + * @property array $extensions File extensions that should be checked, and what tokenizer is used. * E.g., array('inc' => 'PHP'); + * Note: since PHPCS 4.0.0, the tokenizer used will always be 'PHP', + * but the array format of the property has not been changed to prevent + * breaking integrations which may be accessing this property. * @property array $reports The reports to use for printing output after the run. * The format of the array is: * array( @@ -545,8 +548,6 @@ public function restoreDefaults() $this->extensions = [ 'php' => 'PHP', 'inc' => 'PHP', - 'js' => 'JS', - 'css' => 'CSS', ]; $this->sniffs = []; $this->exclude = []; @@ -1146,19 +1147,19 @@ public function processLongArgument($arg, $pos) if (empty($extensionsString) === false) { $extensions = explode(',', $extensionsString); foreach ($extensions as $ext) { - $slash = strpos($ext, '/'); - if ($slash !== false) { + if (strpos($ext, '/') !== false) { // They specified the tokenizer too. list($ext, $tokenizer) = explode('/', $ext); - $newExtensions[$ext] = strtoupper($tokenizer); - continue; + if (strtoupper($tokenizer) !== 'PHP') { + $error = 'ERROR: Specifying the tokenizer to use for an extension is no longer supported.'.PHP_EOL; + $error .= 'PHP_CodeSniffer >= 4.0 only supports scanning PHP files.'.PHP_EOL; + $error .= 'Received: '.substr($arg, 11).PHP_EOL.PHP_EOL; + $error .= $this->printShortUsage(true); + throw new DeepExitException($error, 3); + } } - if (isset($this->extensions[$ext]) === true) { - $newExtensions[$ext] = $this->extensions[$ext]; - } else { - $newExtensions[$ext] = 'PHP'; - } + $newExtensions[$ext] = 'PHP'; } } diff --git a/src/Files/File.php b/src/Files/File.php index cc4356e1fc..34d371f713 100644 --- a/src/Files/File.php +++ b/src/Files/File.php @@ -14,6 +14,7 @@ use PHP_CodeSniffer\Exceptions\TokenizerException; use PHP_CodeSniffer\Fixer; use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Tokenizers\PHP; use PHP_CodeSniffer\Util\Common; use PHP_CodeSniffer\Util\Tokens; @@ -72,17 +73,10 @@ class File /** * The tokenizer being used for this file. * - * @var \PHP_CodeSniffer\Tokenizers\Tokenizer + * @var \PHP_CodeSniffer\Tokenizers\PHP */ public $tokenizer = null; - /** - * The name of the tokenizer being used for this file. - * - * @var string - */ - public $tokenizerType = 'PHP'; - /** * Was the file loaded from cache? * @@ -240,15 +234,6 @@ public function __construct($path, Ruleset $ruleset, Config $config) $this->config = $config; $this->fixer = new Fixer(); - $parts = explode('.', $path); - $extension = array_pop($parts); - if (isset($config->extensions[$extension]) === true) { - $this->tokenizerType = $config->extensions[$extension]; - } else { - // Revert to default. - $this->tokenizerType = 'PHP'; - } - $this->configCache['cache'] = $this->config->cache; $this->configCache['sniffs'] = array_map('strtolower', $this->config->sniffs); $this->configCache['exclude'] = array_map('strtolower', $this->config->exclude); @@ -412,14 +397,8 @@ public function process() continue; } - // Make sure this sniff supports the tokenizer - // we are currently using. $class = $listenerData['class']; - if (isset($listenerData['tokenizers'][$this->tokenizerType]) === false) { - continue; - } - if (trim($this->path, '\'"') !== 'STDIN') { // If the file path matches one of our ignore patterns, skip it. // While there is support for a type of each pattern @@ -505,7 +484,7 @@ public function process() // We don't show this error for STDIN because we can't be sure the content // actually came directly from the user. It could be something like // refs from a Git pre-push hook. - if ($foundCode === false && $this->tokenizerType === 'PHP' && $this->path !== 'STDIN') { + if ($foundCode === false && $this->path !== 'STDIN') { $shortTags = (bool) ini_get('short_open_tag'); if ($shortTags === false) { $error = 'No PHP code was found in this file and short open tags are not allowed by this install of PHP. This file may be using short open tags but PHP does not allow them.'; @@ -543,14 +522,13 @@ public function parse() } try { - $tokenizerClass = 'PHP_CodeSniffer\Tokenizers\\'.$this->tokenizerType; - $this->tokenizer = new $tokenizerClass($this->content, $this->config, $this->eolChar); + $this->tokenizer = new PHP($this->content, $this->config, $this->eolChar); $this->tokens = $this->tokenizer->getTokens(); } catch (TokenizerException $e) { $this->ignored = true; $this->addWarning($e->getMessage(), null, 'Internal.Tokenizer.Exception'); if (PHP_CODESNIFFER_VERBOSITY > 0) { - echo "[$this->tokenizerType => tokenizer error]... "; + echo '[tokenizer error]... '; if (PHP_CODESNIFFER_VERBOSITY > 1) { echo PHP_EOL; } @@ -582,7 +560,7 @@ public function parse() $numLines = $this->tokens[($this->numTokens - 1)]['line']; } - echo "[$this->tokenizerType => $this->numTokens tokens in $numLines lines]... "; + echo "[$this->numTokens tokens in $numLines lines]... "; if (PHP_CODESNIFFER_VERBOSITY > 1) { echo PHP_EOL; } @@ -1249,14 +1227,6 @@ public function getDeclarationName($stackPtr) throw new RuntimeException('Token type "'.$this->tokens[$stackPtr]['type'].'" is not T_FUNCTION, T_CLASS, T_INTERFACE, T_TRAIT or T_ENUM'); } - if ($tokenCode === T_FUNCTION - && strtolower($this->tokens[$stackPtr]['content']) !== 'function' - ) { - // This is a function declared without the "function" keyword. - // So this token is the function name. - return $this->tokens[$stackPtr]['content']; - } - $stopPoint = $this->numTokens; if (isset($this->tokens[$stackPtr]['parenthesis_opener']) === true) { // For functions, stop searching at the parenthesis opener. @@ -1637,22 +1607,20 @@ public function getMethodProperties($stackPtr) if ($this->tokens[$stackPtr]['code'] === T_FUNCTION) { $valid = [ - T_PUBLIC => T_PUBLIC, - T_PRIVATE => T_PRIVATE, - T_PROTECTED => T_PROTECTED, - T_STATIC => T_STATIC, - T_FINAL => T_FINAL, - T_ABSTRACT => T_ABSTRACT, - T_WHITESPACE => T_WHITESPACE, - T_COMMENT => T_COMMENT, - T_DOC_COMMENT => T_DOC_COMMENT, + T_PUBLIC => T_PUBLIC, + T_PRIVATE => T_PRIVATE, + T_PROTECTED => T_PROTECTED, + T_STATIC => T_STATIC, + T_FINAL => T_FINAL, + T_ABSTRACT => T_ABSTRACT, + T_WHITESPACE => T_WHITESPACE, + T_COMMENT => T_COMMENT, ]; } else { $valid = [ - T_STATIC => T_STATIC, - T_WHITESPACE => T_WHITESPACE, - T_COMMENT => T_COMMENT, - T_DOC_COMMENT => T_DOC_COMMENT, + T_STATIC => T_STATIC, + T_WHITESPACE => T_WHITESPACE, + T_COMMENT => T_COMMENT, ]; } @@ -2011,12 +1979,11 @@ public function getClassProperties($stackPtr) } $valid = [ - T_FINAL => T_FINAL, - T_ABSTRACT => T_ABSTRACT, - T_READONLY => T_READONLY, - T_WHITESPACE => T_WHITESPACE, - T_COMMENT => T_COMMENT, - T_DOC_COMMENT => T_DOC_COMMENT, + T_FINAL => T_FINAL, + T_ABSTRACT => T_ABSTRACT, + T_READONLY => T_READONLY, + T_WHITESPACE => T_WHITESPACE, + T_COMMENT => T_COMMENT, ]; $isAbstract = false; diff --git a/src/Ruleset.php b/src/Ruleset.php index 31ed5c36ae..ef3b77461d 100644 --- a/src/Ruleset.php +++ b/src/Ruleset.php @@ -1425,6 +1425,27 @@ public function registerSniffs($files, $restrictions, $exclusions) continue; } + if ($reflection->hasProperty('supportedTokenizers') === true) { + // Using the default value as the class is not yet instantiated and this is not a property which should get changed anyway. + $value = $reflection->getDefaultProperties()['supportedTokenizers']; + + if (is_array($value) === true + && empty($value) === false + && in_array('PHP', $value, true) === false + ) { + if ($reflection->implementsInterface('PHP_CodeSniffer\\Sniffs\\DeprecatedSniff') === true) { + // Silently ignore the sniff if the sniff is marked as deprecated. + continue; + } + + $message = 'Support for scanning files other than PHP, like CSS/JS files, has been removed in PHP_CodeSniffer 4.0.'.PHP_EOL; + $message .= 'The %s sniff is listening for %s.'; + $message = sprintf($message, Common::getSniffCode($className), implode(', ', $value)); + $this->msgCache->add($message, MessageCollector::ERROR); + continue; + } + }//end if + $listeners[$className] = $className; if (PHP_CODESNIFFER_VERBOSITY > 2) { @@ -1464,9 +1485,7 @@ public function populateTokenListeners() $this->sniffs[$sniffClass] = new $sniffClass(); $this->sniffCodes[$sniffCode] = $sniffClass; - $isDeprecated = false; if ($this->sniffs[$sniffClass] instanceof DeprecatedSniff) { - $isDeprecated = true; $this->deprecatedSniffs[$sniffCode] = $sniffClass; } @@ -1477,34 +1496,6 @@ public function populateTokenListeners() } } - $tokenizers = []; - $vars = get_class_vars($sniffClass); - if (empty($vars['supportedTokenizers']) === false - && $isDeprecated === false - && in_array('PHP', $vars['supportedTokenizers'], true) === false - ) { - if (in_array('CSS', $vars['supportedTokenizers'], true) === true - || in_array('JS', $vars['supportedTokenizers'], true) === true - ) { - $message = 'Scanning CSS/JS files is deprecated and support will be removed in PHP_CodeSniffer 4.0.'.PHP_EOL; - } else { - // Just in case someone has an integration with a custom tokenizer. - $message = 'Support for custom tokenizers will be removed in PHP_CodeSniffer 4.0.'.PHP_EOL; - } - - $message .= 'The %s sniff is listening for %s.'; - $message = sprintf($message, $sniffCode, implode(', ', $vars['supportedTokenizers'])); - $this->msgCache->add($message, MessageCollector::DEPRECATED); - } - - if (isset($vars['supportedTokenizers']) === true) { - foreach ($vars['supportedTokenizers'] as $tokenizer) { - $tokenizers[$tokenizer] = $tokenizer; - } - } else { - $tokenizers = ['PHP' => 'PHP']; - } - $tokens = $this->sniffs[$sniffClass]->register(); if (is_array($tokens) === false) { $msg = "The sniff {$sniffClass}::register() method must return an array."; @@ -1544,11 +1535,10 @@ public function populateTokenListeners() if (isset($this->tokenListeners[$token][$sniffClass]) === false) { $this->tokenListeners[$token][$sniffClass] = [ - 'class' => $sniffClass, - 'source' => $sniffCode, - 'tokenizers' => $tokenizers, - 'ignore' => $ignorePatterns, - 'include' => $includePatterns, + 'class' => $sniffClass, + 'source' => $sniffCode, + 'ignore' => $ignorePatterns, + 'include' => $includePatterns, ]; } } diff --git a/src/Standards/Generic/Docs/Debug/CSSLintStandard.xml b/src/Standards/Generic/Docs/Debug/CSSLintStandard.xml deleted file mode 100644 index b57a970685..0000000000 --- a/src/Standards/Generic/Docs/Debug/CSSLintStandard.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - %; } - ]]> - - - %; } - ]]> - - - diff --git a/src/Standards/Generic/Docs/Debug/ClosureLinterStandard.xml b/src/Standards/Generic/Docs/Debug/ClosureLinterStandard.xml deleted file mode 100644 index 9df9aec489..0000000000 --- a/src/Standards/Generic/Docs/Debug/ClosureLinterStandard.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - ]; - ]]> - - - ,]; - ]]> - - - diff --git a/src/Standards/Generic/Docs/Debug/JSHintStandard.xml b/src/Standards/Generic/Docs/Debug/JSHintStandard.xml deleted file mode 100644 index 7525e9e6bf..0000000000 --- a/src/Standards/Generic/Docs/Debug/JSHintStandard.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - var foo = 5; - ]]> - - - foo = 5; - ]]> - - - diff --git a/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php b/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php index f34ffc2b9c..112a8ee576 100644 --- a/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php +++ b/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php @@ -16,16 +16,6 @@ class DocCommentSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * Returns an array of tokens this test wants to listen for. diff --git a/src/Standards/Generic/Sniffs/Commenting/FixmeSniff.php b/src/Standards/Generic/Sniffs/Commenting/FixmeSniff.php index b78a6595ee..8e3cf7da05 100644 --- a/src/Standards/Generic/Sniffs/Commenting/FixmeSniff.php +++ b/src/Standards/Generic/Sniffs/Commenting/FixmeSniff.php @@ -17,16 +17,6 @@ class FixmeSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * Returns an array of tokens this test wants to listen for. diff --git a/src/Standards/Generic/Sniffs/Commenting/TodoSniff.php b/src/Standards/Generic/Sniffs/Commenting/TodoSniff.php index d24111cbd3..cfe3fee7ff 100644 --- a/src/Standards/Generic/Sniffs/Commenting/TodoSniff.php +++ b/src/Standards/Generic/Sniffs/Commenting/TodoSniff.php @@ -16,16 +16,6 @@ class TodoSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * Returns an array of tokens this test wants to listen for. diff --git a/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php b/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php index 1efb15c7be..7f51d6303d 100644 --- a/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php +++ b/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php @@ -16,16 +16,6 @@ class InlineControlStructureSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * If true, an error will be thrown; otherwise a warning. * diff --git a/src/Standards/Generic/Sniffs/Debug/CSSLintSniff.php b/src/Standards/Generic/Sniffs/Debug/CSSLintSniff.php deleted file mode 100644 index db0660d191..0000000000 --- a/src/Standards/Generic/Sniffs/Debug/CSSLintSniff.php +++ /dev/null @@ -1,135 +0,0 @@ - - * @copyright 2013-2014 Roman Levishchenko - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * - * @deprecated 3.9.0 - */ - -namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Debug; - -use PHP_CodeSniffer\Config; -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\DeprecatedSniff; -use PHP_CodeSniffer\Sniffs\Sniff; -use PHP_CodeSniffer\Util\Common; - -class CSSLintSniff implements Sniff, DeprecatedSniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = ['CSS']; - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array - */ - public function register() - { - return [T_OPEN_TAG]; - - }//end register() - - - /** - * Processes the tokens that this sniff is interested in. - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found. - * @param int $stackPtr The position in the stack where - * the token was found. - * - * @return int - */ - public function process(File $phpcsFile, $stackPtr) - { - $csslintPath = Config::getExecutablePath('csslint'); - if ($csslintPath === null) { - return $phpcsFile->numTokens; - } - - $fileName = $phpcsFile->getFilename(); - - $cmd = Common::escapeshellcmd($csslintPath).' '.escapeshellarg($fileName).' 2>&1'; - exec($cmd, $output, $retval); - - if (is_array($output) === false) { - return $phpcsFile->numTokens; - } - - $count = count($output); - - for ($i = 0; $i < $count; $i++) { - $matches = []; - $numMatches = preg_match( - '/(error|warning) at line (\d+)/', - $output[$i], - $matches - ); - - if ($numMatches === 0) { - continue; - } - - $line = (int) $matches[2]; - $message = 'csslint says: '.$output[($i + 1)]; - // First line is message with error line and error code. - // Second is error message. - // Third is wrong line in file. - // Fourth is empty line. - $i += 4; - - $phpcsFile->addWarningOnLine($message, $line, 'ExternalTool'); - }//end for - - // Ignore the rest of the file. - return $phpcsFile->numTokens; - - }//end process() - - - /** - * Provide the version number in which the sniff was deprecated. - * - * @return string - */ - public function getDeprecationVersion() - { - return 'v3.9.0'; - - }//end getDeprecationVersion() - - - /** - * Provide the version number in which the sniff will be removed. - * - * @return string - */ - public function getRemovalVersion() - { - return 'v4.0.0'; - - }//end getRemovalVersion() - - - /** - * Provide a custom message to display with the deprecation. - * - * @return string - */ - public function getDeprecationMessage() - { - return 'Support for scanning CSS files will be removed completely in v4.0.0.'; - - }//end getDeprecationMessage() - - -}//end class diff --git a/src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php b/src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php deleted file mode 100644 index 8d365f2876..0000000000 --- a/src/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php +++ /dev/null @@ -1,156 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * - * @deprecated 3.9.0 - */ - -namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Debug; - -use PHP_CodeSniffer\Config; -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\DeprecatedSniff; -use PHP_CodeSniffer\Sniffs\Sniff; -use PHP_CodeSniffer\Util\Common; - -class ClosureLinterSniff implements Sniff, DeprecatedSniff -{ - - /** - * A list of error codes that should show errors. - * - * All other error codes will show warnings. - * - * @var array - */ - public $errorCodes = []; - - /** - * A list of error codes to ignore. - * - * @var array - */ - public $ignoreCodes = []; - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = ['JS']; - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array - */ - public function register() - { - return [T_OPEN_TAG]; - - }//end register() - - - /** - * Processes the tokens that this sniff is interested in. - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found. - * @param int $stackPtr The position in the stack where - * the token was found. - * - * @return int - * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If jslint.js could not be run. - */ - public function process(File $phpcsFile, $stackPtr) - { - $lintPath = Config::getExecutablePath('gjslint'); - if ($lintPath === null) { - return $phpcsFile->numTokens; - } - - $fileName = $phpcsFile->getFilename(); - - $lintPath = Common::escapeshellcmd($lintPath); - $cmd = $lintPath.' --nosummary --notime --unix_mode '.escapeshellarg($fileName); - exec($cmd, $output, $retval); - - if (is_array($output) === false) { - return $phpcsFile->numTokens; - } - - foreach ($output as $finding) { - $matches = []; - $numMatches = preg_match('/^(.*):([0-9]+):\(.*?([0-9]+)\)(.*)$/', $finding, $matches); - if ($numMatches === 0) { - continue; - } - - // Skip error codes we are ignoring. - $code = $matches[3]; - if (in_array($code, $this->ignoreCodes) === true) { - continue; - } - - $line = (int) $matches[2]; - $error = trim($matches[4]); - - $message = 'gjslint says: (%s) %s'; - $data = [ - $code, - $error, - ]; - if (in_array($code, $this->errorCodes) === true) { - $phpcsFile->addErrorOnLine($message, $line, 'ExternalToolError', $data); - } else { - $phpcsFile->addWarningOnLine($message, $line, 'ExternalTool', $data); - } - }//end foreach - - // Ignore the rest of the file. - return $phpcsFile->numTokens; - - }//end process() - - - /** - * Provide the version number in which the sniff was deprecated. - * - * @return string - */ - public function getDeprecationVersion() - { - return 'v3.9.0'; - - }//end getDeprecationVersion() - - - /** - * Provide the version number in which the sniff will be removed. - * - * @return string - */ - public function getRemovalVersion() - { - return 'v4.0.0'; - - }//end getRemovalVersion() - - - /** - * Provide a custom message to display with the deprecation. - * - * @return string - */ - public function getDeprecationMessage() - { - return 'Support for scanning JavaScript files will be removed completely in v4.0.0.'; - - }//end getDeprecationMessage() - - -}//end class diff --git a/src/Standards/Generic/Sniffs/Debug/ESLintSniff.php b/src/Standards/Generic/Sniffs/Debug/ESLintSniff.php deleted file mode 100644 index 469d636414..0000000000 --- a/src/Standards/Generic/Sniffs/Debug/ESLintSniff.php +++ /dev/null @@ -1,152 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * - * @deprecated 3.9.0 - */ - -namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Debug; - -use PHP_CodeSniffer\Config; -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\DeprecatedSniff; -use PHP_CodeSniffer\Sniffs\Sniff; -use PHP_CodeSniffer\Util\Common; - -class ESLintSniff implements Sniff, DeprecatedSniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = ['JS']; - - /** - * ESLint configuration file path. - * - * @var string|null Path to eslintrc. Null to autodetect. - */ - public $configFile = null; - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array - */ - public function register() - { - return [T_OPEN_TAG]; - - }//end register() - - - /** - * Processes the tokens that this sniff is interested in. - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found. - * @param int $stackPtr The position in the stack where - * the token was found. - * - * @return int - * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If jshint.js could not be run. - */ - public function process(File $phpcsFile, $stackPtr) - { - $eslintPath = Config::getExecutablePath('eslint'); - if ($eslintPath === null) { - return $phpcsFile->numTokens; - } - - $filename = $phpcsFile->getFilename(); - - $configFile = $this->configFile; - if (empty($configFile) === true) { - // Attempt to autodetect. - $candidates = glob('.eslintrc{.js,.yaml,.yml,.json}', GLOB_BRACE); - if (empty($candidates) === false) { - $configFile = $candidates[0]; - } - } - - $eslintOptions = ['--format json']; - if (empty($configFile) === false) { - $eslintOptions[] = '--config '.escapeshellarg($configFile); - } - - $cmd = Common::escapeshellcmd(escapeshellarg($eslintPath).' '.implode(' ', $eslintOptions).' '.escapeshellarg($filename)); - - // Execute! - exec($cmd, $stdout, $code); - - if ($code <= 0) { - // No errors, continue. - return $phpcsFile->numTokens; - } - - $data = json_decode(implode("\n", $stdout)); - if (json_last_error() !== JSON_ERROR_NONE) { - // Ignore any errors. - return $phpcsFile->numTokens; - } - - // Data is a list of files, but we only pass a single one. - $messages = $data[0]->messages; - foreach ($messages as $error) { - $message = 'eslint says: '.$error->message; - if (empty($error->fatal) === false || $error->severity === 2) { - $phpcsFile->addErrorOnLine($message, $error->line, 'ExternalTool'); - } else { - $phpcsFile->addWarningOnLine($message, $error->line, 'ExternalTool'); - } - } - - // Ignore the rest of the file. - return $phpcsFile->numTokens; - - }//end process() - - - /** - * Provide the version number in which the sniff was deprecated. - * - * @return string - */ - public function getDeprecationVersion() - { - return 'v3.9.0'; - - }//end getDeprecationVersion() - - - /** - * Provide the version number in which the sniff will be removed. - * - * @return string - */ - public function getRemovalVersion() - { - return 'v4.0.0'; - - }//end getRemovalVersion() - - - /** - * Provide a custom message to display with the deprecation. - * - * @return string - */ - public function getDeprecationMessage() - { - return 'Support for scanning JavaScript files will be removed completely in v4.0.0.'; - - }//end getDeprecationMessage() - - -}//end class diff --git a/src/Standards/Generic/Sniffs/Debug/JSHintSniff.php b/src/Standards/Generic/Sniffs/Debug/JSHintSniff.php deleted file mode 100644 index 66bc04e3fb..0000000000 --- a/src/Standards/Generic/Sniffs/Debug/JSHintSniff.php +++ /dev/null @@ -1,134 +0,0 @@ - - * @author Alexander Wei§ - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * - * @deprecated 3.9.0 - */ - -namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Debug; - -use PHP_CodeSniffer\Config; -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\DeprecatedSniff; -use PHP_CodeSniffer\Sniffs\Sniff; -use PHP_CodeSniffer\Util\Common; - -class JSHintSniff implements Sniff, DeprecatedSniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = ['JS']; - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array - */ - public function register() - { - return [T_OPEN_TAG]; - - }//end register() - - - /** - * Processes the tokens that this sniff is interested in. - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found. - * @param int $stackPtr The position in the stack where - * the token was found. - * - * @return int - * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If jshint.js could not be run. - */ - public function process(File $phpcsFile, $stackPtr) - { - $rhinoPath = Config::getExecutablePath('rhino'); - $jshintPath = Config::getExecutablePath('jshint'); - if ($jshintPath === null) { - return $phpcsFile->numTokens; - } - - $fileName = $phpcsFile->getFilename(); - $jshintPath = Common::escapeshellcmd($jshintPath); - - if ($rhinoPath !== null) { - $rhinoPath = Common::escapeshellcmd($rhinoPath); - $cmd = "$rhinoPath \"$jshintPath\" ".escapeshellarg($fileName); - exec($cmd, $output, $retval); - - $regex = '`^(?P.+)\(.+:(?P[0-9]+).*:[0-9]+\)$`'; - } else { - $cmd = "$jshintPath ".escapeshellarg($fileName); - exec($cmd, $output, $retval); - - $regex = '`^(.+?): line (?P[0-9]+), col [0-9]+, (?P.+)$`'; - } - - if (is_array($output) === true) { - foreach ($output as $finding) { - $matches = []; - $numMatches = preg_match($regex, $finding, $matches); - if ($numMatches === 0) { - continue; - } - - $line = (int) $matches['line']; - $message = 'jshint says: '.trim($matches['error']); - $phpcsFile->addWarningOnLine($message, $line, 'ExternalTool'); - } - } - - // Ignore the rest of the file. - return $phpcsFile->numTokens; - - }//end process() - - - /** - * Provide the version number in which the sniff was deprecated. - * - * @return string - */ - public function getDeprecationVersion() - { - return 'v3.9.0'; - - }//end getDeprecationVersion() - - - /** - * Provide the version number in which the sniff will be removed. - * - * @return string - */ - public function getRemovalVersion() - { - return 'v4.0.0'; - - }//end getRemovalVersion() - - - /** - * Provide a custom message to display with the deprecation. - * - * @return string - */ - public function getDeprecationMessage() - { - return 'Support for scanning JavaScript files will be removed completely in v4.0.0.'; - - }//end getDeprecationMessage() - - -}//end class diff --git a/src/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php b/src/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php index 71bcabbb7f..ebf9291eb8 100644 --- a/src/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php +++ b/src/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php @@ -15,17 +15,6 @@ class EndFileNewlineSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - 'CSS', - ]; - /** * Returns an array of tokens this test wants to listen for. diff --git a/src/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php b/src/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php index 3f76607560..d75f865410 100644 --- a/src/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php +++ b/src/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php @@ -15,17 +15,6 @@ class EndFileNoNewlineSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - 'CSS', - ]; - /** * Returns an array of tokens this test wants to listen for. diff --git a/src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php b/src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php index 1814b55558..d6b9d3e5c5 100644 --- a/src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php +++ b/src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php @@ -15,17 +15,6 @@ class LineEndingsSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - 'CSS', - ]; - /** * The valid EOL character. * @@ -126,11 +115,6 @@ public function process(File $phpcsFile, $stackPtr) $tokenContent = $tokens[$i]['content']; } - if ($tokenContent === '') { - // Special case for JS/CSS close tag. - continue; - } - $newContent = rtrim($tokenContent, "\r\n"); $newContent .= $eolChar; if ($tokenContent !== $newContent) { diff --git a/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php b/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php index 8916659a9a..87becd7449 100644 --- a/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php +++ b/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php @@ -19,16 +19,6 @@ class MultipleStatementAlignmentSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * If true, an error will be thrown; otherwise a warning. * @@ -137,7 +127,6 @@ public function checkAlignment($phpcsFile, $stackPtr, $end=null) $scopes = Tokens::$scopeOpeners; unset($scopes[T_CLOSURE]); unset($scopes[T_ANON_CLASS]); - unset($scopes[T_OBJECT]); for ($assign = $stackPtr; $assign < $end; $assign++) { if ($tokens[$assign]['level'] < $tokens[$stackPtr]['level']) { diff --git a/src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php b/src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php index a1a6d09367..22c3da2aaa 100644 --- a/src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php +++ b/src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php @@ -16,16 +16,6 @@ class SpaceAfterNotSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * The number of spaces desired after the NOT operator. * diff --git a/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php b/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php index 29e184ec62..6ddbb90df3 100644 --- a/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php @@ -16,16 +16,6 @@ class LowerCaseConstantSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * The tokens this sniff is targetting. * diff --git a/src/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php b/src/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php index 033a6e7b3f..6660aaee71 100644 --- a/src/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php +++ b/src/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php @@ -16,16 +16,6 @@ class UnnecessaryStringConcatSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * If true, an error will be thrown; otherwise a warning. * @@ -51,10 +41,7 @@ class UnnecessaryStringConcatSniff implements Sniff */ public function register() { - return [ - T_STRING_CONCAT, - T_PLUS, - ]; + return [T_STRING_CONCAT]; }//end register() @@ -72,14 +59,6 @@ public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - if ($tokens[$stackPtr]['code'] === T_STRING_CONCAT && $phpcsFile->tokenizerType === 'JS') { - // JS uses T_PLUS for string concatenation, not T_STRING_CONCAT. - return; - } else if ($tokens[$stackPtr]['code'] === T_PLUS && $phpcsFile->tokenizerType === 'PHP') { - // PHP uses T_STRING_CONCAT for string concatenation, not T_PLUS. - return; - } - $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); if ($next === false) { @@ -98,16 +77,14 @@ public function process(File $phpcsFile, $stackPtr) return; } - // Before we throw an error for PHP, allow strings to be + // Before we throw an error, allow strings to be // combined if they would have < and ? next to each other because // this trick is sometimes required in PHP strings. - if ($phpcsFile->tokenizerType === 'PHP') { - $prevChar = substr($tokens[$prev]['content'], -2, 1); - $nextChar = $tokens[$next]['content'][1]; - $combined = $prevChar.$nextChar; - if ($combined === '?'.'>' || $combined === '<'.'?') { - return; - } + $prevChar = substr($tokens[$prev]['content'], -2, 1); + $nextChar = $tokens[$next]['content'][1]; + $combined = $prevChar.$nextChar; + if ($combined === '?'.'>' || $combined === '<'.'?') { + return; } if ($this->allowMultiline === true diff --git a/src/Standards/Generic/Sniffs/VersionControl/GitMergeConflictSniff.php b/src/Standards/Generic/Sniffs/VersionControl/GitMergeConflictSniff.php index 67ca59ae96..30faf73489 100644 --- a/src/Standards/Generic/Sniffs/VersionControl/GitMergeConflictSniff.php +++ b/src/Standards/Generic/Sniffs/VersionControl/GitMergeConflictSniff.php @@ -15,17 +15,6 @@ class GitMergeConflictSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - 'CSS', - ]; - /** * Returns an array of tokens this test wants to listen for. @@ -62,14 +51,10 @@ public function process(File $phpcsFile, $stackPtr) T_IS_IDENTICAL => true, T_COMMENT => true, T_DOC_COMMENT_STRING => true, - // PHP + CSS specific. T_ENCAPSED_AND_WHITESPACE => true, - // PHP specific. T_INLINE_HTML => true, T_HEREDOC => true, T_NOWDOC => true, - // JS specific. - T_ZSR => true, ]; for ($i = 0; $i < $phpcsFile->numTokens; $i++) { @@ -77,146 +62,64 @@ public function process(File $phpcsFile, $stackPtr) continue; } - if ($phpcsFile->tokenizerType !== 'JS') { - switch ($tokens[$i]['code']) { - // Check for first non-comment, non-heredoc/nowdoc, non-inline HTML merge conflict opener. - case T_SL: - if (isset($tokens[($i + 1)], $tokens[($i + 2)]) !== false - && $tokens[($i + 1)]['code'] === T_SL - && $tokens[($i + 2)]['code'] === T_STRING - && trim($tokens[($i + 2)]['content']) === '<<< HEAD' - ) { - $phpcsFile->addError($error, $i, 'OpenerFound', ['opener']); - $i += 2; - } + switch ($tokens[$i]['code']) { + // Check for first non-comment, non-heredoc/nowdoc, non-inline HTML merge conflict opener. + case T_SL: + if (isset($tokens[($i + 1)], $tokens[($i + 2)]) !== false + && $tokens[($i + 1)]['code'] === T_SL + && $tokens[($i + 2)]['code'] === T_STRING + && trim($tokens[($i + 2)]['content']) === '<<< HEAD' + ) { + $phpcsFile->addError($error, $i, 'OpenerFound', ['opener']); + $i += 2; + } + break; + + // Check for merge conflict closer which was opened in a heredoc/nowdoc. + case T_SR: + if (isset($tokens[($i + 1)], $tokens[($i + 2)], $tokens[($i + 3)], $tokens[($i + 4)]) !== false + && $tokens[($i + 1)]['code'] === T_SR + && $tokens[($i + 2)]['code'] === T_SR + && $tokens[($i + 3)]['code'] === T_GREATER_THAN + && $tokens[($i + 4)]['code'] === T_WHITESPACE + && $tokens[($i + 4)]['content'] === ' ' + ) { + $phpcsFile->addError($error, $i, 'CloserFound', ['closer']); + $i += 4; + } + break; + + // - Check for delimiters and closers. + // - Inspect heredoc/nowdoc content, comments and inline HTML. + // - Check for subsequent merge conflict openers after the first broke the tokenizer. + case T_ENCAPSED_AND_WHITESPACE: + case T_COMMENT: + case T_DOC_COMMENT_STRING: + case T_INLINE_HTML: + case T_HEREDOC: + case T_NOWDOC: + if (substr($tokens[$i]['content'], 0, 12) === '<<<<<<< HEAD') { + $phpcsFile->addError($error, $i, 'OpenerFound', ['opener']); break; - - // Check for merge conflict closer which was opened in a heredoc/nowdoc. - case T_SR: - if (isset($tokens[($i + 1)], $tokens[($i + 2)], $tokens[($i + 3)], $tokens[($i + 4)]) !== false - && $tokens[($i + 1)]['code'] === T_SR - && $tokens[($i + 2)]['code'] === T_SR - && $tokens[($i + 3)]['code'] === T_GREATER_THAN - && $tokens[($i + 4)]['code'] === T_WHITESPACE - && $tokens[($i + 4)]['content'] === ' ' - ) { - $phpcsFile->addError($error, $i, 'CloserFound', ['closer']); - $i += 4; - } + } else if (substr($tokens[$i]['content'], 0, 8) === '>>>>>>> ') { + $phpcsFile->addError($error, $i, 'CloserFound', ['closer']); break; + } - // Check for merge conflict delimiter which opened in a CSS comment and closed outside. - case T_IS_IDENTICAL: - if (isset($tokens[($i + 1)], $tokens[($i + 2)], $tokens[($i + 3)]) !== false - && $tokens[($i + 1)]['code'] === T_IS_IDENTICAL - && $tokens[($i + 2)]['code'] === T_EQUAL - && $tokens[($i + 3)]['code'] === T_WHITESPACE - && $tokens[($i + 3)]['content'] === "\n" + if ($tokens[$i]['code'] === T_DOC_COMMENT_STRING) { + if ($tokens[$i]['content'] === '=======' + && $tokens[($i + 1)]['code'] === T_DOC_COMMENT_WHITESPACE ) { $phpcsFile->addError($error, $i, 'DelimiterFound', ['delimiter']); - $i += 3; - } - break; - - // - Check for delimiters and closers. - // - Inspect heredoc/nowdoc content, comments and inline HTML. - // - Check for subsequent merge conflict openers after the first broke the tokenizer. - case T_ENCAPSED_AND_WHITESPACE: - case T_COMMENT: - case T_DOC_COMMENT_STRING: - case T_INLINE_HTML: - case T_HEREDOC: - case T_NOWDOC: - if (substr($tokens[$i]['content'], 0, 12) === '<<<<<<< HEAD') { - $phpcsFile->addError($error, $i, 'OpenerFound', ['opener']); - break; - } else if (substr($tokens[$i]['content'], 0, 8) === '>>>>>>> ') { - $phpcsFile->addError($error, $i, 'CloserFound', ['closer']); break; } - - if ($tokens[$i]['code'] === T_DOC_COMMENT_STRING) { - if ($tokens[$i]['content'] === '=======' - && $tokens[($i + 1)]['code'] === T_DOC_COMMENT_WHITESPACE - ) { - $phpcsFile->addError($error, $i, 'DelimiterFound', ['delimiter']); - break; - } - } else { - if ($tokens[$i]['content'] === "=======\n") { - $phpcsFile->addError($error, $i, 'DelimiterFound', ['delimiter']); - } - } - break; - }//end switch - } else { - // Javascript file. - switch ($tokens[$i]['code']) { - // Merge conflict opener. - case T_SL: - if (isset($tokens[($i + 1)], $tokens[($i + 2)], $tokens[($i + 3)], $tokens[($i + 4)], $tokens[($i + 5)]) !== false - && $tokens[($i + 1)]['code'] === T_SL - && $tokens[($i + 2)]['code'] === T_SL - && $tokens[($i + 3)]['code'] === T_LESS_THAN - && $tokens[($i + 4)]['code'] === T_WHITESPACE - && trim($tokens[($i + 5)]['content']) === 'HEAD' - ) { - $phpcsFile->addError($error, $i, 'OpenerFound', ['opener']); - $i += 5; - } - break; - - // Check for merge conflict delimiter. - case T_IS_IDENTICAL: - if (isset($tokens[($i + 1)], $tokens[($i + 2)], $tokens[($i + 3)]) !== false - && $tokens[($i + 1)]['code'] === T_IS_IDENTICAL - && $tokens[($i + 2)]['code'] === T_EQUAL - && $tokens[($i + 3)]['code'] === T_WHITESPACE - && $tokens[($i + 3)]['content'] === "\n" - ) { + } else { + if ($tokens[$i]['content'] === "=======\n") { $phpcsFile->addError($error, $i, 'DelimiterFound', ['delimiter']); - $i += 3; - } - break; - - // Merge conflict closer. - case T_ZSR: - if ($tokens[$i]['code'] === T_ZSR - && isset($tokens[($i + 1)], $tokens[($i + 2)]) === true - && $tokens[($i + 1)]['code'] === T_ZSR - && $tokens[($i + 2)]['code'] === T_GREATER_THAN - ) { - $phpcsFile->addError($error, $i, 'CloserFound', ['closer']); - $i += 2; } - break; - - // Check for merge conflicts in all comments. - case T_COMMENT: - case T_DOC_COMMENT_STRING: - if (substr($tokens[$i]['content'], 0, 12) === '<<<<<<< HEAD') { - $phpcsFile->addError($error, $i, 'OpenerFound'); - break; - } else if (substr($tokens[$i]['content'], 0, 8) === '>>>>>>> ') { - $phpcsFile->addError($error, $i, 'CloserFound', ['closer']); - break; - } - - if ($tokens[$i]['code'] === T_DOC_COMMENT_STRING) { - if ($tokens[$i]['content'] === '=======' - && $tokens[($i + 1)]['code'] === T_DOC_COMMENT_WHITESPACE - ) { - $phpcsFile->addError($error, $i, 'DelimiterFound', ['delimiter']); - break; - } - } else { - if ($tokens[$i]['content'] === "=======\n") { - $phpcsFile->addError($error, $i, 'DelimiterFound', ['delimiter']); - } - } - break; - }//end switch - }//end if + } + break; + }//end switch }//end for // Ignore the rest of the file. diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php index 37edfc887a..79d3469d40 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php @@ -15,17 +15,6 @@ class DisallowSpaceIndentSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - 'CSS', - ]; - /** * The --tab-width CLI value that is being used. * diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php index b33a58b461..ba431adee6 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php @@ -15,17 +15,6 @@ class DisallowTabIndentSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - 'CSS', - ]; - /** * The --tab-width CLI value that is being used. * diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/IncrementDecrementSpacingSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/IncrementDecrementSpacingSniff.php index 25ba00153f..413a3f01bf 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/IncrementDecrementSpacingSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/IncrementDecrementSpacingSniff.php @@ -16,16 +16,6 @@ class IncrementDecrementSpacingSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * Returns an array of tokens this test wants to listen for. @@ -63,9 +53,7 @@ public function process(File $phpcsFile, $stackPtr) // Is this a pre-increment/decrement ? $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true); if ($nextNonEmpty !== false - && (($phpcsFile->tokenizerType === 'PHP' - && ($tokens[$nextNonEmpty]['code'] === T_VARIABLE || $tokens[$nextNonEmpty]['code'] === T_STRING)) - || ($phpcsFile->tokenizerType === 'JS' && $tokens[$nextNonEmpty]['code'] === T_STRING)) + && ($tokens[$nextNonEmpty]['code'] === T_VARIABLE || $tokens[$nextNonEmpty]['code'] === T_STRING) ) { if ($nextNonEmpty === ($stackPtr + 1)) { $phpcsFile->recordMetric($stackPtr, 'Spacing between in/decrementor and variable', 0); @@ -117,11 +105,9 @@ public function process(File $phpcsFile, $stackPtr) // Is this a post-increment/decrement ? $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); if ($prevNonEmpty !== false - && (($phpcsFile->tokenizerType === 'PHP' && ($tokens[$prevNonEmpty]['code'] === T_VARIABLE || $tokens[$prevNonEmpty]['code'] === T_STRING - || $tokens[$prevNonEmpty]['code'] === T_CLOSE_SQUARE_BRACKET)) - || ($phpcsFile->tokenizerType === 'JS' && $tokens[$prevNonEmpty]['code'] === T_STRING)) + || $tokens[$prevNonEmpty]['code'] === T_CLOSE_SQUARE_BRACKET) ) { if ($prevNonEmpty === ($stackPtr - 1)) { $phpcsFile->recordMetric($stackPtr, 'Spacing between in/decrementor and variable', 0); diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php index 5c7df9a470..164fbe00cc 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php @@ -17,16 +17,6 @@ class ScopeIndentSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * The number of spaces code should be indented. * @@ -691,113 +681,6 @@ public function process(File $phpcsFile, $stackPtr) }//end if }//end if - // Handle scope for JS object notation. - if ($phpcsFile->tokenizerType === 'JS' - && (($checkToken !== null - && $tokens[$checkToken]['code'] === T_CLOSE_OBJECT - && $tokens[$checkToken]['line'] !== $tokens[$tokens[$checkToken]['bracket_opener']]['line']) - || ($checkToken === null - && $tokens[$i]['code'] === T_CLOSE_OBJECT - && $tokens[$i]['line'] !== $tokens[$tokens[$i]['bracket_opener']]['line'])) - ) { - if ($this->debug === true) { - $line = $tokens[$i]['line']; - echo "Close JS object on line $line".PHP_EOL; - } - - $scopeCloser = $checkToken; - if ($scopeCloser === null) { - $scopeCloser = $i; - } else { - $conditionToken = array_pop($openScopes); - if ($this->debug === true) { - $line = $tokens[$conditionToken]['line']; - $type = $tokens[$conditionToken]['type']; - echo "\t=> removed open scope $conditionToken ($type) on line $line".PHP_EOL; - } - } - - $parens = 0; - if (isset($tokens[$scopeCloser]['nested_parenthesis']) === true - && empty($tokens[$scopeCloser]['nested_parenthesis']) === false - ) { - $parens = $tokens[$scopeCloser]['nested_parenthesis']; - end($parens); - $parens = key($parens); - if ($this->debug === true) { - $line = $tokens[$parens]['line']; - echo "\t* token has nested parenthesis $parens on line $line *".PHP_EOL; - } - } - - $condition = 0; - if (isset($tokens[$scopeCloser]['conditions']) === true - && empty($tokens[$scopeCloser]['conditions']) === false - ) { - $condition = $tokens[$scopeCloser]['conditions']; - end($condition); - $condition = key($condition); - if ($this->debug === true) { - $line = $tokens[$condition]['line']; - $type = $tokens[$condition]['type']; - echo "\t* token is inside condition $condition ($type) on line $line *".PHP_EOL; - } - } - - if ($parens > $condition) { - if ($this->debug === true) { - echo "\t* using parenthesis *".PHP_EOL; - } - - $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $parens, true); - $condition = 0; - } else if ($condition > 0) { - if ($this->debug === true) { - echo "\t* using condition *".PHP_EOL; - } - - $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $condition, true); - $parens = 0; - } else { - if ($this->debug === true) { - $line = $tokens[$tokens[$scopeCloser]['bracket_opener']]['line']; - echo "\t* token is not in parenthesis or condition; using opener on line $line *".PHP_EOL; - } - - $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $tokens[$scopeCloser]['bracket_opener'], true); - }//end if - - $currentIndent = ($tokens[$first]['column'] - 1); - if (isset($adjustments[$first]) === true) { - $currentIndent += $adjustments[$first]; - } - - if ($parens > 0 || $condition > 0) { - $checkIndent = ($tokens[$first]['column'] - 1); - if (isset($adjustments[$first]) === true) { - $checkIndent += $adjustments[$first]; - } - - if ($condition > 0) { - $checkIndent += $this->indent; - $currentIndent += $this->indent; - $exact = true; - } - } else { - $checkIndent = $currentIndent; - } - - // Make sure it is divisible by our expected indent. - $currentIndent = (int) (ceil($currentIndent / $this->indent) * $this->indent); - $checkIndent = (int) (ceil($checkIndent / $this->indent) * $this->indent); - $setIndents[$first] = $currentIndent; - - if ($this->debug === true) { - $type = $tokens[$first]['type']; - echo "\t=> checking indent of $checkIndent; main indent set to $currentIndent by token $first ($type)".PHP_EOL; - } - }//end if - if ($checkToken !== null && isset(Tokens::$scopeOpeners[$tokens[$checkToken]['code']]) === true && in_array($tokens[$checkToken]['code'], $this->nonIndentingScopes, true) === false @@ -895,12 +778,6 @@ public function process(File $phpcsFile, $stackPtr) }//end if }//end if - // JS property indentation has to be exact or else if will break - // things like function and object indentation. - if ($checkToken !== null && $tokens[$checkToken]['code'] === T_PROPERTY) { - $exact = true; - } - // Open PHP tags needs to be indented to exact column positions // so they don't cause problems with indent checks for the code // within them, but they don't need to line up with the current indent @@ -1300,44 +1177,6 @@ public function process(File $phpcsFile, $stackPtr) }//end if }//end if - // JS objects set the indent level. - if ($phpcsFile->tokenizerType === 'JS' - && $tokens[$i]['code'] === T_OBJECT - ) { - $closer = $tokens[$i]['bracket_closer']; - if ($tokens[$i]['line'] === $tokens[$closer]['line']) { - if ($this->debug === true) { - $line = $tokens[$i]['line']; - echo "* ignoring single-line JS object on line $line *".PHP_EOL; - } - - $i = $closer; - continue; - } - - if ($this->debug === true) { - $line = $tokens[$i]['line']; - echo "Open JS object on line $line".PHP_EOL; - } - - $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $i, true); - $currentIndent = (($tokens[$first]['column'] - 1) + $this->indent); - if (isset($adjustments[$first]) === true) { - $currentIndent += $adjustments[$first]; - } - - // Make sure it is divisible by our expected indent. - $currentIndent = (int) (ceil($currentIndent / $this->indent) * $this->indent); - $setIndents[$first] = $currentIndent; - - if ($this->debug === true) { - $type = $tokens[$first]['type']; - echo "\t=> indent set to $currentIndent by token $first ($type)".PHP_EOL; - } - - continue; - }//end if - // Closing an anon class, closure, or match. // Each may be returned, which can confuse control structures that // use return as a closer, like CASE statements. @@ -1355,23 +1194,6 @@ public function process(File $phpcsFile, $stackPtr) $prev = false; - $object = 0; - if ($phpcsFile->tokenizerType === 'JS') { - $conditions = $tokens[$i]['conditions']; - krsort($conditions, SORT_NUMERIC); - foreach ($conditions as $token => $condition) { - if ($condition === T_OBJECT) { - $object = $token; - break; - } - } - - if ($this->debug === true && $object !== 0) { - $line = $tokens[$object]['line']; - echo "\t* token is inside JS object $object on line $line *".PHP_EOL; - } - } - $parens = 0; if (isset($tokens[$i]['nested_parenthesis']) === true && empty($tokens[$i]['nested_parenthesis']) === false @@ -1399,21 +1221,12 @@ public function process(File $phpcsFile, $stackPtr) } } - if ($parens > $object && $parens > $condition) { + if ($parens > $condition) { if ($this->debug === true) { echo "\t* using parenthesis *".PHP_EOL; } $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($parens - 1), null, true); - $object = 0; - $condition = 0; - } else if ($object > 0 && $object >= $condition) { - if ($this->debug === true) { - echo "\t* using object *".PHP_EOL; - } - - $prev = $object; - $parens = 0; $condition = 0; } else if ($condition > 0) { if ($this->debug === true) { @@ -1421,7 +1234,6 @@ public function process(File $phpcsFile, $stackPtr) } $prev = $condition; - $object = 0; $parens = 0; }//end if @@ -1466,7 +1278,7 @@ public function process(File $phpcsFile, $stackPtr) } $currentIndent = ($tokens[$first]['column'] - 1); - if ($object > 0 || $condition > 0) { + if ($condition > 0) { $currentIndent += $this->indent; } diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.js b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.js deleted file mode 100644 index bf914411ae..0000000000 --- a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.js +++ /dev/null @@ -1,270 +0,0 @@ - -/** - * Short description. - * - * Long description - * over multiple lines. - * - * @tag1 one - * @tag2 two - * @tag3 three - */ - -/** - * short description - * - * long description - * over multiple lines. - * @tag1 one - */ - -/** - * - * Short description - * - * - * Long description - * over multiple lines - * - * - * @tag1 one - * - */ - -/* - This is not a doc block. - */ - -/** Short description. - * - * @tag one - * @tag2 two - * @tagThree three - * @tagFour four - */ - -/** - * Short description. - * - * @tag one - * - * @param - * @param - * - */ - -/** - * Short description. - * @param - * @param - * @tag one - */ - -/** - * Short description. - * - * - * @param - * - * @param - * - * - * @tag one - */ - - /** - * Short description. - * - * @param - * - * @tag one - * @param - */ - -/** - * Short description. - * - * @groupOne one - * @groupOne two - * - * @group2 one - * @group2 two - * - * - * @g3 - * @g3 two - */ - - /** - * Short description - * over multiple lines. - * - * Long description. - * - * @param - * - * @tag one - */ - -/** - * Short description. - * - * @tag1 one some comment across - * multiple lines - * @tag1 two some comment across - * multiple lines - * @tag1 three some comment across - * multiple lines - */ - - /** - * Returns true if the specified string is in the camel caps format. - * - * @param boolean $classFormat If true, check to see if the string is in the - * class format. Class format strings must start - * with a capital letter and contain no - * underscores. - * @param boolean $strict If true, the string must not have two capital - * letters next to each other. If false, a - * relaxed camel caps policy is used to allow - * for acronyms. - * - * @return boolean - */ - - /** - * Verifies that a @throws tag exists for a function that throws exceptions. - * Verifies the number of @throws tags and the number of throw tokens matches. - * Verifies the exception type. - * - * PHP version 5 - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - - /** - * Comment - * - * @one - * @two - * @one - * - * @two something - * here - * @two foo - * @three something - * here - * @three bar - */ - - /** - * @ var Comment - */ - -/** @var Database $mockedDatabase */ -/** @var Container $mockedContainer */ - -/** - * 这是一条测试评论. - */ - -/** - * I'm a function short-description - * @return boolean - */ - -/** - * this is a test - * @author test - * @param boolean $foo blah - * @return boolean - * @param boolean $bar Blah. - */ - -/** - * Short description. - * - * @tag one - * @param int $number - * @param string $text - * @return something - */ - -/** - * - * @param int $number - * @param string $text - * @return something - */ - -/** - * @param int $number - */ - -/** - * étude des ... - */ - -/**doc comment */ - - /** - * Document behaviour with missing blank lines with indented docblocks. - * @param - * @param - * @tag one - * - */ - - /** Indented doc comment */ - -/** - * Verify and document sniff behaviour when the "tag value" is indented with a mix of tabs and spaces. - * The below is "correctly" aligned. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Verify and document sniff behaviour when the "tag value" is indented with a mix of tabs and spaces. - * The below is incorrectly aligned. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Do something. - * - * @codeCoverageIgnore - * - * @phpcs:disable Stnd.Cat.SniffName - * - * @return void - */ - -// Tests to check handling empty doc comments. -/** - */ - -/** - * - * - * - */ diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.js.fixed b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.js.fixed deleted file mode 100644 index 133b67d3f4..0000000000 --- a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.1.js.fixed +++ /dev/null @@ -1,275 +0,0 @@ - -/** - * Short description. - * - * Long description - * over multiple lines. - * - * @tag1 one - * @tag2 two - * @tag3 three - */ - -/** - * short description - * - * long description - * over multiple lines. - * - * @tag1 one - */ - -/** - * Short description - * - * Long description - * over multiple lines - * - * @tag1 one - */ - -/* - This is not a doc block. - */ - -/** - * Short description. - * - * @tag one - * @tag2 two - * @tagThree three - * @tagFour four - */ - -/** - * Short description. - * - * @tag one - * - * @param - * @param - */ - -/** - * Short description. - * - * @param - * @param - * @tag one - */ - -/** - * Short description. - * - * @param - * - * @param - * - * @tag one - */ - - /** - * Short description. - * - * @param - * - * @tag one - * @param - */ - -/** - * Short description. - * - * @groupOne one - * @groupOne two - * - * @group2 one - * @group2 two - * - * @g3 - * @g3 two - */ - - /** - * Short description - * over multiple lines. - * - * Long description. - * - * @param - * - * @tag one - */ - -/** - * Short description. - * - * @tag1 one some comment across - * multiple lines - * @tag1 two some comment across - * multiple lines - * @tag1 three some comment across - * multiple lines - */ - - /** - * Returns true if the specified string is in the camel caps format. - * - * @param boolean $classFormat If true, check to see if the string is in the - * class format. Class format strings must start - * with a capital letter and contain no - * underscores. - * @param boolean $strict If true, the string must not have two capital - * letters next to each other. If false, a - * relaxed camel caps policy is used to allow - * for acronyms. - * - * @return boolean - */ - - /** - * Verifies that a @throws tag exists for a function that throws exceptions. - * Verifies the number of @throws tags and the number of throw tokens matches. - * Verifies the exception type. - * - * PHP version 5 - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - - /** - * Comment - * - * @one - * @two - * @one - * - * @two something - * here - * @two foo - * @three something - * here - * @three bar - */ - - /** - * @ var Comment - */ - -/** - * @var Database $mockedDatabase -*/ -/** - * @var Container $mockedContainer -*/ - -/** - * 这是一条测试评论. - */ - -/** - * I'm a function short-description - * - * @return boolean - */ - -/** - * this is a test - * - * @author test - * @param boolean $foo blah - * @return boolean - * @param boolean $bar Blah. - */ - -/** - * Short description. - * - * @tag one - * @param int $number - * @param string $text - * @return something - */ - -/** - * - * @param int $number - * @param string $text - * @return something - */ - -/** - * @param int $number - */ - -/** - * étude des ... - */ - -/** -* doc comment -*/ - - /** - * Document behaviour with missing blank lines with indented docblocks. - * - * @param - * @param - * @tag one - */ - - /** - * Indented doc comment -*/ - -/** - * Verify and document sniff behaviour when the "tag value" is indented with a mix of tabs and spaces. - * The below is "correctly" aligned. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Verify and document sniff behaviour when the "tag value" is indented with a mix of tabs and spaces. - * The below is incorrectly aligned. - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood - * @author Marc McIntyre - * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Do something. - * - * @codeCoverageIgnore - * - * @phpcs:disable Stnd.Cat.SniffName - * - * @return void - */ - -// Tests to check handling empty doc comments. -/** - */ - -/** - * - * - * - */ diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.2.js b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.2.js deleted file mode 100644 index 0eaa135fbd..0000000000 --- a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.2.js +++ /dev/null @@ -1,4 +0,0 @@ -// Intentional parse error. Testing that the sniff is *not* triggered -// in this case - -/** No docblock close tag. Must be last test without new line. \ No newline at end of file diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php index e447833d4d..01a710b342 100644 --- a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php +++ b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php @@ -49,7 +49,6 @@ public function getErrorList($testFile='') { switch ($testFile) { case 'DocCommentUnitTest.1.inc': - case 'DocCommentUnitTest.1.js': return [ 14 => 1, 16 => 1, diff --git a/src/Standards/Generic/Tests/Commenting/FixmeUnitTest.js b/src/Standards/Generic/Tests/Commenting/FixmeUnitTest.js deleted file mode 100644 index 7836b9a213..0000000000 --- a/src/Standards/Generic/Tests/Commenting/FixmeUnitTest.js +++ /dev/null @@ -1,23 +0,0 @@ - -/** - * FIXME: Write this comment - * FIXME - */ - -// FIXME: remove this. -alert('test'); - -// FIXME remove this. -alert('test'); - -// fixme - remove this. - -// Extract info from the array. -// FIXME: can this be done faster? - -// Extract info from the array (fixme: make it faster) -// To do this, use a function! -// nofixme! NOFIXME! NOfixme! -//FIXME. -//éfixme -//fixmeé diff --git a/src/Standards/Generic/Tests/Commenting/TodoUnitTest.js b/src/Standards/Generic/Tests/Commenting/TodoUnitTest.js deleted file mode 100644 index 8f01ca17f3..0000000000 --- a/src/Standards/Generic/Tests/Commenting/TodoUnitTest.js +++ /dev/null @@ -1,23 +0,0 @@ - -/** - * TODO: Write this comment - * TODO - */ - -// TODO: remove this. -alert('test'); - -// TODO remove this. -alert('test'); - -// todo - remove this. - -// Extract info from the array. -// TODO: can this be done faster? - -// Extract info from the array (todo: make it faster) -// To do this, use a function! -// notodo! NOTODO! NOtodo! -//TODO. -//étodo -//todoé diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.js b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.js deleted file mode 100644 index 763c1c1c1c..0000000000 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.js +++ /dev/null @@ -1,35 +0,0 @@ - - -if (something) print 'hello'; - -if (something) { - print 'hello'; -} else print 'hi'; - -if (something) { - print 'hello'; -} else if (something) print 'hi'; - -for (i; i > 0; i--) print 'hello'; - -while (something) print 'hello'; - -do { - i--; -} while (something); - -do i++; while (i < 5); - -SomeClass.prototype.for = function() { - // do something -}; - -if ($("#myid").rotationDegrees()=='90') - $('.modal').css({'transform': 'rotate(90deg)'}); - -if ($("#myid").rotationDegrees()=='90') - $foo = {'transform': 'rotate(90deg)'}; - -if (something) { - alert('hello'); -} else /* comment */ if (somethingElse) alert('hi'); diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.js.fixed b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.js.fixed deleted file mode 100644 index 050a406bba..0000000000 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.1.js.fixed +++ /dev/null @@ -1,44 +0,0 @@ - - -if (something) { print 'hello'; -} - -if (something) { - print 'hello'; -} else { print 'hi'; -} - -if (something) { - print 'hello'; -} else if (something) { print 'hi'; -} - -for (i; i > 0; i--) { print 'hello'; -} - -while (something) { print 'hello'; -} - -do { - i--; -} while (something); - -do { i++; -} while (i < 5); - -SomeClass.prototype.for = function() { - // do something -}; - -if ($("#myid").rotationDegrees()=='90') { - $('.modal').css({'transform': 'rotate(90deg)'}); -} - -if ($("#myid").rotationDegrees()=='90') { - $foo = {'transform': 'rotate(90deg)'}; -} - -if (something) { - alert('hello'); -} else /* comment */ if (somethingElse) { alert('hi'); -} diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.2.js b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.2.js deleted file mode 100644 index e26c331270..0000000000 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.2.js +++ /dev/null @@ -1,5 +0,0 @@ -// Intentional parse error (missing closing parenthesis). -// This should be the only test in this file. -// Testing that the sniff is *not* triggered. - -do i++; while (i < 5 diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.3.js b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.3.js deleted file mode 100644 index 9ccedcda33..0000000000 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.3.js +++ /dev/null @@ -1,5 +0,0 @@ -// Intentional parse error (missing opening parenthesis). -// This should be the only test in this file. -// Testing that the sniff is *not* triggered. - -do i++; while diff --git a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php index 22eeb075cc..41be1659b5 100644 --- a/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php +++ b/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php @@ -83,19 +83,6 @@ public function getErrorList($testFile='') 278 => 1, ]; - case 'InlineControlStructureUnitTest.1.js': - return [ - 3 => 1, - 7 => 1, - 11 => 1, - 13 => 1, - 15 => 1, - 21 => 1, - 27 => 1, - 30 => 1, - 35 => 1, - ]; - default: return []; }//end switch diff --git a/src/Standards/Generic/Tests/Debug/CSSLintUnitTest.css b/src/Standards/Generic/Tests/Debug/CSSLintUnitTest.css deleted file mode 100644 index d63da75f60..0000000000 --- a/src/Standards/Generic/Tests/Debug/CSSLintUnitTest.css +++ /dev/null @@ -1,6 +0,0 @@ -/*csslint important: true, order-alphabetical: true, zero-units: true */ - -.selector-with-errors { - font-size: 10px !important; - border: 0px; -} diff --git a/src/Standards/Generic/Tests/Debug/CSSLintUnitTest.php b/src/Standards/Generic/Tests/Debug/CSSLintUnitTest.php deleted file mode 100644 index e4afa67b63..0000000000 --- a/src/Standards/Generic/Tests/Debug/CSSLintUnitTest.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright 2019 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Standards\Generic\Tests\Debug; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; -use PHP_CodeSniffer\Config; - -/** - * Unit test class for the CSSLint sniff. - * - * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Debug\CSSLintSniff - * @covers \PHP_CodeSniffer\Config::getExecutablePath - * @group Windows - */ -final class CSSLintUnitTest extends AbstractSniffUnitTest -{ - - - /** - * Should this test be skipped for some reason. - * - * @return bool - */ - protected function shouldSkipTest() - { - $csslintPath = Config::getExecutablePath('csslint'); - if ($csslintPath === null) { - return true; - } - - return false; - - }//end shouldSkipTest() - - - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getErrorList() - { - return []; - - }//end getErrorList() - - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return [ - 3 => 1, - 4 => 1, - 5 => 1, - ]; - - }//end getWarningList() - - -}//end class diff --git a/src/Standards/Generic/Tests/Debug/ClosureLinterUnitTest.js b/src/Standards/Generic/Tests/Debug/ClosureLinterUnitTest.js deleted file mode 100644 index 693d692319..0000000000 --- a/src/Standards/Generic/Tests/Debug/ClosureLinterUnitTest.js +++ /dev/null @@ -1,6 +0,0 @@ -/** - * My function - */ -function something() { - return a; -} diff --git a/src/Standards/Generic/Tests/Debug/ClosureLinterUnitTest.php b/src/Standards/Generic/Tests/Debug/ClosureLinterUnitTest.php deleted file mode 100644 index 6577f69dfb..0000000000 --- a/src/Standards/Generic/Tests/Debug/ClosureLinterUnitTest.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @copyright 2019 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Standards\Generic\Tests\Debug; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; -use PHP_CodeSniffer\Config; - -/** - * Unit test class for the ClosureLinter sniff. - * - * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Debug\ClosureLinterSniff - */ -final class ClosureLinterUnitTest extends AbstractSniffUnitTest -{ - - - /** - * Should this test be skipped for some reason. - * - * @return bool - */ - protected function shouldSkipTest() - { - $lintPath = Config::getExecutablePath('gjslint'); - if ($lintPath === null) { - return true; - } - - return false; - - }//end shouldSkipTest() - - - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getErrorList() - { - return []; - - }//end getErrorList() - - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return [ - 3 => 1, - 5 => 1, - ]; - - }//end getWarningList() - - -}//end class diff --git a/src/Standards/Generic/Tests/Debug/ESLintUnitTest.js b/src/Standards/Generic/Tests/Debug/ESLintUnitTest.js deleted file mode 100644 index 5beb2724ec..0000000000 --- a/src/Standards/Generic/Tests/Debug/ESLintUnitTest.js +++ /dev/null @@ -1 +0,0 @@ -var foo = bar; diff --git a/src/Standards/Generic/Tests/Debug/ESLintUnitTest.php b/src/Standards/Generic/Tests/Debug/ESLintUnitTest.php deleted file mode 100644 index e035c2088c..0000000000 --- a/src/Standards/Generic/Tests/Debug/ESLintUnitTest.php +++ /dev/null @@ -1,122 +0,0 @@ - - * @copyright 2019 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Standards\Generic\Tests\Debug; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; -use PHP_CodeSniffer\Config; - -/** - * Unit test class for the ESLint sniff. - * - * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Debug\ESLintSniff - */ -final class ESLintUnitTest extends AbstractSniffUnitTest -{ - - /** - * Basic ESLint config to use for testing the sniff. - * - * @var string - */ - const ESLINT_CONFIG = '{ - "parserOptions": { - "ecmaVersion": 5, - "sourceType": "script", - "ecmaFeatures": {} - }, - "rules": { - "no-undef": 2, - "no-unused-vars": 2 - } -}'; - - - /** - * Sets up this unit test. - * - * @before - * - * @return void - */ - protected function setUpPrerequisites() - { - parent::setUpPrerequisites(); - - $cwd = getcwd(); - file_put_contents($cwd.'/.eslintrc.json', self::ESLINT_CONFIG); - - putenv('ESLINT_USE_FLAT_CONFIG=false'); - - }//end setUpPrerequisites() - - - /** - * Remove artifact. - * - * @after - * - * @return void - */ - protected function resetProperties() - { - $cwd = getcwd(); - unlink($cwd.'/.eslintrc.json'); - - }//end resetProperties() - - - /** - * Should this test be skipped for some reason. - * - * @return bool - */ - protected function shouldSkipTest() - { - $eslintPath = Config::getExecutablePath('eslint'); - if ($eslintPath === null) { - return true; - } - - return false; - - }//end shouldSkipTest() - - - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getErrorList() - { - return [1 => 2]; - - }//end getErrorList() - - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return []; - - }//end getWarningList() - - -}//end class diff --git a/src/Standards/Generic/Tests/Debug/JSHintUnitTest.js b/src/Standards/Generic/Tests/Debug/JSHintUnitTest.js deleted file mode 100644 index e347c38622..0000000000 --- a/src/Standards/Generic/Tests/Debug/JSHintUnitTest.js +++ /dev/null @@ -1,3 +0,0 @@ -/* jshint undef: true, unused: true */ - -var foo = bar; diff --git a/src/Standards/Generic/Tests/Debug/JSHintUnitTest.php b/src/Standards/Generic/Tests/Debug/JSHintUnitTest.php deleted file mode 100644 index 2545159945..0000000000 --- a/src/Standards/Generic/Tests/Debug/JSHintUnitTest.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright 2019 Juliette Reinders Folmer. All rights reserved. - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Standards\Generic\Tests\Debug; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; -use PHP_CodeSniffer\Config; - -/** - * Unit test class for the JSHint sniff. - * - * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Debug\JSHintSniff - */ -final class JSHintUnitTest extends AbstractSniffUnitTest -{ - - - /** - * Should this test be skipped for some reason. - * - * @return bool - */ - protected function shouldSkipTest() - { - $jshintPath = Config::getExecutablePath('jshint'); - if ($jshintPath === null) { - return true; - } - - return false; - - }//end shouldSkipTest() - - - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getErrorList() - { - return []; - - }//end getErrorList() - - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return [3 => 2]; - - }//end getWarningList() - - -}//end class diff --git a/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.1.css b/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.1.css deleted file mode 100644 index 2127f8ec7d..0000000000 --- a/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.1.css +++ /dev/null @@ -1,3 +0,0 @@ - -#login-container {} - diff --git a/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.1.js b/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.1.js deleted file mode 100644 index a897ffba2f..0000000000 --- a/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.1.js +++ /dev/null @@ -1,3 +0,0 @@ - -alert('hi); - diff --git a/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.2.css b/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.2.css deleted file mode 100644 index a2d2dd76fe..0000000000 --- a/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.2.css +++ /dev/null @@ -1,2 +0,0 @@ - -#login-container {} diff --git a/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.2.js b/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.2.js deleted file mode 100644 index d1ff76b7c7..0000000000 --- a/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.2.js +++ /dev/null @@ -1,2 +0,0 @@ - -alert('hi); diff --git a/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.3.css b/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.3.css deleted file mode 100644 index 5f15bdefe2..0000000000 --- a/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.3.css +++ /dev/null @@ -1,2 +0,0 @@ - -#login-container {} \ No newline at end of file diff --git a/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.3.css.fixed b/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.3.css.fixed deleted file mode 100644 index a2d2dd76fe..0000000000 --- a/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.3.css.fixed +++ /dev/null @@ -1,2 +0,0 @@ - -#login-container {} diff --git a/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.3.js b/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.3.js deleted file mode 100644 index 6adaa55b71..0000000000 --- a/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.3.js +++ /dev/null @@ -1,2 +0,0 @@ - -alert('hi'); \ No newline at end of file diff --git a/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.3.js.fixed b/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.3.js.fixed deleted file mode 100644 index 5977947b0b..0000000000 --- a/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.3.js.fixed +++ /dev/null @@ -1,2 +0,0 @@ - -alert('hi'); diff --git a/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.php b/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.php index 2db35a195a..2046ae4378 100644 --- a/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.php +++ b/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.php @@ -34,8 +34,6 @@ public function getErrorList($testFile='') { switch ($testFile) { case 'EndFileNewlineUnitTest.3.inc': - case 'EndFileNewlineUnitTest.3.js': - case 'EndFileNewlineUnitTest.3.css': case 'EndFileNewlineUnitTest.4.inc': return [2 => 1]; case 'EndFileNewlineUnitTest.6.inc': diff --git a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.1.css b/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.1.css deleted file mode 100644 index 2127f8ec7d..0000000000 --- a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.1.css +++ /dev/null @@ -1,3 +0,0 @@ - -#login-container {} - diff --git a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.1.css.fixed b/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.1.css.fixed deleted file mode 100644 index 5f15bdefe2..0000000000 --- a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.1.css.fixed +++ /dev/null @@ -1,2 +0,0 @@ - -#login-container {} \ No newline at end of file diff --git a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.1.js b/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.1.js deleted file mode 100644 index a897ffba2f..0000000000 --- a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.1.js +++ /dev/null @@ -1,3 +0,0 @@ - -alert('hi); - diff --git a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.1.js.fixed b/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.1.js.fixed deleted file mode 100644 index 555ce94ac3..0000000000 --- a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.1.js.fixed +++ /dev/null @@ -1,2 +0,0 @@ - -alert('hi); \ No newline at end of file diff --git a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.2.css b/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.2.css deleted file mode 100644 index a2d2dd76fe..0000000000 --- a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.2.css +++ /dev/null @@ -1,2 +0,0 @@ - -#login-container {} diff --git a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.2.css.fixed b/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.2.css.fixed deleted file mode 100644 index 5f15bdefe2..0000000000 --- a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.2.css.fixed +++ /dev/null @@ -1,2 +0,0 @@ - -#login-container {} \ No newline at end of file diff --git a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.2.js b/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.2.js deleted file mode 100644 index d1ff76b7c7..0000000000 --- a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.2.js +++ /dev/null @@ -1,2 +0,0 @@ - -alert('hi); diff --git a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.2.js.fixed b/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.2.js.fixed deleted file mode 100644 index 555ce94ac3..0000000000 --- a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.2.js.fixed +++ /dev/null @@ -1,2 +0,0 @@ - -alert('hi); \ No newline at end of file diff --git a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.3.css b/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.3.css deleted file mode 100644 index 5f15bdefe2..0000000000 --- a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.3.css +++ /dev/null @@ -1,2 +0,0 @@ - -#login-container {} \ No newline at end of file diff --git a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.3.js b/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.3.js deleted file mode 100644 index 6adaa55b71..0000000000 --- a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.3.js +++ /dev/null @@ -1,2 +0,0 @@ - -alert('hi'); \ No newline at end of file diff --git a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.php b/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.php index e41aa51bc9..3ca82bb806 100644 --- a/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.php +++ b/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.php @@ -34,12 +34,8 @@ public function getErrorList($testFile='') { switch ($testFile) { case 'EndFileNoNewlineUnitTest.1.inc': - case 'EndFileNoNewlineUnitTest.1.css': - case 'EndFileNoNewlineUnitTest.1.js': case 'EndFileNoNewlineUnitTest.2.inc': return [3 => 1]; - case 'EndFileNoNewlineUnitTest.2.css': - case 'EndFileNoNewlineUnitTest.2.js': case 'EndFileNoNewlineUnitTest.6.inc': return [2 => 1]; case 'EndFileNoNewlineUnitTest.8.inc': diff --git a/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.css b/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.css deleted file mode 100644 index a8c96255f6..0000000000 --- a/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.css +++ /dev/null @@ -1,3 +0,0 @@ -#login-container { - margin-left: -225px; -} diff --git a/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.css.fixed b/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.css.fixed deleted file mode 100644 index c182ac4d74..0000000000 --- a/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.css.fixed +++ /dev/null @@ -1,3 +0,0 @@ -#login-container { - margin-left: -225px; -} diff --git a/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.js b/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.js deleted file mode 100644 index 49c58d8e05..0000000000 --- a/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.js +++ /dev/null @@ -1,2 +0,0 @@ -alert('hi'); -alert('hi'); diff --git a/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.js.fixed b/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.js.fixed deleted file mode 100644 index 0260099289..0000000000 --- a/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.js.fixed +++ /dev/null @@ -1,2 +0,0 @@ -alert('hi'); -alert('hi'); diff --git a/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.js b/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.js deleted file mode 100644 index dd0a90e1f3..0000000000 --- a/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.js +++ /dev/null @@ -1,118 +0,0 @@ - - -// Valid -var1 = 'var1'; -var10 = 'var1'; -var100 = 'var1'; -var1000 = 'var1'; - -// Invalid -var1 = 'var1'; -var10 = 'var1'; -var100 = 'var1'; -var1000 = 'var1'; - -// Valid -var1 = 'var1'; -var10 = 'var1'; - -var100 = 'var1'; -var1000 = 'var1'; - -// Invalid -var1 = 'var1'; -var10 = 'var1'; - -var100 = 'var1'; -var1000 = 'var1'; - -// Valid -var1 += 'var1'; -var10 += 'var1'; -var100 += 'var1'; -var1000 += 'var1'; - -// Invalid -var1 += 'var1'; -var10+= 'var1'; -var100 += 'var1'; -var1000 += 'var1'; - -// Valid -var1 = 'var1'; -var10 += 'var1'; -var100 = 'var1'; -var1000 += 'var1'; - -// Invalid -var1 = 'var1'; -var10 += 'var1'; -var100 = 'var1'; -var1000+= 'var1'; - -// Valid -var1 += 'var1'; -var10 += 'var1'; - -var100 += 'var1'; -var1000 += 'var1'; - -// Invalid -var1 += 'var1'; -var10 += 'var1'; - -var100 += 'var1'; -var1000 += 'var1'; - -// Valid -var test = 100; - -// InValid -var test = 100; - -commentStart = phpcsFile.findPrevious(); -commentEnd = this._phpcsFile; -expected += '...'; - -// Invalid -this.okButton = {}; -content = {}; - -var buttonid = [this.id, '-positionFormats-add'].join(''); -var buttonWidget = WidgetStore.get(buttonid); -var spinButtonid = [this.id, '-positionFormats-spinButton'].join(''); -var spinButtonWidget = WidgetStore.get(spinButtonid); -var position = spinButtonWidget.getValue(); -var posFormatsList = WidgetStore.get([self.id, '-positionFormats-list'].join('')); - -dfx.stripTags = function(content, allowedTags) -{ - var match; - var re = 'blah'; -}; - -var contents += 'if ('; -var conditions = array(); - -var foo = {}; -foo.blah = 'blah'; - -var script = document.createElement('script'); -script.onload = function() -{ - clearTimeout(t); -}; - -stream.match(stream.sol() ? /^\s*\/\/.*/ : /^\s+\/\/.*/); -function() { - if (condition) - foo = .4 -} - -x = x << y; -x <<= y; -x = x >> y; -x >>= y; - -x = x << y; -x >>>= y; diff --git a/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.js.fixed b/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.js.fixed deleted file mode 100644 index bce6530abb..0000000000 --- a/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.js.fixed +++ /dev/null @@ -1,118 +0,0 @@ - - -// Valid -var1 = 'var1'; -var10 = 'var1'; -var100 = 'var1'; -var1000 = 'var1'; - -// Invalid -var1 = 'var1'; -var10 = 'var1'; -var100 = 'var1'; -var1000 = 'var1'; - -// Valid -var1 = 'var1'; -var10 = 'var1'; - -var100 = 'var1'; -var1000 = 'var1'; - -// Invalid -var1 = 'var1'; -var10 = 'var1'; - -var100 = 'var1'; -var1000 = 'var1'; - -// Valid -var1 += 'var1'; -var10 += 'var1'; -var100 += 'var1'; -var1000 += 'var1'; - -// Invalid -var1 += 'var1'; -var10 += 'var1'; -var100 += 'var1'; -var1000 += 'var1'; - -// Valid -var1 = 'var1'; -var10 += 'var1'; -var100 = 'var1'; -var1000 += 'var1'; - -// Invalid -var1 = 'var1'; -var10 += 'var1'; -var100 = 'var1'; -var1000 += 'var1'; - -// Valid -var1 += 'var1'; -var10 += 'var1'; - -var100 += 'var1'; -var1000 += 'var1'; - -// Invalid -var1 += 'var1'; -var10 += 'var1'; - -var100 += 'var1'; -var1000 += 'var1'; - -// Valid -var test = 100; - -// InValid -var test = 100; - -commentStart = phpcsFile.findPrevious(); -commentEnd = this._phpcsFile; -expected += '...'; - -// Invalid -this.okButton = {}; -content = {}; - -var buttonid = [this.id, '-positionFormats-add'].join(''); -var buttonWidget = WidgetStore.get(buttonid); -var spinButtonid = [this.id, '-positionFormats-spinButton'].join(''); -var spinButtonWidget = WidgetStore.get(spinButtonid); -var position = spinButtonWidget.getValue(); -var posFormatsList = WidgetStore.get([self.id, '-positionFormats-list'].join('')); - -dfx.stripTags = function(content, allowedTags) -{ - var match; - var re = 'blah'; -}; - -var contents += 'if ('; -var conditions = array(); - -var foo = {}; -foo.blah = 'blah'; - -var script = document.createElement('script'); -script.onload = function() -{ - clearTimeout(t); -}; - -stream.match(stream.sol() ? /^\s*\/\/.*/ : /^\s+\/\/.*/); -function() { - if (condition) - foo = .4 -} - -x = x << y; -x <<= y; -x = x >> y; -x >>= y; - -x = x << y; -x >>>= y; diff --git a/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php b/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php index e2b5e0c5df..5b1b6a4d44 100644 --- a/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php +++ b/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php @@ -41,128 +41,88 @@ public function getErrorList() * The key of the array should represent the line number and the value * should represent the number of warnings that should occur on that line. * - * @param string $testFile The name of the file being tested. - * * @return array */ - public function getWarningList($testFile='') + public function getWarningList() { - switch ($testFile) { - case 'MultipleStatementAlignmentUnitTest.inc': - return [ - 11 => 1, - 12 => 1, - 23 => 1, - 24 => 1, - 26 => 1, - 27 => 1, - 37 => 1, - 38 => 1, - 48 => 1, - 50 => 1, - 51 => 1, - 61 => 1, - 62 => 1, - 64 => 1, - 65 => 1, - 71 => 1, - 78 => 1, - 79 => 1, - 86 => 1, - 92 => 1, - 93 => 1, - 94 => 1, - 95 => 1, - 123 => 1, - 124 => 1, - 126 => 1, - 129 => 1, - 154 => 1, - 161 => 1, - 178 => 1, - 179 => 1, - 182 => 1, - 206 => 1, - 207 => 1, - 252 => 1, - 257 => 1, - 263 => 1, - 269 => 1, - 293 => 1, - 295 => 1, - 296 => 1, - 297 => 1, - 301 => 1, - 303 => 1, - 308 => 1, - 311 => 1, - 313 => 1, - 314 => 1, - 321 => 1, - 322 => 1, - 324 => 1, - 329 => 1, - 331 => 1, - 336 => 1, - 339 => 1, - 341 => 1, - 342 => 1, - 349 => 1, - 350 => 1, - 352 => 1, - 357 => 1, - 364 => 1, - 396 => 1, - 398 => 1, - 399 => 1, - 401 => 1, - 420 => 1, - 422 => 1, - 436 => 1, - 438 => 1, - 442 => 1, - 443 => 1, - 454 => 1, - 487 => 1, - 499 => 1, - 500 => 1, - ]; - - case 'MultipleStatementAlignmentUnitTest.js': - return [ - 11 => 1, - 12 => 1, - 23 => 1, - 24 => 1, - 26 => 1, - 27 => 1, - 37 => 1, - 38 => 1, - 48 => 1, - 50 => 1, - 51 => 1, - 61 => 1, - 62 => 1, - 64 => 1, - 65 => 1, - 71 => 1, - 78 => 1, - 79 => 1, - 81 => 1, - 82 => 1, - 83 => 1, - 85 => 1, - 86 => 1, - 100 => 1, - 112 => 1, - 113 => 1, - 114 => 1, - 117 => 1, - ]; - - default: - return []; - }//end switch + return [ + 11 => 1, + 12 => 1, + 23 => 1, + 24 => 1, + 26 => 1, + 27 => 1, + 37 => 1, + 38 => 1, + 48 => 1, + 50 => 1, + 51 => 1, + 61 => 1, + 62 => 1, + 64 => 1, + 65 => 1, + 71 => 1, + 78 => 1, + 79 => 1, + 86 => 1, + 92 => 1, + 93 => 1, + 94 => 1, + 95 => 1, + 123 => 1, + 124 => 1, + 126 => 1, + 129 => 1, + 154 => 1, + 161 => 1, + 178 => 1, + 179 => 1, + 182 => 1, + 206 => 1, + 207 => 1, + 252 => 1, + 257 => 1, + 263 => 1, + 269 => 1, + 293 => 1, + 295 => 1, + 296 => 1, + 297 => 1, + 301 => 1, + 303 => 1, + 308 => 1, + 311 => 1, + 313 => 1, + 314 => 1, + 321 => 1, + 322 => 1, + 324 => 1, + 329 => 1, + 331 => 1, + 336 => 1, + 339 => 1, + 341 => 1, + 342 => 1, + 349 => 1, + 350 => 1, + 352 => 1, + 357 => 1, + 364 => 1, + 396 => 1, + 398 => 1, + 399 => 1, + 401 => 1, + 420 => 1, + 422 => 1, + 436 => 1, + 438 => 1, + 442 => 1, + 443 => 1, + 454 => 1, + 487 => 1, + 499 => 1, + 500 => 1, + ]; }//end getWarningList() diff --git a/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.js b/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.js deleted file mode 100644 index 6ac1d0e834..0000000000 --- a/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.js +++ /dev/null @@ -1,5 +0,0 @@ - -if (!someVar || !x) {} -if (! someVar || ! x) {} -if (!foo() && (!x || true)) {} -var z = !(x || y); diff --git a/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.js.fixed b/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.js.fixed deleted file mode 100644 index 055113d378..0000000000 --- a/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.js.fixed +++ /dev/null @@ -1,5 +0,0 @@ - -if (! someVar || ! x) {} -if (! someVar || ! x) {} -if (! foo() && (! x || true)) {} -var z = ! (x || y); diff --git a/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.php b/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.php index a439517ad4..1ea522975d 100644 --- a/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.php +++ b/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.php @@ -64,13 +64,6 @@ public function getErrorList($testFile='') 79 => 1, ]; - case 'SpaceAfterNotUnitTest.js': - return [ - 2 => 2, - 4 => 2, - 5 => 1, - ]; - default: return []; }//end switch diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.js b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.js deleted file mode 100644 index 87cfb820c0..0000000000 --- a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.js +++ /dev/null @@ -1,14 +0,0 @@ -if (variable === true) { } -if (variable === TRUE) { } -if (variable === True) { } -variable = True; - -if (variable === false) { } -if (variable === FALSE) { } -if (variable === False) { } -variable = false; - -if (variable === null) { } -if (variable === NULL) { } -if (variable === Null) { } -variable = NULL; diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.js.fixed b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.js.fixed deleted file mode 100644 index 7dbf3adf50..0000000000 --- a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.js.fixed +++ /dev/null @@ -1,14 +0,0 @@ -if (variable === true) { } -if (variable === true) { } -if (variable === true) { } -variable = true; - -if (variable === false) { } -if (variable === false) { } -if (variable === false) { } -variable = false; - -if (variable === null) { } -if (variable === null) { } -if (variable === null) { } -variable = null; diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php index a2725864fc..fb6e381010 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php @@ -68,18 +68,6 @@ public function getErrorList($testFile='') 153 => 1, ]; - case 'LowerCaseConstantUnitTest.js': - return [ - 2 => 1, - 3 => 1, - 4 => 1, - 7 => 1, - 8 => 1, - 12 => 1, - 13 => 1, - 14 => 1, - ]; - default: return []; }//end switch diff --git a/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.js b/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.js deleted file mode 100644 index 6be7900869..0000000000 --- a/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.js +++ /dev/null @@ -1,15 +0,0 @@ -var x = 'My ' + 'string'; -var x = 'My ' + 1234; -var x = 'My ' + y + ' test'; - -this.errors['test'] = x; -this.errors['test' + 10] = x; -this.errors['test' + y] = x; -this.errors['test' + 'blah'] = x; -this.errors[y] = x; -this.errors[y + z] = x; -this.errors[y + z + 'My' + 'String'] = x; - -var long = 'This is a really long string. ' - + 'It is being used for errors. ' - + 'The message is not translated.'; diff --git a/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php b/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php index e657e48700..9d42a4dbab 100644 --- a/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php +++ b/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php @@ -43,15 +43,6 @@ public function getErrorList($testFile='') 20 => 1, ]; - case 'UnnecessaryStringConcatUnitTest.js': - return [ - 1 => 1, - 8 => 1, - 11 => 1, - 14 => 1, - 15 => 1, - ]; - default: return []; }//end switch diff --git a/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.1.css b/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.1.css deleted file mode 100644 index de84a948e5..0000000000 --- a/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.1.css +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This is a CSS comment. -<<<<<<< HEAD - * This is a merge conflict... -======= - * which should be detected. ->>>>>>> ref/heads/feature-branch - */ - -.SettingsTabPaneWidgetType-tab-mid { - background: transparent url(tab_inact_mid.png) repeat-x; -<<<<<<< HEAD - line-height: -25px; -======= - line-height: -20px; ->>>>>>> ref/heads/feature-branch - cursor: pointer; - -moz-user-select: none; -} - -/* - * The above tests are based on "normal" tokens. - * The below test checks that once the tokenizer breaks down because of - * unexpected merge conflict boundaries, subsequent boundaries will still - * be detected correctly. - */ - -/* - * This is a CSS comment. -<<<<<<< HEAD - * This is a merge conflict... -======= - * which should be detected. ->>>>>>> ref/heads/feature-branch - */ diff --git a/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.2.css b/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.2.css deleted file mode 100644 index 6caa78d02d..0000000000 --- a/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.2.css +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This is a CSS comment. -<<<<<<< HEAD - * This is a merge conflict started in a comment, ending in a CSS block. - */ -.SettingsTabPaneWidgetType-tab-mid { - background: transparent url(tab_inact_mid.png) repeat-x; -======= - * which should be detected. - **/ -.SettingsTabPaneWidgetType-tab-start { - line-height: -25px; ->>>>>>> ref/heads/feature-branch - cursor: pointer; - -moz-user-select: none; -} - -/* - * The above tests are based on "normal" tokens. - * The below test checks that once the tokenizer breaks down because of - * unexpected merge conflict boundaries, subsequent boundaries will still - * be detected correctly. - */ - -/* - * This is a CSS comment. -<<<<<<< HEAD - * This is a merge conflict... -======= - * which should be detected. ->>>>>>> ref/heads/feature-branch - */ diff --git a/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.js b/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.js deleted file mode 100644 index cd7bc760f3..0000000000 --- a/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.js +++ /dev/null @@ -1,33 +0,0 @@ - -result = x?y:z; -result = x ? y : z; - -<<<<<<< HEAD -if (something === true -======= -if (something === false ->>>>>>> develop - ^ somethingElse === true -) { -<<<<<<< HEAD - return true; -======= - return false; ->>>>>>> develop -} - -y = 1 - + 2 - - 3; - -/* -<<<<<<< HEAD - * @var string $bar - */ -if (something === true - -/** -======= - * @var string $foo ->>>>>>> master - */ diff --git a/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.php b/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.php index bc96638499..8034191327 100644 --- a/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.php +++ b/src/Standards/Generic/Tests/VersionControl/GitMergeConflictUnitTest.php @@ -114,42 +114,6 @@ public function getErrorList($testFile='') 16 => 1, ]; - case 'GitMergeConflictUnitTest.1.css': - return [ - 3 => 1, - 5 => 1, - 7 => 1, - 12 => 1, - 14 => 1, - 16 => 1, - 30 => 1, - 32 => 1, - 34 => 1, - ]; - - case 'GitMergeConflictUnitTest.2.css': - return [ - 3 => 1, - 8 => 1, - 13 => 1, - 27 => 1, - 29 => 1, - 31 => 1, - ]; - - case 'GitMergeConflictUnitTest.js': - return [ - 5 => 1, - 7 => 1, - 9 => 1, - 12 => 1, - 14 => 1, - 16 => 1, - 24 => 1, - 30 => 1, - 32 => 1, - ]; - default: return []; }//end switch diff --git a/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.css b/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.css deleted file mode 100644 index 8bd566b702..0000000000 --- a/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.css +++ /dev/null @@ -1,4 +0,0 @@ -#login-container { - margin-left: -225px; - width: 450px; -} diff --git a/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.css.fixed b/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.css.fixed deleted file mode 100644 index edca8e91af..0000000000 --- a/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.css.fixed +++ /dev/null @@ -1,4 +0,0 @@ -#login-container { - margin-left: -225px; - width: 450px; -} diff --git a/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.js b/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.js deleted file mode 100644 index d412fcc0b0..0000000000 --- a/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.js +++ /dev/null @@ -1,9 +0,0 @@ -var x = { - abc: 1, - zyz: 2, - abc: 5, - mno: { - abc: 4 - }, - abc: 5 -} diff --git a/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.js.fixed b/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.js.fixed deleted file mode 100644 index 5772278a61..0000000000 --- a/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.js.fixed +++ /dev/null @@ -1,9 +0,0 @@ -var x = { - abc: 1, - zyz: 2, - abc: 5, - mno: { - abc: 4 - }, - abc: 5 -} diff --git a/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php index 21e89c646f..d0ed07c9a2 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php @@ -114,12 +114,6 @@ public function getErrorList($testFile='') // PHP 7.2 or lower: PHP version which doesn't support flexible heredocs/nowdocs yet. return []; - case 'DisallowSpaceIndentUnitTest.js': - return [3 => 1]; - - case 'DisallowSpaceIndentUnitTest.css': - return [2 => 1]; - default: return []; }//end switch diff --git a/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.css b/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.css deleted file mode 100644 index 80870da8f6..0000000000 --- a/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.css +++ /dev/null @@ -1,5 +0,0 @@ -#login-container { - margin-left: -225px; - width: 450px; -} - diff --git a/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.css.fixed b/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.css.fixed deleted file mode 100644 index a8fa12b9e1..0000000000 --- a/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.css.fixed +++ /dev/null @@ -1,5 +0,0 @@ -#login-container { - margin-left: -225px; - width: 450px; -} - diff --git a/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.js b/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.js deleted file mode 100644 index ca4d67a565..0000000000 --- a/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.js +++ /dev/null @@ -1,9 +0,0 @@ -var x = { - abc: 1, - zyz: 2, - abc: 5, - mno: { - abc: 4 - }, - abc: 5 -} diff --git a/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.js.fixed b/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.js.fixed deleted file mode 100644 index 42a2837f64..0000000000 --- a/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.js.fixed +++ /dev/null @@ -1,9 +0,0 @@ -var x = { - abc: 1, - zyz: 2, - abc: 5, - mno: { - abc: 4 - }, - abc: 5 -} diff --git a/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php index 9618e55d86..4810195f39 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php @@ -115,19 +115,6 @@ public function getErrorList($testFile='') // PHP 7.2 or lower: PHP version which doesn't support flexible heredocs/nowdocs yet. return []; - case 'DisallowTabIndentUnitTest.js': - return [ - 3 => 1, - 5 => 1, - 6 => 1, - ]; - - case 'DisallowTabIndentUnitTest.css': - return [ - 1 => 1, - 2 => 1, - ]; - default: return []; }//end switch diff --git a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.js b/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.js deleted file mode 100644 index b7b1c2f260..0000000000 --- a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.js +++ /dev/null @@ -1,17 +0,0 @@ -var i; - -i = 10; ---i; --- i; --- /*comment*/ i; -++i; -++ - i; -++/*comment*/i; - -i--; -i --; -i /*comment*/ --; -i++; -i ++; -i /*comment*/ ++; diff --git a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.js.fixed b/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.js.fixed deleted file mode 100644 index 5d8b33a0e3..0000000000 --- a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.js.fixed +++ /dev/null @@ -1,16 +0,0 @@ -var i; - -i = 10; ---i; ---i; --- /*comment*/ i; -++i; -++i; -++/*comment*/i; - -i--; -i--; -i /*comment*/ --; -i++; -i++; -i /*comment*/ ++; diff --git a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php index 91e349338d..0286b95408 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/IncrementDecrementSpacingUnitTest.php @@ -26,13 +26,11 @@ final class IncrementDecrementSpacingUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * - * @param string $testFile The name of the file being tested. - * * @return array */ - public function getErrorList($testFile='') + public function getErrorList() { - $errors = [ + return [ 5 => 1, 6 => 1, 8 => 1, @@ -41,30 +39,18 @@ public function getErrorList($testFile='') 14 => 1, 16 => 1, 17 => 1, + 21 => 1, + 23 => 1, + 26 => 1, + 27 => 1, + 30 => 1, + 31 => 1, + 34 => 1, + 37 => 1, + 40 => 1, + 42 => 1, ]; - switch ($testFile) { - case 'IncrementDecrementSpacingUnitTest.inc': - $errors[21] = 1; - $errors[23] = 1; - $errors[26] = 1; - $errors[27] = 1; - $errors[30] = 1; - $errors[31] = 1; - $errors[34] = 1; - $errors[37] = 1; - $errors[40] = 1; - $errors[42] = 1; - - return $errors; - - case 'IncrementDecrementSpacingUnitTest.js': - return $errors; - - default: - return []; - }//end switch - }//end getErrorList() diff --git a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.js b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.js deleted file mode 100644 index 2195bfb9b9..0000000000 --- a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.js +++ /dev/null @@ -1,239 +0,0 @@ -phpcs:set Generic.WhiteSpace.ScopeIndent tabIndent false -var script = document.createElement('script'); -script.onload = function() -{ - clearTimeout(t); - script456.onload = null; - script.onreadystatechange = null; - callback.call(this); - -}; - -this.callbacks[type] = { - namespaces: {}, -others: [] -}; - -blah = function() -{ - print something; - - } - -test(blah, function() { - print something; -}); - -var test = [{x: 10}]; -var test = [{ - x: 10, - y: { - b14h: 12, - 'b14h': 12 - }, - z: 23 -}]; - -Viper.prototype = { - - _removeEvents: function(elem) - { - if (!elem) { - elem = this.element; - } - - ViperUtil.removeEvent(elem, '.' + this.getEventNamespace()); - - } - -}; - -this.init = function(data) { - if (_pageListWdgt) { - GUI.getWidget('changedPagesList').addItemClickedCallback( - function(itemid, target) { - draftChangeTypeClicked( - itemid, - target, - { - reviewData: _reviewData, - pageid: itemid - } - ); - } - ); - }//end if - -}; - -a( - function() { - var _a = function() { - b = false; - - }; - true - } -); - -(function() { - a = function() { - a(function() { - if (true) { - a = true; - } - }); - - a( - function() { - if (true) { - if (true) { - a = true; - } - } - } - ); - - a( - function() { - if (true) { - a = true; - } - } - ); - - }; - -})(); - -a.prototype = { - - a: function() - { - var currentSize = null; - ViperUtil.addEvent( - header, - 'safedblclick', - function() {}, - ); - - if (topContent) { - ViperUtil.addClass(topContent, 'Viper-popup-top'); - main.appendChild(topContent); - } - - ViperUtil.addClass(midContent, 'Viper-popup-content'); - main.appendChild(midContent); - } - -}; - -a.prototype = { - - a: function() - { - ViperUtil.addClass(midContent, 'Viper-popup-content'); - main.appendChild(midContent); - - var mouseUpAction = function() {}; - var preventMouseUp = false; - var self = this; - if (clickAction) { - } - } - -}; - -a.prototype = { - - a: function() - { - var a = function() { - var a = 'foo'; - }; - - if (true) { - } - - }, - - b: function() - { - ViperUtil.addEvent( - function() { - if (fullScreen !== true) { - currentSize = { - }; - - showfullScreen(); - } - } - ); - - }, - - c: function() - { - this.a( - { - a: function() { - form.onsubmit = function() { - return false; - }; - - var a = true; - } - } - ); - - } - -}; - -a.prototype = { - init: function() - {}, - - _b: function() - { - } - -}; - -for (var i = 0; i < 10; i++) { - var foo = {foo:{'a':'b', - 'c':'d'}}; -} - -class TestOk -{ - destroy() - { - setTimeout(a, 1000); - - if (typeof self.callbackOnClose === "function") { - self.callbackOnClose(); - } - } -} - -class TestBad -{ - destroy() - { - setTimeout(function () { - return; - }, 1000); - - if (typeof self.callbackOnClose === "function") { - self.callbackOnClose(); - } - } -} - -( function( $ ) { - foo(function( value ) { - value.bind( function( newval ) { - $( '#bar' ).html( newval ); - } ); - } )( jQuery ); diff --git a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.js.fixed b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.js.fixed deleted file mode 100644 index d4bf409bcd..0000000000 --- a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.js.fixed +++ /dev/null @@ -1,239 +0,0 @@ -phpcs:set Generic.WhiteSpace.ScopeIndent tabIndent false -var script = document.createElement('script'); -script.onload = function() -{ - clearTimeout(t); - script456.onload = null; - script.onreadystatechange = null; - callback.call(this); - -}; - -this.callbacks[type] = { - namespaces: {}, - others: [] -}; - -blah = function() -{ - print something; - -} - -test(blah, function() { - print something; -}); - -var test = [{x: 10}]; -var test = [{ - x: 10, - y: { - b14h: 12, - 'b14h': 12 - }, - z: 23 -}]; - -Viper.prototype = { - - _removeEvents: function(elem) - { - if (!elem) { - elem = this.element; - } - - ViperUtil.removeEvent(elem, '.' + this.getEventNamespace()); - - } - -}; - -this.init = function(data) { - if (_pageListWdgt) { - GUI.getWidget('changedPagesList').addItemClickedCallback( - function(itemid, target) { - draftChangeTypeClicked( - itemid, - target, - { - reviewData: _reviewData, - pageid: itemid - } - ); - } - ); - }//end if - -}; - -a( - function() { - var _a = function() { - b = false; - - }; - true - } -); - -(function() { - a = function() { - a(function() { - if (true) { - a = true; - } - }); - - a( - function() { - if (true) { - if (true) { - a = true; - } - } - } - ); - - a( - function() { - if (true) { - a = true; - } - } - ); - - }; - -})(); - -a.prototype = { - - a: function() - { - var currentSize = null; - ViperUtil.addEvent( - header, - 'safedblclick', - function() {}, - ); - - if (topContent) { - ViperUtil.addClass(topContent, 'Viper-popup-top'); - main.appendChild(topContent); - } - - ViperUtil.addClass(midContent, 'Viper-popup-content'); - main.appendChild(midContent); - } - -}; - -a.prototype = { - - a: function() - { - ViperUtil.addClass(midContent, 'Viper-popup-content'); - main.appendChild(midContent); - - var mouseUpAction = function() {}; - var preventMouseUp = false; - var self = this; - if (clickAction) { - } - } - -}; - -a.prototype = { - - a: function() - { - var a = function() { - var a = 'foo'; - }; - - if (true) { - } - - }, - - b: function() - { - ViperUtil.addEvent( - function() { - if (fullScreen !== true) { - currentSize = { - }; - - showfullScreen(); - } - } - ); - - }, - - c: function() - { - this.a( - { - a: function() { - form.onsubmit = function() { - return false; - }; - - var a = true; - } - } - ); - - } - -}; - -a.prototype = { - init: function() - {}, - - _b: function() - { - } - -}; - -for (var i = 0; i < 10; i++) { - var foo = {foo:{'a':'b', - 'c':'d'}}; -} - -class TestOk -{ - destroy() - { - setTimeout(a, 1000); - - if (typeof self.callbackOnClose === "function") { - self.callbackOnClose(); - } - } -} - -class TestBad -{ - destroy() - { - setTimeout(function () { - return; - }, 1000); - - if (typeof self.callbackOnClose === "function") { - self.callbackOnClose(); - } - } -} - -( function( $ ) { - foo(function( value ) { - value.bind( function( newval ) { - $( '#bar' ).html( newval ); - } ); - } )( jQuery ); diff --git a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php index fc9f9a8b92..576ebf4ee8 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php @@ -52,33 +52,6 @@ public function setCliValues($testFile, $config) */ public function getErrorList($testFile='') { - if ($testFile === 'ScopeIndentUnitTest.1.js') { - return [ - 6 => 1, - 14 => 1, - 21 => 1, - 30 => 1, - 32 => 1, - 33 => 1, - 34 => 1, - 39 => 1, - 42 => 1, - 59 => 1, - 60 => 1, - 75 => 1, - 120 => 1, - 121 => 1, - 122 => 1, - 123 => 1, - 141 => 1, - 142 => 1, - 155 => 1, - 156 => 1, - 168 => 1, - 184 => 1, - ]; - }//end if - if ($testFile === 'ScopeIndentUnitTest.3.inc') { return [ 6 => 1, diff --git a/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php b/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php index c47466a0d5..9ebcd3fc2a 100644 --- a/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php +++ b/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php @@ -172,7 +172,6 @@ public function process(File $phpcsFile, $stackPtr) T_ABSTRACT, T_READONLY, T_CONST, - T_PROPERTY, ]; if (in_array($tokens[$nextToken]['code'], $ignore, true) === true) { diff --git a/src/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php b/src/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php index 08752edaa6..323850d4fd 100644 --- a/src/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php +++ b/src/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php @@ -16,16 +16,6 @@ class MultiLineConditionSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * The number of spaces code should be indented. * diff --git a/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php b/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php index 772ab6b8c0..79f1fbbaef 100644 --- a/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php +++ b/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php @@ -16,16 +16,6 @@ class FunctionCallSignatureSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * The number of spaces code should be indented. * diff --git a/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php b/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php index 93ccd89a2c..4ccc0b8137 100644 --- a/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php +++ b/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php @@ -18,16 +18,6 @@ class FunctionDeclarationSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * The number of spaces code should be indented. * diff --git a/src/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.js b/src/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.js deleted file mode 100644 index 064d7ff7ae..0000000000 --- a/src/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.js +++ /dev/null @@ -1,251 +0,0 @@ -if (blah(param)) { - -} - -if ((condition1 - || condition2) - && condition3 - && condition4 - && condition5 -) { -} - -if ((condition1 || condition2) && condition3 && condition4 && condition5) { -} - -if ((condition1 || condition2) - && condition3 -) { -} - -if ( - (condition1 || condition2) - && condition3 -) { -} - -if ((condition1 - || condition2) -) { -} - -if ((condition1 - || condition2) - && condition3 && - condition4 -) { -} - -if ((condition1 - || condition2) - && condition3 - && condition4 - && condition5 -) { -} - -if (($condition1 - || $condition2) -) { -} - -if ((condition1 - || condition2) - ) { -} - -if ( - ( - condition1 - || condition2 - ) - && condition3 -) { -} - - -if ( condition1 - || condition2 - || condition3 -) { -} - -if (condition1 - || condition2 - || condition3 -) { -} else if (condition1 - || condition2 - || condition3 -) { -} - -if (condition1 - || condition2 - || condition3 -) { -} else if ( - condition1 - || condition2 && - condition3 -) { -} - -if (condition1 - || condition2 -|| condition3) { -} - -if (condition1 - || condition2 || condition3 -){ -} - -if (condition1) - console.info('bar'); - -if (condition1 - || condition2 -|| condition3) - console.info('bar'); - - -if (condition1 - || condition2 || condition3 -) - console.info('bar'); - -if (!a(post) - && (!a(context.header) - ^ a(context.header, 'Content-Type')) -) { -// ... -} - -if (foo) -{ - console.info('bar'); -} - -// Should be no errors even though lines are -// not exactly aligned together. Multi-line function -// call takes precedence. -if (array_key_exists(key, value) - && foo.bar.baz( - key, value2 - ) -) { -} - -if (true) { - foo = true; -}; - -if (foo == 401 || // comment - bar == 3200) /* long comment - here - */ -{ - return false; -} - -if (foo == 401 || // comment - bar == 3200) // long comment here -{ - return false; -} - -if (IPP.errorCode() == 401 - // Comment explaining the next condition here. - || IPP.errorCode() == 3200 -) { - return false; -} - -function bar() { - if (a - && b -) { - return false; - } -} - -if (a - && foo( - 'a', - 'b' - )) { - return false; -} - - - - - - - - - - - - - -if (foo == 401 || // phpcs:ignore Standard.Category.Sniff -- for reasons. - bar == 3200) /* - phpcs:ignore Standard.Category.Sniff -- for reasons. - */ -{ - return false; -} - -if (foo == 401 || // phpcs:disable Standard.Category.Sniff -- for reasons. - bar == 3200) // phpcs:enable -{ - return false; -} - -if (IPP.errorCode() == 401 - // phpcs:ignore Standard.Category.Sniff -- for reasons. - || IPP.errorCode() == 3200 -) { - return false; -} - - if (foo == 401 || - /* - * phpcs:disable Standard.Category.Sniff -- for reasons. - */ - bar == 3200 - ) { - return false; - } - -if (IPP.errorCode() == 401 - || IPP.errorCode() == 3200 - // phpcs:ignore Standard.Category.Sniff -- for reasons. -) { - return false; -} - -if (foo == 401 - || bar - == 'someverylongexpectedoutput' -) { - return false; -} - -if (IPP.errorCode() == 401 - || bar - // A comment. - == 'someverylongexpectedoutput' -) { - return false; -} - -if (foo == 401 - || IPP.errorCode() - // phpcs:ignore Standard.Category.Sniff -- for reasons. - == 'someverylongexpectedoutput' -) { - return false; -} diff --git a/src/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.js.fixed b/src/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.js.fixed deleted file mode 100644 index cfde75d740..0000000000 --- a/src/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.js.fixed +++ /dev/null @@ -1,247 +0,0 @@ -if (blah(param)) { - -} - -if ((condition1 - || condition2) - && condition3 - && condition4 - && condition5 -) { -} - -if ((condition1 || condition2) && condition3 && condition4 && condition5) { -} - -if ((condition1 || condition2) - && condition3 -) { -} - -if ((condition1 || condition2) - && condition3 -) { -} - -if ((condition1 - || condition2) -) { -} - -if ((condition1 - || condition2) - && condition3 - && condition4 -) { -} - -if ((condition1 - || condition2) - && condition3 - && condition4 - && condition5 -) { -} - -if (($condition1 - || $condition2) -) { -} - -if ((condition1 - || condition2) -) { -} - -if ((condition1 - || condition2) - && condition3 -) { -} - - -if (condition1 - || condition2 - || condition3 -) { -} - -if (condition1 - || condition2 - || condition3 -) { -} else if (condition1 - || condition2 - || condition3 -) { -} - -if (condition1 - || condition2 - || condition3 -) { -} else if (condition1 - || condition2 - && condition3 -) { -} - -if (condition1 - || condition2 - || condition3 -) { -} - -if (condition1 - || condition2 || condition3 -) { -} - -if (condition1) - console.info('bar'); - -if (condition1 - || condition2 - || condition3 -) - console.info('bar'); - - -if (condition1 - || condition2 || condition3 -) - console.info('bar'); - -if (!a(post) - && (!a(context.header) - ^ a(context.header, 'Content-Type')) -) { -// ... -} - -if (foo) { - console.info('bar'); -} - -// Should be no errors even though lines are -// not exactly aligned together. Multi-line function -// call takes precedence. -if (array_key_exists(key, value) - && foo.bar.baz( - key, value2 - ) -) { -} - -if (true) { - foo = true; -}; - -if (foo == 401 // comment - || bar == 3200 /* long comment - here - */ -) { - return false; -} - -if (foo == 401 // comment - || bar == 3200 // long comment here -) { - return false; -} - -if (IPP.errorCode() == 401 - // Comment explaining the next condition here. - || IPP.errorCode() == 3200 -) { - return false; -} - -function bar() { - if (a - && b - ) { - return false; - } -} - -if (a - && foo( - 'a', - 'b' - ) -) { - return false; -} - - - - - - - - - - - - - -if (foo == 401 // phpcs:ignore Standard.Category.Sniff -- for reasons. - || bar == 3200 /* - phpcs:ignore Standard.Category.Sniff -- for reasons. - */ -) { - return false; -} - -if (foo == 401 // phpcs:disable Standard.Category.Sniff -- for reasons. - || bar == 3200 // phpcs:enable -) { - return false; -} - -if (IPP.errorCode() == 401 - // phpcs:ignore Standard.Category.Sniff -- for reasons. - || IPP.errorCode() == 3200 -) { - return false; -} - - if (foo == 401 - /* - * phpcs:disable Standard.Category.Sniff -- for reasons. - */ - || bar == 3200 - ) { - return false; - } - -if (IPP.errorCode() == 401 - || IPP.errorCode() == 3200 - // phpcs:ignore Standard.Category.Sniff -- for reasons. -) { - return false; -} - -if (foo == 401 - || bar == 'someverylongexpectedoutput' -) { - return false; -} - -if (IPP.errorCode() == 401 - || bar - // A comment. - == 'someverylongexpectedoutput' -) { - return false; -} - -if (foo == 401 - || IPP.errorCode() - // phpcs:ignore Standard.Category.Sniff -- for reasons. - == 'someverylongexpectedoutput' -) { - return false; -} diff --git a/src/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php b/src/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php index 263906d189..d4f7069f52 100644 --- a/src/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php +++ b/src/Standards/PEAR/Tests/ControlStructures/MultiLineConditionUnitTest.php @@ -26,13 +26,11 @@ final class MultiLineConditionUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * - * @param string $testFile The name of the file being tested. - * * @return array */ - public function getErrorList($testFile='') + public function getErrorList() { - $errors = [ + return [ 21 => 1, 22 => 1, 35 => 1, @@ -59,6 +57,7 @@ public function getErrorList($testFile='') 153 => 2, 168 => 1, 177 => 1, + 183 => 1, 194 => 2, 202 => 2, 215 => 1, @@ -69,12 +68,6 @@ public function getErrorList($testFile='') 248 => 2, ]; - if ($testFile === 'MultiLineConditionUnitTest.inc') { - $errors[183] = 1; - } - - return $errors; - }//end getErrorList() diff --git a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.js b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.js deleted file mode 100644 index 5e77e57a2f..0000000000 --- a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.js +++ /dev/null @@ -1,80 +0,0 @@ -test( -); -test(); -test(arg, arg2); -test (); -test( ); -test() ; -test( arg); -test( arg ); -test ( arg ); - -if (foo(arg) === true) { - -} - -var something = get(arg1, arg2); -var something = get(arg1, arg2) ; -var something = get(arg1, arg2) ; - -make_foo(string/*the string*/, true/*test*/); -make_foo(string/*the string*/, true/*test*/ ); -make_foo(string /*the string*/, true /*test*/); -make_foo(/*the string*/string, /*test*/true); -make_foo( /*the string*/string, /*test*/true); - -// phpcs:set PEAR.Functions.FunctionCallSignature requiredSpacesAfterOpen 1 -// phpcs:set PEAR.Functions.FunctionCallSignature requiredSpacesBeforeClose 1 -test(arg, arg2); -test( arg, arg2 ); -test( arg, arg2 ); -// phpcs:set PEAR.Functions.FunctionCallSignature requiredSpacesAfterOpen 0 -// phpcs:set PEAR.Functions.FunctionCallSignature requiredSpacesBeforeClose 0 - -this.init = function(data) { - a.b('').a(function(itemid, target) { - b( - itemid, - target, - { - reviewData: _reviewData, - pageid: itemid - }, - '', - function() { - var _showAspectItems = function(itemid) { - a.a(a.c(''), ''); - a.b(a.c('-' + itemid), ''); - }; - a.foo(function(itemid, target) { - _foo(itemid); - }); - } - ); - }); -}; - -a.prototype = { - - a: function() - { - this.addItem( - { - /** - * @return void - */ - a: function() - { - - }, - /** - * @return void - */ - a: function() - { - - }, - } - ); - } -}; diff --git a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.js.fixed b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.js.fixed deleted file mode 100644 index 7855ac6773..0000000000 --- a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.js.fixed +++ /dev/null @@ -1,84 +0,0 @@ -test( -); -test(); -test(arg, arg2); -test(); -test(); -test(); -test(arg); -test(arg); -test(arg); - -if (foo(arg) === true) { - -} - -var something = get(arg1, arg2); -var something = get(arg1, arg2); -var something = get(arg1, arg2); - -make_foo(string/*the string*/, true/*test*/); -make_foo(string/*the string*/, true/*test*/); -make_foo(string /*the string*/, true /*test*/); -make_foo(/*the string*/string, /*test*/true); -make_foo(/*the string*/string, /*test*/true); - -// phpcs:set PEAR.Functions.FunctionCallSignature requiredSpacesAfterOpen 1 -// phpcs:set PEAR.Functions.FunctionCallSignature requiredSpacesBeforeClose 1 -test( arg, arg2 ); -test( arg, arg2 ); -test( arg, arg2 ); -// phpcs:set PEAR.Functions.FunctionCallSignature requiredSpacesAfterOpen 0 -// phpcs:set PEAR.Functions.FunctionCallSignature requiredSpacesBeforeClose 0 - -this.init = function(data) { - a.b('').a( - function(itemid, target) { - b( - itemid, - target, - { - reviewData: _reviewData, - pageid: itemid - }, - '', - function() { - var _showAspectItems = function(itemid) { - a.a(a.c(''), ''); - a.b(a.c('-' + itemid), ''); - }; - a.foo( - function(itemid, target) { - _foo(itemid); - } - ); - } - ); - } - ); -}; - -a.prototype = { - - a: function() - { - this.addItem( - { - /** - * @return void - */ - a: function() - { - - }, - /** - * @return void - */ - a: function() - { - - }, - } - ); - } -}; diff --git a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php index 5884bd8f7a..88e978d178 100644 --- a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php +++ b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php @@ -26,35 +26,10 @@ final class FunctionCallSignatureUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * - * @param string $testFile The name of the file being tested. - * * @return array */ - public function getErrorList($testFile='') + public function getErrorList() { - if ($testFile === 'FunctionCallSignatureUnitTest.js') { - return [ - 5 => 1, - 6 => 2, - 7 => 1, - 8 => 1, - 9 => 2, - 10 => 3, - 17 => 1, - 18 => 1, - 21 => 1, - 24 => 1, - 28 => 2, - 30 => 2, - 35 => 1, - 49 => 1, - 51 => 1, - 54 => 1, - 70 => 1, - 71 => 1, - ]; - }//end if - return [ 5 => 1, 6 => 2, diff --git a/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.js b/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.js deleted file mode 100644 index 8c58690a3f..0000000000 --- a/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.js +++ /dev/null @@ -1,59 +0,0 @@ - -function someFunctionWithAVeryLongName(firstParameter='something', - secondParameter='booooo', third=null, fourthParameter=false, - fifthParameter=123.12, sixthParam=true -){ -} - -function someFunctionWithAVeryLongName2(firstParameter='something', -secondParameter='booooo', third=null, fourthParameter=false, -fifthParameter=123.12, sixthParam=true -) { -} - -function blah() { -} - -function blah() -{ -} - -var object = -{ - - someFunctionWithAVeryLongName: function (firstParameter='something', - secondParameter='booooo', third=null, fourthParameter=false, - fifthParameter=123.12, sixthParam=true - ) /** w00t */ { - } - - someFunctionWithAVeryLongName2: function ( - firstParameter='something', secondParameter='booooo', third=null - ) { - } - -} - -function getInstalledStandards( - includeGeneric=false, - standardsDir='' -) -{ -} - -var a = Function('return 1+1'); - -class test -{ - myFunction() { - return false; - } - - myFunction2() - { - return false; - } -} - -( function ( $ ) { - foo(function ( value ) {} )( jQuery ); diff --git a/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.js.fixed b/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.js.fixed deleted file mode 100644 index ca0b091100..0000000000 --- a/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.js.fixed +++ /dev/null @@ -1,60 +0,0 @@ - -function someFunctionWithAVeryLongName(firstParameter='something', - secondParameter='booooo', third=null, fourthParameter=false, - fifthParameter=123.12, sixthParam=true -) { -} - -function someFunctionWithAVeryLongName2(firstParameter='something', - secondParameter='booooo', third=null, fourthParameter=false, - fifthParameter=123.12, sixthParam=true -) { -} - -function blah() -{ -} - -function blah() -{ -} - -var object = -{ - - someFunctionWithAVeryLongName: function (firstParameter='something', - secondParameter='booooo', third=null, fourthParameter=false, - fifthParameter=123.12, sixthParam=true - ) /** w00t */ { - } - - someFunctionWithAVeryLongName2: function ( - firstParameter='something', secondParameter='booooo', third=null - ) { - } - -} - -function getInstalledStandards( - includeGeneric=false, - standardsDir='' -) { -} - -var a = Function('return 1+1'); - -class test -{ - myFunction() - { - return false; - } - - myFunction2() - { - return false; - } -} - -( function ( $ ) { - foo(function ( value ) {} )( jQuery ); diff --git a/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php b/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php index 1971a5dbe0..e18075b65e 100644 --- a/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php +++ b/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php @@ -110,20 +110,6 @@ public function getErrorList($testFile='') 490 => 2, ]; - case 'FunctionDeclarationUnitTest.js': - return [ - 3 => 1, - 4 => 1, - 5 => 1, - 9 => 1, - 10 => 1, - 11 => 1, - 14 => 1, - 17 => 1, - 41 => 1, - 48 => 1, - ]; - case 'FunctionDeclarationUnitTest.4.inc': return [ 7 => 1, diff --git a/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php b/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php deleted file mode 100644 index 608b23a2b8..0000000000 --- a/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php +++ /dev/null @@ -1,173 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * - * @deprecated 3.9.0 - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; - -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\DeprecatedSniff; -use PHP_CodeSniffer\Sniffs\Sniff; -use PHP_CodeSniffer\Util\Tokens; - -class ClassDefinitionClosingBraceSpaceSniff implements Sniff, DeprecatedSniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = ['CSS']; - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array - */ - public function register() - { - return [T_CLOSE_CURLY_BRACKET]; - - }//end register() - - - /** - * Processes the tokens that this sniff is interested in. - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found. - * @param int $stackPtr The position in the stack where - * the token was found. - * - * @return void - */ - public function process(File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - $next = $stackPtr; - while (true) { - $next = $phpcsFile->findNext(T_WHITESPACE, ($next + 1), null, true); - if ($next === false) { - return; - } - - if (isset(Tokens::$emptyTokens[$tokens[$next]['code']]) === true - && $tokens[$next]['line'] === $tokens[$stackPtr]['line'] - ) { - // Trailing comment. - continue; - } - - break; - } - - if ($tokens[$next]['code'] !== T_CLOSE_TAG) { - $found = (($tokens[$next]['line'] - $tokens[$stackPtr]['line']) - 1); - if ($found !== 1) { - $error = 'Expected one blank line after closing brace of class definition; %s found'; - $data = [max(0, $found)]; - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpacingAfterClose', $data); - - if ($fix === true) { - $firstOnLine = $next; - while ($tokens[$firstOnLine]['column'] !== 1) { - --$firstOnLine; - } - - if ($found < 0) { - // Next statement on same line as the closing brace. - $phpcsFile->fixer->addContentBefore($next, $phpcsFile->eolChar.$phpcsFile->eolChar); - } else if ($found === 0) { - // Next statement on next line, no blank line. - $phpcsFile->fixer->addContentBefore($firstOnLine, $phpcsFile->eolChar); - } else { - // Too many blank lines. - $phpcsFile->fixer->beginChangeset(); - for ($i = ($firstOnLine - 1); $i > $stackPtr; $i--) { - if ($tokens[$i]['code'] !== T_WHITESPACE) { - break; - } - - $phpcsFile->fixer->replaceToken($i, ''); - } - - $phpcsFile->fixer->addContentBefore($firstOnLine, $phpcsFile->eolChar.$phpcsFile->eolChar); - $phpcsFile->fixer->endChangeset(); - } - }//end if - }//end if - }//end if - - // Ignore nested style definitions from here on. The spacing before the closing brace - // (a single blank line) will be enforced by the above check, which ensures there is a - // blank line after the last nested class. - $found = $phpcsFile->findPrevious( - T_CLOSE_CURLY_BRACKET, - ($stackPtr - 1), - $tokens[$stackPtr]['bracket_opener'] - ); - - if ($found !== false) { - return; - } - - $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); - if ($prev === false) { - return; - } - - if ($tokens[$prev]['line'] === $tokens[$stackPtr]['line']) { - $error = 'Closing brace of class definition must be on new line'; - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'ContentBeforeClose'); - if ($fix === true) { - $phpcsFile->fixer->addNewlineBefore($stackPtr); - } - } - - }//end process() - - - /** - * Provide the version number in which the sniff was deprecated. - * - * @return string - */ - public function getDeprecationVersion() - { - return 'v3.9.0'; - - }//end getDeprecationVersion() - - - /** - * Provide the version number in which the sniff will be removed. - * - * @return string - */ - public function getRemovalVersion() - { - return 'v4.0.0'; - - }//end getRemovalVersion() - - - /** - * Provide a custom message to display with the deprecation. - * - * @return string - */ - public function getDeprecationMessage() - { - return 'Support for scanning CSS files will be removed completely in v4.0.0.'; - - }//end getDeprecationMessage() - - -}//end class diff --git a/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php b/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php deleted file mode 100644 index c8bef79a51..0000000000 --- a/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php +++ /dev/null @@ -1,150 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * - * @deprecated 3.9.0 - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; - -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\DeprecatedSniff; -use PHP_CodeSniffer\Sniffs\Sniff; -use PHP_CodeSniffer\Util\Tokens; - -class ClassDefinitionNameSpacingSniff implements Sniff, DeprecatedSniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = ['CSS']; - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array - */ - public function register() - { - return [T_OPEN_CURLY_BRACKET]; - - }//end register() - - - /** - * Processes the tokens that this sniff is interested in. - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found. - * @param int $stackPtr The position in the stack where - * the token was found. - * - * @return void - */ - public function process(File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - if (isset($tokens[$stackPtr]['bracket_closer']) === false) { - // Syntax error or live coding, bow out. - return; - } - - // Do not check nested style definitions as, for example, in @media style rules. - $nested = $phpcsFile->findNext(T_OPEN_CURLY_BRACKET, ($stackPtr + 1), $tokens[$stackPtr]['bracket_closer']); - if ($nested !== false) { - return; - } - - // Find the first blank line before this opening brace, unless we get - // to another style definition, comment or the start of the file. - $endTokens = [ - T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET, - T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET, - T_OPEN_TAG => T_OPEN_TAG, - ]; - $endTokens += Tokens::$commentTokens; - - $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); - - $foundContent = false; - $currentLine = $tokens[$prev]['line']; - for ($i = ($stackPtr - 1); $i >= 0; $i--) { - if (isset($endTokens[$tokens[$i]['code']]) === true) { - break; - } - - if ($tokens[$i]['line'] === $currentLine) { - if ($tokens[$i]['code'] !== T_WHITESPACE) { - $foundContent = true; - } - - continue; - } - - // We changed lines. - if ($foundContent === false) { - // Before we throw an error, make sure we are not looking - // at a gap before the style definition. - $prev = $phpcsFile->findPrevious(T_WHITESPACE, $i, null, true); - if ($prev !== false - && isset($endTokens[$tokens[$prev]['code']]) === false - ) { - $error = 'Blank lines are not allowed between class names'; - $phpcsFile->addError($error, ($i + 1), 'BlankLinesFound'); - } - - break; - } - - $foundContent = false; - $currentLine = $tokens[$i]['line']; - }//end for - - }//end process() - - - /** - * Provide the version number in which the sniff was deprecated. - * - * @return string - */ - public function getDeprecationVersion() - { - return 'v3.9.0'; - - }//end getDeprecationVersion() - - - /** - * Provide the version number in which the sniff will be removed. - * - * @return string - */ - public function getRemovalVersion() - { - return 'v4.0.0'; - - }//end getRemovalVersion() - - - /** - * Provide a custom message to display with the deprecation. - * - * @return string - */ - public function getDeprecationMessage() - { - return 'Support for scanning CSS files will be removed completely in v4.0.0.'; - - }//end getDeprecationMessage() - - -}//end class diff --git a/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php b/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php deleted file mode 100644 index 92e3750a2a..0000000000 --- a/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php +++ /dev/null @@ -1,215 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * - * @deprecated 3.9.0 - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; - -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\DeprecatedSniff; -use PHP_CodeSniffer\Sniffs\Sniff; -use PHP_CodeSniffer\Util\Tokens; - -class ClassDefinitionOpeningBraceSpaceSniff implements Sniff, DeprecatedSniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = ['CSS']; - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array - */ - public function register() - { - return [T_OPEN_CURLY_BRACKET]; - - }//end register() - - - /** - * Processes the tokens that this sniff is interested in. - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found. - * @param int $stackPtr The position in the stack where - * the token was found. - * - * @return void - */ - public function process(File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - $prevNonWhitespace = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); - - if ($prevNonWhitespace !== false) { - $length = 0; - if ($tokens[$stackPtr]['line'] !== $tokens[$prevNonWhitespace]['line']) { - $length = 'newline'; - } else if ($tokens[($stackPtr - 1)]['code'] === T_WHITESPACE) { - if (strpos($tokens[($stackPtr - 1)]['content'], "\t") !== false) { - $length = 'tab'; - } else { - $length = $tokens[($stackPtr - 1)]['length']; - } - } - - if ($length === 0) { - $error = 'Expected 1 space before opening brace of class definition; 0 found'; - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NoneBefore'); - if ($fix === true) { - $phpcsFile->fixer->addContentBefore($stackPtr, ' '); - } - } else if ($length !== 1) { - $error = 'Expected 1 space before opening brace of class definition; %s found'; - $data = [$length]; - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Before', $data); - if ($fix === true) { - $phpcsFile->fixer->beginChangeset(); - - for ($i = ($stackPtr - 1); $i > $prevNonWhitespace; $i--) { - $phpcsFile->fixer->replaceToken($i, ''); - } - - $phpcsFile->fixer->addContentBefore($stackPtr, ' '); - $phpcsFile->fixer->endChangeset(); - } - }//end if - }//end if - - $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true); - if ($nextNonEmpty === false) { - return; - } - - if ($tokens[$nextNonEmpty]['line'] === $tokens[$stackPtr]['line']) { - $error = 'Opening brace should be the last content on the line'; - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'ContentBefore'); - if ($fix === true) { - $phpcsFile->fixer->beginChangeset(); - $phpcsFile->fixer->addNewline($stackPtr); - - // Remove potentially left over trailing whitespace. - if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) { - $phpcsFile->fixer->replaceToken(($stackPtr + 1), ''); - } - - $phpcsFile->fixer->endChangeset(); - } - } else { - if (isset($tokens[$stackPtr]['bracket_closer']) === false) { - // Syntax error or live coding, bow out. - return; - } - - // Check for nested class definitions. - $found = $phpcsFile->findNext( - T_OPEN_CURLY_BRACKET, - ($stackPtr + 1), - $tokens[$stackPtr]['bracket_closer'] - ); - - if ($found === false) { - // Not nested. - return; - } - - $lastOnLine = $stackPtr; - for ($lastOnLine; $lastOnLine < $tokens[$stackPtr]['bracket_closer']; $lastOnLine++) { - if ($tokens[$lastOnLine]['line'] !== $tokens[($lastOnLine + 1)]['line']) { - break; - } - } - - $nextNonWhiteSpace = $phpcsFile->findNext(T_WHITESPACE, ($lastOnLine + 1), null, true); - if ($nextNonWhiteSpace === false) { - return; - } - - $foundLines = ($tokens[$nextNonWhiteSpace]['line'] - $tokens[$stackPtr]['line'] - 1); - if ($foundLines !== 1) { - $error = 'Expected 1 blank line after opening brace of nesting class definition; %s found'; - $data = [max(0, $foundLines)]; - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'AfterNesting', $data); - - if ($fix === true) { - $firstOnNextLine = $nextNonWhiteSpace; - while ($tokens[$firstOnNextLine]['column'] !== 1) { - --$firstOnNextLine; - } - - if ($found < 0) { - // First statement on same line as the opening brace. - $phpcsFile->fixer->addContentBefore($nextNonWhiteSpace, $phpcsFile->eolChar.$phpcsFile->eolChar); - } else if ($found === 0) { - // Next statement on next line, no blank line. - $phpcsFile->fixer->addNewlineBefore($firstOnNextLine); - } else { - // Too many blank lines. - $phpcsFile->fixer->beginChangeset(); - for ($i = ($firstOnNextLine - 1); $i > $stackPtr; $i--) { - if ($tokens[$i]['code'] !== T_WHITESPACE) { - break; - } - - $phpcsFile->fixer->replaceToken($i, ''); - } - - $phpcsFile->fixer->addContentBefore($firstOnNextLine, $phpcsFile->eolChar.$phpcsFile->eolChar); - $phpcsFile->fixer->endChangeset(); - } - }//end if - }//end if - }//end if - - }//end process() - - - /** - * Provide the version number in which the sniff was deprecated. - * - * @return string - */ - public function getDeprecationVersion() - { - return 'v3.9.0'; - - }//end getDeprecationVersion() - - - /** - * Provide the version number in which the sniff will be removed. - * - * @return string - */ - public function getRemovalVersion() - { - return 'v4.0.0'; - - }//end getRemovalVersion() - - - /** - * Provide a custom message to display with the deprecation. - * - * @return string - */ - public function getDeprecationMessage() - { - return 'Support for scanning CSS files will be removed completely in v4.0.0.'; - - }//end getDeprecationMessage() - - -}//end class diff --git a/src/Standards/Squiz/Sniffs/CSS/ColonSpacingSniff.php b/src/Standards/Squiz/Sniffs/CSS/ColonSpacingSniff.php deleted file mode 100644 index 21e49b1a2e..0000000000 --- a/src/Standards/Squiz/Sniffs/CSS/ColonSpacingSniff.php +++ /dev/null @@ -1,146 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * - * @deprecated 3.9.0 - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; - -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\DeprecatedSniff; -use PHP_CodeSniffer\Sniffs\Sniff; -use PHP_CodeSniffer\Util\Tokens; - -class ColonSpacingSniff implements Sniff, DeprecatedSniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = ['CSS']; - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array - */ - public function register() - { - return [T_COLON]; - - }//end register() - - - /** - * Processes the tokens that this sniff is interested in. - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found. - * @param int $stackPtr The position in the stack where - * the token was found. - * - * @return void - */ - public function process(File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); - if ($tokens[$prev]['code'] !== T_STYLE) { - // The colon is not part of a style definition. - return; - } - - if ($tokens[$prev]['content'] === 'progid') { - // Special case for IE filters. - return; - } - - if ($tokens[($stackPtr - 1)]['code'] === T_WHITESPACE) { - $error = 'There must be no space before a colon in a style definition'; - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Before'); - if ($fix === true) { - $phpcsFile->fixer->replaceToken(($stackPtr - 1), ''); - } - } - - $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); - if ($tokens[$next]['code'] === T_SEMICOLON || $tokens[$next]['code'] === T_STYLE) { - // Empty style definition, ignore it. - return; - } - - if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) { - $error = 'Expected 1 space after colon in style definition; 0 found'; - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NoneAfter'); - if ($fix === true) { - $phpcsFile->fixer->addContent($stackPtr, ' '); - } - } else { - $content = $tokens[($stackPtr + 1)]['content']; - if (strpos($content, $phpcsFile->eolChar) === false) { - $length = strlen($content); - if ($length !== 1) { - $error = 'Expected 1 space after colon in style definition; %s found'; - $data = [$length]; - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'After', $data); - if ($fix === true) { - $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' '); - } - } - } else { - $error = 'Expected 1 space after colon in style definition; newline found'; - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'AfterNewline'); - if ($fix === true) { - $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' '); - } - } - }//end if - - }//end process() - - - /** - * Provide the version number in which the sniff was deprecated. - * - * @return string - */ - public function getDeprecationVersion() - { - return 'v3.9.0'; - - }//end getDeprecationVersion() - - - /** - * Provide the version number in which the sniff will be removed. - * - * @return string - */ - public function getRemovalVersion() - { - return 'v4.0.0'; - - }//end getRemovalVersion() - - - /** - * Provide a custom message to display with the deprecation. - * - * @return string - */ - public function getDeprecationMessage() - { - return 'Support for scanning CSS files will be removed completely in v4.0.0.'; - - }//end getDeprecationMessage() - - -}//end class diff --git a/src/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php b/src/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php deleted file mode 100644 index ff89dd8d78..0000000000 --- a/src/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php +++ /dev/null @@ -1,127 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * - * @deprecated 3.9.0 - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; - -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\DeprecatedSniff; -use PHP_CodeSniffer\Sniffs\Sniff; - -class ColourDefinitionSniff implements Sniff, DeprecatedSniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = ['CSS']; - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array - */ - public function register() - { - return [T_COLOUR]; - - }//end register() - - - /** - * Processes the tokens that this sniff is interested in. - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found. - * @param int $stackPtr The position in the stack where - * the token was found. - * - * @return void - */ - public function process(File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - $colour = $tokens[$stackPtr]['content']; - - $expected = strtoupper($colour); - if ($colour !== $expected) { - $error = 'CSS colours must be defined in uppercase; expected %s but found %s'; - $data = [ - $expected, - $colour, - ]; - - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NotUpper', $data); - if ($fix === true) { - $phpcsFile->fixer->replaceToken($stackPtr, $expected); - } - } - - // Now check if shorthand can be used. - if (strlen($colour) !== 7) { - return; - } - - if ($colour[1] === $colour[2] && $colour[3] === $colour[4] && $colour[5] === $colour[6]) { - $expected = '#'.$colour[1].$colour[3].$colour[5]; - $error = 'CSS colours must use shorthand if available; expected %s but found %s'; - $data = [ - $expected, - $colour, - ]; - - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Shorthand', $data); - if ($fix === true) { - $phpcsFile->fixer->replaceToken($stackPtr, $expected); - } - } - - }//end process() - - - /** - * Provide the version number in which the sniff was deprecated. - * - * @return string - */ - public function getDeprecationVersion() - { - return 'v3.9.0'; - - }//end getDeprecationVersion() - - - /** - * Provide the version number in which the sniff will be removed. - * - * @return string - */ - public function getRemovalVersion() - { - return 'v4.0.0'; - - }//end getRemovalVersion() - - - /** - * Provide a custom message to display with the deprecation. - * - * @return string - */ - public function getDeprecationMessage() - { - return 'Support for scanning CSS files will be removed completely in v4.0.0.'; - - }//end getDeprecationMessage() - - -}//end class diff --git a/src/Standards/Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php b/src/Standards/Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php deleted file mode 100644 index f8db90924e..0000000000 --- a/src/Standards/Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php +++ /dev/null @@ -1,110 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * - * @deprecated 3.9.0 - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; - -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\DeprecatedSniff; -use PHP_CodeSniffer\Sniffs\Sniff; - -class DisallowMultipleStyleDefinitionsSniff implements Sniff, DeprecatedSniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var string[] - */ - public $supportedTokenizers = ['CSS']; - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array - */ - public function register() - { - return [T_STYLE]; - - }//end register() - - - /** - * Processes the tokens that this sniff is interested in. - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found. - * @param int $stackPtr The position in the stack where - * the token was found. - * - * @return void - */ - public function process(File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - $next = $phpcsFile->findNext(T_STYLE, ($stackPtr + 1)); - if ($next === false) { - return; - } - - if ($tokens[$next]['content'] === 'progid') { - // Special case for IE filters. - return; - } - - if ($tokens[$next]['line'] === $tokens[$stackPtr]['line']) { - $error = 'Each style definition must be on a line by itself'; - $fix = $phpcsFile->addFixableError($error, $next, 'Found'); - if ($fix === true) { - $phpcsFile->fixer->addNewlineBefore($next); - } - } - - }//end process() - - - /** - * Provide the version number in which the sniff was deprecated. - * - * @return string - */ - public function getDeprecationVersion() - { - return 'v3.9.0'; - - }//end getDeprecationVersion() - - - /** - * Provide the version number in which the sniff will be removed. - * - * @return string - */ - public function getRemovalVersion() - { - return 'v4.0.0'; - - }//end getRemovalVersion() - - - /** - * Provide a custom message to display with the deprecation. - * - * @return string - */ - public function getDeprecationMessage() - { - return 'Support for scanning CSS files will be removed completely in v4.0.0.'; - - }//end getDeprecationMessage() - - -}//end class diff --git a/src/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php b/src/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php deleted file mode 100644 index f6b2459059..0000000000 --- a/src/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php +++ /dev/null @@ -1,155 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * - * @deprecated 3.9.0 - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; - -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\DeprecatedSniff; -use PHP_CodeSniffer\Sniffs\Sniff; -use PHP_CodeSniffer\Util\Tokens; - -class DuplicateClassDefinitionSniff implements Sniff, DeprecatedSniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = ['CSS']; - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array - */ - public function register() - { - return [T_OPEN_TAG]; - - }//end register() - - - /** - * Processes the tokens that this sniff is interested in. - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found. - * @param int $stackPtr The position in the stack where - * the token was found. - * - * @return void - */ - public function process(File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - // Find the content of each class definition name. - $classNames = []; - $next = $phpcsFile->findNext(T_OPEN_CURLY_BRACKET, ($stackPtr + 1)); - if ($next === false) { - // No class definitions in the file. - return; - } - - // Save the class names in a "scope", - // to prevent false positives with @media blocks. - $scope = 'main'; - - $find = [ - T_CLOSE_CURLY_BRACKET, - T_OPEN_CURLY_BRACKET, - T_OPEN_TAG, - ]; - - while ($next !== false) { - $prev = $phpcsFile->findPrevious($find, ($next - 1)); - - // Check if an inner block was closed. - $beforePrev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($prev - 1), null, true); - if ($beforePrev !== false - && $tokens[$beforePrev]['code'] === T_CLOSE_CURLY_BRACKET - ) { - $scope = 'main'; - } - - // Create a sorted name for the class so we can compare classes - // even when the individual names are all over the place. - $name = ''; - for ($i = ($prev + 1); $i < $next; $i++) { - $name .= $tokens[$i]['content']; - } - - $name = trim($name); - $name = str_replace("\n", ' ', $name); - $name = preg_replace('|[\s]+|', ' ', $name); - $name = preg_replace('|\s*/\*.*\*/\s*|', '', $name); - $name = str_replace(', ', ',', $name); - - $names = explode(',', $name); - sort($names); - $name = implode(',', $names); - - if ($name[0] === '@') { - // Media block has its own "scope". - $scope = $name; - } else if (isset($classNames[$scope][$name]) === true) { - $first = $classNames[$scope][$name]; - $error = 'Duplicate class definition found; first defined on line %s'; - $data = [$tokens[$first]['line']]; - $phpcsFile->addError($error, $next, 'Found', $data); - } else { - $classNames[$scope][$name] = $next; - } - - $next = $phpcsFile->findNext(T_OPEN_CURLY_BRACKET, ($next + 1)); - }//end while - - }//end process() - - - /** - * Provide the version number in which the sniff was deprecated. - * - * @return string - */ - public function getDeprecationVersion() - { - return 'v3.9.0'; - - }//end getDeprecationVersion() - - - /** - * Provide the version number in which the sniff will be removed. - * - * @return string - */ - public function getRemovalVersion() - { - return 'v4.0.0'; - - }//end getRemovalVersion() - - - /** - * Provide a custom message to display with the deprecation. - * - * @return string - */ - public function getDeprecationMessage() - { - return 'Support for scanning CSS files will be removed completely in v4.0.0.'; - - }//end getDeprecationMessage() - - -}//end class diff --git a/src/Standards/Squiz/Sniffs/CSS/DuplicateStyleDefinitionSniff.php b/src/Standards/Squiz/Sniffs/CSS/DuplicateStyleDefinitionSniff.php deleted file mode 100644 index 4426ad112d..0000000000 --- a/src/Standards/Squiz/Sniffs/CSS/DuplicateStyleDefinitionSniff.php +++ /dev/null @@ -1,127 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * - * @deprecated 3.9.0 - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; - -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\DeprecatedSniff; -use PHP_CodeSniffer\Sniffs\Sniff; - -class DuplicateStyleDefinitionSniff implements Sniff, DeprecatedSniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = ['CSS']; - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array - */ - public function register() - { - return [T_OPEN_CURLY_BRACKET]; - - }//end register() - - - /** - * Processes the tokens that this sniff is interested in. - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found. - * @param int $stackPtr The position in the stack where - * the token was found. - * - * @return void - */ - public function process(File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - if (isset($tokens[$stackPtr]['bracket_closer']) === false) { - // Syntax error or live coding, bow out. - return; - } - - // Find the content of each style definition name. - $styleNames = []; - - $next = $stackPtr; - $end = $tokens[$stackPtr]['bracket_closer']; - - do { - $next = $phpcsFile->findNext([T_STYLE, T_OPEN_CURLY_BRACKET], ($next + 1), $end); - if ($next === false) { - // Class definition is empty. - break; - } - - if ($tokens[$next]['code'] === T_OPEN_CURLY_BRACKET) { - $next = $tokens[$next]['bracket_closer']; - continue; - } - - $name = $tokens[$next]['content']; - if (isset($styleNames[$name]) === true) { - $first = $styleNames[$name]; - $error = 'Duplicate style definition found; first defined on line %s'; - $data = [$tokens[$first]['line']]; - $phpcsFile->addError($error, $next, 'Found', $data); - } else { - $styleNames[$name] = $next; - } - } while ($next !== false); - - }//end process() - - - /** - * Provide the version number in which the sniff was deprecated. - * - * @return string - */ - public function getDeprecationVersion() - { - return 'v3.9.0'; - - }//end getDeprecationVersion() - - - /** - * Provide the version number in which the sniff will be removed. - * - * @return string - */ - public function getRemovalVersion() - { - return 'v4.0.0'; - - }//end getRemovalVersion() - - - /** - * Provide a custom message to display with the deprecation. - * - * @return string - */ - public function getDeprecationMessage() - { - return 'Support for scanning CSS files will be removed completely in v4.0.0.'; - - }//end getDeprecationMessage() - - -}//end class diff --git a/src/Standards/Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php b/src/Standards/Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php deleted file mode 100644 index eb8b92edef..0000000000 --- a/src/Standards/Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php +++ /dev/null @@ -1,100 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * - * @deprecated 3.9.0 - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; - -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\DeprecatedSniff; -use PHP_CodeSniffer\Sniffs\Sniff; -use PHP_CodeSniffer\Util\Tokens; - -class EmptyClassDefinitionSniff implements Sniff, DeprecatedSniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = ['CSS']; - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array - */ - public function register() - { - return [T_OPEN_CURLY_BRACKET]; - - }//end register() - - - /** - * Processes the tokens that this sniff is interested in. - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found. - * @param int $stackPtr The position in the stack where - * the token was found. - * - * @return void - */ - public function process(File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true); - - if ($next === false || $tokens[$next]['code'] === T_CLOSE_CURLY_BRACKET) { - $error = 'Class definition is empty'; - $phpcsFile->addError($error, $stackPtr, 'Found'); - } - - }//end process() - - - /** - * Provide the version number in which the sniff was deprecated. - * - * @return string - */ - public function getDeprecationVersion() - { - return 'v3.9.0'; - - }//end getDeprecationVersion() - - - /** - * Provide the version number in which the sniff will be removed. - * - * @return string - */ - public function getRemovalVersion() - { - return 'v4.0.0'; - - }//end getRemovalVersion() - - - /** - * Provide a custom message to display with the deprecation. - * - * @return string - */ - public function getDeprecationMessage() - { - return 'Support for scanning CSS files will be removed completely in v4.0.0.'; - - }//end getDeprecationMessage() - - -}//end class diff --git a/src/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php b/src/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php deleted file mode 100644 index 5a549372a8..0000000000 --- a/src/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * - * @deprecated 3.9.0 - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; - -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\DeprecatedSniff; -use PHP_CodeSniffer\Sniffs\Sniff; -use PHP_CodeSniffer\Util\Tokens; - -class EmptyStyleDefinitionSniff implements Sniff, DeprecatedSniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = ['CSS']; - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array - */ - public function register() - { - return [T_STYLE]; - - }//end register() - - - /** - * Processes the tokens that this sniff is interested in. - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found. - * @param int $stackPtr The position in the stack where - * the token was found. - * - * @return void - */ - public function process(File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - $ignore = Tokens::$emptyTokens; - $ignore[] = T_COLON; - - $next = $phpcsFile->findNext($ignore, ($stackPtr + 1), null, true); - if ($next === false || $tokens[$next]['code'] === T_SEMICOLON || $tokens[$next]['line'] !== $tokens[$stackPtr]['line']) { - $error = 'Style definition is empty'; - $phpcsFile->addError($error, $stackPtr, 'Found'); - } - - }//end process() - - - /** - * Provide the version number in which the sniff was deprecated. - * - * @return string - */ - public function getDeprecationVersion() - { - return 'v3.9.0'; - - }//end getDeprecationVersion() - - - /** - * Provide the version number in which the sniff will be removed. - * - * @return string - */ - public function getRemovalVersion() - { - return 'v4.0.0'; - - }//end getRemovalVersion() - - - /** - * Provide a custom message to display with the deprecation. - * - * @return string - */ - public function getDeprecationMessage() - { - return 'Support for scanning CSS files will be removed completely in v4.0.0.'; - - }//end getDeprecationMessage() - - -}//end class diff --git a/src/Standards/Squiz/Sniffs/CSS/ForbiddenStylesSniff.php b/src/Standards/Squiz/Sniffs/CSS/ForbiddenStylesSniff.php deleted file mode 100644 index a28f02f83c..0000000000 --- a/src/Standards/Squiz/Sniffs/CSS/ForbiddenStylesSniff.php +++ /dev/null @@ -1,216 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * - * @deprecated 3.9.0 - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; - -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\DeprecatedSniff; -use PHP_CodeSniffer\Sniffs\Sniff; - -class ForbiddenStylesSniff implements Sniff, DeprecatedSniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = ['CSS']; - - /** - * A list of forbidden styles with their alternatives. - * - * The value is NULL if no alternative exists. i.e., the - * style should just not be used. - * - * @var array - */ - protected $forbiddenStyles = [ - '-moz-border-radius' => 'border-radius', - '-webkit-border-radius' => 'border-radius', - '-moz-border-radius-topleft' => 'border-top-left-radius', - '-moz-border-radius-topright' => 'border-top-right-radius', - '-moz-border-radius-bottomright' => 'border-bottom-right-radius', - '-moz-border-radius-bottomleft' => 'border-bottom-left-radius', - '-moz-box-shadow' => 'box-shadow', - '-webkit-box-shadow' => 'box-shadow', - ]; - - /** - * A cache of forbidden style names, for faster lookups. - * - * @var string[] - */ - protected $forbiddenStyleNames = []; - - /** - * If true, forbidden styles will be considered regular expressions. - * - * @var boolean - */ - protected $patternMatch = false; - - /** - * If true, an error will be thrown; otherwise a warning. - * - * @var boolean - */ - public $error = true; - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - $this->forbiddenStyleNames = array_keys($this->forbiddenStyles); - - if ($this->patternMatch === true) { - foreach ($this->forbiddenStyleNames as $i => $name) { - $this->forbiddenStyleNames[$i] = '/'.$name.'/i'; - } - } - - return [T_STYLE]; - - }//end register() - - - /** - * Processes this test, when one of its tokens is encountered. - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token in - * the stack passed in $tokens. - * - * @return void - */ - public function process(File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - $style = strtolower($tokens[$stackPtr]['content']); - $pattern = null; - - if ($this->patternMatch === true) { - $count = 0; - $pattern = preg_replace( - $this->forbiddenStyleNames, - $this->forbiddenStyleNames, - $style, - 1, - $count - ); - - if ($count === 0) { - return; - } - - // Remove the pattern delimiters and modifier. - $pattern = substr($pattern, 1, -2); - } else { - if (in_array($style, $this->forbiddenStyleNames, true) === false) { - return; - } - }//end if - - $this->addError($phpcsFile, $stackPtr, $style, $pattern); - - }//end process() - - - /** - * Generates the error or warning for this sniff. - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the forbidden style - * in the token array. - * @param string $style The name of the forbidden style. - * @param string $pattern The pattern used for the match. - * - * @return void - */ - protected function addError($phpcsFile, $stackPtr, $style, $pattern=null) - { - $data = [$style]; - $error = 'The use of style %s is '; - if ($this->error === true) { - $type = 'Found'; - $error .= 'forbidden'; - } else { - $type = 'Discouraged'; - $error .= 'discouraged'; - } - - if ($pattern === null) { - $pattern = $style; - } - - if ($this->forbiddenStyles[$pattern] !== null) { - $data[] = $this->forbiddenStyles[$pattern]; - if ($this->error === true) { - $fix = $phpcsFile->addFixableError($error.'; use %s instead', $stackPtr, $type.'WithAlternative', $data); - } else { - $fix = $phpcsFile->addFixableWarning($error.'; use %s instead', $stackPtr, $type.'WithAlternative', $data); - } - - if ($fix === true) { - $phpcsFile->fixer->replaceToken($stackPtr, $this->forbiddenStyles[$pattern]); - } - } else { - if ($this->error === true) { - $phpcsFile->addError($error, $stackPtr, $type, $data); - } else { - $phpcsFile->addWarning($error, $stackPtr, $type, $data); - } - } - - }//end addError() - - - /** - * Provide the version number in which the sniff was deprecated. - * - * @return string - */ - public function getDeprecationVersion() - { - return 'v3.9.0'; - - }//end getDeprecationVersion() - - - /** - * Provide the version number in which the sniff will be removed. - * - * @return string - */ - public function getRemovalVersion() - { - return 'v4.0.0'; - - }//end getRemovalVersion() - - - /** - * Provide a custom message to display with the deprecation. - * - * @return string - */ - public function getDeprecationMessage() - { - return 'Support for scanning CSS files will be removed completely in v4.0.0.'; - - }//end getDeprecationMessage() - - -}//end class diff --git a/src/Standards/Squiz/Sniffs/CSS/IndentationSniff.php b/src/Standards/Squiz/Sniffs/CSS/IndentationSniff.php deleted file mode 100644 index 3b0336b8c9..0000000000 --- a/src/Standards/Squiz/Sniffs/CSS/IndentationSniff.php +++ /dev/null @@ -1,189 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * - * @deprecated 3.9.0 - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; - -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\DeprecatedSniff; -use PHP_CodeSniffer\Sniffs\Sniff; -use PHP_CodeSniffer\Util\Tokens; - -class IndentationSniff implements Sniff, DeprecatedSniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = ['CSS']; - - /** - * The number of spaces code should be indented. - * - * @var integer - */ - public $indent = 4; - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array - */ - public function register() - { - return [T_OPEN_TAG]; - - }//end register() - - - /** - * Processes the tokens that this sniff is interested in. - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found. - * @param int $stackPtr The position in the stack where - * the token was found. - * - * @return void - */ - public function process(File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - $numTokens = (count($tokens) - 2); - $indentLevel = 0; - $nestingLevel = 0; - for ($i = 1; $i < $numTokens; $i++) { - if ($tokens[$i]['code'] === T_COMMENT - || isset(Tokens::$phpcsCommentTokens[$tokens[$i]['code']]) === true - ) { - // Don't check the indent of comments. - continue; - } - - if ($tokens[$i]['code'] === T_OPEN_CURLY_BRACKET) { - $indentLevel++; - - if (isset($tokens[$i]['bracket_closer']) === false) { - // Syntax error or live coding. - // Anything after this would receive incorrect fixes, so bow out. - return; - } - - // Check for nested class definitions. - $found = $phpcsFile->findNext( - T_OPEN_CURLY_BRACKET, - ($i + 1), - $tokens[$i]['bracket_closer'] - ); - - if ($found !== false) { - $nestingLevel = $indentLevel; - } - } - - if (($tokens[$i]['code'] === T_CLOSE_CURLY_BRACKET - && $tokens[$i]['line'] !== $tokens[($i - 1)]['line']) - || ($tokens[($i + 1)]['code'] === T_CLOSE_CURLY_BRACKET - && $tokens[$i]['line'] === $tokens[($i + 1)]['line']) - ) { - $indentLevel--; - if ($indentLevel === 0) { - $nestingLevel = 0; - } - } - - if ($tokens[$i]['column'] !== 1 - || $tokens[$i]['code'] === T_OPEN_CURLY_BRACKET - || $tokens[$i]['code'] === T_CLOSE_CURLY_BRACKET - ) { - continue; - } - - // We started a new line, so check indent. - if ($tokens[$i]['code'] === T_WHITESPACE) { - $content = str_replace($phpcsFile->eolChar, '', $tokens[$i]['content']); - $foundIndent = strlen($content); - } else { - $foundIndent = 0; - } - - $expectedIndent = ($indentLevel * $this->indent); - if ($expectedIndent > 0 - && strpos($tokens[$i]['content'], $phpcsFile->eolChar) !== false - ) { - if ($nestingLevel !== $indentLevel) { - $error = 'Blank lines are not allowed in class definitions'; - $fix = $phpcsFile->addFixableError($error, $i, 'BlankLine'); - if ($fix === true) { - $phpcsFile->fixer->replaceToken($i, ''); - } - } - } else if ($foundIndent !== $expectedIndent) { - $error = 'Line indented incorrectly; expected %s spaces, found %s'; - $data = [ - $expectedIndent, - $foundIndent, - ]; - - $fix = $phpcsFile->addFixableError($error, $i, 'Incorrect', $data); - if ($fix === true) { - $indent = str_repeat(' ', $expectedIndent); - if ($foundIndent === 0) { - $phpcsFile->fixer->addContentBefore($i, $indent); - } else { - $phpcsFile->fixer->replaceToken($i, $indent); - } - } - }//end if - }//end for - - }//end process() - - - /** - * Provide the version number in which the sniff was deprecated. - * - * @return string - */ - public function getDeprecationVersion() - { - return 'v3.9.0'; - - }//end getDeprecationVersion() - - - /** - * Provide the version number in which the sniff will be removed. - * - * @return string - */ - public function getRemovalVersion() - { - return 'v4.0.0'; - - }//end getRemovalVersion() - - - /** - * Provide a custom message to display with the deprecation. - * - * @return string - */ - public function getDeprecationMessage() - { - return 'Support for scanning CSS files will be removed completely in v4.0.0.'; - - }//end getDeprecationMessage() - - -}//end class diff --git a/src/Standards/Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php b/src/Standards/Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php deleted file mode 100644 index 8246cf5aa6..0000000000 --- a/src/Standards/Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php +++ /dev/null @@ -1,136 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * - * @deprecated 3.9.0 - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; - -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\DeprecatedSniff; -use PHP_CodeSniffer\Sniffs\Sniff; - -class LowercaseStyleDefinitionSniff implements Sniff, DeprecatedSniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = ['CSS']; - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array - */ - public function register() - { - return [T_OPEN_CURLY_BRACKET]; - - }//end register() - - - /** - * Processes the tokens that this sniff is interested in. - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found. - * @param int $stackPtr The position in the stack where - * the token was found. - * - * @return void - */ - public function process(File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - $start = ($stackPtr + 1); - $end = ($tokens[$stackPtr]['bracket_closer'] - 1); - $inStyle = null; - - for ($i = $start; $i <= $end; $i++) { - // Skip nested definitions as they are checked individually. - if ($tokens[$i]['code'] === T_OPEN_CURLY_BRACKET) { - $i = $tokens[$i]['bracket_closer']; - continue; - } - - if ($tokens[$i]['code'] === T_STYLE) { - $inStyle = $tokens[$i]['content']; - } - - if ($tokens[$i]['code'] === T_SEMICOLON) { - $inStyle = null; - } - - if ($inStyle === 'progid') { - // Special case for IE filters. - continue; - } - - if ($tokens[$i]['code'] === T_STYLE - || ($inStyle !== null - && $tokens[$i]['code'] === T_STRING) - ) { - $expected = strtolower($tokens[$i]['content']); - if ($expected !== $tokens[$i]['content']) { - $error = 'Style definitions must be lowercase; expected %s but found %s'; - $data = [ - $expected, - $tokens[$i]['content'], - ]; - - $fix = $phpcsFile->addFixableError($error, $i, 'FoundUpper', $data); - if ($fix === true) { - $phpcsFile->fixer->replaceToken($i, $expected); - } - } - } - }//end for - - }//end process() - - - /** - * Provide the version number in which the sniff was deprecated. - * - * @return string - */ - public function getDeprecationVersion() - { - return 'v3.9.0'; - - }//end getDeprecationVersion() - - - /** - * Provide the version number in which the sniff will be removed. - * - * @return string - */ - public function getRemovalVersion() - { - return 'v4.0.0'; - - }//end getRemovalVersion() - - - /** - * Provide a custom message to display with the deprecation. - * - * @return string - */ - public function getDeprecationMessage() - { - return 'Support for scanning CSS files will be removed completely in v4.0.0.'; - - }//end getDeprecationMessage() - - -}//end class diff --git a/src/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php b/src/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php deleted file mode 100644 index d86debe052..0000000000 --- a/src/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php +++ /dev/null @@ -1,130 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * - * @deprecated 3.9.0 - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; - -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\DeprecatedSniff; -use PHP_CodeSniffer\Sniffs\Sniff; - -class MissingColonSniff implements Sniff, DeprecatedSniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = ['CSS']; - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array - */ - public function register() - { - return [T_OPEN_CURLY_BRACKET]; - - }//end register() - - - /** - * Processes the tokens that this sniff is interested in. - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found. - * @param int $stackPtr The position in the stack where - * the token was found. - * - * @return void - */ - public function process(File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - if (isset($tokens[$stackPtr]['bracket_closer']) === false) { - // Syntax error or live coding, bow out. - return; - } - - $lastLine = $tokens[$stackPtr]['line']; - $end = $tokens[$stackPtr]['bracket_closer']; - - // Do not check nested style definitions as, for example, in @media style rules. - $nested = $phpcsFile->findNext(T_OPEN_CURLY_BRACKET, ($stackPtr + 1), $end); - if ($nested !== false) { - return; - } - - $foundColon = false; - $foundString = false; - for ($i = ($stackPtr + 1); $i <= $end; $i++) { - if ($tokens[$i]['line'] !== $lastLine) { - // We changed lines. - if ($foundColon === false && $foundString !== false) { - // We didn't find a colon on the previous line. - $error = 'No style definition found on line; check for missing colon'; - $phpcsFile->addError($error, $foundString, 'Found'); - } - - $foundColon = false; - $foundString = false; - $lastLine = $tokens[$i]['line']; - } - - if ($tokens[$i]['code'] === T_STRING) { - $foundString = $i; - } else if ($tokens[$i]['code'] === T_COLON) { - $foundColon = $i; - } - }//end for - - }//end process() - - - /** - * Provide the version number in which the sniff was deprecated. - * - * @return string - */ - public function getDeprecationVersion() - { - return 'v3.9.0'; - - }//end getDeprecationVersion() - - - /** - * Provide the version number in which the sniff will be removed. - * - * @return string - */ - public function getRemovalVersion() - { - return 'v4.0.0'; - - }//end getRemovalVersion() - - - /** - * Provide a custom message to display with the deprecation. - * - * @return string - */ - public function getDeprecationMessage() - { - return 'Support for scanning CSS files will be removed completely in v4.0.0.'; - - }//end getDeprecationMessage() - - -}//end class diff --git a/src/Standards/Squiz/Sniffs/CSS/NamedColoursSniff.php b/src/Standards/Squiz/Sniffs/CSS/NamedColoursSniff.php deleted file mode 100644 index fea0a15517..0000000000 --- a/src/Standards/Squiz/Sniffs/CSS/NamedColoursSniff.php +++ /dev/null @@ -1,132 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * - * @deprecated 3.9.0 - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; - -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\DeprecatedSniff; -use PHP_CodeSniffer\Sniffs\Sniff; - -class NamedColoursSniff implements Sniff, DeprecatedSniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = ['CSS']; - - /** - * A list of named colours. - * - * This is the list of standard colours defined in the CSS specification. - * - * @var array - */ - protected $colourNames = [ - 'aqua' => 'aqua', - 'black' => 'black', - 'blue' => 'blue', - 'fuchsia' => 'fuchsia', - 'gray' => 'gray', - 'green' => 'green', - 'lime' => 'lime', - 'maroon' => 'maroon', - 'navy' => 'navy', - 'olive' => 'olive', - 'orange' => 'orange', - 'purple' => 'purple', - 'red' => 'red', - 'silver' => 'silver', - 'teal' => 'teal', - 'white' => 'white', - 'yellow' => 'yellow', - ]; - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array - */ - public function register() - { - return [T_STRING]; - - }//end register() - - - /** - * Processes the tokens that this sniff is interested in. - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found. - * @param int $stackPtr The position in the stack where - * the token was found. - * - * @return void - */ - public function process(File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - if ($tokens[($stackPtr - 1)]['code'] === T_HASH - || $tokens[($stackPtr - 1)]['code'] === T_STRING_CONCAT - ) { - // Class name. - return; - } - - if (isset($this->colourNames[strtolower($tokens[$stackPtr]['content'])]) === true) { - $error = 'Named colours are forbidden; use hex, rgb, or rgba values instead'; - $phpcsFile->addError($error, $stackPtr, 'Forbidden'); - } - - }//end process() - - - /** - * Provide the version number in which the sniff was deprecated. - * - * @return string - */ - public function getDeprecationVersion() - { - return 'v3.9.0'; - - }//end getDeprecationVersion() - - - /** - * Provide the version number in which the sniff will be removed. - * - * @return string - */ - public function getRemovalVersion() - { - return 'v4.0.0'; - - }//end getRemovalVersion() - - - /** - * Provide a custom message to display with the deprecation. - * - * @return string - */ - public function getDeprecationMessage() - { - return 'Support for scanning CSS files will be removed completely in v4.0.0.'; - - }//end getDeprecationMessage() - - -}//end class diff --git a/src/Standards/Squiz/Sniffs/CSS/OpacitySniff.php b/src/Standards/Squiz/Sniffs/CSS/OpacitySniff.php deleted file mode 100644 index e9dfe7c3e5..0000000000 --- a/src/Standards/Squiz/Sniffs/CSS/OpacitySniff.php +++ /dev/null @@ -1,140 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * - * @deprecated 3.9.0 - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; - -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\DeprecatedSniff; -use PHP_CodeSniffer\Sniffs\Sniff; -use PHP_CodeSniffer\Util\Tokens; - -class OpacitySniff implements Sniff, DeprecatedSniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = ['CSS']; - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array - */ - public function register() - { - return [T_STYLE]; - - }//end register() - - - /** - * Processes the tokens that this sniff is interested in. - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found. - * @param int $stackPtr The position in the stack where - * the token was found. - * - * @return void - */ - public function process(File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - if ($tokens[$stackPtr]['content'] !== 'opacity') { - return; - } - - $ignore = Tokens::$emptyTokens; - $ignore[] = T_COLON; - - $next = $phpcsFile->findNext($ignore, ($stackPtr + 1), null, true); - - if ($next === false - || ($tokens[$next]['code'] !== T_DNUMBER - && $tokens[$next]['code'] !== T_LNUMBER) - ) { - return; - } - - $value = $tokens[$next]['content']; - if ($tokens[$next]['code'] === T_LNUMBER) { - if ($value !== '0' && $value !== '1') { - $error = 'Opacity values must be between 0 and 1'; - $phpcsFile->addError($error, $next, 'Invalid'); - } - } else { - if (strlen($value) > 3) { - $error = 'Opacity values must have a single value after the decimal point'; - $phpcsFile->addError($error, $next, 'DecimalPrecision'); - } else if ($value === '0.0' || $value === '1.0') { - $error = 'Opacity value does not require decimal point; use %s instead'; - $data = [$value[0]]; - $fix = $phpcsFile->addFixableError($error, $next, 'PointNotRequired', $data); - if ($fix === true) { - $phpcsFile->fixer->replaceToken($next, $value[0]); - } - } else if ($value[0] === '.') { - $error = 'Opacity values must not start with a decimal point; use 0%s instead'; - $data = [$value]; - $fix = $phpcsFile->addFixableError($error, $next, 'StartWithPoint', $data); - if ($fix === true) { - $phpcsFile->fixer->replaceToken($next, '0'.$value); - } - } else if ($value[0] !== '0') { - $error = 'Opacity values must be between 0 and 1'; - $phpcsFile->addError($error, $next, 'Invalid'); - }//end if - }//end if - - }//end process() - - - /** - * Provide the version number in which the sniff was deprecated. - * - * @return string - */ - public function getDeprecationVersion() - { - return 'v3.9.0'; - - }//end getDeprecationVersion() - - - /** - * Provide the version number in which the sniff will be removed. - * - * @return string - */ - public function getRemovalVersion() - { - return 'v4.0.0'; - - }//end getRemovalVersion() - - - /** - * Provide a custom message to display with the deprecation. - * - * @return string - */ - public function getDeprecationMessage() - { - return 'Support for scanning CSS files will be removed completely in v4.0.0.'; - - }//end getDeprecationMessage() - - -}//end class diff --git a/src/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php b/src/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php deleted file mode 100644 index 7c205d8186..0000000000 --- a/src/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php +++ /dev/null @@ -1,142 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * - * @deprecated 3.9.0 - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; - -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\DeprecatedSniff; -use PHP_CodeSniffer\Sniffs\Sniff; -use PHP_CodeSniffer\Util\Tokens; - -class SemicolonSpacingSniff implements Sniff, DeprecatedSniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = ['CSS']; - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array - */ - public function register() - { - return [T_STYLE]; - - }//end register() - - - /** - * Processes the tokens that this sniff is interested in. - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found. - * @param int $stackPtr The position in the stack where - * the token was found. - * - * @return void - */ - public function process(File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - $nextStatement = $phpcsFile->findNext([T_STYLE, T_CLOSE_CURLY_BRACKET], ($stackPtr + 1)); - if ($nextStatement === false) { - return; - } - - $ignore = Tokens::$emptyTokens; - if ($tokens[$nextStatement]['code'] === T_STYLE) { - // Allow for star-prefix hack. - $ignore[] = T_MULTIPLY; - } - - $endOfThisStatement = $phpcsFile->findPrevious($ignore, ($nextStatement - 1), null, true); - if ($tokens[$endOfThisStatement]['code'] !== T_SEMICOLON) { - $error = 'Style definitions must end with a semicolon'; - $phpcsFile->addError($error, $endOfThisStatement, 'NotAtEnd'); - return; - } - - if ($tokens[($endOfThisStatement - 1)]['code'] !== T_WHITESPACE) { - return; - } - - // There is a semicolon, so now find the last token in the statement. - $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($endOfThisStatement - 1), null, true); - $found = $tokens[($endOfThisStatement - 1)]['length']; - if ($tokens[$prevNonEmpty]['line'] !== $tokens[$endOfThisStatement]['line']) { - $found = 'newline'; - } - - $error = 'Expected 0 spaces before semicolon in style definition; %s found'; - $data = [$found]; - $fix = $phpcsFile->addFixableError($error, $prevNonEmpty, 'SpaceFound', $data); - if ($fix === true) { - $phpcsFile->fixer->beginChangeset(); - $phpcsFile->fixer->addContent($prevNonEmpty, ';'); - $phpcsFile->fixer->replaceToken($endOfThisStatement, ''); - - for ($i = ($endOfThisStatement - 1); $i > $prevNonEmpty; $i--) { - if ($tokens[$i]['code'] !== T_WHITESPACE) { - break; - } - - $phpcsFile->fixer->replaceToken($i, ''); - } - - $phpcsFile->fixer->endChangeset(); - } - - }//end process() - - - /** - * Provide the version number in which the sniff was deprecated. - * - * @return string - */ - public function getDeprecationVersion() - { - return 'v3.9.0'; - - }//end getDeprecationVersion() - - - /** - * Provide the version number in which the sniff will be removed. - * - * @return string - */ - public function getRemovalVersion() - { - return 'v4.0.0'; - - }//end getRemovalVersion() - - - /** - * Provide a custom message to display with the deprecation. - * - * @return string - */ - public function getDeprecationMessage() - { - return 'Support for scanning CSS files will be removed completely in v4.0.0.'; - - }//end getDeprecationMessage() - - -}//end class diff --git a/src/Standards/Squiz/Sniffs/CSS/ShorthandSizeSniff.php b/src/Standards/Squiz/Sniffs/CSS/ShorthandSizeSniff.php deleted file mode 100644 index 252a06d199..0000000000 --- a/src/Standards/Squiz/Sniffs/CSS/ShorthandSizeSniff.php +++ /dev/null @@ -1,220 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * - * @deprecated 3.9.0 - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; - -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\DeprecatedSniff; -use PHP_CodeSniffer\Sniffs\Sniff; - -class ShorthandSizeSniff implements Sniff, DeprecatedSniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = ['CSS']; - - /** - * A list of styles that we shouldn't check. - * - * These have values that looks like sizes, but are not. - * - * @var array - */ - protected $excludeStyles = [ - 'background-position' => 'background-position', - 'box-shadow' => 'box-shadow', - 'transform-origin' => 'transform-origin', - '-webkit-transform-origin' => '-webkit-transform-origin', - '-ms-transform-origin' => '-ms-transform-origin', - ]; - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array - */ - public function register() - { - return [T_STYLE]; - - }//end register() - - - /** - * Processes the tokens that this sniff is interested in. - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found. - * @param int $stackPtr The position in the stack where - * the token was found. - * - * @return void - */ - public function process(File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - // Some styles look like shorthand but are not actually a set of 4 sizes. - $style = strtolower($tokens[$stackPtr]['content']); - if (isset($this->excludeStyles[$style]) === true) { - return; - } - - $end = $phpcsFile->findNext(T_SEMICOLON, ($stackPtr + 1)); - if ($end === false) { - // Live coding or parse error. - return; - } - - // Get the whole style content. - $origContent = $phpcsFile->getTokensAsString(($stackPtr + 1), ($end - $stackPtr - 1)); - $origContent = trim($origContent, ':'); - $origContent = trim($origContent); - - // Account for a !important annotation. - $content = $origContent; - if (substr($content, -10) === '!important') { - $content = substr($content, 0, -10); - $content = trim($content); - } - - // Check if this style value is a set of numbers with optional prefixes. - $content = preg_replace('/\s+/', ' ', $content); - $values = []; - $num = preg_match_all( - '/(?:[0-9]+)(?:[a-zA-Z]{2}\s+|%\s+|\s+)/', - $content.' ', - $values, - PREG_SET_ORDER - ); - - // Only interested in styles that have multiple sizes defined. - if ($num < 2) { - return; - } - - // Rebuild the content we matched to ensure we got everything. - $matched = ''; - foreach ($values as $value) { - $matched .= $value[0]; - } - - if ($content !== trim($matched)) { - return; - } - - if ($num === 3) { - $expected = trim($content.' '.$values[1][0]); - $error = 'Shorthand syntax not allowed here; use %s instead'; - $data = [$expected]; - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NotAllowed', $data); - - if ($fix === true) { - $phpcsFile->fixer->beginChangeset(); - if (substr($origContent, -10) === '!important') { - $expected .= ' !important'; - } - - $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 2), null, true); - $phpcsFile->fixer->replaceToken($next, $expected); - for ($next++; $next < $end; $next++) { - $phpcsFile->fixer->replaceToken($next, ''); - } - - $phpcsFile->fixer->endChangeset(); - } - - return; - }//end if - - if ($num === 2) { - if ($values[0][0] !== $values[1][0]) { - // Both values are different, so it is already shorthand. - return; - } - } else if ($values[0][0] !== $values[2][0] || $values[1][0] !== $values[3][0]) { - // Can't shorthand this. - return; - } - - if ($values[0][0] === $values[1][0]) { - // All values are the same. - $expected = trim($values[0][0]); - } else { - $expected = trim($values[0][0]).' '.trim($values[1][0]); - } - - $error = 'Size definitions must use shorthand if available; expected "%s" but found "%s"'; - $data = [ - $expected, - $content, - ]; - - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NotUsed', $data); - if ($fix === true) { - $phpcsFile->fixer->beginChangeset(); - if (substr($origContent, -10) === '!important') { - $expected .= ' !important'; - } - - $next = $phpcsFile->findNext(T_COLON, ($stackPtr + 1)); - $phpcsFile->fixer->addContent($next, ' '.$expected); - for ($next++; $next < $end; $next++) { - $phpcsFile->fixer->replaceToken($next, ''); - } - - $phpcsFile->fixer->endChangeset(); - } - - }//end process() - - - /** - * Provide the version number in which the sniff was deprecated. - * - * @return string - */ - public function getDeprecationVersion() - { - return 'v3.9.0'; - - }//end getDeprecationVersion() - - - /** - * Provide the version number in which the sniff will be removed. - * - * @return string - */ - public function getRemovalVersion() - { - return 'v4.0.0'; - - }//end getRemovalVersion() - - - /** - * Provide a custom message to display with the deprecation. - * - * @return string - */ - public function getDeprecationMessage() - { - return 'Support for scanning CSS files will be removed completely in v4.0.0.'; - - }//end getDeprecationMessage() - - -}//end class diff --git a/src/Standards/Squiz/Sniffs/Classes/DuplicatePropertySniff.php b/src/Standards/Squiz/Sniffs/Classes/DuplicatePropertySniff.php deleted file mode 100644 index 225a29659a..0000000000 --- a/src/Standards/Squiz/Sniffs/Classes/DuplicatePropertySniff.php +++ /dev/null @@ -1,121 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * - * @deprecated 3.9.0 - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes; - -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\DeprecatedSniff; -use PHP_CodeSniffer\Sniffs\Sniff; - -class DuplicatePropertySniff implements Sniff, DeprecatedSniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = ['JS']; - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return [T_OBJECT]; - - }//end register() - - - /** - * Processes this test, when one of its tokens is encountered. - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The current file being processed. - * @param int $stackPtr The position of the current token in the - * stack passed in $tokens. - * - * @return void - */ - public function process(File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - $properties = []; - $wantedTokens = [ - T_PROPERTY, - T_OBJECT, - ]; - - $next = $phpcsFile->findNext($wantedTokens, ($stackPtr + 1), $tokens[$stackPtr]['bracket_closer']); - while ($next !== false && $next < $tokens[$stackPtr]['bracket_closer']) { - if ($tokens[$next]['code'] === T_OBJECT) { - // Skip nested objects. - $next = $tokens[$next]['bracket_closer']; - } else { - $propName = $tokens[$next]['content']; - if (isset($properties[$propName]) === true) { - $error = 'Duplicate property definition found for "%s"; previously defined on line %s'; - $data = [ - $propName, - $tokens[$properties[$propName]]['line'], - ]; - $phpcsFile->addError($error, $next, 'Found', $data); - } - - $properties[$propName] = $next; - }//end if - - $next = $phpcsFile->findNext($wantedTokens, ($next + 1), $tokens[$stackPtr]['bracket_closer']); - }//end while - - }//end process() - - - /** - * Provide the version number in which the sniff was deprecated. - * - * @return string - */ - public function getDeprecationVersion() - { - return 'v3.9.0'; - - }//end getDeprecationVersion() - - - /** - * Provide the version number in which the sniff will be removed. - * - * @return string - */ - public function getRemovalVersion() - { - return 'v4.0.0'; - - }//end getRemovalVersion() - - - /** - * Provide a custom message to display with the deprecation. - * - * @return string - */ - public function getDeprecationMessage() - { - return 'Support for scanning JavaScript files will be removed completely in v4.0.0.'; - - }//end getDeprecationMessage() - - -}//end class diff --git a/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php index 332de5660b..59ebbc31ba 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php @@ -16,16 +16,6 @@ class DocCommentAlignmentSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * Returns an array of tokens this test wants to listen for. @@ -53,14 +43,7 @@ public function process(File $phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); // We are only interested in function/class/interface doc block comments. - $ignore = Tokens::$emptyTokens; - if ($phpcsFile->tokenizerType === 'JS') { - $ignore[] = T_EQUAL; - $ignore[] = T_STRING; - $ignore[] = T_OBJECT_OPERATOR; - } - - $nextToken = $phpcsFile->findNext($ignore, ($stackPtr + 1), null, true); + $nextToken = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true); $ignore = [ T_CLASS => true, T_INTERFACE => true, @@ -73,9 +56,6 @@ public function process(File $phpcsFile, $stackPtr) T_STATIC => true, T_ABSTRACT => true, T_FINAL => true, - T_PROPERTY => true, - T_OBJECT => true, - T_PROTOTYPE => true, T_VAR => true, T_READONLY => true, ]; diff --git a/src/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php index cfff91fc6d..03fa97cc59 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php @@ -15,16 +15,6 @@ class FileCommentSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * Returns an array of tokens this test wants to listen for. @@ -106,7 +96,6 @@ public function process(File $phpcsFile, $stackPtr) T_ABSTRACT, T_READONLY, T_CONST, - T_PROPERTY, T_INCLUDE, T_INCLUDE_ONCE, T_REQUIRE, diff --git a/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php index 3c1ead70a9..973513450d 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php @@ -16,16 +16,6 @@ class InlineCommentSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * Returns an array of tokens this test wants to listen for. @@ -85,7 +75,6 @@ public function process(File $phpcsFile, $stackPtr) T_ABSTRACT, T_READONLY, T_CONST, - T_PROPERTY, T_INCLUDE, T_INCLUDE_ONCE, T_REQUIRE, @@ -96,23 +85,6 @@ public function process(File $phpcsFile, $stackPtr) return; } - if ($phpcsFile->tokenizerType === 'JS') { - // We allow block comments if a function or object - // is being assigned to a variable. - $ignore = Tokens::$emptyTokens; - $ignore[] = T_EQUAL; - $ignore[] = T_STRING; - $ignore[] = T_OBJECT_OPERATOR; - $nextToken = $phpcsFile->findNext($ignore, ($nextToken + 1), null, true); - if ($tokens[$nextToken]['code'] === T_FUNCTION - || $tokens[$nextToken]['code'] === T_CLOSURE - || $tokens[$nextToken]['code'] === T_OBJECT - || $tokens[$nextToken]['code'] === T_PROTOTYPE - ) { - return; - } - } - $prevToken = $phpcsFile->findPrevious( Tokens::$emptyTokens, ($stackPtr - 1), @@ -146,16 +118,6 @@ public function process(File $phpcsFile, $stackPtr) if ($tokens[$previousContent]['code'] === T_CLOSE_CURLY_BRACKET) { return; } - - // Special case for JS files. - if ($tokens[$previousContent]['code'] === T_COMMA - || $tokens[$previousContent]['code'] === T_SEMICOLON - ) { - $lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($previousContent - 1), null, true); - if ($tokens[$lastContent]['code'] === T_CLOSE_CURLY_BRACKET) { - return; - } - } } // Only want inline comments. diff --git a/src/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php index 9ae49096f8..05499e9f2c 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php @@ -15,16 +15,6 @@ class LongConditionClosingCommentSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * The openers that we are interested in. * diff --git a/src/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php index 82b934a792..660b1d7b86 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php @@ -15,16 +15,6 @@ class PostStatementCommentSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * Exceptions to the rule. * @@ -87,7 +77,7 @@ public function process(File $phpcsFile, $stackPtr) return; } - // Special case for JS files and PHP closures. + // Special case for closures. if ($tokens[$lastContent]['code'] === T_COMMA || $tokens[$lastContent]['code'] === T_SEMICOLON ) { @@ -109,9 +99,7 @@ public function process(File $phpcsFile, $stackPtr) } } - if ($phpcsFile->tokenizerType === 'PHP' - && preg_match('|^//[ \t]*@[^\s]+|', $tokens[$stackPtr]['content']) === 1 - ) { + if (preg_match('|^//[ \t]*@[^\s]+|', $tokens[$stackPtr]['content']) === 1) { $error = 'Annotations may not appear after statements'; $phpcsFile->addError($error, $stackPtr, 'AnnotationFound'); return; diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php index 06fd3edccc..1a781f3283 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php @@ -23,16 +23,6 @@ class ControlSignatureSniff implements Sniff */ public $requiredSpacesBeforeColon = 1; - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * Returns an array of tokens this test wants to listen for. diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php index 38313e1668..51fd738291 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php @@ -37,16 +37,6 @@ class ForLoopDeclarationSniff implements Sniff */ public $ignoreNewlines = false; - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * Returns an array of tokens this test wants to listen for. diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php index 2a9d2c7315..77d49749bb 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php @@ -16,16 +16,6 @@ class SwitchDeclarationSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * The number of spaces code should be indented. * diff --git a/src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php b/src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php deleted file mode 100644 index 9d4d79bee0..0000000000 --- a/src/Standards/Squiz/Sniffs/Debug/JSLintSniff.php +++ /dev/null @@ -1,125 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * - * @deprecated 3.9.0 - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Debug; - -use PHP_CodeSniffer\Config; -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\DeprecatedSniff; -use PHP_CodeSniffer\Sniffs\Sniff; -use PHP_CodeSniffer\Util\Common; - -class JSLintSniff implements Sniff, DeprecatedSniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = ['JS']; - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array - */ - public function register() - { - return [T_OPEN_TAG]; - - }//end register() - - - /** - * Processes the tokens that this sniff is interested in. - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found. - * @param int $stackPtr The position in the stack where - * the token was found. - * - * @return int - * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If jslint.js could not be run. - */ - public function process(File $phpcsFile, $stackPtr) - { - $rhinoPath = Config::getExecutablePath('rhino'); - $jslintPath = Config::getExecutablePath('jslint'); - if ($rhinoPath === null || $jslintPath === null) { - return $phpcsFile->numTokens; - } - - $fileName = $phpcsFile->getFilename(); - - $rhinoPath = Common::escapeshellcmd($rhinoPath); - $jslintPath = Common::escapeshellcmd($jslintPath); - - $cmd = "$rhinoPath \"$jslintPath\" ".escapeshellarg($fileName); - exec($cmd, $output, $retval); - - if (is_array($output) === true) { - foreach ($output as $finding) { - $matches = []; - $numMatches = preg_match('/Lint at line ([0-9]+).*:(.*)$/', $finding, $matches); - if ($numMatches === 0) { - continue; - } - - $line = (int) $matches[1]; - $message = 'jslint says: '.trim($matches[2]); - $phpcsFile->addWarningOnLine($message, $line, 'ExternalTool'); - } - } - - // Ignore the rest of the file. - return $phpcsFile->numTokens; - - }//end process() - - - /** - * Provide the version number in which the sniff was deprecated. - * - * @return string - */ - public function getDeprecationVersion() - { - return 'v3.9.0'; - - }//end getDeprecationVersion() - - - /** - * Provide the version number in which the sniff will be removed. - * - * @return string - */ - public function getRemovalVersion() - { - return 'v4.0.0'; - - }//end getRemovalVersion() - - - /** - * Provide a custom message to display with the deprecation. - * - * @return string - */ - public function getDeprecationMessage() - { - return 'Support for scanning JavaScript files will be removed completely in v4.0.0.'; - - }//end getDeprecationMessage() - - -}//end class diff --git a/src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php b/src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php deleted file mode 100644 index a1fe215e28..0000000000 --- a/src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php +++ /dev/null @@ -1,128 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * - * @deprecated 3.9.0 - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Debug; - -use PHP_CodeSniffer\Config; -use PHP_CodeSniffer\Exceptions\RuntimeException; -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\DeprecatedSniff; -use PHP_CodeSniffer\Sniffs\Sniff; -use PHP_CodeSniffer\Util\Common; - -class JavaScriptLintSniff implements Sniff, DeprecatedSniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = ['JS']; - - - /** - * Returns the token types that this sniff is interested in. - * - * @return array - */ - public function register() - { - return [T_OPEN_TAG]; - - }//end register() - - - /** - * Processes the tokens that this sniff is interested in. - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found. - * @param int $stackPtr The position in the stack where - * the token was found. - * - * @return int - * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If Javascript Lint ran into trouble. - */ - public function process(File $phpcsFile, $stackPtr) - { - $jslPath = Config::getExecutablePath('jsl'); - if ($jslPath === null) { - return $phpcsFile->numTokens; - } - - $fileName = $phpcsFile->getFilename(); - - $cmd = '"'.Common::escapeshellcmd($jslPath).'" -nologo -nofilelisting -nocontext -nosummary -output-format __LINE__:__ERROR__ -process '.escapeshellarg($fileName); - $msg = exec($cmd, $output, $retval); - - // Variable $exitCode is the last line of $output if no error occurs, on - // error it is numeric. Try to handle various error conditions and - // provide useful error reporting. - if ($retval === 2 || $retval === 4) { - if (is_array($output) === true) { - $msg = implode('\n', $output); - } - - throw new RuntimeException("Failed invoking JavaScript Lint, retval was [$retval], output was [$msg]"); - } - - if (is_array($output) === true) { - foreach ($output as $finding) { - $split = strpos($finding, ':'); - $line = substr($finding, 0, $split); - $message = substr($finding, ($split + 1)); - $phpcsFile->addWarningOnLine(trim($message), $line, 'ExternalTool'); - } - } - - // Ignore the rest of the file. - return $phpcsFile->numTokens; - - }//end process() - - - /** - * Provide the version number in which the sniff was deprecated. - * - * @return string - */ - public function getDeprecationVersion() - { - return 'v3.9.0'; - - }//end getDeprecationVersion() - - - /** - * Provide the version number in which the sniff will be removed. - * - * @return string - */ - public function getRemovalVersion() - { - return 'v4.0.0'; - - }//end getRemovalVersion() - - - /** - * Provide a custom message to display with the deprecation. - * - * @return string - */ - public function getDeprecationMessage() - { - return 'Support for scanning JavaScript files will be removed completely in v4.0.0.'; - - }//end getDeprecationMessage() - - -}//end class diff --git a/src/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php b/src/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php index 821f9b7f47..aefb01da5d 100644 --- a/src/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php +++ b/src/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php @@ -16,16 +16,6 @@ class OperatorBracketSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * Returns an array of tokens this test wants to listen for. @@ -52,13 +42,6 @@ public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - if ($phpcsFile->tokenizerType === 'JS' && $tokens[$stackPtr]['code'] === T_PLUS) { - // JavaScript uses the plus operator for string concatenation as well - // so we cannot accurately determine if it is a string concat or addition. - // So just ignore it. - return; - } - // If the & is a reference, then we don't want to check for brackets. if ($tokens[$stackPtr]['code'] === T_BITWISE_AND && $phpcsFile->isReference($stackPtr) === true) { return; @@ -139,7 +122,6 @@ public function process(File $phpcsFile, $stackPtr) T_STRING => T_STRING, T_WHITESPACE => T_WHITESPACE, T_NS_SEPARATOR => T_NS_SEPARATOR, - T_THIS => T_THIS, T_SELF => T_SELF, T_STATIC => T_STATIC, T_PARENT => T_PARENT, @@ -283,7 +265,6 @@ public function addMissingBracketsError($phpcsFile, $stackPtr) T_DOUBLE_QUOTED_STRING => true, T_WHITESPACE => true, T_NS_SEPARATOR => true, - T_THIS => true, T_SELF => true, T_STATIC => true, T_OBJECT_OPERATOR => true, @@ -297,12 +278,6 @@ public function addMissingBracketsError($phpcsFile, $stackPtr) // Find the first token in the expression. for ($before = ($stackPtr - 1); $before > 0; $before--) { - // Special case for plus operators because we can't tell if they are used - // for addition or string contact. So assume string concat to be safe. - if ($phpcsFile->tokenizerType === 'JS' && $tokens[$before]['code'] === T_PLUS) { - break; - } - if (isset(Tokens::$emptyTokens[$tokens[$before]['code']]) === true || isset(Tokens::$operators[$tokens[$before]['code']]) === true || isset(Tokens::$castTokens[$tokens[$before]['code']]) === true @@ -337,12 +312,6 @@ public function addMissingBracketsError($phpcsFile, $stackPtr) // Find the last token in the expression. for ($after = ($stackPtr + 1); $after < $phpcsFile->numTokens; $after++) { - // Special case for plus operators because we can't tell if they are used - // for addition or string concat. So assume string concat to be safe. - if ($phpcsFile->tokenizerType === 'JS' && $tokens[$after]['code'] === T_PLUS) { - break; - } - if (isset(Tokens::$emptyTokens[$tokens[$after]['code']]) === true || isset(Tokens::$operators[$tokens[$after]['code']]) === true || isset(Tokens::$castTokens[$tokens[$after]['code']]) === true diff --git a/src/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php b/src/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php index e88d5c9a97..77289e9d40 100644 --- a/src/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php @@ -15,16 +15,6 @@ class MultiLineFunctionDeclarationSniff extends PEARFunctionDeclarationSniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * Determine if this is a multi-line function declaration. diff --git a/src/Standards/Squiz/Sniffs/Objects/DisallowObjectStringIndexSniff.php b/src/Standards/Squiz/Sniffs/Objects/DisallowObjectStringIndexSniff.php deleted file mode 100644 index a956a7c4c8..0000000000 --- a/src/Standards/Squiz/Sniffs/Objects/DisallowObjectStringIndexSniff.php +++ /dev/null @@ -1,124 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * - * @deprecated 3.9.0 - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Objects; - -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\DeprecatedSniff; -use PHP_CodeSniffer\Sniffs\Sniff; - -class DisallowObjectStringIndexSniff implements Sniff, DeprecatedSniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = ['JS']; - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return [T_OPEN_SQUARE_BRACKET]; - - }//end register() - - - /** - * Processes this test, when one of its tokens is encountered. - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. - * - * @return void - */ - public function process(File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - // Check if the next non whitespace token is a string. - $index = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); - if ($tokens[$index]['code'] !== T_CONSTANT_ENCAPSED_STRING) { - return; - } - - // Make sure it is the only thing in the square brackets. - $next = $phpcsFile->findNext(T_WHITESPACE, ($index + 1), null, true); - if ($tokens[$next]['code'] !== T_CLOSE_SQUARE_BRACKET) { - return; - } - - // Allow indexes that have dots in them because we can't write - // them in dot notation. - $content = trim($tokens[$index]['content'], '"\' '); - if (strpos($content, '.') !== false) { - return; - } - - // Also ignore reserved words. - if ($content === 'super') { - return; - } - - // Token before the opening square bracket cannot be a var name. - $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); - if ($tokens[$prev]['code'] === T_STRING) { - $error = 'Object indexes must be written in dot notation'; - $phpcsFile->addError($error, $prev, 'Found'); - } - - }//end process() - - - /** - * Provide the version number in which the sniff was deprecated. - * - * @return string - */ - public function getDeprecationVersion() - { - return 'v3.9.0'; - - }//end getDeprecationVersion() - - - /** - * Provide the version number in which the sniff will be removed. - * - * @return string - */ - public function getRemovalVersion() - { - return 'v4.0.0'; - - }//end getRemovalVersion() - - - /** - * Provide a custom message to display with the deprecation. - * - * @return string - */ - public function getDeprecationMessage() - { - return 'Support for scanning JavaScript files will be removed completely in v4.0.0.'; - - }//end getDeprecationMessage() - - -}//end class diff --git a/src/Standards/Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php b/src/Standards/Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php deleted file mode 100644 index b7fc84dfd5..0000000000 --- a/src/Standards/Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * - * @deprecated 3.9.0 - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Objects; - -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\DeprecatedSniff; -use PHP_CodeSniffer\Sniffs\Sniff; -use PHP_CodeSniffer\Util\Tokens; - -class ObjectMemberCommaSniff implements Sniff, DeprecatedSniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = ['JS']; - - - /** - * Registers the token types that this sniff wishes to listen to. - * - * @return array - */ - public function register() - { - return [T_CLOSE_OBJECT]; - - }//end register() - - - /** - * Process the tokens that this sniff is listening for. - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found. - * @param int $stackPtr The position in the stack where - * the token was found. - * - * @return void - */ - public function process(File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); - if ($tokens[$prev]['code'] === T_COMMA) { - $error = 'Last member of object must not be followed by a comma'; - $fix = $phpcsFile->addFixableError($error, $prev, 'Found'); - if ($fix === true) { - $phpcsFile->fixer->replaceToken($prev, ''); - } - } - - }//end process() - - - /** - * Provide the version number in which the sniff was deprecated. - * - * @return string - */ - public function getDeprecationVersion() - { - return 'v3.9.0'; - - }//end getDeprecationVersion() - - - /** - * Provide the version number in which the sniff will be removed. - * - * @return string - */ - public function getRemovalVersion() - { - return 'v4.0.0'; - - }//end getRemovalVersion() - - - /** - * Provide a custom message to display with the deprecation. - * - * @return string - */ - public function getDeprecationMessage() - { - return 'Support for scanning JavaScript files will be removed completely in v4.0.0.'; - - }//end getDeprecationMessage() - - -}//end class diff --git a/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php b/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php index 425cedb150..b99c6295ef 100644 --- a/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php +++ b/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php @@ -16,16 +16,6 @@ class ComparisonOperatorUsageSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * A list of valid comparison operators. * @@ -44,18 +34,12 @@ class ComparisonOperatorUsageSniff implements Sniff /** * A list of invalid operators with their alternatives. * - * @var array> + * @var array */ private static $invalidOps = [ - 'PHP' => [ - T_IS_EQUAL => '===', - T_IS_NOT_EQUAL => '!==', - T_BOOLEAN_NOT => '=== FALSE', - ], - 'JS' => [ - T_IS_EQUAL => '===', - T_IS_NOT_EQUAL => '!==', - ], + T_IS_EQUAL => '===', + T_IS_NOT_EQUAL => '!==', + T_BOOLEAN_NOT => '=== FALSE', ]; @@ -88,8 +72,7 @@ public function register() */ public function process(File $phpcsFile, $stackPtr) { - $tokens = $phpcsFile->getTokens(); - $tokenizer = $phpcsFile->tokenizerType; + $tokens = $phpcsFile->getTokens(); if ($tokens[$stackPtr]['code'] === T_INLINE_THEN) { $end = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); @@ -166,11 +149,11 @@ public function process(File $phpcsFile, $stackPtr) for ($i = $start; $i <= $end; $i++) { $type = $tokens[$i]['code']; - if (isset(self::$invalidOps[$tokenizer][$type]) === true) { + if (isset(self::$invalidOps[$type]) === true) { $error = 'Operator %s prohibited; use %s instead'; $data = [ $tokens[$i]['content'], - self::$invalidOps[$tokenizer][$type], + self::$invalidOps[$type], ]; $phpcsFile->addError($error, $i, 'NotAllowed', $data); $foundOps++; @@ -191,9 +174,8 @@ public function process(File $phpcsFile, $stackPtr) $foundBooleans++; } - if ($phpcsFile->tokenizerType !== 'JS' - && ($tokens[$i]['code'] === T_BOOLEAN_AND - || $tokens[$i]['code'] === T_BOOLEAN_OR) + if ($tokens[$i]['code'] === T_BOOLEAN_AND + || $tokens[$i]['code'] === T_BOOLEAN_OR ) { $requiredOps++; @@ -221,10 +203,7 @@ public function process(File $phpcsFile, $stackPtr) $requiredOps++; - if ($phpcsFile->tokenizerType !== 'JS' - && $foundOps < $requiredOps - && ($requiredOps !== $foundBooleans) - ) { + if ($foundOps < $requiredOps && $requiredOps !== $foundBooleans) { $error = 'Implicit true comparisons prohibited; use === TRUE instead'; $phpcsFile->addError($error, $stackPtr, 'ImplicitTrue'); } diff --git a/src/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php b/src/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php index c8e1a40303..d9e78ba6c5 100644 --- a/src/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php @@ -12,21 +12,12 @@ use PHP_CodeSniffer\Exceptions\TokenizerException; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Tokenizers\PHP; use PHP_CodeSniffer\Util\Tokens; class CommentedOutCodeSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'CSS', - ]; - /** * If a comment is more than $maxPercentage% code, a warning will be shown. * @@ -168,18 +159,15 @@ public function process(File $phpcsFile, $stackPtr) return ($lastCommentBlockToken + 1); } - if ($phpcsFile->tokenizerType === 'PHP') { - $content = ''; - } + $content = ''; // Because we are not really parsing code, the tokenizer can throw all sorts // of errors that don't mean anything, so ignore them. $oldErrors = ini_get('error_reporting'); ini_set('error_reporting', 0); try { - $tokenizerClass = get_class($phpcsFile->tokenizer); - $tokenizer = new $tokenizerClass($content, $phpcsFile->config, $phpcsFile->eolChar); - $stringTokens = $tokenizer->getTokens(); + $tokenizer = new PHP($content, $phpcsFile->config, $phpcsFile->eolChar); + $stringTokens = $tokenizer->getTokens(); } catch (TokenizerException $e) { // We couldn't check the comment, so ignore it. ini_set('error_reporting', $oldErrors); @@ -215,17 +203,15 @@ public function process(File $phpcsFile, $stackPtr) --$numTokens; } - // Second last token is always whitespace or a comment, depending + // The second last token is always whitespace or a comment, depending // on the code inside the comment. - if ($phpcsFile->tokenizerType === 'PHP') { - if (isset(Tokens::$emptyTokens[$stringTokens[($numTokens - 1)]['code']]) === false) { - return ($lastCommentBlockToken + 1); - } + if (isset(Tokens::$emptyTokens[$stringTokens[($numTokens - 1)]['code']]) === false) { + return ($lastCommentBlockToken + 1); + } - if ($stringTokens[($numTokens - 1)]['code'] === T_WHITESPACE) { - array_pop($stringTokens); - --$numTokens; - } + if ($stringTokens[($numTokens - 1)]['code'] === T_WHITESPACE) { + array_pop($stringTokens); + --$numTokens; } $emptyTokens = [ diff --git a/src/Standards/Squiz/Sniffs/PHP/DisallowInlineIfSniff.php b/src/Standards/Squiz/Sniffs/PHP/DisallowInlineIfSniff.php index f2620c7d71..48bda2bb0a 100644 --- a/src/Standards/Squiz/Sniffs/PHP/DisallowInlineIfSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/DisallowInlineIfSniff.php @@ -15,16 +15,6 @@ class DisallowInlineIfSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * Returns an array of tokens this test wants to listen for. diff --git a/src/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php b/src/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php index 5d71c3ec6b..95142b5f3d 100644 --- a/src/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php @@ -15,28 +15,15 @@ class DisallowSizeFunctionsInLoopsSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * An array of functions we don't want in the condition of loops. * * @var array */ protected $forbiddenFunctions = [ - 'PHP' => [ - 'sizeof' => true, - 'strlen' => true, - 'count' => true, - ], - 'JS' => ['length' => true], + 'sizeof' => true, + 'strlen' => true, + 'count' => true, ]; @@ -67,7 +54,6 @@ public function register() public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - $tokenizer = $phpcsFile->tokenizerType; $openBracket = $tokens[$stackPtr]['parenthesis_opener']; $closeBracket = $tokens[$stackPtr]['parenthesis_closer']; @@ -82,28 +68,19 @@ public function process(File $phpcsFile, $stackPtr) for ($i = ($start + 1); $i < $end; $i++) { if ($tokens[$i]['code'] === T_STRING - && isset($this->forbiddenFunctions[$tokenizer][$tokens[$i]['content']]) === true + && isset($this->forbiddenFunctions[$tokens[$i]['content']]) === true ) { $functionName = $tokens[$i]['content']; - if ($tokenizer === 'JS') { - // Needs to be in the form object.function to be valid. - $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($i - 1), null, true); - if ($prev === false || $tokens[$prev]['code'] !== T_OBJECT_OPERATOR) { - continue; - } - - $functionName = 'object.'.$functionName; - } else { - // Make sure it isn't a member var. - if ($tokens[($i - 1)]['code'] === T_OBJECT_OPERATOR - || $tokens[($i - 1)]['code'] === T_NULLSAFE_OBJECT_OPERATOR - ) { - continue; - } - - $functionName .= '()'; + + // Make sure it isn't a member var. + if ($tokens[($i - 1)]['code'] === T_OBJECT_OPERATOR + || $tokens[($i - 1)]['code'] === T_NULLSAFE_OBJECT_OPERATOR + ) { + continue; } + $functionName .= '()'; + $error = 'The use of %s inside a loop condition is not allowed; assign the return value to a variable and use the variable in the loop condition instead'; $data = [$functionName]; $phpcsFile->addError($error, $i, 'Found', $data); diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php index eb6e5b2aee..8f323722c8 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php @@ -16,16 +16,6 @@ class ControlStructureSpacingSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * Returns an array of tokens this test wants to listen for. diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php index 54b9ca9270..9cfdeb910c 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php @@ -15,16 +15,6 @@ class FunctionClosingBraceSpaceSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * Returns an array of tokens this test wants to listen for. @@ -62,26 +52,6 @@ public function process(File $phpcsFile, $stackPtr) $closeBrace = $tokens[$stackPtr]['scope_closer']; $prevContent = $phpcsFile->findPrevious(T_WHITESPACE, ($closeBrace - 1), null, true); - // Special case for empty JS functions. - if ($phpcsFile->tokenizerType === 'JS' && $prevContent === $tokens[$stackPtr]['scope_opener']) { - // In this case, the opening and closing brace must be - // right next to each other. - if ($tokens[$stackPtr]['scope_closer'] !== ($tokens[$stackPtr]['scope_opener'] + 1)) { - $error = 'The opening and closing braces of empty functions must be directly next to each other; e.g., function () {}'; - $fix = $phpcsFile->addFixableError($error, $closeBrace, 'SpacingBetween'); - if ($fix === true) { - $phpcsFile->fixer->beginChangeset(); - for ($i = ($tokens[$stackPtr]['scope_opener'] + 1); $i < $closeBrace; $i++) { - $phpcsFile->fixer->replaceToken($i, ''); - } - - $phpcsFile->fixer->endChangeset(); - } - } - - return; - } - $nestedFunction = false; if ($phpcsFile->hasCondition($stackPtr, [T_FUNCTION, T_CLOSURE]) === true || isset($tokens[$stackPtr]['nested_parenthesis']) === true diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php index 3eff4e0fff..4e6e9603d8 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php @@ -15,16 +15,6 @@ class FunctionOpeningBraceSpaceSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * Returns an array of tokens this test wants to listen for. diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/LogicalOperatorSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/LogicalOperatorSpacingSniff.php index d0f4c80c2b..3147190d49 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/LogicalOperatorSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/LogicalOperatorSpacingSniff.php @@ -16,16 +16,6 @@ class LogicalOperatorSpacingSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * Returns an array of tokens this test wants to listen for. diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php index 2a87978a0c..b694ac11c6 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php @@ -16,16 +16,6 @@ class OperatorSpacingSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * Allow newlines instead of spaces. * diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/PropertyLabelSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/PropertyLabelSpacingSniff.php deleted file mode 100644 index 7e5bf9c204..0000000000 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/PropertyLabelSpacingSniff.php +++ /dev/null @@ -1,118 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * - * @deprecated 3.9.0 - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace; - -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Sniffs\DeprecatedSniff; -use PHP_CodeSniffer\Sniffs\Sniff; - -class PropertyLabelSpacingSniff implements Sniff, DeprecatedSniff -{ - - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = ['JS']; - - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return [ - T_PROPERTY, - T_LABEL, - ]; - - }//end register() - - - /** - * Processes this test, when one of its tokens is encountered. - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. - * - * @return void - */ - public function process(File $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - - $colon = $phpcsFile->findNext(T_COLON, ($stackPtr + 1)); - - if ($colon !== ($stackPtr + 1)) { - $error = 'There must be no space before the colon in a property/label declaration'; - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Before'); - if ($fix === true) { - $phpcsFile->fixer->replaceToken(($stackPtr + 1), ''); - } - } - - if ($tokens[($colon + 1)]['code'] !== T_WHITESPACE || $tokens[($colon + 1)]['content'] !== ' ') { - $error = 'There must be a single space after the colon in a property/label declaration'; - $fix = $phpcsFile->addFixableError($error, $stackPtr, 'After'); - if ($fix === true) { - if ($tokens[($colon + 1)]['code'] === T_WHITESPACE) { - $phpcsFile->fixer->replaceToken(($colon + 1), ' '); - } else { - $phpcsFile->fixer->addContent($colon, ' '); - } - } - } - - }//end process() - - - /** - * Provide the version number in which the sniff was deprecated. - * - * @return string - */ - public function getDeprecationVersion() - { - return 'v3.9.0'; - - }//end getDeprecationVersion() - - - /** - * Provide the version number in which the sniff will be removed. - * - * @return string - */ - public function getRemovalVersion() - { - return 'v4.0.0'; - - }//end getRemovalVersion() - - - /** - * Provide a custom message to display with the deprecation. - * - * @return string - */ - public function getDeprecationMessage() - { - return 'Support for scanning JavaScript files will be removed completely in v4.0.0.'; - - }//end getDeprecationMessage() - - -}//end class diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php index dbf719d20e..85b5bb0267 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php @@ -16,16 +16,6 @@ class SemicolonSpacingSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - ]; - /** * Returns an array of tokens this test wants to listen for. diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php index f13baba9f2..1bdfa5fcb9 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php @@ -19,17 +19,6 @@ class SuperfluousWhitespaceSniff implements Sniff { - /** - * A list of tokenizers this sniff supports. - * - * @var array - */ - public $supportedTokenizers = [ - 'PHP', - 'JS', - 'CSS', - ]; - /** * If TRUE, whitespace rules are not checked for blank lines. * @@ -78,40 +67,26 @@ public function process(File $phpcsFile, $stackPtr) Check for start of file whitespace. */ - if ($phpcsFile->tokenizerType !== 'PHP') { - // The first token is always the open tag inserted when tokenized - // and the second token is always the first piece of content in - // the file. If the second token is whitespace, there was - // whitespace at the start of the file. - if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) { - return; - } + // If it's the first token, then there is no space. + if ($stackPtr === 0) { + return; + } - if ($phpcsFile->fixer->enabled === true) { - $stackPtr = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); - } - } else { - // If it's the first token, then there is no space. - if ($stackPtr === 0) { + $beforeOpen = ''; + + for ($i = ($stackPtr - 1); $i >= 0; $i--) { + // If we find something that isn't inline html then there is something previous in the file. + if ($tokens[$i]['type'] !== 'T_INLINE_HTML') { return; } - $beforeOpen = ''; - - for ($i = ($stackPtr - 1); $i >= 0; $i--) { - // If we find something that isn't inline html then there is something previous in the file. - if ($tokens[$i]['type'] !== 'T_INLINE_HTML') { - return; - } - - $beforeOpen .= $tokens[$i]['content']; - } + $beforeOpen .= $tokens[$i]['content']; + } - // If we have ended up with inline html make sure it isn't just whitespace. - if (preg_match('`^[\pZ\s]+$`u', $beforeOpen) !== 1) { - return; - } - }//end if + // If we have ended up with inline html make sure it isn't just whitespace. + if (preg_match('`^[\pZ\s]+$`u', $beforeOpen) !== 1) { + return; + } $fix = $phpcsFile->addFixableError('Additional whitespace found at start of file', $stackPtr, 'StartFile'); if ($fix === true) { @@ -127,56 +102,30 @@ public function process(File $phpcsFile, $stackPtr) Check for end of file whitespace. */ - if ($phpcsFile->tokenizerType === 'PHP') { - if (isset($tokens[($stackPtr + 1)]) === false) { - // The close PHP token is the last in the file. - return; - } - - $afterClose = ''; - - for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) { - // If we find something that isn't inline HTML then there - // is more to the file. - if ($tokens[$i]['type'] !== 'T_INLINE_HTML') { - return; - } + if (isset($tokens[($stackPtr + 1)]) === false) { + // The close PHP token is the last in the file. + return; + } - $afterClose .= $tokens[$i]['content']; - } + $afterClose = ''; - // If we have ended up with inline html make sure it isn't just whitespace. - if (preg_match('`^[\pZ\s]+$`u', $afterClose) !== 1) { - return; - } - } else { - // The last token is always the close tag inserted when tokenized - // and the second last token is always the last piece of content in - // the file. If the second last token is whitespace, there was - // whitespace at the end of the file. - $stackPtr--; - - // The pointer is now looking at the last content in the file and - // not the fake PHP end tag the tokenizer inserted. - if ($tokens[$stackPtr]['code'] !== T_WHITESPACE) { + for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) { + // If we find something that isn't inline HTML then there + // is more to the file. + if ($tokens[$i]['type'] !== 'T_INLINE_HTML') { return; } - // Allow a single newline at the end of the last line in the file. - if ($tokens[($stackPtr - 1)]['code'] !== T_WHITESPACE - && $tokens[$stackPtr]['content'] === $phpcsFile->eolChar - ) { - return; - } - }//end if + $afterClose .= $tokens[$i]['content']; + } + + // If we have ended up with inline html make sure it isn't just whitespace. + if (preg_match('`^[\pZ\s]+$`u', $afterClose) !== 1) { + return; + } $fix = $phpcsFile->addFixableError('Additional whitespace found at end of file', $stackPtr, 'EndFile'); if ($fix === true) { - if ($phpcsFile->tokenizerType !== 'PHP') { - $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); - $stackPtr = ($prev + 1); - } - $phpcsFile->fixer->beginChangeset(); for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) { $phpcsFile->fixer->replaceToken($i, ''); diff --git a/src/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.css b/src/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.css deleted file mode 100644 index 39abce232b..0000000000 --- a/src/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.css +++ /dev/null @@ -1,81 +0,0 @@ -.my-style { -} - - -.my-style { -} - -/* Comment */ - -.my-style { -} - - -/* Comment */ - -.my-style { - float: left; - -} - -.AssetLineageWidgetType-item { - color: #CCC; -} - -/*.AssetLineageWidgetType-item2 .selected, -.AssetLineageWidgetType-item .selected { -}*/ - -.AssetLineageWidgetType-item.selected { -} - -@media screen and (max-device-width: 769px) { - - header #logo img { - max-width: 100%; - } - -} - -@media screen and (max-device-width: 769px) { - - header #logo img { - max-width: 100%; - } -} - -.GUITextBox.container:after {} - -@media screen and (max-device-width: 769px) { - .no-blank-line-after { - } - .no-blank-line-after-second-def { - } .my-style { - } - - .no-blank-line-and-trailing-comment { - } /* end long class */ - .too-many-blank-lines-and-trailing-comment-extra-whitespace-after-brace { - } /* end long class */ - - - - .has-blank-line-and-trailing-comment { - } /* end long class */ - - .no-blank-line-and-annotation { - } /* phpcs:ignore Standard.Cat.SniffName -- for reasons */ - .too-many-blank-lines-annotation { - } /* phpcs:ignore Standard.Cat.SniffName -- for reasons */ - - - - .has-blank-line-and-annotation { - } /* phpcs:ignore Standard.Cat.SniffName -- for reasons */ - -} - -@media screen and (max-device-width: 769px) { - - header #logo img { - max-width: 100%;}} diff --git a/src/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.css.fixed b/src/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.css.fixed deleted file mode 100644 index ca77e83b66..0000000000 --- a/src/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.css.fixed +++ /dev/null @@ -1,85 +0,0 @@ -.my-style { -} - -.my-style { -} - -/* Comment */ - -.my-style { -} - -/* Comment */ - -.my-style { - float: left; - -} - -.AssetLineageWidgetType-item { - color: #CCC; -} - -/*.AssetLineageWidgetType-item2 .selected, -.AssetLineageWidgetType-item .selected { -}*/ - -.AssetLineageWidgetType-item.selected { -} - -@media screen and (max-device-width: 769px) { - - header #logo img { - max-width: 100%; - } - -} - -@media screen and (max-device-width: 769px) { - - header #logo img { - max-width: 100%; - } - -} - -.GUITextBox.container:after { -} - -@media screen and (max-device-width: 769px) { - .no-blank-line-after { - } - - .no-blank-line-after-second-def { - } - -.my-style { - } - - .no-blank-line-and-trailing-comment { - } /* end long class */ - - .too-many-blank-lines-and-trailing-comment-extra-whitespace-after-brace { - } /* end long class */ - - .has-blank-line-and-trailing-comment { - } /* end long class */ - - .no-blank-line-and-annotation { - } /* phpcs:ignore Standard.Cat.SniffName -- for reasons */ - - .too-many-blank-lines-annotation { - } /* phpcs:ignore Standard.Cat.SniffName -- for reasons */ - - .has-blank-line-and-annotation { - } /* phpcs:ignore Standard.Cat.SniffName -- for reasons */ - -} - -@media screen and (max-device-width: 769px) { - - header #logo img { - max-width: 100%; -} - -} diff --git a/src/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.php b/src/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.php deleted file mode 100644 index c9770cc161..0000000000 --- a/src/Standards/Squiz/Tests/CSS/ClassDefinitionClosingBraceSpaceUnitTest.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; - -/** - * Unit test class for the ClassDefinitionClosingBraceSpace sniff. - * - * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\ClassDefinitionClosingBraceSpaceSniff - */ -final class ClassDefinitionClosingBraceSpaceUnitTest extends AbstractSniffUnitTest -{ - - - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getErrorList() - { - return [ - 2 => 1, - 11 => 1, - 44 => 1, - 47 => 1, - 51 => 1, - 53 => 1, - 57 => 1, - 59 => 1, - 67 => 1, - 69 => 1, - 81 => 2, - ]; - - }//end getErrorList() - - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return []; - - }//end getWarningList() - - -}//end class diff --git a/src/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.css b/src/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.css deleted file mode 100644 index 6496cb839e..0000000000 --- a/src/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.css +++ /dev/null @@ -1,66 +0,0 @@ -.AssetListingEditWidgetType-BottomPanel select, -#EditEditingModeWidgetType-assetEditor-filters-assetTypes-addNew { - float: left; -} - -.AssetListingEditWidgetType-BottomPanel select, - -#EditEditingModeWidgetType-assetEditor-filters-assetTypes-addNew { - float: left; -} - -.AssetListingEditWidgetType-BottomPanel select, -/*.AssetListingEditWidgetType-BottomPanel ul,*/ -#EditEditingModeWidgetType-assetEditor-filters-assetTypes-addNew { - float: left; -} - -.AssetListingEditWidgetType-BottomPanel select, - -.AssetListingEditWidgetType-BottomPanel ul, -#EditEditingModeWidgetType-assetEditor-filters-assetTypes-addNew { - float: left; -} - -#SuperUsersSystemConfigScreen-table { - display: block; - left: 50%; - margin-left: -500px; - margin-top: 180px; - position: relative; - width: 1000px; -} - -/** - * More styles below here. - */ - -td.TableWidgetType-header.TableWidgetType-header-lastLogin, -td.TableWidgetType-header.TableWidgetType-header-remove, -td.TableWidgetType-header.TableWidgetType-header-email, -td.TableWidgetType-header.TableWidgetType-header-userName { - background: url(images/ScreenImages/table_header_bg.png) repeat-x; - border-top: 1px solid #D4D4D4; - color: #787878; - height: 33px; - padding-left: 12px; - width: 150px; -} - -@media screen and (max-device-width: 769px) { - - header #logo img { - max-width: 100%; - padding: 20px; - margin: 40px; - } -} - -.foo -{ - border: none; -} - -/* Live coding. Has to be the last test in the file. */ -.intentional-parse-error { - float: left diff --git a/src/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.php b/src/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.php deleted file mode 100644 index 5320047c08..0000000000 --- a/src/Standards/Squiz/Tests/CSS/ClassDefinitionNameSpacingUnitTest.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; - -/** - * Unit test class for the ClassDefinitionNameSpacing sniff. - * - * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\ClassDefinitionNameSpacingSniff - */ -final class ClassDefinitionNameSpacingUnitTest extends AbstractSniffUnitTest -{ - - - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getErrorList() - { - return [ - 7 => 1, - 19 => 1, - ]; - - }//end getErrorList() - - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return []; - - }//end getWarningList() - - -}//end class diff --git a/src/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.css b/src/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.css deleted file mode 100644 index 98c8fa5635..0000000000 --- a/src/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.css +++ /dev/null @@ -1,108 +0,0 @@ -.HelpWidgetType-new-bug-title { - float: left; -} -.HelpWidgetType-new-bug-title { - float: left; -} -.HelpWidgetType-new-bug-title { - float: left; -} -.HelpWidgetType-new-bug-title{ - float: left; -} -.HelpWidgetType-new-bug-title { - - float: left; -} - -@media screen and (max-device-width: 769px) { - - header #logo img { - max-width: 100%; - } - -} - -@media screen and (max-device-width: 769px) { - header #logo img { - max-width: 100%; - } - -} - -@media screen and (max-device-width: 769px) { - - - - header #logo img { - max-width: 100%; - } - -} - -.GUITextBox.container:after {} - -.single-line {float: left;} - -#opening-brace-on-different-line - - -{ - color: #FFFFFF; -} - -#opening-brace-on-different-line-and-inline-style - - -{color: #FFFFFF;} - -@media screen and (max-device-width: 769px) { .everything-on-one-line { float: left; } } - -/* Document handling of comments in various places */ -.no-space-before-opening-with-comment /* comment*/{ - float: left; -} - -.space-before-opening-with-comment-on-next-line -/* comment*/ { - float: left; -} - -#opening-brace-on-different-line-with-comment-between -/*comment*/ -{ - padding: 0; -} - -.single-line-with-comment { /* comment*/ float: left; } - -.multi-line-with-trailing-comment { /* comment*/ - float: left; -} - - -@media screen and (max-device-width: 769px) { - /*comment*/ - .comment-line-after-nesting-class-opening { - } -} - -@media screen and (max-device-width: 769px) { - - /*comment*/ - .blank-line-and-comment-line-after-nesting-class-opening { - } -} - -@media screen and (max-device-width: 769px) { - - - - /* phpcs:ignore Standard.Category.Sniffname -- for reasons */ - .blank-line-and-annotation-after-nesting-class-opening { - } -} - -/* Live coding. Has to be the last test in the file. */ -.intentional-parse-error { - float: left diff --git a/src/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.css.fixed b/src/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.css.fixed deleted file mode 100644 index b3f48a5cee..0000000000 --- a/src/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.css.fixed +++ /dev/null @@ -1,106 +0,0 @@ -.HelpWidgetType-new-bug-title { - float: left; -} -.HelpWidgetType-new-bug-title { - float: left; -} -.HelpWidgetType-new-bug-title { - float: left; -} -.HelpWidgetType-new-bug-title { - float: left; -} -.HelpWidgetType-new-bug-title { - - float: left; -} - -@media screen and (max-device-width: 769px) { - - header #logo img { - max-width: 100%; - } - -} - -@media screen and (max-device-width: 769px) { - - header #logo img { - max-width: 100%; - } - -} - -@media screen and (max-device-width: 769px) { - - header #logo img { - max-width: 100%; - } - -} - -.GUITextBox.container:after { -} - -.single-line { -float: left;} - -#opening-brace-on-different-line { - color: #FFFFFF; -} - -#opening-brace-on-different-line-and-inline-style { -color: #FFFFFF;} - -@media screen and (max-device-width: 769px) { - -.everything-on-one-line { -float: left; } } - -/* Document handling of comments in various places */ -.no-space-before-opening-with-comment /* comment*/ { - float: left; -} - -.space-before-opening-with-comment-on-next-line -/* comment*/ { - float: left; -} - -#opening-brace-on-different-line-with-comment-between -/*comment*/ { - padding: 0; -} - -.single-line-with-comment { -/* comment*/ float: left; } - -.multi-line-with-trailing-comment { /* comment*/ - float: left; -} - - -@media screen and (max-device-width: 769px) { - - /*comment*/ - .comment-line-after-nesting-class-opening { - } -} - -@media screen and (max-device-width: 769px) { - - /*comment*/ - .blank-line-and-comment-line-after-nesting-class-opening { - } -} - -@media screen and (max-device-width: 769px) { - - /* phpcs:ignore Standard.Category.Sniffname -- for reasons */ - .blank-line-and-annotation-after-nesting-class-opening { - } -} - -/* Live coding. Has to be the last test in the file. */ -.intentional-parse-error { - float: left diff --git a/src/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.php b/src/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.php deleted file mode 100644 index 3d5f37bb60..0000000000 --- a/src/Standards/Squiz/Tests/CSS/ClassDefinitionOpeningBraceSpaceUnitTest.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; - -/** - * Unit test class for the ClassDefinitionOpeningBraceSpace sniff. - * - * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\ClassDefinitionOpeningBraceSpaceSniff - */ -final class ClassDefinitionOpeningBraceSpaceUnitTest extends AbstractSniffUnitTest -{ - - - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getErrorList() - { - return [ - 4 => 1, - 7 => 1, - 10 => 1, - 26 => 1, - 33 => 1, - 43 => 1, - 45 => 1, - 50 => 1, - 57 => 2, - 59 => 2, - 62 => 1, - 73 => 1, - 77 => 1, - 84 => 1, - 97 => 1, - ]; - - }//end getErrorList() - - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return []; - - }//end getWarningList() - - -}//end class diff --git a/src/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.css b/src/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.css deleted file mode 100644 index 391bc85acb..0000000000 --- a/src/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.css +++ /dev/null @@ -1,42 +0,0 @@ -body { -font-family: Arial, Helvetica, sans-serif; -margin : 40px 0 0 0; -padding : 0; -background: #8FB7DB url(diag_lines_bg.gif) top left; -margin-top: -10px; -margin-bottom: -0px; -} - -.TableWidgetType .recover:hover { - background-color: #FFF; -} - -#clearCache-settings:rootNodes-list_0 { - border-top: none; -} - -.LookupEditScreenWidgetType-urls a, .LookupEditScreenWidgetType-urls a:visited { - text-decoration: none; - color: #444; -} - -/* checking embedded PHP */ -li { - background:url(/images//bullet.gif) left px no-repeat; - margin:0px; - padding-left:10px; - margin-bottom:px; - margin-top: px; - line-height:13px; - filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr=#2e62a8, endColorstr=#123363); -} - -/* Empty style defs. */ -.p { - margin:; - margin-right: - margin-left: 10px; - float:/* Some comment. */ ; -} diff --git a/src/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.css.fixed b/src/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.css.fixed deleted file mode 100644 index e68bddce66..0000000000 --- a/src/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.css.fixed +++ /dev/null @@ -1,40 +0,0 @@ -body { -font-family: Arial, Helvetica, sans-serif; -margin: 40px 0 0 0; -padding: 0; -background: #8FB7DB url(diag_lines_bg.gif) top left; -margin-top: 10px; -margin-bottom: 0px; -} - -.TableWidgetType .recover:hover { - background-color: #FFF; -} - -#clearCache-settings:rootNodes-list_0 { - border-top: none; -} - -.LookupEditScreenWidgetType-urls a, .LookupEditScreenWidgetType-urls a:visited { - text-decoration: none; - color: #444; -} - -/* checking embedded PHP */ -li { - background: url(/images//bullet.gif) left px no-repeat; - margin: 0px; - padding-left: 10px; - margin-bottom: px; - margin-top: px; - line-height: 13px; - filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr=#2e62a8, endColorstr=#123363); -} - -/* Empty style defs. */ -.p { - margin:; - margin-right: - margin-left: 10px; - float: /* Some comment. */ ; -} diff --git a/src/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.php b/src/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.php deleted file mode 100644 index 222bbe4e18..0000000000 --- a/src/Standards/Squiz/Tests/CSS/ColonSpacingUnitTest.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; - -/** - * Unit test class for the ColonSpacing sniff. - * - * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\ColonSpacingSniff - */ -final class ColonSpacingUnitTest extends AbstractSniffUnitTest -{ - - - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getErrorList() - { - return [ - 3 => 1, - 4 => 2, - 5 => 1, - 6 => 1, - 8 => 1, - 27 => 1, - 28 => 1, - 29 => 1, - 30 => 1, - 32 => 1, - 41 => 1, - ]; - - }//end getErrorList() - - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return []; - - }//end getWarningList() - - -}//end class diff --git a/src/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.css b/src/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.css deleted file mode 100644 index 2dfd22adb5..0000000000 --- a/src/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.css +++ /dev/null @@ -1,16 +0,0 @@ -#title-bar-bottom-right { - background-color: #333333; - padding: 10px; - border-bottom: 1px dotted #F0F0F0; - border-top: 1px dotted #FF00FF; - background: #08f7db url(diag_lines_bg.gif) top left; - - /* The sniff only deals with HEX colours. */ - color: DarkSlateGray; - background-color: rgb(255, 0, 0); - background-color: rgba(0, 0, 255, 0.3); - background-color: hsl(120, 100%, 50%); -} - -#add-new-comment { -} diff --git a/src/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.css.fixed b/src/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.css.fixed deleted file mode 100644 index 039209dd5a..0000000000 --- a/src/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.css.fixed +++ /dev/null @@ -1,16 +0,0 @@ -#title-bar-bottom-right { - background-color: #333; - padding: 10px; - border-bottom: 1px dotted #F0F0F0; - border-top: 1px dotted #F0F; - background: #08F7DB url(diag_lines_bg.gif) top left; - - /* The sniff only deals with HEX colours. */ - color: DarkSlateGray; - background-color: rgb(255, 0, 0); - background-color: rgba(0, 0, 255, 0.3); - background-color: hsl(120, 100%, 50%); -} - -#add-new-comment { -} diff --git a/src/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.php b/src/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.php deleted file mode 100644 index 44a2d64f7c..0000000000 --- a/src/Standards/Squiz/Tests/CSS/ColourDefinitionUnitTest.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; - -/** - * Unit test class for the ColourDefinition sniff. - * - * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\ColourDefinitionSniff - */ -final class ColourDefinitionUnitTest extends AbstractSniffUnitTest -{ - - - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getErrorList() - { - return [ - 2 => 1, - 5 => 1, - 6 => 1, - ]; - - }//end getErrorList() - - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return []; - - }//end getWarningList() - - -}//end class diff --git a/src/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.css b/src/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.css deleted file mode 100644 index 4c11beaa85..0000000000 --- a/src/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.css +++ /dev/null @@ -1,17 +0,0 @@ -.SettingsTabPaneWidgetType-tab-mid { - background: transparent url(tab_inact_mid.png) repeat-x; - height: 100%;float: left; - line-height: -25px; - cursor: pointer; margin: 10px; float: right; -} - -/* testing embedded PHP */ -li { - background:url(/images//bullet.gif) left px no-repeat; margin:0px; padding-left:10px; margin-bottom:px; line-height:13px; - filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr=#2e62a8, endColorstr=#123363); -} - -/* Document handling of comments and annotations. */ -div#annotations {-webkit-tap-highlight-color:transparent;/* phpcs:disable Standard.Cat.SniffName */-webkit-touch-callout:none;/*phpcs:enable*/-webkit-user-select:none;} - -div#comments {height:100%;/*comment*/width:100%;} diff --git a/src/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.css.fixed b/src/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.css.fixed deleted file mode 100644 index 93a7815e69..0000000000 --- a/src/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.css.fixed +++ /dev/null @@ -1,27 +0,0 @@ -.SettingsTabPaneWidgetType-tab-mid { - background: transparent url(tab_inact_mid.png) repeat-x; - height: 100%; -float: left; - line-height: -25px; - cursor: pointer; -margin: 10px; -float: right; -} - -/* testing embedded PHP */ -li { - background:url(/images//bullet.gif) left px no-repeat; -margin:0px; -padding-left:10px; -margin-bottom:px; -line-height:13px; - filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr=#2e62a8, endColorstr=#123363); -} - -/* Document handling of comments and annotations. */ -div#annotations {-webkit-tap-highlight-color:transparent;/* phpcs:disable Standard.Cat.SniffName */ --webkit-touch-callout:none;/*phpcs:enable*/ --webkit-user-select:none;} - -div#comments {height:100%;/*comment*/ -width:100%;} diff --git a/src/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.php b/src/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.php deleted file mode 100644 index 18abf1a5cd..0000000000 --- a/src/Standards/Squiz/Tests/CSS/DisallowMultipleStyleDefinitionsUnitTest.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; - -/** - * Unit test class for the DisallowMultipleStyleDefinitions sniff. - * - * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\DisallowMultipleStyleDefinitionsSniff - */ -final class DisallowMultipleStyleDefinitionsUnitTest extends AbstractSniffUnitTest -{ - - - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getErrorList() - { - return [ - 3 => 1, - 5 => 2, - 10 => 4, - 15 => 2, - 17 => 1, - ]; - - }//end getErrorList() - - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return []; - - }//end getWarningList() - - -}//end class diff --git a/src/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.css b/src/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.css deleted file mode 100644 index 8ac95012a8..0000000000 --- a/src/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.css +++ /dev/null @@ -1,103 +0,0 @@ -.AssetLineageWidgetType-item { - color: #FFF; -} - -.AssetLineageWidgetType-title { - color: #CCC; -} - -.AssetLineageWidgetType-item { - color: #CCC; -} - -.AssetLineageWidgetType-item .selected { -} - -.AssetLineageWidgetType-item.selected { -} - -#Blah .AssetLineageWidgetType-item { -} - -#X.selected, -.AssetLineageWidgetType-item { -} - -.MyClass, .YourClass { -} - -.YourClass, .MyClass { -} - -.YourClass, .MyClass, .OurClass { -} - - -.ClassAtTopOfMediaBlock { -} - -@media print { - .ClassAtTopOfMediaBlock { - } - - .ClassInMultipleMediaBlocks { - } -} - -.ClassNotAtTopOfMediaBlock { -} - -@media handheld { - .SameClassInMediaBlock { - } - - .ClassNotAtTopOfMediaBlock { - } - - .SameClassInMediaBlock { - } -} - -@media braille { - .PlaceholderClass { - } - - .ClassNotAtTopOfMediaBlock { - } - - .ClassInMultipleMediaBlocks { - } -} - -.foo /* any comment */ -{ color: red; } - -/* print comment */ -@media print { - /* comment1 */ - td { - } - - /* comment2 */ - img { - } - - /* comment3 */ - td { - } -} - -@media handheld /* handheld comment */ -{ - td /* comment1 */ - { - } - - img /* comment2 */ - { - } - - td /* comment3 */ - { - } -} diff --git a/src/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.php b/src/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.php deleted file mode 100644 index 70bc5b1059..0000000000 --- a/src/Standards/Squiz/Tests/CSS/DuplicateClassDefinitionUnitTest.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; - -/** - * Unit test class for the DuplicateClassDefinition sniff. - * - * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\DuplicateClassDefinitionSniff - */ -final class DuplicateClassDefinitionUnitTest extends AbstractSniffUnitTest -{ - - - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getErrorList() - { - return [ - 9 => 1, - 29 => 1, - 57 => 1, - 86 => 1, - 101 => 1, - ]; - - }//end getErrorList() - - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return []; - - }//end getWarningList() - - -}//end class diff --git a/src/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.css b/src/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.css deleted file mode 100644 index c9c849f612..0000000000 --- a/src/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.css +++ /dev/null @@ -1,27 +0,0 @@ -.ViperSubToolbar-wrapper { - height: 34px; - left: 0; - position: fixed; - top: 60px; - z-index: 997; - left: 50%; -} - -.expandable { - -moz-transition-property: margin-left, margin-right; - -moz-transition-duration: 0.2s; - -moz-transition-timing-function: ease; - -webkit-transition-property: margin-left, margin-right; - -webkit-transition-duration: 0.2s; - -webkit-transition-timing-function: ease; - z-index: 2; -} - -@media only screen and (max-width: 480px) { - header nav.meta a { display: none; } - header nav.meta a.search { display: block; } -} - -/* Live coding. Has to be the last test in the file. */ -.intentional-parse-error { - float: left diff --git a/src/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.php b/src/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.php deleted file mode 100644 index f7e9e95f09..0000000000 --- a/src/Standards/Squiz/Tests/CSS/DuplicateStyleDefinitionUnitTest.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; - -/** - * Unit test class for the DuplicateStyleDefinition sniff. - * - * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\DuplicateStyleDefinitionSniff - */ -final class DuplicateStyleDefinitionUnitTest extends AbstractSniffUnitTest -{ - - - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getErrorList() - { - return [7 => 1]; - - }//end getErrorList() - - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return []; - - }//end getWarningList() - - -}//end class diff --git a/src/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.css b/src/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.css deleted file mode 100644 index 801dcda119..0000000000 --- a/src/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.css +++ /dev/null @@ -1,15 +0,0 @@ -.HelpWidgetType-new-bug-title {} -.HelpWidgetType-new-bug-title { -} -.HelpWidgetType-new-bug-title { - -} -.HelpWidgetType-new-bug-title { - -} -.HelpWidgetType-new-bug-title { - /* Nothing to see here */ -} -.HelpWidgetType-new-bug-title { - float: left; -} diff --git a/src/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.php b/src/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.php deleted file mode 100644 index b75873002f..0000000000 --- a/src/Standards/Squiz/Tests/CSS/EmptyClassDefinitionUnitTest.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; - -/** - * Unit test class for the EmptyClassDefinition sniff. - * - * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\EmptyClassDefinitionSniff - */ -final class EmptyClassDefinitionUnitTest extends AbstractSniffUnitTest -{ - - - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getErrorList() - { - return [ - 1 => 1, - 2 => 1, - 4 => 1, - 7 => 1, - 10 => 1, - ]; - - }//end getErrorList() - - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return []; - - }//end getWarningList() - - -}//end class diff --git a/src/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.css b/src/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.css deleted file mode 100644 index 24910b714c..0000000000 --- a/src/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.css +++ /dev/null @@ -1,11 +0,0 @@ -#MetadataAdminScreen-addField-fieldType { - margin-left: 10px; - margin-right: - float: ; -} - -#MetadataAdminScreen-addField-fieldType li { - margin-right: /* @todo */ - margin-left: 10px; - float: /* Some comment. */ ; -} diff --git a/src/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php b/src/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php deleted file mode 100644 index 55ec5331ec..0000000000 --- a/src/Standards/Squiz/Tests/CSS/EmptyStyleDefinitionUnitTest.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; - -/** - * Unit test class for the EmptyStyleDefinition sniff. - * - * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\EmptyStyleDefinitionSniff - */ -final class EmptyStyleDefinitionUnitTest extends AbstractSniffUnitTest -{ - - - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getErrorList() - { - return [ - 3 => 1, - 4 => 1, - 8 => 1, - 10 => 1, - ]; - - }//end getErrorList() - - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return []; - - }//end getWarningList() - - -}//end class diff --git a/src/Standards/Squiz/Tests/CSS/ForbiddenStylesUnitTest.css b/src/Standards/Squiz/Tests/CSS/ForbiddenStylesUnitTest.css deleted file mode 100644 index dbd5487056..0000000000 --- a/src/Standards/Squiz/Tests/CSS/ForbiddenStylesUnitTest.css +++ /dev/null @@ -1,18 +0,0 @@ -#add-new-comment { - -moz-border-radius: 1px; - -webkit-border-radius: 1px; - border-radius: 1px; - - -moz-border-radius-topleft: 1px; - -moz-border-radius-topright: 1px; - -moz-border-radius-bottomright: 1px; - -moz-border-radius-bottomleft: 1px; - border-top-left-radius: 1px; - border-top-right-radius: 1px; - border-bottom-right-radius: 1px; - border-bottom-left-radius: 1px; - - -moz-box-shadow: 1px; - -webkit-box-shadow: 1px; - box-shadow: 1px; -} diff --git a/src/Standards/Squiz/Tests/CSS/ForbiddenStylesUnitTest.css.fixed b/src/Standards/Squiz/Tests/CSS/ForbiddenStylesUnitTest.css.fixed deleted file mode 100644 index a8ea270487..0000000000 --- a/src/Standards/Squiz/Tests/CSS/ForbiddenStylesUnitTest.css.fixed +++ /dev/null @@ -1,18 +0,0 @@ -#add-new-comment { - border-radius: 1px; - border-radius: 1px; - border-radius: 1px; - - border-top-left-radius: 1px; - border-top-right-radius: 1px; - border-bottom-right-radius: 1px; - border-bottom-left-radius: 1px; - border-top-left-radius: 1px; - border-top-right-radius: 1px; - border-bottom-right-radius: 1px; - border-bottom-left-radius: 1px; - - box-shadow: 1px; - box-shadow: 1px; - box-shadow: 1px; -} diff --git a/src/Standards/Squiz/Tests/CSS/ForbiddenStylesUnitTest.php b/src/Standards/Squiz/Tests/CSS/ForbiddenStylesUnitTest.php deleted file mode 100644 index f5cdae4367..0000000000 --- a/src/Standards/Squiz/Tests/CSS/ForbiddenStylesUnitTest.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; - -/** - * Unit test class for the ForbiddenStyles sniff. - * - * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\ForbiddenStylesSniff - */ -final class ForbiddenStylesUnitTest extends AbstractSniffUnitTest -{ - - - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getErrorList() - { - return [ - 2 => 1, - 3 => 1, - 6 => 1, - 7 => 1, - 8 => 1, - 9 => 1, - 15 => 1, - 16 => 1, - ]; - - }//end getErrorList() - - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return []; - - }//end getWarningList() - - -}//end class diff --git a/src/Standards/Squiz/Tests/CSS/IndentationUnitTest.1.css b/src/Standards/Squiz/Tests/CSS/IndentationUnitTest.1.css deleted file mode 100644 index 216f00ee5e..0000000000 --- a/src/Standards/Squiz/Tests/CSS/IndentationUnitTest.1.css +++ /dev/null @@ -1,79 +0,0 @@ -body { - - font-family: Arial, Helvetica, sans-serif; - margin: 40px 0 0 0; -padding: 0; - background: #8FB7DB url(diag_lines_bg.gif) top left; - -} - -td { - margin: 40px; - - padding: 20px; -} - -/* -#AdminScreenModeWidgetType-tab_pane-containers .TabPaneWidgetType-tab-selected-left { - background: transparent url(images/ScreenImages/tab_on_left.png) no-repeat; -} -#AdminScreenModeWidgetType-tab_pane-containers .TabPaneWidgetType-tab-selected-right { - background: transparent url(images/ScreenImages/tab_on_right.png) no-repeat; -} -*/ - -.GUITextBox.container:after {} - -@media screen and (max-device-width: 769px) { - - header #logo img { - max-width: 100%; - padding: 20px; - margin: 40px; - } -} - -@media screen and (max-device-width: 769px) { - - header #logo img { - max-width: 100%; - } - - header #logo img { - min-width: 100%; - } - -} - -td { - margin: 40px; - - padding: 20px; - - -} - -.GUIFileUpload { -/* opacity: 0.25; */ -} - -.foo -{ - border: none; -} - -.mortgage-calculator h2 { - background: #072237; - color: #fff; - font-weight: normal; - height: 50px; - line-height: 50px; - padding: 0 0 0 30px; - } - -.WhitelistCommentIndentationShouldBeIgnored { -/* phpcs:disable Standard.Category.Sniff -- for reasons. */ -} - -/* syntax error */ ---------------------------------------------- */ diff --git a/src/Standards/Squiz/Tests/CSS/IndentationUnitTest.1.css.fixed b/src/Standards/Squiz/Tests/CSS/IndentationUnitTest.1.css.fixed deleted file mode 100644 index 1fd128a5e0..0000000000 --- a/src/Standards/Squiz/Tests/CSS/IndentationUnitTest.1.css.fixed +++ /dev/null @@ -1,73 +0,0 @@ -body { - font-family: Arial, Helvetica, sans-serif; - margin: 40px 0 0 0; - padding: 0; - background: #8FB7DB url(diag_lines_bg.gif) top left; -} - -td { - margin: 40px; - padding: 20px; -} - -/* -#AdminScreenModeWidgetType-tab_pane-containers .TabPaneWidgetType-tab-selected-left { - background: transparent url(images/ScreenImages/tab_on_left.png) no-repeat; -} -#AdminScreenModeWidgetType-tab_pane-containers .TabPaneWidgetType-tab-selected-right { - background: transparent url(images/ScreenImages/tab_on_right.png) no-repeat; -} -*/ - -.GUITextBox.container:after {} - -@media screen and (max-device-width: 769px) { - - header #logo img { - max-width: 100%; - padding: 20px; - margin: 40px; - } -} - -@media screen and (max-device-width: 769px) { - - header #logo img { - max-width: 100%; - } - - header #logo img { - min-width: 100%; - } - -} - -td { - margin: 40px; - padding: 20px; -} - -.GUIFileUpload { -/* opacity: 0.25; */ -} - -.foo -{ - border: none; -} - -.mortgage-calculator h2 { - background: #072237; - color: #fff; - font-weight: normal; - height: 50px; - line-height: 50px; - padding: 0 0 0 30px; -} - -.WhitelistCommentIndentationShouldBeIgnored { -/* phpcs:disable Standard.Category.Sniff -- for reasons. */ -} - -/* syntax error */ ---------------------------------------------- */ diff --git a/src/Standards/Squiz/Tests/CSS/IndentationUnitTest.2.css b/src/Standards/Squiz/Tests/CSS/IndentationUnitTest.2.css deleted file mode 100644 index 48b22f6d4d..0000000000 --- a/src/Standards/Squiz/Tests/CSS/IndentationUnitTest.2.css +++ /dev/null @@ -1,3 +0,0 @@ -/* Live coding. Has to be the last (only) test in the file. */ -.intentional-parse-error { - float: left diff --git a/src/Standards/Squiz/Tests/CSS/IndentationUnitTest.php b/src/Standards/Squiz/Tests/CSS/IndentationUnitTest.php deleted file mode 100644 index fe79ffb3e0..0000000000 --- a/src/Standards/Squiz/Tests/CSS/IndentationUnitTest.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; - -/** - * Unit test class for the Indentation sniff. - * - * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\IndentationSniff - */ -final class IndentationUnitTest extends AbstractSniffUnitTest -{ - - - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @param string $testFile The name of the file being tested. - * - * @return array - */ - public function getErrorList($testFile='') - { - switch ($testFile) { - case 'IndentationUnitTest.1.css': - return [ - 2 => 1, - 3 => 1, - 5 => 1, - 6 => 1, - 7 => 1, - 12 => 1, - 30 => 1, - 32 => 1, - 50 => 1, - 52 => 1, - 53 => 1, - 66 => 1, - 67 => 1, - 68 => 1, - 69 => 1, - 70 => 1, - 71 => 1, - 72 => 1, - ]; - - default: - return []; - }//end switch - - }//end getErrorList() - - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return []; - - }//end getWarningList() - - -}//end class diff --git a/src/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.css b/src/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.css deleted file mode 100644 index d0f2982fbf..0000000000 --- a/src/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.css +++ /dev/null @@ -1,14 +0,0 @@ -.SettingsTabPaneWidgetType-tab-mid { - font-family: Arial; - Font-Family: arial; - background-color: #DA9393; - BACKGROUND-IMAGE: URL(Warning_Close.png); -} - -@media screen and (max-device-width: 769px) { - - .SettingsTabPaneWidgetType-tab-mid { - Font-Family: arial; - filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr=#2e62a8, endColorstr=#123363); - } -} diff --git a/src/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.php b/src/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.php deleted file mode 100644 index c47455a143..0000000000 --- a/src/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; - -/** - * Unit test class for the LowercaseStyleDefinition sniff. - * - * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\LowercaseStyleDefinitionSniff - */ -final class LowercaseStyleDefinitionUnitTest extends AbstractSniffUnitTest -{ - - - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getErrorList() - { - return [ - 2 => 1, - 3 => 1, - 5 => 2, - 11 => 1, - ]; - - }//end getErrorList() - - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return []; - - }//end getWarningList() - - -}//end class diff --git a/src/Standards/Squiz/Tests/CSS/MissingColonUnitTest.css b/src/Standards/Squiz/Tests/CSS/MissingColonUnitTest.css deleted file mode 100644 index 6c947e5b5d..0000000000 --- a/src/Standards/Squiz/Tests/CSS/MissingColonUnitTest.css +++ /dev/null @@ -1,21 +0,0 @@ -.my-style { - margin-right 15px; - float: left; - margin-left 15px; - margin-top: 15px; - margin-bottom 15px; -} - -@media screen and (max-device-width: 769px) { - header #logo img { - max-width: 100%; - margin-bottom 15px; - } -} - -#foo { background-color: #FF0000; -} - -/* Live coding. Has to be the last test in the file. */ -.intentional-parse-error { - float diff --git a/src/Standards/Squiz/Tests/CSS/MissingColonUnitTest.php b/src/Standards/Squiz/Tests/CSS/MissingColonUnitTest.php deleted file mode 100644 index 29e39848b2..0000000000 --- a/src/Standards/Squiz/Tests/CSS/MissingColonUnitTest.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; - -/** - * Unit test class for the MissingColon sniff. - * - * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\MissingColonSniff - */ -final class MissingColonUnitTest extends AbstractSniffUnitTest -{ - - - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getErrorList() - { - return [ - 2 => 1, - 4 => 1, - 6 => 1, - 12 => 1, - ]; - - }//end getErrorList() - - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return []; - - }//end getWarningList() - - -}//end class diff --git a/src/Standards/Squiz/Tests/CSS/NamedColoursUnitTest.css b/src/Standards/Squiz/Tests/CSS/NamedColoursUnitTest.css deleted file mode 100644 index 05637a6023..0000000000 --- a/src/Standards/Squiz/Tests/CSS/NamedColoursUnitTest.css +++ /dev/null @@ -1,25 +0,0 @@ -#red { - background-color: red; -} - -.red { - border-bottom: 1px dotted black; - border-top: 1px dotted gray; -} - -#red.yellow { - background: yellow url(diag_lines_bg.gif) top left; - text-shadow: 0 1px 0 white; -} - -.something--white { - border: 0; -} - -.something--------------white { - border: 0; -} - -.-white { - border: 0; -} diff --git a/src/Standards/Squiz/Tests/CSS/NamedColoursUnitTest.php b/src/Standards/Squiz/Tests/CSS/NamedColoursUnitTest.php deleted file mode 100644 index 90744d3581..0000000000 --- a/src/Standards/Squiz/Tests/CSS/NamedColoursUnitTest.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; - -/** - * Unit test class for the NamedColours sniff. - * - * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\NamedColoursSniff - */ -final class NamedColoursUnitTest extends AbstractSniffUnitTest -{ - - - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getErrorList() - { - return [ - 2 => 1, - 6 => 1, - 7 => 1, - 11 => 1, - 12 => 1, - ]; - - }//end getErrorList() - - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return []; - - }//end getWarningList() - - -}//end class diff --git a/src/Standards/Squiz/Tests/CSS/OpacityUnitTest.css b/src/Standards/Squiz/Tests/CSS/OpacityUnitTest.css deleted file mode 100644 index c656c78eee..0000000000 --- a/src/Standards/Squiz/Tests/CSS/OpacityUnitTest.css +++ /dev/null @@ -1,35 +0,0 @@ -.my-style { - opacity: 0; - opacity: 0.0; - opacity: 1; - opacity: 1.0; - opacity: 1.5; - opacity: .5; - opacity: 0.5; - opacity: 2; - opacity: -1; - opacity: 0.55; -} - -div { - font-size: 1.2em; - background: linear-gradient(to bottom, #00F, #0F0) repeat scroll 50% 50% #EEE; - min-width: 250px; - max-width: 100%; - padding-bottom: 50px; - box-shadow: 2px -3px 3px rgba(100, 100, 100, 0.33); - border-left: 1px solid #000; - border-right: 1px solid #000; - border-top: 1px solid #000; - border-bottom: 1px dotted #000; - background: url(../1/2/3/4-5-6_7_100x100.png) repeat scroll 50% 50% #EEE; - opacity: -1; -} - -.my-commented-style { - opacity: /*comment*/ 0; - opacity: /* phpcs:ignore Standard.Cat.Sniff -- for reasons */ - 0.0; - opacity: /*comment*/ 1.0; - opacity: /*comment*/ .5; -} diff --git a/src/Standards/Squiz/Tests/CSS/OpacityUnitTest.css.fixed b/src/Standards/Squiz/Tests/CSS/OpacityUnitTest.css.fixed deleted file mode 100644 index 257e41a78a..0000000000 --- a/src/Standards/Squiz/Tests/CSS/OpacityUnitTest.css.fixed +++ /dev/null @@ -1,35 +0,0 @@ -.my-style { - opacity: 0; - opacity: 0; - opacity: 1; - opacity: 1; - opacity: 1.5; - opacity: 0.5; - opacity: 0.5; - opacity: 2; - opacity: -1; - opacity: 0.55; -} - -div { - font-size: 1.2em; - background: linear-gradient(to bottom, #00F, #0F0) repeat scroll 50% 50% #EEE; - min-width: 250px; - max-width: 100%; - padding-bottom: 50px; - box-shadow: 2px -3px 3px rgba(100, 100, 100, 0.33); - border-left: 1px solid #000; - border-right: 1px solid #000; - border-top: 1px solid #000; - border-bottom: 1px dotted #000; - background: url(../1/2/3/4-5-6_7_100x100.png) repeat scroll 50% 50% #EEE; - opacity: -1; -} - -.my-commented-style { - opacity: /*comment*/ 0; - opacity: /* phpcs:ignore Standard.Cat.Sniff -- for reasons */ - 0; - opacity: /*comment*/ 1; - opacity: /*comment*/ 0.5; -} diff --git a/src/Standards/Squiz/Tests/CSS/OpacityUnitTest.php b/src/Standards/Squiz/Tests/CSS/OpacityUnitTest.php deleted file mode 100644 index d323477b2d..0000000000 --- a/src/Standards/Squiz/Tests/CSS/OpacityUnitTest.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; - -/** - * Unit test class for the Opacity sniff. - * - * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\OpacitySniff - */ -final class OpacityUnitTest extends AbstractSniffUnitTest -{ - - - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getErrorList() - { - return [ - 3 => 1, - 5 => 1, - 6 => 1, - 7 => 1, - 9 => 1, - 10 => 1, - 11 => 1, - 26 => 1, - 32 => 1, - 33 => 1, - 34 => 1, - ]; - - }//end getErrorList() - - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return []; - - }//end getWarningList() - - -}//end class diff --git a/src/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.css b/src/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.css deleted file mode 100644 index 3ccb162e83..0000000000 --- a/src/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.css +++ /dev/null @@ -1,61 +0,0 @@ -.HelpWidgetType-new-bug-title { - width: 308px - float: left; -} - -#MetadataAdminScreen-addField-add { - float: left ; -} - -.TableWidgetType .recover:hover { - background-color: #FFF; -} - -#clearCache-settings:rootNodes-list_0 { - border-top: none; -} - -.HelpWidgetType-list { - list-style-image: url(); -} - -@media (min-width: 320px) and (max-width: 961px) { - .tooltipsrt:hover span.tltp, - .tooltipstp:hover span.tltp { - visibility: hidden; - } -} - -#single-line-multi-statement-no-semicolon { - padding: 0 border: 20; -} - -#multi-line-style-no-semicolon { - padding: 0 /* phpcs:ignore Standard.Cat.Sniff -- for reasons */ - border: - 20 - margin: - 0px /* top */ - 10px /* right + left */ -} - -#multi-line-style-whitespace { - padding: 0 /* phpcs:ignore Standard.Cat.Sniff -- for reasons */ ; - border: - 20 ; - margin: - 10px /* top */ - 0px /* right + left */ - - - ; -} - -.allow-for-star-hack { - cursor: pointer; - *cursor: hand; -} - -/* Live coding. Has to be the last test in the file. */ -.intentional-parse-error { - float: left diff --git a/src/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.css.fixed b/src/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.css.fixed deleted file mode 100644 index 7efef58820..0000000000 --- a/src/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.css.fixed +++ /dev/null @@ -1,58 +0,0 @@ -.HelpWidgetType-new-bug-title { - width: 308px - float: left; -} - -#MetadataAdminScreen-addField-add { - float: left; -} - -.TableWidgetType .recover:hover { - background-color: #FFF; -} - -#clearCache-settings:rootNodes-list_0 { - border-top: none; -} - -.HelpWidgetType-list { - list-style-image: url(); -} - -@media (min-width: 320px) and (max-width: 961px) { - .tooltipsrt:hover span.tltp, - .tooltipstp:hover span.tltp { - visibility: hidden; - } -} - -#single-line-multi-statement-no-semicolon { - padding: 0 border: 20; -} - -#multi-line-style-no-semicolon { - padding: 0 /* phpcs:ignore Standard.Cat.Sniff -- for reasons */ - border: - 20 - margin: - 0px /* top */ - 10px /* right + left */ -} - -#multi-line-style-whitespace { - padding: 0; /* phpcs:ignore Standard.Cat.Sniff -- for reasons */ - border: - 20; - margin: - 10px /* top */ - 0px; /* right + left */ -} - -.allow-for-star-hack { - cursor: pointer; - *cursor: hand; -} - -/* Live coding. Has to be the last test in the file. */ -.intentional-parse-error { - float: left diff --git a/src/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.php b/src/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.php deleted file mode 100644 index ab2c839beb..0000000000 --- a/src/Standards/Squiz/Tests/CSS/SemicolonSpacingUnitTest.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; - -/** - * Unit test class for the SemicolonSpacing sniff. - * - * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\SemicolonSpacingSniff - */ -final class SemicolonSpacingUnitTest extends AbstractSniffUnitTest -{ - - - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getErrorList() - { - return [ - 2 => 1, - 7 => 1, - 30 => 1, - 34 => 1, - 36 => 1, - 39 => 1, - 43 => 1, - 45 => 1, - 48 => 1, - ]; - - }//end getErrorList() - - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return []; - - }//end getWarningList() - - -}//end class diff --git a/src/Standards/Squiz/Tests/CSS/ShorthandSizeUnitTest.1.css b/src/Standards/Squiz/Tests/CSS/ShorthandSizeUnitTest.1.css deleted file mode 100644 index c3d07ef5c4..0000000000 --- a/src/Standards/Squiz/Tests/CSS/ShorthandSizeUnitTest.1.css +++ /dev/null @@ -1,41 +0,0 @@ -#add-new-comment { - background-color: #333333; - padding: 10px; - border-bottom: 1px dotted #F0F0F0; - border-top: 1px dotted #FF00FF; - background: #8fb7db url(diag_lines_bg.gif) top left; - tab-size: 1; - margin: 8px 8px 8px 8px; - margin: 8px 8px; - margin: 0 0 0 0; - margin: 0 8px 0 8px; - margin: 8px 4px 8px 4px; - margin: 8px 4% 8px 4%; - margin: 6px 2px 9px 2px; - margin: 6px 2px 9px; - border-radius: 2px 2px 2px 2px !important; - border-width: 2px 2px 2px 2px; - border-width: 1px 2px 2px 4px; - margin: 97px auto 0 auto; - text-shadow: 0 1px 0 #fff; - border-width: - 2px - 4px - 2px - 4px; - - /* These are style names excluded from this rule. */ - background-position: 0 0; - box-shadow: 2px 2px 2px 2px; - transform-origin: 0 110% 0; - - /* Sizes with comments between them will be ignored for the purposes of this sniff. */ - margin: 8px /*top*/ 8px /*right*/ 8px /*bottom*/ 8px /*left*/; - - /* Same with PHPCS annotations. */ - border-width: - 2px /* phpcs:ignore Standard.Category.SniffName -- for reasons */ - 4px - 2px /* phpcs:disable Standard.Category.SniffName -- for reasons */ - 4px; -} diff --git a/src/Standards/Squiz/Tests/CSS/ShorthandSizeUnitTest.1.css.fixed b/src/Standards/Squiz/Tests/CSS/ShorthandSizeUnitTest.1.css.fixed deleted file mode 100644 index 36297dd60d..0000000000 --- a/src/Standards/Squiz/Tests/CSS/ShorthandSizeUnitTest.1.css.fixed +++ /dev/null @@ -1,37 +0,0 @@ -#add-new-comment { - background-color: #333333; - padding: 10px; - border-bottom: 1px dotted #F0F0F0; - border-top: 1px dotted #FF00FF; - background: #8fb7db url(diag_lines_bg.gif) top left; - tab-size: 1; - margin: 8px; - margin: 8px; - margin: 0; - margin: 0 8px; - margin: 8px 4px; - margin: 8px 4%; - margin: 6px 2px 9px 2px; - margin: 6px 2px 9px 2px; - border-radius: 2px !important; - border-width: 2px; - border-width: 1px 2px 2px 4px; - margin: 97px auto 0 auto; - text-shadow: 0 1px 0 #fff; - border-width: 2px 4px; - - /* These are style names excluded from this rule. */ - background-position: 0 0; - box-shadow: 2px 2px 2px 2px; - transform-origin: 0 110% 0; - - /* Sizes with comments between them will be ignored for the purposes of this sniff. */ - margin: 8px /*top*/ 8px /*right*/ 8px /*bottom*/ 8px /*left*/; - - /* Same with PHPCS annotations. */ - border-width: - 2px /* phpcs:ignore Standard.Category.SniffName -- for reasons */ - 4px - 2px /* phpcs:disable Standard.Category.SniffName -- for reasons */ - 4px; -} diff --git a/src/Standards/Squiz/Tests/CSS/ShorthandSizeUnitTest.2.css b/src/Standards/Squiz/Tests/CSS/ShorthandSizeUnitTest.2.css deleted file mode 100644 index 2a91cf71a3..0000000000 --- a/src/Standards/Squiz/Tests/CSS/ShorthandSizeUnitTest.2.css +++ /dev/null @@ -1,3 +0,0 @@ -/* Intentional parse error. Live coding resilience. */ -#live-coding { - margin: 8px 8px 8px 8px diff --git a/src/Standards/Squiz/Tests/CSS/ShorthandSizeUnitTest.php b/src/Standards/Squiz/Tests/CSS/ShorthandSizeUnitTest.php deleted file mode 100644 index 7394b77c2f..0000000000 --- a/src/Standards/Squiz/Tests/CSS/ShorthandSizeUnitTest.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Tests\CSS; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; - -/** - * Unit test class for the ShorthandSize sniff. - * - * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\ShorthandSizeSniff - */ -final class ShorthandSizeUnitTest extends AbstractSniffUnitTest -{ - - - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @param string $testFile The name of the file being tested. - * - * @return array - */ - public function getErrorList($testFile='') - { - switch ($testFile) { - case 'ShorthandSizeUnitTest.1.css': - return [ - 8 => 1, - 9 => 1, - 10 => 1, - 11 => 1, - 12 => 1, - 13 => 1, - 15 => 1, - 16 => 1, - 17 => 1, - 21 => 1, - ]; - - default: - return []; - }//end switch - - }//end getErrorList() - - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return []; - - }//end getWarningList() - - -}//end class diff --git a/src/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.js b/src/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.js deleted file mode 100644 index 04126f86ab..0000000000 --- a/src/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.js +++ /dev/null @@ -1,45 +0,0 @@ -var x = { - abc: 1, - zyz: 2, - abc: 5, - mno: { - abc: 4 - }, - abc: 5 - - this.request({ - action: 'getSubmissions' - }); - - this.request({ - action: 'deleteSubmission' - }); -} - - -LinkingEditScreenWidgetType.prototype = { - - _addDeleteButtonEvent: function(parentid) - { - var params = { - screen: 'LinkingEditScreenWidget', - assetid: self.assetid, - parentid: parentid, - assetid: parentid, - op: 'deleteLink' - }; - - }, - - saveDesignEdit: function() - { - var params = { - screen: [this.id, 'Widget'].join(''), - assetid: this.assetid, - changes: dfx.jsonEncode(this.currnetLinksWdgt.getChanges()), - op: 'saveLinkEdit' - }; - - } - -}; \ No newline at end of file diff --git a/src/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.php b/src/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.php deleted file mode 100644 index 567a89cc29..0000000000 --- a/src/Standards/Squiz/Tests/Classes/DuplicatePropertyUnitTest.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Tests\Classes; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; - -/** - * Unit test class for the DuplicateProperty sniff. - * - * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes\DuplicatePropertySniff - */ -final class DuplicatePropertyUnitTest extends AbstractSniffUnitTest -{ - - - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getErrorList() - { - return [ - 4 => 1, - 8 => 1, - 28 => 1, - ]; - - }//end getErrorList() - - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return []; - - }//end getWarningList() - - -}//end class diff --git a/src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.js b/src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.js deleted file mode 100644 index 6e1a878127..0000000000 --- a/src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.js +++ /dev/null @@ -1,76 +0,0 @@ - -/** -* Some info about the class here - * - */ -foo.prototype = { - - /** - * Some info about the function here. - * - *@return void - */ - bar: function() {} -} - -/** - * Some info about the class here - * - */ -foo.prototype = { - - /** - *Some info about the function here. - * - * @return void - */ - bar: function() {} -} - -/** - * Some info about the class here - * -*/ -foo.prototype = { - - /** - * Some info about the function here. - * - * @return void - */ - bar: function() {} -} - -/** @var Database $mockedDatabase */ -/** @var Container $mockedContainer */ - -function myFunction() -{ - console.info('hi'); - /** - Comment here. - */ -} - -/** - * Creates a map of tokens => line numbers for each token. - * - * Long description with some points: - * - one - * - two - * - three - * - * @param array &$tokens The array of tokens to process. - * @param object $tokenizer The tokenizer being used to - * process this file. - * @param string $eolChar The EOL character to use for splitting strings. - * - * @return void - */ -function myFunction() {} - -$.extend(Datepicker.prototype, { - _widgetDatepicker: function() { - }, - /* Action for selecting a new month/year. */ -}); diff --git a/src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.js.fixed b/src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.js.fixed deleted file mode 100644 index 9edb4ccc6d..0000000000 --- a/src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.js.fixed +++ /dev/null @@ -1,76 +0,0 @@ - -/** - * Some info about the class here - * - */ -foo.prototype = { - - /** - * Some info about the function here. - * - * @return void - */ - bar: function() {} -} - -/** - * Some info about the class here - * - */ -foo.prototype = { - - /** - * Some info about the function here. - * - * @return void - */ - bar: function() {} -} - -/** - * Some info about the class here - * - */ -foo.prototype = { - - /** - * Some info about the function here. - * - * @return void - */ - bar: function() {} -} - -/** @var Database $mockedDatabase */ -/** @var Container $mockedContainer */ - -function myFunction() -{ - console.info('hi'); - /** - Comment here. - */ -} - -/** - * Creates a map of tokens => line numbers for each token. - * - * Long description with some points: - * - one - * - two - * - three - * - * @param array &$tokens The array of tokens to process. - * @param object $tokenizer The tokenizer being used to - * process this file. - * @param string $eolChar The EOL character to use for splitting strings. - * - * @return void - */ -function myFunction() {} - -$.extend(Datepicker.prototype, { - _widgetDatepicker: function() { - }, - /* Action for selecting a new month/year. */ -}); diff --git a/src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php index eb9d7543e6..56e217045b 100644 --- a/src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/DocCommentAlignmentUnitTest.php @@ -26,47 +26,39 @@ final class DocCommentAlignmentUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * - * @param string $testFile The name of the file being tested. - * * @return array */ - public function getErrorList($testFile='') + public function getErrorList() { - $errors = [ - 3 => 1, - 11 => 1, - 17 => 1, - 18 => 1, - 19 => 1, - 23 => 2, - 24 => 1, - 25 => 2, - 26 => 1, - 32 => 1, - 33 => 1, - 38 => 1, - 39 => 1, + return [ + 3 => 1, + 11 => 1, + 17 => 1, + 18 => 1, + 19 => 1, + 23 => 2, + 24 => 1, + 25 => 2, + 26 => 1, + 32 => 1, + 33 => 1, + 38 => 1, + 39 => 1, + 75 => 1, + 83 => 1, + 84 => 1, + 90 => 1, + 91 => 1, + 95 => 1, + 96 => 1, + 106 => 1, + 107 => 1, + 111 => 2, + 112 => 1, + 113 => 1, + 114 => 1, ]; - if ($testFile === 'DocCommentAlignmentUnitTest.inc') { - $errors[75] = 1; - $errors[83] = 1; - $errors[84] = 1; - $errors[90] = 1; - $errors[91] = 1; - $errors[95] = 1; - $errors[96] = 1; - - $errors[106] = 1; - $errors[107] = 1; - $errors[111] = 2; - $errors[112] = 1; - $errors[113] = 1; - $errors[114] = 1; - } - - return $errors; - }//end getErrorList() diff --git a/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.1.js b/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.1.js deleted file mode 100644 index 57d8d37a68..0000000000 --- a/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.1.js +++ /dev/null @@ -1,40 +0,0 @@ - - - - -/** -* -* 0Multi-line short description without full stop -* -* -* asdasd -* long description for file (if any) -* asdasdadada -* -* PHP versio -* -* LICENSE: This source file is subject to version 3.0 of the PHP license -* that is available through the world-wide-web at the following URI: -* http://www.php.net/license/3_0.txt. If you did not receive a copy of -* the PHP License and are unable to obtain it through the web, please -* send a note to license@php.net so we can mail you a copy immediately. -* @package SquizCMS -* @package ADDITIONAL PACKAGE TAG -* @subpkg not_camelcased -* @author Antônio Carlos Venâncio Júnior -* @author -* @copyright 1997~1994 The PHP Group -* @copyright 1994-1997 The PHP Group -* @copyright The PHP Group -* @license http://www.php.net/license/3_0.txt -* @summary An unknown summary tag -* -*/ - - -/** -* This bit here is not qualified as file comment -* -* as it is not the first comment in the file -* -*/ diff --git a/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.1.js.fixed b/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.1.js.fixed deleted file mode 100644 index 44ff449ac3..0000000000 --- a/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.1.js.fixed +++ /dev/null @@ -1,40 +0,0 @@ - - - - -/** -* -* 0Multi-line short description without full stop -* -* -* asdasd -* long description for file (if any) -* asdasdadada -* -* PHP versio -* -* LICENSE: This source file is subject to version 3.0 of the PHP license -* that is available through the world-wide-web at the following URI: -* http://www.php.net/license/3_0.txt. If you did not receive a copy of -* the PHP License and are unable to obtain it through the web, please -* send a note to license@php.net so we can mail you a copy immediately. -* @package SquizCMS -* @package ADDITIONAL PACKAGE TAG -* @subpkg not_camelcased -* @author Squiz Pty Ltd -* @author -* @copyright 1997 Squiz Pty Ltd (ABN 77 084 670 600) -* @copyright 1994-1997 Squiz Pty Ltd (ABN 77 084 670 600) -* @copyright 2025 Squiz Pty Ltd (ABN 77 084 670 600) -* @license http://www.php.net/license/3_0.txt -* @summary An unknown summary tag -* -*/ - - -/** -* This bit here is not qualified as file comment -* -* as it is not the first comment in the file -* -*/ diff --git a/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.2.js b/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.2.js deleted file mode 100644 index 4bb4d50d6e..0000000000 --- a/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.2.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * File comment. - * - * @package Package - * @subpackage Subpackage - * @author Squiz Pty Ltd - * @copyright 2010-2014 Squiz Pty Ltd (ABN 77 084 670 600) - */ - -print 'hi'; \ No newline at end of file diff --git a/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php index d5816bff47..98e38ced87 100644 --- a/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php @@ -34,7 +34,6 @@ public function getErrorList($testFile='') { switch ($testFile) { case 'FileCommentUnitTest.1.inc': - case 'FileCommentUnitTest.1.js': return [ 1 => 1, 22 => 2, diff --git a/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.js b/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.js deleted file mode 100644 index 6b1093e6ac..0000000000 --- a/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.js +++ /dev/null @@ -1,129 +0,0 @@ -// Some content here. -var code = 'hello'; - -// This comment contains # multiple -// hash signs (#). -code = 'hello'; - -/** - * This is the first line of a function comment. - * This is the second line. - */ -function testFunction() -{ - // Callback methods which are added by external objects. - this.callbacks = {}; - -}//end testFunction() - -/** - * This is the first line of a class comment. - * This is the second line. - */ -myClass.prototype = { - - /** - * This is the first line of a method comment. - * This is the second line. - */ - load: function(url, callback) - { - // Some code here. - - } -}; - -// some code goes here! - -/* - A longer comment goes here. - It spans multiple lines!! - Or does it? -*/ - -// 0This is a simple multi-line -// comment! -code = 'hello'; - -//This is not valid. -code = 'hello'; - -// Neither is this! -code = 'hello'; - -// -code = 'hello'; - -/** Neither is this! **/ -code = 'hello'; - -/** - * This is the first line of a function comment. - * This is the second line. - */ -var myFunction = function() { -} - -/** - * This is the first line of a function comment. - * This is the second line. - */ -myFunction = function() { -} - -/** - * This is the first line of a function comment. - * This is the second line. - */ -myClass.myFunction = function() { -} - -dfx.getIframeDocument = function(iframe) -{ - return doc; - -};//end dfx.getIframeDocument() - -mig.Gallery.prototype = { - - init: function(cb) - { - - },//end init() - - imageClicked: function(id) - { - - }//end imageClicked() - -}; - -// Here is some inline example code: -// -> One -// -> One.One -// -> Two - -/* - Here is some inline example code: - -> One - -> One.One - -> Two -*/ - - -var foo = 'foo'; // Var set to foo. - -console.info(foo); - -// Comment here. -console.info(foo); - -//** -* invalid comment -*/ - -// some comment without capital or full stop -console.log(foo); // An unrelated comment. - -// An unrelated comment. -console.log(foo); // some comment without capital or full stop diff --git a/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.js.fixed b/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.js.fixed deleted file mode 100644 index 20e5041e68..0000000000 --- a/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.js.fixed +++ /dev/null @@ -1,125 +0,0 @@ -// Some content here. -var code = 'hello'; - -// This comment contains # multiple -// hash signs (#). -code = 'hello'; - -/** - * This is the first line of a function comment. - * This is the second line. - */ -function testFunction() -{ - // Callback methods which are added by external objects. - this.callbacks = {}; - -}//end testFunction() - -/** - * This is the first line of a class comment. - * This is the second line. - */ -myClass.prototype = { - - /** - * This is the first line of a method comment. - * This is the second line. - */ - load: function(url, callback) - { - // Some code here. - } -}; - -// some code goes here! -/* - A longer comment goes here. - It spans multiple lines!! - Or does it? -*/ - -// 0This is a simple multi-line -// comment! -code = 'hello'; - -// This is not valid. -code = 'hello'; - -// Neither is this! -code = 'hello'; - -code = 'hello'; - -/** Neither is this! **/ -code = 'hello'; - -/** - * This is the first line of a function comment. - * This is the second line. - */ -var myFunction = function() { -} - -/** - * This is the first line of a function comment. - * This is the second line. - */ -myFunction = function() { -} - -/** - * This is the first line of a function comment. - * This is the second line. - */ -myClass.myFunction = function() { -} - -dfx.getIframeDocument = function(iframe) -{ - return doc; - -};//end dfx.getIframeDocument() - -mig.Gallery.prototype = { - - init: function(cb) - { - - },//end init() - - imageClicked: function(id) - { - - }//end imageClicked() - -}; - -// Here is some inline example code: -// -> One -// -> One.One -// -> Two -/* - Here is some inline example code: - -> One - -> One.One - -> Two -*/ - - -var foo = 'foo'; // Var set to foo. - -console.info(foo); - -// Comment here. -console.info(foo); - -// ** -* invalid comment -*/ - -// some comment without capital or full stop -console.log(foo); // An unrelated comment. - -// An unrelated comment. -console.log(foo); // some comment without capital or full stop diff --git a/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php index a2bbc4eb61..b1fdef8938 100644 --- a/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.php @@ -26,55 +26,30 @@ final class InlineCommentUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * - * @param string $testFile The name of the file being tested. - * * @return array */ - public function getErrorList($testFile='') + public function getErrorList() { - switch ($testFile) { - case 'InlineCommentUnitTest.inc': - $errors = [ - 17 => 1, - 27 => 1, - 28 => 1, - 32 => 2, - 36 => 1, - 44 => 2, - 58 => 1, - 61 => 1, - 64 => 1, - 67 => 1, - 95 => 1, - 96 => 1, - 97 => 3, - 118 => 1, - 126 => 2, - 130 => 2, - 149 => 1, - 189 => 1, - ]; - - return $errors; - case 'InlineCommentUnitTest.js': - return [ - 31 => 1, - 36 => 2, - 48 => 1, - 51 => 1, - 54 => 1, - 57 => 1, - 102 => 1, - 103 => 1, - 104 => 3, - 118 => 1, - 121 => 1, - 125 => 2, - 129 => 2, - ]; - default: - return []; - }//end switch + return [ + 17 => 1, + 27 => 1, + 28 => 1, + 32 => 2, + 36 => 1, + 44 => 2, + 58 => 1, + 61 => 1, + 64 => 1, + 67 => 1, + 95 => 1, + 96 => 1, + 97 => 3, + 118 => 1, + 126 => 2, + 130 => 2, + 149 => 1, + 189 => 1, + ]; }//end getErrorList() diff --git a/src/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.js b/src/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.js deleted file mode 100644 index c0cf2821d3..0000000000 --- a/src/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.js +++ /dev/null @@ -1,444 +0,0 @@ -function long_function() -{ - if (longFunction) { - // This is a long - // IF statement - // that does - // not have - // an ELSE - // block on it - variable = 'hello'; - - if (variable === 'hello') { - // This is a short - // IF statement - } - - if (variable === 'hello') { - // This is a short - // IF statement - } else { - // This is a short ELSE - // statement - } - }//end if - - if (longFunction) { - // This is a long - // IF statement - // that does - // not have - // an ELSE - // block on it - variable = 'hello'; - - if (variable === 'hello') { - // This is a short - // IF statement - } - - if (variable === 'hello') { - // This is a short - // IF statement - } else { - // This is a short ELSE - // statement - } - } - - if (longFunction) { - // This is a long - // IF statement - // that does - // not have - // an ELSE - // block on it - variable = 'hello'; - - if (variable === 'hello') { - // This is a short - // IF statement - } - - if (variable === 'hello') { - // This is a short - // IF statement - } else { - // This is a short ELSE - // statement - } - } else { - // Short ELSE - }//end if - - if (longFunction) { - // This is a long - // IF statement - // that does - // not have - // an ELSE - // block on it - variable = 'hello'; - - if (variable === 'hello') { - // This is a short - // IF statement - } - - if (variable === 'hello') { - // This is a short - // IF statement - } else { - // This is a short ELSE - // statement - } - } else { - // Short ELSE - } -} - -for (variable=1; variable < 20; variable++) { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - // Line 10 - // Line 11 - // Line 12 - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -}//end for - -for (variable=1; variable < 20; variable++) { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - for (val =1; val < 20; val++) { - // Short for. - } - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -} - -while (variable < 20) { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - // Line 10 - // Line 11 - // Line 12 - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -}//end while - -while (variable < 20) { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - while (something) { - // Short while. - } - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -} - -if (longFunction) { - // This is a long - // IF statement - // that does - // not have - // an ELSE - // block on it - variable = 'hello'; - - if (variable === 'hello') { - // This is a short - // IF statement - } - - if (variable === 'hello') { - // This is a short - // IF statement - } else { - // This is a short ELSE - // statement - } -} //end if - -if (longFunction) { - // This is a long - // IF statement - // that does - // not have - // an ELSE - // block on it - variable = 'hello'; - - if (variable === 'hello') { - // This is a short - // IF statement - } - - if (variable === 'hello') { - // This is a short - // IF statement - } else { - // This is a short ELSE - // statement - } -} else { - // Short ELSE -} //end if - -for (variable=1; variable < 20; variable++) { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - // Line 10 - // Line 11 - // Line 12 - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -} //end for - -while (variable < 20) { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - // Line 10 - // Line 11 - // Line 12 - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -} //end while - -while (variable < 20) { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - // Line 10 - // Line 11 - // Line 12 - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -}//end for - -if (true) { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - // Line 10 - // Line 11 - // Line 12 - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -} else if (condition) { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - // Line 10 - // Line 11 - // Line 12 - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -} else { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - // Line 10 - // Line 11 - // Line 12 - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -}//end if - -if (something) { - // Line 1 - // Line 2 -} else if (somethingElse) { - // Line 1 - // Line 2 -} else { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - // Line 10 - // Line 11 - // Line 12 - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -} - -switch (something) { - case '1': - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - break; - case '2': - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - break; - case '3': - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - break; - case '4': - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - break; - case '5': - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - break; -} - -// Wrong comment -if (condition) { - condition = true; -}//end foreach diff --git a/src/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.js.fixed b/src/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.js.fixed deleted file mode 100644 index 231b51c5cb..0000000000 --- a/src/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.js.fixed +++ /dev/null @@ -1,444 +0,0 @@ -function long_function() -{ - if (longFunction) { - // This is a long - // IF statement - // that does - // not have - // an ELSE - // block on it - variable = 'hello'; - - if (variable === 'hello') { - // This is a short - // IF statement - } - - if (variable === 'hello') { - // This is a short - // IF statement - } else { - // This is a short ELSE - // statement - } - }//end if - - if (longFunction) { - // This is a long - // IF statement - // that does - // not have - // an ELSE - // block on it - variable = 'hello'; - - if (variable === 'hello') { - // This is a short - // IF statement - } - - if (variable === 'hello') { - // This is a short - // IF statement - } else { - // This is a short ELSE - // statement - } - }//end if - - if (longFunction) { - // This is a long - // IF statement - // that does - // not have - // an ELSE - // block on it - variable = 'hello'; - - if (variable === 'hello') { - // This is a short - // IF statement - } - - if (variable === 'hello') { - // This is a short - // IF statement - } else { - // This is a short ELSE - // statement - } - } else { - // Short ELSE - }//end if - - if (longFunction) { - // This is a long - // IF statement - // that does - // not have - // an ELSE - // block on it - variable = 'hello'; - - if (variable === 'hello') { - // This is a short - // IF statement - } - - if (variable === 'hello') { - // This is a short - // IF statement - } else { - // This is a short ELSE - // statement - } - } else { - // Short ELSE - }//end if -} - -for (variable=1; variable < 20; variable++) { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - // Line 10 - // Line 11 - // Line 12 - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -}//end for - -for (variable=1; variable < 20; variable++) { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - for (val =1; val < 20; val++) { - // Short for. - } - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -}//end for - -while (variable < 20) { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - // Line 10 - // Line 11 - // Line 12 - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -}//end while - -while (variable < 20) { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - while (something) { - // Short while. - } - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -}//end while - -if (longFunction) { - // This is a long - // IF statement - // that does - // not have - // an ELSE - // block on it - variable = 'hello'; - - if (variable === 'hello') { - // This is a short - // IF statement - } - - if (variable === 'hello') { - // This is a short - // IF statement - } else { - // This is a short ELSE - // statement - } -} //end if - -if (longFunction) { - // This is a long - // IF statement - // that does - // not have - // an ELSE - // block on it - variable = 'hello'; - - if (variable === 'hello') { - // This is a short - // IF statement - } - - if (variable === 'hello') { - // This is a short - // IF statement - } else { - // This is a short ELSE - // statement - } -} else { - // Short ELSE -} //end if - -for (variable=1; variable < 20; variable++) { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - // Line 10 - // Line 11 - // Line 12 - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -} //end for - -while (variable < 20) { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - // Line 10 - // Line 11 - // Line 12 - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -} //end while - -while (variable < 20) { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - // Line 10 - // Line 11 - // Line 12 - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -}//end while - -if (true) { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - // Line 10 - // Line 11 - // Line 12 - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -} else if (condition) { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - // Line 10 - // Line 11 - // Line 12 - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -} else { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - // Line 10 - // Line 11 - // Line 12 - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -}//end if - -if (something) { - // Line 1 - // Line 2 -} else if (somethingElse) { - // Line 1 - // Line 2 -} else { - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - // Line 6 - // Line 7 - // Line 8 - // Line 9 - // Line 10 - // Line 11 - // Line 12 - // Line 13 - // Line 14 - // Line 15 - // Line 16 - // Line 17 - // Line 18 - // Line 19 - // Line 20 -}//end if - -switch (something) { - case '1': - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - break; - case '2': - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - break; - case '3': - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - break; - case '4': - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - break; - case '5': - // Line 1 - // Line 2 - // Line 3 - // Line 4 - // Line 5 - break; -}//end switch - -// Wrong comment -if (condition) { - condition = true; -}//end if diff --git a/src/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php index e2a0f7b00c..206b31c9a9 100644 --- a/src/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/LongConditionClosingCommentUnitTest.php @@ -26,65 +26,41 @@ final class LongConditionClosingCommentUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * - * @param string $testFile The name of the file being tested. - * * @return array */ - public function getErrorList($testFile='') + public function getErrorList() { - switch ($testFile) { - case 'LongConditionClosingCommentUnitTest.inc': - return [ - 49 => 1, - 99 => 1, - 146 => 1, - 192 => 1, - 215 => 1, - 238 => 1, - 261 => 1, - 286 => 1, - 309 => 1, - 332 => 1, - 355 => 1, - 378 => 1, - 493 => 1, - 531 => 1, - 536 => 1, - 540 => 1, - 562 => 1, - 601 => 1, - 629 => 1, - 663 => 1, - 765 => 1, - 798 => 1, - 811 => 1, - 897 => 1, - 931 => 1, - 962 => 1, - 985 => 2, - 1008 => 1, - 1032 => 1, - ]; - - case 'LongConditionClosingCommentUnitTest.js': - return [ - 47 => 1, - 97 => 1, - 144 => 1, - 190 => 1, - 213 => 1, - 238 => 1, - 261 => 1, - 284 => 1, - 307 => 1, - 401 => 1, - 439 => 1, - 444 => 1, - ]; - - default: - return []; - }//end switch + return [ + 49 => 1, + 99 => 1, + 146 => 1, + 192 => 1, + 215 => 1, + 238 => 1, + 261 => 1, + 286 => 1, + 309 => 1, + 332 => 1, + 355 => 1, + 378 => 1, + 493 => 1, + 531 => 1, + 536 => 1, + 540 => 1, + 562 => 1, + 601 => 1, + 629 => 1, + 663 => 1, + 765 => 1, + 798 => 1, + 811 => 1, + 897 => 1, + 931 => 1, + 962 => 1, + 985 => 2, + 1008 => 1, + 1032 => 1, + ]; }//end getErrorList() diff --git a/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.1.js b/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.1.js deleted file mode 100644 index 6de6421073..0000000000 --- a/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.1.js +++ /dev/null @@ -1,36 +0,0 @@ -function test(id, buttons) // cool function -{ - alert('hello'); - alert('hello again'); // And again. - // Valid comment. - -}//end test() - -var good = true; // Indeed. - -mig.Gallery.prototype = { - - init: function(cb) - { - - },//end init() - - imageClicked: function(id) - { - - }//end imageClicked() - -}; - -dfx.getIframeDocument = function(iframe) -{ - - return doc; - -};//end dfx.getIframeDocument() - -// Verify that multi-line control structure with comments and annotations are left alone. -if (condition // comment - && anotherCondition) { - condition = true; -} diff --git a/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.1.js.fixed b/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.1.js.fixed deleted file mode 100644 index 1953760da5..0000000000 --- a/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.1.js.fixed +++ /dev/null @@ -1,39 +0,0 @@ -function test(id, buttons) -// cool function -{ - alert('hello'); - alert('hello again'); -// And again. - // Valid comment. - -}//end test() - -var good = true; -// Indeed. - -mig.Gallery.prototype = { - - init: function(cb) - { - - },//end init() - - imageClicked: function(id) - { - - }//end imageClicked() - -}; - -dfx.getIframeDocument = function(iframe) -{ - - return doc; - -};//end dfx.getIframeDocument() - -// Verify that multi-line control structure with comments and annotations are left alone. -if (condition // comment - && anotherCondition) { - condition = true; -} diff --git a/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.2.js b/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.2.js deleted file mode 100644 index 88d0e7d442..0000000000 --- a/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.2.js +++ /dev/null @@ -1,2 +0,0 @@ -// Comment as first thing in a JS file. -var i = 100; diff --git a/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php index ba3b1c7222..192b5e00e9 100644 --- a/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php @@ -26,38 +26,23 @@ final class PostStatementCommentUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * - * @param string $testFile The name of the file being tested. - * * @return array */ - public function getErrorList($testFile='') + public function getErrorList() { - switch ($testFile) { - case 'PostStatementCommentUnitTest.inc': - return [ - 6 => 1, - 10 => 1, - 18 => 1, - 35 => 1, - 53 => 1, - 57 => 1, - 58 => 1, - 59 => 1, - 60 => 1, - 63 => 1, - 64 => 1, - ]; - - case 'PostStatementCommentUnitTest.1.js': - return [ - 1 => 1, - 4 => 1, - 9 => 1, - ]; - - default: - return []; - }//end switch + return [ + 6 => 1, + 10 => 1, + 18 => 1, + 35 => 1, + 53 => 1, + 57 => 1, + 58 => 1, + 59 => 1, + 60 => 1, + 63 => 1, + 64 => 1, + ]; }//end getErrorList() diff --git a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.js b/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.js deleted file mode 100644 index 6c2e9ffe05..0000000000 --- a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.js +++ /dev/null @@ -1,135 +0,0 @@ - -i = 0; -do { - i = 0; -} while (i > 0); - -do -{ - i = 0; -} while (i > 0); - -do -{ - i = 0; -} -while (i > 0); - -do { i = 0; } while (i > 0); - -do{ - i = 0; -}while(i > 0); - -while (i < 1) { - i = 0; -} - -while(i < 1){ - i = 0; -} - -while (i < 1) { i = 0; } - -for (i = 1; i < 1; i++) { - i = 0; -} - -for(i = 1; i < 1; i++){ - i = 0; -} - -for (i = 1; i < 1; i++) { i = 0; } - -if (i == 0) { - i = 1; -} - -if(i == 0){ - i = 1; -} - -if (i == 0) { i = 1; } - -if (i == 0) { - i = 1; -} else { - i = 0; -} - -if (i == 0) { - i = 1; -}else{ - i = 0; -} - -if (i == 0) { i = 1; } else { i = 0; } - -if (i == 0) { - i = 1; -} else if (i == 2) { - i = 0; -} - -if (i == 0) { - i = 1; -}else if(i == 2){ - i = 0; -} - -if (i == 0) { i = 1; } else if (i == 2) { i = 0; } - -if (i == 0) { // comments are allowed - i = 1; -} - -if (i == 0) {// comments are allowed - i = 1; -} - -if (i == 0) { /* comments are allowed*/ - i = 1; -} - -if (i == 0) -{ // this is ok - i = 1; -} - -if (i == 0) /* this is ok */ { -} - -try { - code = 'this'; -} catch (e) { - // Caught! -} - -try { code = 'this'; } catch (e) { - // Caught! -} - -do { i = 0; -} while (i > 0); - -if (i === 0) { - - i = 1 -} - -if (window.jQuery)(function($) { - $.fn.reset = function() { - return this.each(function() { - try { - this.reset(); - } catch (e) { - } - }); - }; -})(jQuery); - -if ($("#myid").rotationDegrees()=='90') - $('.modal').css({'transform': 'rotate(90deg)'}); - -if ($("#myid").rotationDegrees()=='90') - $foo = {'transform': 'rotate(90deg)'}; diff --git a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.js.fixed b/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.js.fixed deleted file mode 100644 index e3ed6de742..0000000000 --- a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.js.fixed +++ /dev/null @@ -1,141 +0,0 @@ - -i = 0; -do { - i = 0; -} while (i > 0); - -do { - i = 0; -} while (i > 0); - -do { - i = 0; -} while (i > 0); - -do { -i = 0; } while (i > 0); - -do { - i = 0; -} while (i > 0); - -while (i < 1) { - i = 0; -} - -while (i < 1) { - i = 0; -} - -while (i < 1) { -i = 0; } - -for (i = 1; i < 1; i++) { - i = 0; -} - -for (i = 1; i < 1; i++) { - i = 0; -} - -for (i = 1; i < 1; i++) { -i = 0; } - -if (i == 0) { - i = 1; -} - -if (i == 0) { - i = 1; -} - -if (i == 0) { -i = 1; } - -if (i == 0) { - i = 1; -} else { - i = 0; -} - -if (i == 0) { - i = 1; -} else { - i = 0; -} - -if (i == 0) { -i = 1; } else { -i = 0; } - -if (i == 0) { - i = 1; -} else if (i == 2) { - i = 0; -} - -if (i == 0) { - i = 1; -} else if (i == 2) { - i = 0; -} - -if (i == 0) { -i = 1; } else if (i == 2) { -i = 0; } - -if (i == 0) { // comments are allowed - i = 1; -} - -if (i == 0) {// comments are allowed - i = 1; -} - -if (i == 0) { /* comments are allowed*/ - i = 1; -} - -if (i == 0) { // this is ok - i = 1; -} - -if (i == 0) { /* this is ok */ -} - -try { - code = 'this'; -} catch (e) { - // Caught! -} - -try { -code = 'this'; } catch (e) { - // Caught! -} - -do { -i = 0; -} while (i > 0); - -if (i === 0) { - - i = 1 -} - -if (window.jQuery)(function($) { - $.fn.reset = function() { - return this.each(function() { - try { - this.reset(); - } catch (e) { - } - }); - }; -})(jQuery); - -if ($("#myid").rotationDegrees()=='90') - $('.modal').css({'transform': 'rotate(90deg)'}); - -if ($("#myid").rotationDegrees()=='90') - $foo = {'transform': 'rotate(90deg)'}; diff --git a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php index f6db4b19a0..bd6b5cba9c 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php @@ -32,63 +32,59 @@ final class ControlSignatureUnitTest extends AbstractSniffUnitTest */ public function getErrorList($testFile='') { - $errors = [ - 7 => 1, - 12 => 1, - 15 => 1, - 18 => 1, - 20 => 1, - 22 => 2, - 28 => 2, - 32 => 1, - 38 => 2, - 42 => 1, - 48 => 2, - 52 => 1, - 62 => 2, - 66 => 2, - 76 => 4, - 80 => 2, - 94 => 1, - 99 => 1, - 108 => 1, - 112 => 1, - ]; switch ($testFile) { case 'ControlSignatureUnitTest.1.inc': - $errors[122] = 1; - $errors[130] = 2; - $errors[134] = 1; - $errors[150] = 1; - $errors[153] = 1; - $errors[158] = 1; - $errors[165] = 1; - $errors[170] = 2; - $errors[185] = 1; - $errors[190] = 2; - $errors[191] = 2; - $errors[195] = 1; - $errors[227] = 1; - $errors[234] = 1; - $errors[239] = 2; - $errors[243] = 2; - $errors[244] = 2; - $errors[248] = 1; - $errors[259] = 1; - $errors[262] = 1; - $errors[267] = 1; - $errors[269] = 1; - $errors[276] = 1; - $errors[279] = 1; - $errors[283] = 1; - $errors[306] = 3; - $errors[309] = 1; - $errors[315] = 1; - return $errors; - - case 'ControlSignatureUnitTest.js': - return $errors; + return [ + 7 => 1, + 12 => 1, + 15 => 1, + 18 => 1, + 20 => 1, + 22 => 2, + 28 => 2, + 32 => 1, + 38 => 2, + 42 => 1, + 48 => 2, + 52 => 1, + 62 => 2, + 66 => 2, + 76 => 4, + 80 => 2, + 94 => 1, + 99 => 1, + 108 => 1, + 112 => 1, + 122 => 1, + 130 => 2, + 134 => 1, + 150 => 1, + 153 => 1, + 158 => 1, + 165 => 1, + 170 => 2, + 185 => 1, + 190 => 2, + 191 => 2, + 195 => 1, + 227 => 1, + 234 => 1, + 239 => 2, + 243 => 2, + 244 => 2, + 248 => 1, + 259 => 1, + 262 => 1, + 267 => 1, + 269 => 1, + 276 => 1, + 279 => 1, + 283 => 1, + 306 => 3, + 309 => 1, + 315 => 1, + ]; default: return []; diff --git a/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.1.js b/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.1.js deleted file mode 100644 index 94e1f7484f..0000000000 --- a/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.1.js +++ /dev/null @@ -1,122 +0,0 @@ -// Valid. -for (var i = 0; i < 10; i++) { -} - -// Invalid. -for ( i = 0; i < 10; i++ ) { -} - -for (i = 0; i < 10; i++) { -} - -for (var i = 0 ; i < 10 ; i++) { -} - -for (i = 0;i < 10;i++) { -} - -// The works. -for ( var i = 0 ; i < 10 ; i++ ) { -} - -this.formats = {}; -dfx.inherits('ContentFormat', 'Widget'); - -for (var widgetid in this.loadedContents) { - if (dfx.isset(widget) === true) { - widget.loadAutoSaveCWidgetStore.setData('activeScreen', null);widget.getContents(this.loadedContents[widgetid], function() {self.widgetLoaded(widget.id);}); - } -} - -for (var i = 0; i < 10;) { -} -for (var i = 0; i < 10; ) { -} - -for (var i = 0; ; i++) { -} -for (var i = 0;; i++) { -} - -// phpcs:set Squiz.ControlStructures.ForLoopDeclaration requiredSpacesAfterOpen 1 -// phpcs:set Squiz.ControlStructures.ForLoopDeclaration requiredSpacesBeforeClose 1 -for (var i = 0; i < 10; i++) {} -for ( var i = 0; i < 10; i++ ) {} -for ( var i = 0; i < 10; i++ ) {} -// phpcs:set Squiz.ControlStructures.ForLoopDeclaration requiredSpacesAfterOpen 0 -// phpcs:set Squiz.ControlStructures.ForLoopDeclaration requiredSpacesBeforeClose 0 - -for ( ; i < 10; i++) {} -for (; i < 10; i++) {} - -// phpcs:set Squiz.ControlStructures.ForLoopDeclaration requiredSpacesAfterOpen 1 -// phpcs:set Squiz.ControlStructures.ForLoopDeclaration requiredSpacesBeforeClose 1 -for ( ; i < 10; i++ ) {} -for ( ; i < 10; i++ ) {} -for (; i < 10; i++ ) {} - -for ( i = 0; i < 10; ) {} -for ( i = 0; i < 10;) {} -for ( i = 0; i < 10; ) {} -// phpcs:set Squiz.ControlStructures.ForLoopDeclaration requiredSpacesAfterOpen 0 -// phpcs:set Squiz.ControlStructures.ForLoopDeclaration requiredSpacesBeforeClose 0 - -// Test handling of comments and inline annotations. -for ( /*phpcs:enable*/ i = 0 /*start*/ ; /*end*/i < 10/*comment*/; i++ /*comment*/ ) {} - -// Test multi-line FOR control structure. -for ( - i = 0; - i < 10; - i++ -) {} - -// Test multi-line FOR control structure with comments and annotations. -for ( - i = 0; /* Start */ - i < 10; /* phpcs:ignore Standard.Category.SniffName -- for reasons. */ - i++ // comment - -) {} - -// Test fixing each error in one go. Note: lines 84 + 88 contain trailing whitespace on purpose. -for ( - - - i = 0 - - ; - - i < 10 - - ; - - i++ - - -) {} - -// phpcs:set Squiz.ControlStructures.ForLoopDeclaration requiredSpacesAfterOpen 1 -// phpcs:set Squiz.ControlStructures.ForLoopDeclaration requiredSpacesBeforeClose 1 -for ( - - - - i = 0 - - ; - - i < 10 - - ; - - i++ - - -) {} -// phpcs:set Squiz.ControlStructures.ForLoopDeclaration requiredSpacesAfterOpen 0 -// phpcs:set Squiz.ControlStructures.ForLoopDeclaration requiredSpacesBeforeClose 0 - -// Test with semicolon not belonging to for. -for (i = function() {self.widgetLoaded(widget.id) ; }; i < function() {self.widgetLoaded(widget.id);}; i++) {} -for (i = function() {self.widgetLoaded(widget.id);}; i < function() {self.widgetLoaded(widget.id);} ; i++) {} diff --git a/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.1.js.fixed b/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.1.js.fixed deleted file mode 100644 index fbf9b60980..0000000000 --- a/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.1.js.fixed +++ /dev/null @@ -1,88 +0,0 @@ -// Valid. -for (var i = 0; i < 10; i++) { -} - -// Invalid. -for (i = 0; i < 10; i++) { -} - -for (i = 0; i < 10; i++) { -} - -for (var i = 0; i < 10; i++) { -} - -for (i = 0; i < 10; i++) { -} - -// The works. -for (var i = 0; i < 10; i++) { -} - -this.formats = {}; -dfx.inherits('ContentFormat', 'Widget'); - -for (var widgetid in this.loadedContents) { - if (dfx.isset(widget) === true) { - widget.loadAutoSaveCWidgetStore.setData('activeScreen', null);widget.getContents(this.loadedContents[widgetid], function() {self.widgetLoaded(widget.id);}); - } -} - -for (var i = 0; i < 10;) { -} -for (var i = 0; i < 10;) { -} - -for (var i = 0;; i++) { -} -for (var i = 0;; i++) { -} - -// phpcs:set Squiz.ControlStructures.ForLoopDeclaration requiredSpacesAfterOpen 1 -// phpcs:set Squiz.ControlStructures.ForLoopDeclaration requiredSpacesBeforeClose 1 -for ( var i = 0; i < 10; i++ ) {} -for ( var i = 0; i < 10; i++ ) {} -for ( var i = 0; i < 10; i++ ) {} -// phpcs:set Squiz.ControlStructures.ForLoopDeclaration requiredSpacesAfterOpen 0 -// phpcs:set Squiz.ControlStructures.ForLoopDeclaration requiredSpacesBeforeClose 0 - -for (; i < 10; i++) {} -for (; i < 10; i++) {} - -// phpcs:set Squiz.ControlStructures.ForLoopDeclaration requiredSpacesAfterOpen 1 -// phpcs:set Squiz.ControlStructures.ForLoopDeclaration requiredSpacesBeforeClose 1 -for ( ; i < 10; i++ ) {} -for ( ; i < 10; i++ ) {} -for ( ; i < 10; i++ ) {} - -for ( i = 0; i < 10; ) {} -for ( i = 0; i < 10; ) {} -for ( i = 0; i < 10; ) {} -// phpcs:set Squiz.ControlStructures.ForLoopDeclaration requiredSpacesAfterOpen 0 -// phpcs:set Squiz.ControlStructures.ForLoopDeclaration requiredSpacesBeforeClose 0 - -// Test handling of comments and inline annotations. -for (/*phpcs:enable*/ i = 0 /*start*/; /*end*/i < 10/*comment*/; i++ /*comment*/) {} - -// Test multi-line FOR control structure. -for (i = 0; i < 10; i++) {} - -// Test multi-line FOR control structure with comments and annotations. -for (i = 0; /* Start */ - i < 10; /* phpcs:ignore Standard.Category.SniffName -- for reasons. */ - i++ // comment - -) {} - -// Test fixing each error in one go. Note: lines 84 + 88 contain trailing whitespace on purpose. -for (i = 0; i < 10; i++) {} - -// phpcs:set Squiz.ControlStructures.ForLoopDeclaration requiredSpacesAfterOpen 1 -// phpcs:set Squiz.ControlStructures.ForLoopDeclaration requiredSpacesBeforeClose 1 -for ( i = 0; i < 10; i++ ) {} -// phpcs:set Squiz.ControlStructures.ForLoopDeclaration requiredSpacesAfterOpen 0 -// phpcs:set Squiz.ControlStructures.ForLoopDeclaration requiredSpacesBeforeClose 0 - -// Test with semicolon not belonging to for. -for (i = function() {self.widgetLoaded(widget.id) ; }; i < function() {self.widgetLoaded(widget.id);}; i++) {} -for (i = function() {self.widgetLoaded(widget.id);}; i < function() {self.widgetLoaded(widget.id);}; i++) {} diff --git a/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.2.js b/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.2.js deleted file mode 100644 index c05d2092eb..0000000000 --- a/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.2.js +++ /dev/null @@ -1,2 +0,0 @@ -// Intentional parse error check. Live coding resilience. -for diff --git a/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php index 90b29021bb..0f8fff6d54 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/ForLoopDeclarationUnitTest.php @@ -67,40 +67,6 @@ public function getErrorList($testFile='') 116 => 2, ]; - case 'ForLoopDeclarationUnitTest.1.js': - return [ - 6 => 2, - 9 => 2, - 12 => 2, - 15 => 2, - 19 => 6, - 33 => 1, - 36 => 1, - 43 => 2, - 45 => 2, - 49 => 1, - 55 => 1, - 56 => 1, - 59 => 1, - 60 => 1, - 65 => 4, - 68 => 1, - 69 => 1, - 70 => 1, - 72 => 1, - 75 => 1, - 80 => 1, - 83 => 1, - 88 => 2, - 92 => 2, - 97 => 1, - 101 => 1, - 107 => 2, - 111 => 2, - 116 => 1, - 122 => 2, - ]; - default: return []; }//end switch @@ -125,9 +91,6 @@ public function getWarningList($testFile='') case 'ForLoopDeclarationUnitTest.3.inc': return [6 => 1]; - case 'ForLoopDeclarationUnitTest.2.js': - return [2 => 1]; - default: return []; }//end switch diff --git a/src/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.js b/src/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.js deleted file mode 100644 index 08e1c3ffb6..0000000000 --- a/src/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.js +++ /dev/null @@ -1,287 +0,0 @@ - - -// Valid SWITCH statement. -switch (something) { - case '1': - myvar = '1'; - break; - - case '2': - case '3': - myvar = '5'; - break; - - case '4': - myvar = '4'; - break; - - default: - myvar = null; - break; -} - -// Alignment wrong. -switch (something) { - case '1': - myvar = '1'; - break; - -case '2': - case '3': - myvar = '5'; - break; - -case '4': - myvar = '4'; -break; - - default: - myvar = null; - break; -} - -// Closing brace wrong. -switch (something) { - case '1': - myvar = '1'; - break; - } - -// PEAR style. -switch (something) { -case '1': - myvar = '1'; - break; -case '2': -case '3': - myvar = '5'; - break; -case '4': - myvar = '4'; - break; -default: - myvar = null; - break; -} - -// Valid, but missing BREAKS. -switch (something) { - case '1': - myvar = '1'; - - case '2': - case '3': - myvar = '5'; - - case '4': - myvar = '4'; - - default: - myvar = null; -} - -// Invalid, and missing BREAKS. -switch (something) { - Case '1' : - myvar = '1'; - -case '2': - case '3' : - myvar = '5'; - - case'4': - myvar = '4'; - - Default : - myvar = null; - something = 'hello'; - other = 'hi'; - } - -// Valid -switch (condition) { - case 'string': - varStr = 'test'; - - default: - // Ignore the default. - break; -} - -// No default comment -switch (condition) { - case 'string': - varStr = 'test'; - - default: - break; -} - -// Break problems -switch (condition) { - case 'string': - - - varStr = 'test'; - - break; - - - case 'bool': - varStr = 'test'; - - - break; - default: - - varStr = 'test'; - break; - -} - -switch (var) { - case 'one': - case 'two': - break; - - case 'three': - // Nothing to do. - break; - - case 'four': - echo hi; - break; - - default: - // No default. - break; -} - -switch (var) { - case 'one': - if (blah) { - } - - break; - - default: - // No default. - break; -} - -switch (name) { - case "1": - switch (name2) { - case "1": - return true; - break; - - case "2": - return true; - break; - - default: - // No default. - break; - } - break; - - case "2": -switch (name2) { - case "1": - return true; - break; - - case "2": - return true; - break; - - default: - // No default. - break; -} - break; -} - -switch (name) { - case "1": - switch (name2) { - case "1": - return true; - - default: - // No default. - break; - } - break; - - default: - // No default. - break; -} - -switch (name2) { - default: - // No default. - break; -} - -switch (foo) { - case "1": - return true; - - default: - if (foo === false) { - break; - } - break; -} - -// Valid SWITCH statement. -switch (something) { - case '1': - myvar = '1'; - return '1'; - - case '2': - case '3': - myvar = '5'; - return '2'; - - case '4': - myvar = '4'; - return '3'; - - default: - myvar = null; - return '4'; -} - -switch (something) { - case '1': - myvar = '1'; - break; - - case '2': - throw 'message'; - - default: - throw 'message'; -} - -switch (something) { - case '1'; - print('one'); - break; - - default: - print('default'); - return; -} - -switch (foo) { - case '1': - return; // comment - break; - -} diff --git a/src/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php b/src/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php index 310024dce7..c3c9ded1d8 100644 --- a/src/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/ControlStructures/SwitchDeclarationUnitTest.php @@ -26,111 +26,59 @@ final class SwitchDeclarationUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * - * @param string $testFile The name of the file being tested. - * * @return array */ - public function getErrorList($testFile='') + public function getErrorList() { - switch ($testFile) { - case 'SwitchDeclarationUnitTest.inc': - return [ - 27 => 1, - 29 => 1, - 34 => 1, - 36 => 1, - 44 => 1, - 48 => 1, - 52 => 1, - 54 => 1, - 55 => 1, - 56 => 1, - 58 => 1, - 59 => 1, - 61 => 1, - 62 => 1, - 79 => 1, - 85 => 2, - 88 => 2, - 89 => 2, - 92 => 1, - 95 => 3, - 99 => 1, - 116 => 1, - 122 => 1, - 127 => 2, - 134 => 2, - 135 => 1, - 138 => 1, - 143 => 1, - 144 => 1, - 147 => 1, - 165 => 1, - 172 => 1, - 176 => 2, - 180 => 1, - 192 => 2, - 196 => 1, - 223 => 1, - 266 => 1, - 282 => 1, - 284 => 2, - 322 => 1, - 323 => 1, - 327 => 1, - 329 => 1, - 330 => 1, - 339 => 2, - 342 => 1, - ]; - - case 'SwitchDeclarationUnitTest.js': - return [ - 27 => 1, - 29 => 1, - 34 => 1, - 36 => 1, - 44 => 1, - 48 => 1, - 52 => 1, - 54 => 1, - 55 => 1, - 56 => 1, - 58 => 1, - 59 => 1, - 61 => 1, - 62 => 1, - 79 => 1, - 85 => 2, - 88 => 2, - 89 => 2, - 92 => 1, - 95 => 3, - 99 => 1, - 116 => 1, - 122 => 1, - 127 => 2, - 134 => 2, - 135 => 1, - 138 => 1, - 143 => 1, - 144 => 1, - 147 => 1, - 165 => 1, - 172 => 1, - 176 => 2, - 180 => 1, - 192 => 2, - 196 => 1, - 223 => 1, - 266 => 1, - 282 => 1, - 284 => 2, - ]; - - default: - return []; - }//end switch + return [ + 27 => 1, + 29 => 1, + 34 => 1, + 36 => 1, + 44 => 1, + 48 => 1, + 52 => 1, + 54 => 1, + 55 => 1, + 56 => 1, + 58 => 1, + 59 => 1, + 61 => 1, + 62 => 1, + 79 => 1, + 85 => 2, + 88 => 2, + 89 => 2, + 92 => 1, + 95 => 3, + 99 => 1, + 116 => 1, + 122 => 1, + 127 => 2, + 134 => 2, + 135 => 1, + 138 => 1, + 143 => 1, + 144 => 1, + 147 => 1, + 165 => 1, + 172 => 1, + 176 => 2, + 180 => 1, + 192 => 2, + 196 => 1, + 223 => 1, + 266 => 1, + 282 => 1, + 284 => 2, + 322 => 1, + 323 => 1, + 327 => 1, + 329 => 1, + 330 => 1, + 339 => 2, + 342 => 1, + ]; }//end getErrorList() @@ -141,16 +89,10 @@ public function getErrorList($testFile='') * The key of the array should represent the line number and the value * should represent the number of warnings that should occur on that line. * - * @param string $testFile The name of the file being tested. - * * @return array */ - public function getWarningList($testFile='') + public function getWarningList() { - if ($testFile === 'SwitchDeclarationUnitTest.js') { - return [273 => 1]; - } - return []; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/Debug/JSLintUnitTest.js b/src/Standards/Squiz/Tests/Debug/JSLintUnitTest.js deleted file mode 100644 index 797e0eea2a..0000000000 --- a/src/Standards/Squiz/Tests/Debug/JSLintUnitTest.js +++ /dev/null @@ -1,2 +0,0 @@ -alert('hi') -alert('hi'); diff --git a/src/Standards/Squiz/Tests/Debug/JSLintUnitTest.php b/src/Standards/Squiz/Tests/Debug/JSLintUnitTest.php deleted file mode 100644 index c4b14dc2e3..0000000000 --- a/src/Standards/Squiz/Tests/Debug/JSLintUnitTest.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Tests\Debug; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; -use PHP_CodeSniffer\Config; - -/** - * Unit test class for the JSLint sniff. - * - * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Debug\JSLintSniff - */ -final class JSLintUnitTest extends AbstractSniffUnitTest -{ - - - /** - * Should this test be skipped for some reason. - * - * @return bool - */ - protected function shouldSkipTest() - { - $jslPath = Config::getExecutablePath('jslint'); - if ($jslPath === null) { - return true; - } - - return false; - - }//end shouldSkipTest() - - - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getErrorList() - { - return []; - - }//end getErrorList() - - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return [ - 1 => 2, - 2 => 1, - ]; - - }//end getWarningList() - - -}//end class diff --git a/src/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.js b/src/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.js deleted file mode 100644 index 797e0eea2a..0000000000 --- a/src/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.js +++ /dev/null @@ -1,2 +0,0 @@ -alert('hi') -alert('hi'); diff --git a/src/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php b/src/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php deleted file mode 100644 index 96a68d7c8f..0000000000 --- a/src/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Tests\Debug; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; -use PHP_CodeSniffer\Config; - -/** - * Unit test class for the JavaScriptLint sniff. - * - * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Debug\JavaScriptLintSniff - */ -final class JavaScriptLintUnitTest extends AbstractSniffUnitTest -{ - - - /** - * Should this test be skipped for some reason. - * - * @return bool - */ - protected function shouldSkipTest() - { - $jslPath = Config::getExecutablePath('jsl'); - if ($jslPath === null) { - return true; - } - - return false; - - }//end shouldSkipTest() - - - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getErrorList() - { - return []; - - }//end getErrorList() - - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return [2 => 1]; - - }//end getWarningList() - - -}//end class diff --git a/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.js b/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.js deleted file mode 100644 index 92ed8038a3..0000000000 --- a/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.js +++ /dev/null @@ -1,118 +0,0 @@ -value = (one + two); -value = one + two; - -value = (one - two); -value = one - two; - -value = (one * two); -value = one * two; - -value = (one / two); -value = one / two; - -value = (one % two); -value = one % two; - -value = (one + two + three); -value = one + two + three; -value = (one + (two + three)); -value = one + (two + three); - -value++; -value--; -value = -1; -value = - 1; - -value = (1 + 2); -value = 1 + 2; - -value = (1 - 2); -value = 1 - 2; - -value = (1 * 2); -value = 1 * 2; - -value = (1 / 2); -value = 1 / 2; - -value = (1 % 2); -value = 1 % 2; - -value = (1 + 2 + 3); -value = 1 + 2 + 3; -value = (1 + (2 + 3)); -value = 1 + (2 + 3); - -value = one + 2 + 3 - (four * five * (6 + 7)) + nine + 2; -value = myFunction(tokens[stackPtr - 1]); - -for (i = 1 + 2; i < 4 + 5; i++) { -} - -function myFunction() -{ - value = (one + 1) + (two + 2) + (myFunction() + 2); - value = myFunction() + 2; - value = (myFunction(mvar) + myFunction2(mvar)); - return -1; -} - -params['mode'] = id.replace(/WidgetType/, ''); - -if (index < -1) index = 0; -if (index < - 1) index = 0; - -var classN = prvId.replace(/\./g, '-'); - -three = myFunction(one / two); -three = myFunction((one / two) / four); -three = myFunction(one / (two / four)); - -four = -0.25; - -id = id.replace(/row\/:/gi, ''); -return /MSIE/.test(navigator.userAgent); - -var re = new RegExp(/<\/?(\w+)((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim); - -var options = { - minVal: -1, - maxVal: -1 -}; - -stepWidth = Math.round(this.width / 5); - -date.setMonth(d[2] - 1); - -switch (number % 10) { - case -1: - suffix = 'st'; - break; -} - -var pathSplit = ipt.value.split(/\/|\\/); - -if (pairs[i].search(/=/) !== -1) { -} - -if (urlValue.search(/[a-zA-z]+:\/\//) !== 0) { -} - -if (urlValue.search(/[a-zA-z]+:\/\/*/) !== 0) { -} - -if (!value || /^\s*$/.test(value)) { - return true; -} - -parseInt(dfx.attr(selectors[idx], 'elemOffsetTop'), 10) - scrollCoords.y + 'px' - -if (something === true - ^ somethingElse === true -) { - return false; -} - -if (true === /^\d*\.?\d*$/.test(input)) return true; - -if ( ! /^(?:a|select)$/i.test( element.tagName ) ) return true; diff --git a/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.js.fixed b/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.js.fixed deleted file mode 100644 index 04e35d977c..0000000000 --- a/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.js.fixed +++ /dev/null @@ -1,118 +0,0 @@ -value = (one + two); -value = one + two; - -value = (one - two); -value = (one - two); - -value = (one * two); -value = (one * two); - -value = (one / two); -value = (one / two); - -value = (one % two); -value = (one % two); - -value = (one + two + three); -value = one + two + three; -value = (one + (two + three)); -value = one + (two + three); - -value++; -value--; -value = -1; -value = - 1; - -value = (1 + 2); -value = 1 + 2; - -value = (1 - 2); -value = (1 - 2); - -value = (1 * 2); -value = (1 * 2); - -value = (1 / 2); -value = (1 / 2); - -value = (1 % 2); -value = (1 % 2); - -value = (1 + 2 + 3); -value = 1 + 2 + 3; -value = (1 + (2 + 3)); -value = 1 + (2 + 3); - -value = one + 2 + (3 - (four * five * (6 + 7))) + nine + 2; -value = myFunction(tokens[(stackPtr - 1)]); - -for (i = 1 + 2; i < 4 + 5; i++) { -} - -function myFunction() -{ - value = (one + 1) + (two + 2) + (myFunction() + 2); - value = myFunction() + 2; - value = (myFunction(mvar) + myFunction2(mvar)); - return -1; -} - -params['mode'] = id.replace(/WidgetType/, ''); - -if (index < -1) index = 0; -if (index < - 1) index = 0; - -var classN = prvId.replace(/\./g, '-'); - -three = myFunction(one / two); -three = myFunction((one / two) / four); -three = myFunction(one / (two / four)); - -four = -0.25; - -id = id.replace(/row\/:/gi, ''); -return /MSIE/.test(navigator.userAgent); - -var re = new RegExp(/<\/?(\w+)((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim); - -var options = { - minVal: -1, - maxVal: -1 -}; - -stepWidth = Math.round(this.width / 5); - -date.setMonth(d[2] - 1); - -switch (number % 10) { - case -1: - suffix = 'st'; - break; -} - -var pathSplit = ipt.value.split(/\/|\\/); - -if (pairs[i].search(/=/) !== -1) { -} - -if (urlValue.search(/[a-zA-z]+:\/\//) !== 0) { -} - -if (urlValue.search(/[a-zA-z]+:\/\/*/) !== 0) { -} - -if (!value || /^\s*$/.test(value)) { - return true; -} - -(parseInt(dfx.attr(selectors[idx], 'elemOffsetTop'), 10) - scrollCoords.y) + 'px' - -if (something === true - ^ somethingElse === true -) { - return false; -} - -if (true === /^\d*\.?\d*$/.test(input)) return true; - -if ( ! /^(?:a|select)$/i.test( element.tagName ) ) return true; diff --git a/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php b/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php index aac4327571..68c153c0c4 100644 --- a/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php +++ b/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php @@ -79,23 +79,6 @@ public function getErrorList($testFile='') 194 => 2, ]; - case 'OperatorBracketUnitTest.js': - return [ - 5 => 1, - 8 => 1, - 11 => 1, - 14 => 1, - 24 => 1, - 30 => 1, - 33 => 1, - 36 => 1, - 39 => 1, - 46 => 1, - 47 => 1, - 63 => 1, - 108 => 1, - ]; - default: return []; }//end switch diff --git a/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.js b/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.js deleted file mode 100644 index c3a8ddf8c8..0000000000 --- a/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.js +++ /dev/null @@ -1,73 +0,0 @@ - -function someFunctionWithAVeryLongName(firstParameter='something', - secondParameter='booooo', - third=null, fourthParameter=false, - fifthParameter=123.12, - sixthParam=true -){ -} - -function someFunctionWithAVeryLongName2( -firstParameter='something', -secondParameter='booooo', -) { -} - -function blah() { -} - -function blah() -{ -} - -var object = -{ - - someFunctionWithAVeryLongName: function( - firstParameter='something', - secondParameter='booooo', - third=null, - fourthParameter=false, - fifthParameter=123.12, - sixthParam=true - ) /** w00t */ { - } - - someFunctionWithAVeryLongName2: function (firstParameter='something', - secondParameter='booooo', - third=null - ) { - } - - someFunctionWithAVeryLongName3: function ( - firstParameter, secondParameter, third=null - ) { - } - - someFunctionWithAVeryLongName4: function ( - firstParameter, secondParameter - ) { - } - - someFunctionWithAVeryLongName5: function ( - firstParameter, - secondParameter=array(1,2,3), - third=null - ) { - } - -} - -var a = Function('return 1+1'); - -class test -{ - myFunction() { - return false; - } - - myFunction2() - { - return false; - } -} diff --git a/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.js.fixed b/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.js.fixed deleted file mode 100644 index bbfcfc4a2a..0000000000 --- a/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.js.fixed +++ /dev/null @@ -1,81 +0,0 @@ - -function someFunctionWithAVeryLongName( - firstParameter='something', - secondParameter='booooo', - third=null, - fourthParameter=false, - fifthParameter=123.12, - sixthParam=true -) { -} - -function someFunctionWithAVeryLongName2( - firstParameter='something', - secondParameter='booooo', -) { -} - -function blah() -{ -} - -function blah() -{ -} - -var object = -{ - - someFunctionWithAVeryLongName: function ( - firstParameter='something', - secondParameter='booooo', - third=null, - fourthParameter=false, - fifthParameter=123.12, - sixthParam=true - ) /** w00t */ { - } - - someFunctionWithAVeryLongName2: function ( - firstParameter='something', - secondParameter='booooo', - third=null - ) { - } - - someFunctionWithAVeryLongName3: function ( - firstParameter, - secondParameter, - third=null - ) { - } - - someFunctionWithAVeryLongName4: function ( - firstParameter, - secondParameter - ) { - } - - someFunctionWithAVeryLongName5: function ( - firstParameter, - secondParameter=array(1,2,3), - third=null - ) { - } - -} - -var a = Function('return 1+1'); - -class test -{ - myFunction() - { - return false; - } - - myFunction2() - { - return false; - } -} diff --git a/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php b/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php index cc1dc35eda..f4bcfc4a0f 100644 --- a/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php +++ b/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php @@ -26,78 +26,55 @@ final class MultiLineFunctionDeclarationUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * - * @param string $testFile The name of the file being tested. - * * @return array */ - public function getErrorList($testFile='') + public function getErrorList() { - if ($testFile === 'MultiLineFunctionDeclarationUnitTest.inc') { - $errors = [ - 2 => 1, - 3 => 1, - 4 => 2, - 5 => 1, - 7 => 1, - 11 => 1, - 12 => 1, - 13 => 1, - 16 => 1, - 36 => 1, - 43 => 2, - 48 => 1, - 81 => 1, - 82 => 2, - 88 => 1, - 102 => 2, - 137 => 1, - 141 => 2, - 142 => 1, - 158 => 1, - 160 => 1, - 182 => 2, - 186 => 2, - 190 => 2, - 194 => 1, - 195 => 1, - 233 => 1, - 234 => 1, - 235 => 1, - 236 => 1, - 244 => 1, - 245 => 1, - 246 => 1, - 247 => 1, - 248 => 1, - 249 => 1, - 250 => 1, - 251 => 1, - 252 => 1, - 253 => 1, - 254 => 1, - 318 => 1, - 323 => 1, - ]; - } else { - $errors = [ - 2 => 1, - 3 => 1, - 4 => 2, - 5 => 1, - 7 => 1, - 11 => 1, - 12 => 1, - 13 => 1, - 16 => 1, - 26 => 1, - 36 => 1, - 43 => 2, - 48 => 1, - 65 => 1, - ]; - }//end if - - return $errors; + return [ + 2 => 1, + 3 => 1, + 4 => 2, + 5 => 1, + 7 => 1, + 11 => 1, + 12 => 1, + 13 => 1, + 16 => 1, + 36 => 1, + 43 => 2, + 48 => 1, + 81 => 1, + 82 => 2, + 88 => 1, + 102 => 2, + 137 => 1, + 141 => 2, + 142 => 1, + 158 => 1, + 160 => 1, + 182 => 2, + 186 => 2, + 190 => 2, + 194 => 1, + 195 => 1, + 233 => 1, + 234 => 1, + 235 => 1, + 236 => 1, + 244 => 1, + 245 => 1, + 246 => 1, + 247 => 1, + 248 => 1, + 249 => 1, + 250 => 1, + 251 => 1, + 252 => 1, + 253 => 1, + 254 => 1, + 318 => 1, + 323 => 1, + ]; }//end getErrorList() diff --git a/src/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.js b/src/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.js deleted file mode 100644 index 1c61fbfbbb..0000000000 --- a/src/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.js +++ /dev/null @@ -1,37 +0,0 @@ -function test(id) -{ - - this.id = id; - -} -/**/ -test.prototype = { - init: function() - { - var x = {}; - x.name = 'test'; - x['phone'] = 123124324; - var t = ['test', 'this'].join(''); - var y = ['test'].join(''); - var a = x[0]; - var z = x[x['name']]; - var p = x[x.name]; - } - -}; - -function test() { - this.errors['step_' + step] = errors; - this.errors['test'] = x; - this.errors['test' + 10] = x; - this.errors['test' + y] = x; - this.errors['test' + 'blah'] = x; - this.errors[y] = x; - this.errors[y + z] = x; - this.permissions['workflow.cancel'] = x; -} - -if (child.prototype) { - above.prototype['constructor'] = parent; - child.prototype['super'] = new above(); -} diff --git a/src/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php b/src/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php deleted file mode 100644 index 36880a9a58..0000000000 --- a/src/Standards/Squiz/Tests/Objects/DisallowObjectStringIndexUnitTest.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Tests\Objects; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; - -/** - * Unit test class for the DisallowObjectStringIndex sniff. - * - * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Objects\DisallowObjectStringIndexSniff - */ -final class DisallowObjectStringIndexUnitTest extends AbstractSniffUnitTest -{ - - - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @param string $testFile The name of the file being tested. - * - * @return array - */ - public function getErrorList($testFile='') - { - if ($testFile !== 'DisallowObjectStringIndexUnitTest.js') { - return []; - } - - return [ - 13 => 1, - 17 => 1, - 25 => 1, - 35 => 1, - ]; - - }//end getErrorList() - - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return []; - - }//end getWarningList() - - -}//end class diff --git a/src/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.js b/src/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.js deleted file mode 100644 index 28bf85adeb..0000000000 --- a/src/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.js +++ /dev/null @@ -1,47 +0,0 @@ -this.request({ action: 'getTypeFormatContents', }); - -addTypeFormatButton.addClickEvent(function() { - self.addNewTypeFormat(); -}); - -var x = {}; - -var y = { - VarOne : 'If you ask me, thats if you ask', - VarTwo : ['Alonzo played you', 'for a fool', 'esse'], - VarThree: function(arg) { - console.info(1); - } -}; - -var z = { - VarOne : 'If you ask me, thats if you ask', - VarTwo : ['Alonzo played you', 'for a fool', 'esse'], - VarThree: function(arg) { - console.info(1); - }, -}; - -var x = function() { - console.info(2); -}; - -AssetListingEditWidgetType.prototype = { - init: function(data, assetid, editables) - { - } -}; - -AssetListingEditWidgetType.prototype = { - init: function(data, assetid, editables) - { - }, -}; - -AssetListingEditWidgetType.prototype = { - // phpcs: disable Standard.Cat.SniffName -- testing annotation between closing brace and comma - init: function(data, assetid, editables) - { - }, - // phpcs:enable -}; diff --git a/src/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.js.fixed b/src/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.js.fixed deleted file mode 100644 index df548c741c..0000000000 --- a/src/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.js.fixed +++ /dev/null @@ -1,47 +0,0 @@ -this.request({ action: 'getTypeFormatContents' }); - -addTypeFormatButton.addClickEvent(function() { - self.addNewTypeFormat(); -}); - -var x = {}; - -var y = { - VarOne : 'If you ask me, thats if you ask', - VarTwo : ['Alonzo played you', 'for a fool', 'esse'], - VarThree: function(arg) { - console.info(1); - } -}; - -var z = { - VarOne : 'If you ask me, thats if you ask', - VarTwo : ['Alonzo played you', 'for a fool', 'esse'], - VarThree: function(arg) { - console.info(1); - } -}; - -var x = function() { - console.info(2); -}; - -AssetListingEditWidgetType.prototype = { - init: function(data, assetid, editables) - { - } -}; - -AssetListingEditWidgetType.prototype = { - init: function(data, assetid, editables) - { - } -}; - -AssetListingEditWidgetType.prototype = { - // phpcs: disable Standard.Cat.SniffName -- testing annotation between closing brace and comma - init: function(data, assetid, editables) - { - } - // phpcs:enable -}; diff --git a/src/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.php b/src/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.php deleted file mode 100644 index 0ac826f3ad..0000000000 --- a/src/Standards/Squiz/Tests/Objects/ObjectMemberCommaUnitTest.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Tests\Objects; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; - -/** - * Unit test class for the ObjectMemberComma sniff. - * - * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Objects\ObjectMemberCommaSniff - */ -final class ObjectMemberCommaUnitTest extends AbstractSniffUnitTest -{ - - - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getErrorList() - { - return [ - 1 => 1, - 22 => 1, - 38 => 1, - 45 => 1, - ]; - - }//end getErrorList() - - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return []; - - }//end getWarningList() - - -}//end class diff --git a/src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.js b/src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.js deleted file mode 100644 index 048223ba10..0000000000 --- a/src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.js +++ /dev/null @@ -1,71 +0,0 @@ -if (value === TRUE) { -} else if (value === FALSE) { -} - -if (value == TRUE) { -} else if (value == FALSE) { -} - -if (value) { -} else if (!value) { -} - -if (value.isSomething === TRUE) { -} else if (myFunction(value) === FALSE) { -} - -if (value.isSomething == TRUE) { -} else if (myFunction(value) == FALSE) { -} - -if (value.isSomething) { -} else if (!myFunction(value)) { -} - -if (value === TRUE || other === FALSE) { -} - -if (value == TRUE || other == FALSE) { -} - -if (value || !other) { -} - -if (one === TRUE || two === TRUE || three === FALSE || four === TRUE) { -} - -if (one || two || !three || four) { -} - -while (one == true) { -} - -while (one === true) { -} - -do { -} while (one == true); - -do { -} while (one === true); - -for (one = 10; one != 0; one--) { -} - -for (one = 10; one !== 0; one--) { -} - -for (type in types) { -} - -variable = (variable2 === true) ? variable1 : "foobar"; - -variable = (variable2 == true) ? variable1 : "foobar"; - -variable = (variable2 === false) ? variable1 : "foobar"; - -variable = (variable2 == false) ? variable1 : "foobar"; - -variable = (variable2 === 0) ? variable1 : "foobar"; - -variable = (variable2 == 0) ? variable1 : "foobar"; diff --git a/src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php b/src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php index 1189725bcf..cefde97f77 100644 --- a/src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php +++ b/src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php @@ -26,63 +26,40 @@ final class ComparisonOperatorUsageUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * - * @param string $testFile The name of the file being tested. - * * @return array */ - public function getErrorList($testFile='') + public function getErrorList() { - switch ($testFile) { - case 'ComparisonOperatorUsageUnitTest.inc': - return [ - 6 => 1, - 7 => 1, - 10 => 1, - 11 => 1, - 18 => 1, - 19 => 1, - 22 => 1, - 23 => 1, - 29 => 2, - 32 => 2, - 38 => 4, - 47 => 2, - 69 => 1, - 72 => 1, - 75 => 1, - 78 => 1, - 80 => 1, - 82 => 1, - 83 => 1, - 89 => 1, - 92 => 1, - 100 => 1, - 106 => 1, - 112 => 1, - 123 => 1, - 127 => 1, - 131 => 1, - 135 => 1, - ]; - - case 'ComparisonOperatorUsageUnitTest.js': - return [ - 5 => 1, - 6 => 1, - 17 => 1, - 18 => 1, - 28 => 2, - 40 => 1, - 47 => 1, - 52 => 1, - 63 => 1, - 67 => 1, - 71 => 1, - ]; - - default: - return []; - }//end switch + return [ + 6 => 1, + 7 => 1, + 10 => 1, + 11 => 1, + 18 => 1, + 19 => 1, + 22 => 1, + 23 => 1, + 29 => 2, + 32 => 2, + 38 => 4, + 47 => 2, + 69 => 1, + 72 => 1, + 75 => 1, + 78 => 1, + 80 => 1, + 82 => 1, + 83 => 1, + 89 => 1, + 92 => 1, + 100 => 1, + 106 => 1, + 112 => 1, + 123 => 1, + 127 => 1, + 131 => 1, + 135 => 1, + ]; }//end getErrorList() diff --git a/src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.css b/src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.css deleted file mode 100644 index 94cc8f27cf..0000000000 --- a/src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.css +++ /dev/null @@ -1,23 +0,0 @@ -/* CSS Document */ - -body { -font-family: Arial, Helvetica, sans-serif; -margin : 40px 0 0 0; -padding : 0; -/*background: #8FB7DB url(login_glow_bg.jpg) no-repeat 30% 0;*/ -background: #8FB7DB url(diag_lines_bg.gif) top left; -} - -#login-container { - margin-left: -225px; - margin-top: -161px; - position:absolute; - top :50%; - /*left :50%;*/ - width:450px; -} - -#cacheConfig-dayLabel, #cacheConfig-hourLabel, #cacheConfig-minuteLabel { - float: left; - padding-right: 8px; -} diff --git a/src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php b/src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php index 99d8f01ace..e7149cd586 100644 --- a/src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php @@ -41,38 +41,24 @@ public function getErrorList() * The key of the array should represent the line number and the value * should represent the number of warnings that should occur on that line. * - * @param string $testFile The name of the file being tested. - * * @return array */ - public function getWarningList($testFile='') + public function getWarningList() { - switch ($testFile) { - case 'CommentedOutCodeUnitTest.inc': - return [ - 6 => 1, - 8 => 1, - 15 => 1, - 19 => 1, - 87 => 1, - 91 => 1, - 97 => 1, - 109 => 1, - 116 => 1, - 128 => 1, - 147 => 1, - 158 => 1, - ]; - - case 'CommentedOutCodeUnitTest.css': - return [ - 7 => 1, - 16 => 1, - ]; - - default: - return []; - }//end switch + return [ + 6 => 1, + 8 => 1, + 15 => 1, + 19 => 1, + 87 => 1, + 91 => 1, + 97 => 1, + 109 => 1, + 116 => 1, + 128 => 1, + 147 => 1, + 158 => 1, + ]; }//end getWarningList() diff --git a/src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.js b/src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.js deleted file mode 100644 index 56387c06f3..0000000000 --- a/src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.js +++ /dev/null @@ -1,2 +0,0 @@ -x = (x?a:x); -id = id.replace(/row\/:/gi, ''); diff --git a/src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php b/src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php index 14f79c87e2..a487c07108 100644 --- a/src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php @@ -26,25 +26,14 @@ final class DisallowInlineIfUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * - * @param string $testFile The name of the file being tested. - * * @return array */ - public function getErrorList($testFile='') + public function getErrorList() { - switch ($testFile) { - case 'DisallowInlineIfUnitTest.inc': - return [ - 8 => 1, - 18 => 1, - ]; - - case 'DisallowInlineIfUnitTest.js': - return [1 => 1]; - - default: - return []; - }//end switch + return [ + 8 => 1, + 18 => 1, + ]; }//end getErrorList() diff --git a/src/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.js b/src/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.js deleted file mode 100644 index 8f7f7b94f0..0000000000 --- a/src/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.js +++ /dev/null @@ -1,13 +0,0 @@ -for (var i = 0; i < permissions.length; i++) { - // Code here. -} - -var permLen = permissions.length; -for (var length = 0; i < permLen; i++) { - // Code here. -} - -var myArray = [1, 2, 3, 4]; -for (var i = myArray.length; i >= 0; i--) { - var x = i; -} diff --git a/src/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php b/src/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php index 3f923ad6b0..1a5f4dcdcb 100644 --- a/src/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php +++ b/src/Standards/Squiz/Tests/PHP/DisallowSizeFunctionsInLoopsUnitTest.php @@ -26,35 +26,24 @@ final class DisallowSizeFunctionsInLoopsUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * - * @param string $testFile The name of the file being tested. - * * @return array */ - public function getErrorList($testFile='') + public function getErrorList() { - switch ($testFile) { - case 'DisallowSizeFunctionsInLoopsUnitTest.inc': - return [ - 2 => 1, - 7 => 1, - 11 => 1, - 13 => 1, - 18 => 1, - 23 => 1, - 27 => 1, - 29 => 1, - 35 => 1, - 40 => 1, - 44 => 1, - 46 => 1, - ]; - - case 'DisallowSizeFunctionsInLoopsUnitTest.js': - return [1 => 1]; - - default: - return []; - }//end switch + return [ + 2 => 1, + 7 => 1, + 11 => 1, + 13 => 1, + 18 => 1, + 23 => 1, + 27 => 1, + 29 => 1, + 35 => 1, + 40 => 1, + 44 => 1, + 46 => 1, + ]; }//end getErrorList() diff --git a/src/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.js b/src/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.js deleted file mode 100644 index 1c889a1c09..0000000000 --- a/src/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.js +++ /dev/null @@ -1,93 +0,0 @@ - -if (something) { -} -for (i = 0; i < 10; i++) { -} - -while (true) { - for (i = 0; i < 10; i++) { - } - if (something) { - } - - do { - } while (true); - -} - -if (one) { -} else (two) { -} else if (three) { -} -if (one) { -} else (two) { -} else if (three) { -} - -switch (blah) { - case 'one': - if (blah) { - // There are no spaces before break. - } - break; - - default: - if (blah) { - // There are no spaces before break. - } - break; -} - -switch (blah) { - case 'one': - if (blah) { - // There are no spaces before break. - } - break; - - default: - if (blah) { - // Code here. - } -} - -for (i = 0; i < 10; i++) { - if (blah) { - } - break; -} - -while (true) { - for (i = 0; i < 10; i++) { - - if (something) { - } - - } - - do { - - alert(i); - } while (true); -} - -for ( i = 0; i < 10; i++ ) { - if ( blah ) { - } -} - -var x = { - a: function () { - if (blah) { - } - - }, -}; - -if (one) { -} -// else if something -else if (two) { -} // else do something -else { -} diff --git a/src/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.js.fixed b/src/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.js.fixed deleted file mode 100644 index bb979bc8ea..0000000000 --- a/src/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.js.fixed +++ /dev/null @@ -1,93 +0,0 @@ - -if (something) { -} - -for (i = 0; i < 10; i++) { -} - -while (true) { - for (i = 0; i < 10; i++) { - } - - if (something) { - } - - do { - } while (true); -} - -if (one) { -} else (two) { -} else if (three) { -} - -if (one) { -} else (two) { -} else if (three) { -} - -switch (blah) { - case 'one': - if (blah) { - // There are no spaces before break. - } - break; - - default: - if (blah) { - // There are no spaces before break. - } - break; -} - -switch (blah) { - case 'one': - if (blah) { - // There are no spaces before break. - } - break; - - default: - if (blah) { - // Code here. - } -} - -for (i = 0; i < 10; i++) { - if (blah) { - } - - break; -} - -while (true) { - for (i = 0; i < 10; i++) { - if (something) { - } - } - - do { - alert(i); - } while (true); -} - -for (i = 0; i < 10; i++) { - if (blah) { - } -} - -var x = { - a: function () { - if (blah) { - } - - }, -}; - -if (one) { -} -// else if something -else if (two) { -} // else do something -else { -} diff --git a/src/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php index c5567cb723..ded042ed90 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php @@ -26,65 +26,42 @@ final class ControlStructureSpacingUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * - * @param string $testFile The name of the file being tested. - * * @return array */ - public function getErrorList($testFile='') + public function getErrorList() { - switch ($testFile) { - case 'ControlStructureSpacingUnitTest.inc': - return [ - 3 => 1, - 5 => 1, - 8 => 1, - 15 => 1, - 23 => 1, - 74 => 1, - 79 => 1, - 82 => 1, - 83 => 1, - 87 => 1, - 103 => 1, - 113 => 2, - 114 => 2, - 118 => 1, - 150 => 1, - 153 => 1, - 154 => 1, - 157 => 1, - 170 => 1, - 176 => 2, - 179 => 1, - 189 => 1, - 225 => 1, - 237 => 1, - 242 => 1, - 246 => 1, - 248 => 1, - 257 => 3, - 261 => 1, - 262 => 1, - ]; - - case 'ControlStructureSpacingUnitTest.js': - return [ - 3 => 1, - 9 => 1, - 15 => 1, - 21 => 1, - 56 => 1, - 61 => 1, - 64 => 1, - 65 => 1, - 68 => 1, - 74 => 2, - 75 => 2, - ]; - - default: - return []; - }//end switch + return [ + 3 => 1, + 5 => 1, + 8 => 1, + 15 => 1, + 23 => 1, + 74 => 1, + 79 => 1, + 82 => 1, + 83 => 1, + 87 => 1, + 103 => 1, + 113 => 2, + 114 => 2, + 118 => 1, + 150 => 1, + 153 => 1, + 154 => 1, + 157 => 1, + 170 => 1, + 176 => 2, + 179 => 1, + 189 => 1, + 225 => 1, + 237 => 1, + 242 => 1, + 246 => 1, + 248 => 1, + 257 => 3, + 261 => 1, + 262 => 1, + ]; }//end getErrorList() diff --git a/src/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.js b/src/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.js deleted file mode 100644 index fc7521fa79..0000000000 --- a/src/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.js +++ /dev/null @@ -1,132 +0,0 @@ -function FuncOne() -{ - // Code here. - -}//end AdjustModalDialogWidgetType - - -Testing.prototype = { - - doSomething: function() - { - // Code here. - }, - - doSomethingElse: function() - { - // Code here. - - }, -}; - -function FuncFour() -{ - // Code here. -} - -function FuncFive() -{ - // Code here. - - -} - -function valid() -{ - if (true) { - test = { - namespaces: {} - }; - } - -} - -dfx.addEvent(this.rightScroll, 'mousedown', function() { - t = setInterval(function() { - pos -= 10; - }, 30); -}); - -// Valid because function is empty. -if (dfx.isFn(callback) === false) { - callback = function() {}; - callback = function() { }; -} - -AbstractAttributeEditorWidgetType.prototype = { - isActive: function() { - return this.active; - }, - - activate: function(data) - { - var x = { - test: function () { - alert('This is ok'); - - } - }; - - this.active = true; - - } - -}; - -var myFunc = function() -{ - var x = 1; - - blah(function() { - alert(2); - }); - - blah(function() { alert(2); }); - - return x; - -} - -a.prototype = { - - a: function() - { - var settings = { - default: '' - }; - - }, - - b: function() - { - var self = this; - - } - -}; - -var a = new function() -{ - this.initScreen = function(usersFolderid) - { - for (var i = 0; i < paramSelectors.length; i++) { - }//end for - } - -}; - -a.prototype = { - - this.addItem( - id, - { - b: function() - { - for (var i = 0; i < paramSelectors.length; i++) { - }//end for - - } - } - ) - -}; diff --git a/src/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.js.fixed b/src/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.js.fixed deleted file mode 100644 index db272adc2f..0000000000 --- a/src/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.js.fixed +++ /dev/null @@ -1,133 +0,0 @@ -function FuncOne() -{ - // Code here. - -}//end AdjustModalDialogWidgetType - - -Testing.prototype = { - - doSomething: function() - { - // Code here. - - }, - - doSomethingElse: function() - { - // Code here. - - }, -}; - -function FuncFour() -{ - // Code here. - -} - -function FuncFive() -{ - // Code here. - -} - -function valid() -{ - if (true) { - test = { - namespaces: {} - }; - } - -} - -dfx.addEvent(this.rightScroll, 'mousedown', function() { - t = setInterval(function() { - pos -= 10; - }, 30); -}); - -// Valid because function is empty. -if (dfx.isFn(callback) === false) { - callback = function() {}; - callback = function() {}; -} - -AbstractAttributeEditorWidgetType.prototype = { - isActive: function() { - return this.active; - - }, - - activate: function(data) - { - var x = { - test: function () { - alert('This is ok'); - } - }; - - this.active = true; - - } - -}; - -var myFunc = function() -{ - var x = 1; - - blah(function() { - alert(2); - }); - - blah(function() { alert(2); -}); - - return x; - -} - -a.prototype = { - - a: function() - { - var settings = { - default: '' - }; - - }, - - b: function() - { - var self = this; - - } - -}; - -var a = new function() -{ - this.initScreen = function(usersFolderid) - { - for (var i = 0; i < paramSelectors.length; i++) { - }//end for - } - -}; - -a.prototype = { - - this.addItem( - id, - { - b: function() - { - for (var i = 0; i < paramSelectors.length; i++) { - }//end for - } - } - ) - -}; diff --git a/src/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php index 7361cf499d..fbd6cc9b07 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/FunctionClosingBraceSpaceUnitTest.php @@ -26,42 +26,22 @@ final class FunctionClosingBraceSpaceUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * - * @param string $testFile The name of the file being tested. - * * @return array */ - public function getErrorList($testFile='') + public function getErrorList() { - switch ($testFile) { - case 'FunctionClosingBraceSpaceUnitTest.inc': - return [ - 10 => 1, - 21 => 1, - 28 => 1, - 29 => 1, - 31 => 1, - 39 => 1, - 66 => 1, - 72 => 1, - 81 => 1, - 88 => 1, - ]; - - case 'FunctionClosingBraceSpaceUnitTest.js': - return [ - 13 => 1, - 25 => 1, - 32 => 1, - 53 => 1, - 59 => 1, - 67 => 1, - 84 => 1, - 128 => 1, - ]; - - default: - return []; - }//end switch + return [ + 10 => 1, + 21 => 1, + 28 => 1, + 29 => 1, + 31 => 1, + 39 => 1, + 66 => 1, + 72 => 1, + 81 => 1, + 88 => 1, + ]; }//end getErrorList() diff --git a/src/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.js b/src/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.js deleted file mode 100644 index 71fd2a94e1..0000000000 --- a/src/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.js +++ /dev/null @@ -1,115 +0,0 @@ -function FuncOne() -{ - // Code here. - -}//end AdjustModalDialogWidgetType - - -Testing.prototype = { - - doSomething: function() - { - - // Code here. - - }, - - doSomethingElse: function() - { - // Code here. - - }, - - start: function() - { - this.toolbarPlugin.addButton('Image', 'imageEditor', 'Insert/Edit Image', function () { self.editImage() }); - - }, -}; - -function FuncFour() -{ - - - // Code here. -} - -AbstractAttributeEditorWidgetType.prototype = { - isActive: function() { - - return this.active; - - }, - - activate: function(data) - { - var x = { - test: function () { - alert('This is ok'); - } - }; - - this.active = true; - - } - -}; - -function test() { - var x = 1; - var y = function() - { - alert(1); - } - - return x; - -} - -var myFunc = function() -{ - var x = 1; - - blah(x, y, function() - { - alert(2); - }, z); - - blah(function() { alert(2); }); - - return x; - -} - -HelpWidgetType.prototype = { - init: function() { - var x = 1; - var y = { - test: function() { - - - alert(3); - } - } - return x; - - } -} - -CustomFormEditWidgetType.prototype = { - - addQuestion: function() - { - var settings = { - default: '' - }; - - }, - - addQuestionRulesEvent: function() - { - var self = this; - - } - -}; diff --git a/src/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.js.fixed b/src/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.js.fixed deleted file mode 100644 index d3f27fd96e..0000000000 --- a/src/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.js.fixed +++ /dev/null @@ -1,109 +0,0 @@ -function FuncOne() -{ - // Code here. - -}//end AdjustModalDialogWidgetType - - -Testing.prototype = { - - doSomething: function() - { - // Code here. - - }, - - doSomethingElse: function() - { - // Code here. - - }, - - start: function() - { - this.toolbarPlugin.addButton('Image', 'imageEditor', 'Insert/Edit Image', function () { self.editImage() }); - - }, -}; - -function FuncFour() -{ - // Code here. -} - -AbstractAttributeEditorWidgetType.prototype = { - isActive: function() { - return this.active; - - }, - - activate: function(data) - { - var x = { - test: function () { - alert('This is ok'); - } - }; - - this.active = true; - - } - -}; - -function test() { - var x = 1; - var y = function() - { - alert(1); - } - - return x; - -} - -var myFunc = function() -{ - var x = 1; - - blah(x, y, function() - { - alert(2); - }, z); - - blah(function() { alert(2); }); - - return x; - -} - -HelpWidgetType.prototype = { - init: function() { - var x = 1; - var y = { - test: function() { - alert(3); - } - } - return x; - - } -} - -CustomFormEditWidgetType.prototype = { - - addQuestion: function() - { - var settings = { - default: '' - }; - - }, - - addQuestionRulesEvent: function() - { - var self = this; - - } - -}; diff --git a/src/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php index dcfb3dd17b..84db17edf0 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/FunctionOpeningBraceSpaceUnitTest.php @@ -26,31 +26,15 @@ final class FunctionOpeningBraceSpaceUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * - * @param string $testFile The name of the file being tested. - * * @return array */ - public function getErrorList($testFile='') + public function getErrorList() { - switch ($testFile) { - case 'FunctionOpeningBraceSpaceUnitTest.inc': - return [ - 10 => 1, - 25 => 1, - 49 => 1, - ]; - - case 'FunctionOpeningBraceSpaceUnitTest.js': - return [ - 11 => 1, - 31 => 1, - 38 => 1, - 88 => 1, - ]; - - default: - return []; - }//end switch + return [ + 10 => 1, + 25 => 1, + 49 => 1, + ]; }//end getErrorList() diff --git a/src/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.js b/src/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.js deleted file mode 100644 index 694fbc61be..0000000000 --- a/src/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.js +++ /dev/null @@ -1,19 +0,0 @@ - - -if (foo || bar) {} -if (foo||bar && baz) {} -if (foo|| bar&&baz) {} -if (foo || bar && baz) {} - -// Spacing after || below is ignored as it is EOL whitespace. -if (foo || - bar - && baz -) { -} - -if (foo|| - bar - &&baz -) { -} diff --git a/src/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.js.fixed b/src/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.js.fixed deleted file mode 100644 index 8f06a35be4..0000000000 --- a/src/Standards/Squiz/Tests/WhiteSpace/LogicalOperatorSpacingUnitTest.js.fixed +++ /dev/null @@ -1,19 +0,0 @@ - - -if (foo || bar) {} -if (foo || bar && baz) {} -if (foo || bar && baz) {} -if (foo || bar && baz) {} - -// Spacing after || below is ignored as it is EOL whitespace. -if (foo || - bar - && baz -) { -} - -if (foo || - bar - && baz -) { -} diff --git a/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js b/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js deleted file mode 100644 index f37df9d863..0000000000 --- a/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js +++ /dev/null @@ -1,104 +0,0 @@ - - -result = 1 + 2; -result = 1 + 2; -result = 1 + 2; -result = 1 +2; -result = 1+ 2; -result = 1+2; - -result = 1 - 2; -result = 1 - 2; -result = 1 - 2; -result = 1 -2; -result = 1- 2; -result = 1-2; - -result = 1 * 2; -result = 1 * 2; -result = 1 * 2; -result = 1 *2; -result = 1* 2; -result = 1*2; - -result = 1 / 2; -result = 1 / 2; -result = 1 / 2; -result = 1 /2; -result = 1/ 2; -result = 1/2; - -result = 1 % 2; -result = 1 % 2; -result = 1 % 2; -result = 1 %2; -result = 1% 2; -result = 1%2; -result = '100%'; - -result += 4; -result+=4; -result -= 4; -result-=4; -result /= 4; -result/=4; -result *=4; -result*=4; - -$.localScroll({offset: {top: -32}}); - -switch (result) { - case -1: - break; -} - -result = x?y:z; -result = x ? y : z; - -if (something === true - ^ somethingElse === true -) { - return false; -} - -y = 1 - + 2 - - 3; - -y = 1 + - 2 - - 3; - -y = 1 -+ 2 -- 3; - -// phpcs:set Squiz.WhiteSpace.OperatorSpacing ignoreNewlines true -y = 1 - + 2 - - 3; - -y = 1 + - 2 - - 3; - -y = 1 -+ 2 -- 3; -// phpcs:set Squiz.WhiteSpace.OperatorSpacing ignoreNewlines false - -if (true || -1 == b) { -} - -x = x << y; -x <<= y; -x = x >> y; -x >>= y; -x = x >>> y; -x >>>= y; - -var foo = bar.map(baz=> baz.length); - -// phpcs:set Squiz.WhiteSpace.OperatorSpacing ignoreSpacingBeforeAssignments false -a = 3; -// phpcs:set Squiz.WhiteSpace.OperatorSpacing ignoreSpacingBeforeAssignments true diff --git a/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js.fixed b/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js.fixed deleted file mode 100644 index 47c89302b3..0000000000 --- a/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js.fixed +++ /dev/null @@ -1,98 +0,0 @@ - - -result = 1 + 2; -result = 1 + 2; -result = 1 + 2; -result = 1 + 2; -result = 1 + 2; -result = 1 + 2; - -result = 1 - 2; -result = 1 - 2; -result = 1 - 2; -result = 1 - 2; -result = 1 - 2; -result = 1 - 2; - -result = 1 * 2; -result = 1 * 2; -result = 1 * 2; -result = 1 * 2; -result = 1 * 2; -result = 1 * 2; - -result = 1 / 2; -result = 1 / 2; -result = 1 / 2; -result = 1 / 2; -result = 1 / 2; -result = 1 / 2; - -result = 1 % 2; -result = 1 % 2; -result = 1 % 2; -result = 1 % 2; -result = 1 % 2; -result = 1 % 2; -result = '100%'; - -result += 4; -result += 4; -result -= 4; -result -= 4; -result /= 4; -result /= 4; -result *= 4; -result *= 4; - -$.localScroll({offset: {top: -32}}); - -switch (result) { - case -1: - break; -} - -result = x ? y : z; -result = x ? y : z; - -if (something === true - ^ somethingElse === true -) { - return false; -} - -y = 1 + 2 - 3; - -y = 1 + 2 - 3; - -y = 1 + 2 - 3; - -// phpcs:set Squiz.WhiteSpace.OperatorSpacing ignoreNewlines true -y = 1 - + 2 - - 3; - -y = 1 + - 2 - - 3; - -y = 1 -+ 2 -- 3; -// phpcs:set Squiz.WhiteSpace.OperatorSpacing ignoreNewlines false - -if (true || -1 == b) { -} - -x = x << y; -x <<= y; -x = x >> y; -x >>= y; -x = x >>> y; -x >>>= y; - -var foo = bar.map(baz => baz.length); - -// phpcs:set Squiz.WhiteSpace.OperatorSpacing ignoreSpacingBeforeAssignments false -a = 3; -// phpcs:set Squiz.WhiteSpace.OperatorSpacing ignoreSpacingBeforeAssignments true diff --git a/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php index e34a2ec4a8..c1cb3e22bf 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php @@ -112,49 +112,6 @@ public function getErrorList($testFile='') 504 => 1, ]; - case 'OperatorSpacingUnitTest.js': - return [ - 4 => 1, - 5 => 2, - 6 => 1, - 7 => 1, - 8 => 2, - 11 => 1, - 12 => 2, - 13 => 1, - 14 => 1, - 15 => 2, - 18 => 1, - 19 => 2, - 20 => 1, - 21 => 1, - 22 => 2, - 25 => 1, - 26 => 2, - 27 => 1, - 28 => 1, - 29 => 2, - 32 => 1, - 33 => 2, - 34 => 1, - 35 => 1, - 36 => 2, - 40 => 2, - 42 => 2, - 44 => 2, - 45 => 1, - 46 => 2, - 55 => 4, - 65 => 1, - 66 => 1, - 68 => 1, - 69 => 1, - 73 => 1, - 74 => 1, - 100 => 1, - 103 => 2, - ]; - default: return []; }//end switch diff --git a/src/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.js b/src/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.js deleted file mode 100644 index 15890b96ae..0000000000 --- a/src/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.js +++ /dev/null @@ -1,40 +0,0 @@ -var x = { - b: 'x', - xasd: x, - abc:x, - a: function () { - alert('thats right'); - x = (x?a:x); - }, - casdasd : 123123, - omgwtfbbq: { - a: 1, - b: 2 - } -}; - -id = id.replace(/row\/:/gi, ''); - -outer_loop: -for (i=0; i<3; i++) { - for (j=0; j<5; j++) { - if (j==x) - break outer_loop; - } -} -alert('hi'); - -even_number: if ((i % 2) == 0) { - if (i == 12) - break even_number; -} - -switch (blah) { - case dfx.DOM_VK_LEFT: - this.caretLeft(shiftKey); - break; - default: - if (blah) { - } - break; -} diff --git a/src/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.js.fixed b/src/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.js.fixed deleted file mode 100644 index f332878e6e..0000000000 --- a/src/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.js.fixed +++ /dev/null @@ -1,39 +0,0 @@ -var x = { - b: 'x', - xasd: x, - abc: x, - a: function () { - alert('thats right'); - x = (x?a:x); - }, - casdasd: 123123, - omgwtfbbq: { - a: 1, - b: 2 - } -}; - -id = id.replace(/row\/:/gi, ''); - -outer_loop: for (i=0; i<3; i++) { - for (j=0; j<5; j++) { - if (j==x) - break outer_loop; - } -} -alert('hi'); - -even_number: if ((i % 2) == 0) { - if (i == 12) - break even_number; -} - -switch (blah) { - case dfx.DOM_VK_LEFT: - this.caretLeft(shiftKey); - break; - default: - if (blah) { - } - break; -} diff --git a/src/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.php deleted file mode 100644 index 5c20b00104..0000000000 --- a/src/Standards/Squiz/Tests/WhiteSpace/PropertyLabelSpacingUnitTest.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Standards\Squiz\Tests\WhiteSpace; - -use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; - -/** - * Unit test class for the PropertyLabel sniff. - * - * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\PropertyLabelSpacingSniff - */ -final class PropertyLabelSpacingUnitTest extends AbstractSniffUnitTest -{ - - - /** - * Returns the lines where errors should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array - */ - public function getErrorList() - { - return [ - 2 => 1, - 4 => 1, - 9 => 2, - 10 => 1, - 12 => 1, - 18 => 1, - ]; - - }//end getErrorList() - - - /** - * Returns the lines where warnings should occur. - * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array - */ - public function getWarningList() - { - return []; - - }//end getWarningList() - - -}//end class diff --git a/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.js b/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.js deleted file mode 100644 index 3aafd6da90..0000000000 --- a/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.js +++ /dev/null @@ -1,25 +0,0 @@ -var x = { - a: function () { - alert('thats right') ; - x = (x?a:x) ; - }, -} ; - -id = id.replace(/row\/:;/gi, ''); - -for (i=0 ; i<3 ; i++) { - for (j=0; j<5 ; j++) { - if (j==x) - break ; - } -} -alert('hi'); -; - -var sum = a /* + b */; - -var sum = a // +b -; - -var sum = a /* +b - + c */ ; diff --git a/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.js.fixed b/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.js.fixed deleted file mode 100644 index a547144dee..0000000000 --- a/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.js.fixed +++ /dev/null @@ -1,25 +0,0 @@ -var x = { - a: function () { - alert('thats right'); - x = (x?a:x); - }, -}; - -id = id.replace(/row\/:;/gi, ''); - -for (i=0; i<3; i++) { - for (j=0; j<5; j++) { - if (j==x) - break; - } -} -alert('hi'); -; - -var sum = a; /* + b */ - -var sum = a; // +b - - -var sum = a; /* +b - + c */ diff --git a/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php index 218666dc09..7347708da7 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php @@ -26,45 +26,24 @@ final class SemicolonSpacingUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * - * @param string $testFile The name of the file being tested. - * * @return array */ - public function getErrorList($testFile='') + public function getErrorList() { - switch ($testFile) { - case 'SemicolonSpacingUnitTest.inc': - return [ - 3 => 1, - 4 => 1, - 5 => 2, - 6 => 1, - 8 => 1, - 9 => 1, - 14 => 1, - 16 => 1, - 18 => 1, - 29 => 1, - 30 => 2, - 36 => 1, - ]; - - case 'SemicolonSpacingUnitTest.js': - return [ - 3 => 1, - 4 => 1, - 6 => 1, - 10 => 2, - 11 => 1, - 13 => 1, - 19 => 1, - 22 => 1, - 25 => 1, - ]; - - default: - return []; - }//end switch + return [ + 3 => 1, + 4 => 1, + 5 => 2, + 6 => 1, + 8 => 1, + 9 => 1, + 14 => 1, + 16 => 1, + 18 => 1, + 29 => 1, + 30 => 2, + 36 => 1, + ]; }//end getErrorList() diff --git a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.1.css b/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.1.css deleted file mode 100644 index e3f3f02918..0000000000 --- a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.1.css +++ /dev/null @@ -1,32 +0,0 @@ - -.HelpWidgetType-new-bug-title { - float: left; -} -.HelpWidgetType-new-bug-title { - float: left; -} -.HelpWidgetType-new-bug-title { - float: left; -} - -.HelpWidgetType-new-bug-title{ - float: left; -} - -/* phpcs:set Squiz.WhiteSpace.SuperfluousWhitespace ignoreBlankLines true */ -.HelpWidgetType-new-bug-title{ - float: left; -} - -.HelpWidgetType-new-bug-title{ - float: left; -} -/* phpcs:set Squiz.WhiteSpace.SuperfluousWhitespace ignoreBlankLines false */ - -// /** -// * This text is in two types of comment: each line is commented out -// * individually, and the whole block is in what looks like a -// * docblock-comment. This sniff should ignore all this text as there -// * is no superfluous white-space here. -// */ - diff --git a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.1.css.fixed b/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.1.css.fixed deleted file mode 100644 index 11be21d5c9..0000000000 --- a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.1.css.fixed +++ /dev/null @@ -1,30 +0,0 @@ -.HelpWidgetType-new-bug-title { - float: left; -} -.HelpWidgetType-new-bug-title { - float: left; -} -.HelpWidgetType-new-bug-title { - float: left; -} - -.HelpWidgetType-new-bug-title{ - float: left; -} - -/* phpcs:set Squiz.WhiteSpace.SuperfluousWhitespace ignoreBlankLines true */ -.HelpWidgetType-new-bug-title{ - float: left; -} - -.HelpWidgetType-new-bug-title{ - float: left; -} -/* phpcs:set Squiz.WhiteSpace.SuperfluousWhitespace ignoreBlankLines false */ - -// /** -// * This text is in two types of comment: each line is commented out -// * individually, and the whole block is in what looks like a -// * docblock-comment. This sniff should ignore all this text as there -// * is no superfluous white-space here. -// */ diff --git a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.1.js b/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.1.js deleted file mode 100644 index be542e776a..0000000000 --- a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.1.js +++ /dev/null @@ -1,56 +0,0 @@ - -alert('hi'); -alert('hello'); - -if (something) { - -} - - -function myFunction() -{ - alert('code here'); - - alert('code here'); - - - // Hello. - - /* - HI - */ - - -} - -function myFunction2() -{ - alert('code here'); - - - alert('code here'); - -} - -MyFunction = function() -{ - alert('code here'); - - - alert('code here'); - -}; - -// phpcs:set Squiz.WhiteSpace.SuperfluousWhitespace ignoreBlankLines true - -function myFunction2() -{ - alert('code here'); - - alert('code here'); - -} - -// phpcs:set Squiz.WhiteSpace.SuperfluousWhitespace ignoreBlankLines false - - diff --git a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.1.js.fixed b/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.1.js.fixed deleted file mode 100644 index 960111a5e4..0000000000 --- a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.1.js.fixed +++ /dev/null @@ -1,50 +0,0 @@ -alert('hi'); -alert('hello'); - -if (something) { - -} - - -function myFunction() -{ - alert('code here'); - - alert('code here'); - - // Hello. - - /* - HI - */ - -} - -function myFunction2() -{ - alert('code here'); - - alert('code here'); - -} - -MyFunction = function() -{ - alert('code here'); - - alert('code here'); - -}; - -// phpcs:set Squiz.WhiteSpace.SuperfluousWhitespace ignoreBlankLines true - -function myFunction2() -{ - alert('code here'); - - alert('code here'); - -} - -// phpcs:set Squiz.WhiteSpace.SuperfluousWhitespace ignoreBlankLines false - diff --git a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.2.css b/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.2.css deleted file mode 100644 index 2025eeb195..0000000000 --- a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.2.css +++ /dev/null @@ -1,3 +0,0 @@ -.HelpWidgetType-new-bug-title { - float: left; -} \ No newline at end of file diff --git a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.2.css.fixed b/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.2.css.fixed deleted file mode 100644 index 2025eeb195..0000000000 --- a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.2.css.fixed +++ /dev/null @@ -1,3 +0,0 @@ -.HelpWidgetType-new-bug-title { - float: left; -} \ No newline at end of file diff --git a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.2.js b/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.2.js deleted file mode 100644 index 7b0c8eacda..0000000000 --- a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.2.js +++ /dev/null @@ -1 +0,0 @@ -alert('hi'); \ No newline at end of file diff --git a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.2.js.fixed b/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.2.js.fixed deleted file mode 100644 index 7b0c8eacda..0000000000 --- a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.2.js.fixed +++ /dev/null @@ -1 +0,0 @@ -alert('hi'); \ No newline at end of file diff --git a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.3.css b/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.3.css deleted file mode 100644 index 9f794a0820..0000000000 --- a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.3.css +++ /dev/null @@ -1,3 +0,0 @@ -.HelpWidgetType-new-bug-title { - float: left; -} diff --git a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.3.css.fixed b/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.3.css.fixed deleted file mode 100644 index 2025eeb195..0000000000 --- a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.3.css.fixed +++ /dev/null @@ -1,3 +0,0 @@ -.HelpWidgetType-new-bug-title { - float: left; -} \ No newline at end of file diff --git a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.3.js b/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.3.js deleted file mode 100644 index 70f67193ad..0000000000 --- a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.3.js +++ /dev/null @@ -1 +0,0 @@ -alert('hi'); diff --git a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.3.js.fixed b/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.3.js.fixed deleted file mode 100644 index 70f67193ad..0000000000 --- a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.3.js.fixed +++ /dev/null @@ -1 +0,0 @@ -alert('hi'); diff --git a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php b/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php index 4f7c7cdbcf..7bc0054b18 100644 --- a/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php +++ b/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php @@ -69,29 +69,6 @@ public function getErrorList($testFile='') 4 => 1, ]; - case 'SuperfluousWhitespaceUnitTest.1.js': - return [ - 1 => 1, - 3 => 1, - 4 => 1, - 5 => 1, - 6 => 1, - 15 => 1, - 22 => 1, - 29 => 1, - 38 => 1, - 56 => 1, - ]; - - case 'SuperfluousWhitespaceUnitTest.1.css': - return [ - 1 => 1, - 8 => 1, - 9 => 1, - 11 => 1, - 32 => 1, - ]; - default: return []; }//end switch diff --git a/src/Standards/Squiz/ruleset.xml b/src/Standards/Squiz/ruleset.xml index 1767d84cfc..0b5af6b85d 100644 --- a/src/Standards/Squiz/ruleset.xml +++ b/src/Standards/Squiz/ruleset.xml @@ -70,23 +70,6 @@ 0 - - - - - - - - - - - - - - - %2$s - - diff --git a/src/Tokenizers/CSS.php b/src/Tokenizers/CSS.php deleted file mode 100644 index 36631ddc39..0000000000 --- a/src/Tokenizers/CSS.php +++ /dev/null @@ -1,541 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Tokenizers; - -use PHP_CodeSniffer\Config; -use PHP_CodeSniffer\Exceptions\TokenizerException; -use PHP_CodeSniffer\Util; - -class CSS extends PHP -{ - - - /** - * Initialise the tokenizer. - * - * Pre-checks the content to see if it looks minified. - * - * @param string $content The content to tokenize. - * @param \PHP_CodeSniffer\Config $config The config data for the run. - * @param string $eolChar The EOL char used in the content. - * - * @return void - * @throws \PHP_CodeSniffer\Exceptions\TokenizerException If the file appears to be minified. - */ - public function __construct($content, Config $config, $eolChar='\n') - { - if ($this->isMinifiedContent($content, $eolChar) === true) { - throw new TokenizerException('File appears to be minified and cannot be processed'); - } - - parent::__construct($content, $config, $eolChar); - - }//end __construct() - - - /** - * Creates an array of tokens when given some CSS code. - * - * Uses the PHP tokenizer to do all the tricky work - * - * @param string $string The string to tokenize. - * - * @return array - */ - public function tokenize($string) - { - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t*** START CSS TOKENIZING 1ST PASS ***".PHP_EOL; - } - - // If the content doesn't have an EOL char on the end, add one so - // the open and close tags we add are parsed correctly. - $eolAdded = false; - if (substr($string, (strlen($this->eolChar) * -1)) !== $this->eolChar) { - $string .= $this->eolChar; - $eolAdded = true; - } - - $string = str_replace('', '^PHPCS_CSS_T_CLOSE_TAG^', $string); - $tokens = parent::tokenize(''); - - $finalTokens = []; - $finalTokens[0] = [ - 'code' => T_OPEN_TAG, - 'type' => 'T_OPEN_TAG', - 'content' => '', - ]; - - $newStackPtr = 1; - $numTokens = count($tokens); - $multiLineComment = false; - for ($stackPtr = 1; $stackPtr < $numTokens; $stackPtr++) { - $token = $tokens[$stackPtr]; - - // CSS files don't have lists, breaks etc, so convert these to - // standard strings early so they can be converted into T_STYLE - // tokens and joined with other strings if needed. - if ($token['code'] === T_BREAK - || $token['code'] === T_LIST - || $token['code'] === T_DEFAULT - || $token['code'] === T_SWITCH - || $token['code'] === T_FOR - || $token['code'] === T_FOREACH - || $token['code'] === T_WHILE - || $token['code'] === T_DEC - || $token['code'] === T_NEW - ) { - $token['type'] = 'T_STRING'; - $token['code'] = T_STRING; - } - - $token['content'] = str_replace('^PHPCS_CSS_T_OPEN_TAG^', '', $token['content']); - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $type = $token['type']; - $content = Util\Common::prepareForOutput($token['content']); - echo "\tProcess token $stackPtr: $type => $content".PHP_EOL; - } - - if ($token['code'] === T_BITWISE_XOR - && $tokens[($stackPtr + 1)]['content'] === 'PHPCS_CSS_T_OPEN_TAG' - ) { - $content = ''; - $stackPtr += 2; - break; - } else { - $content .= $tokens[$stackPtr]['content']; - } - } - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t\t=> Found embedded PHP code: "; - $cleanContent = Util\Common::prepareForOutput($content); - echo $cleanContent.PHP_EOL; - } - - $finalTokens[$newStackPtr] = [ - 'type' => 'T_EMBEDDED_PHP', - 'code' => T_EMBEDDED_PHP, - 'content' => $content, - ]; - - $newStackPtr++; - continue; - }//end if - - if ($token['code'] === T_GOTO_LABEL) { - // Convert these back to T_STRING followed by T_COLON so we can - // more easily process style definitions. - $finalTokens[$newStackPtr] = [ - 'type' => 'T_STRING', - 'code' => T_STRING, - 'content' => substr($token['content'], 0, -1), - ]; - $newStackPtr++; - $finalTokens[$newStackPtr] = [ - 'type' => 'T_COLON', - 'code' => T_COLON, - 'content' => ':', - ]; - $newStackPtr++; - continue; - } - - if ($token['code'] === T_FUNCTION) { - // There are no functions in CSS, so convert this to a string. - $finalTokens[$newStackPtr] = [ - 'type' => 'T_STRING', - 'code' => T_STRING, - 'content' => $token['content'], - ]; - - $newStackPtr++; - continue; - } - - if ($token['code'] === T_COMMENT - && substr($token['content'], 0, 2) === '/*' - ) { - // Multi-line comment. Record it so we can ignore other - // comment tags until we get out of this one. - $multiLineComment = true; - } - - if ($token['code'] === T_COMMENT - && $multiLineComment === false - && (substr($token['content'], 0, 2) === '//' - || $token['content'][0] === '#') - ) { - $content = ltrim($token['content'], '#/'); - - // Guard against PHP7+ syntax errors by stripping - // leading zeros so the content doesn't look like an invalid int. - $leadingZero = false; - if ($content[0] === '0') { - $content = '1'.$content; - $leadingZero = true; - } - - $commentTokens = parent::tokenize(''); - - // The first and last tokens are the open/close tags. - array_shift($commentTokens); - $closeTag = array_pop($commentTokens); - - while ($closeTag['content'] !== '?'.'>') { - $closeTag = array_pop($commentTokens); - } - - if ($leadingZero === true) { - $commentTokens[0]['content'] = substr($commentTokens[0]['content'], 1); - $content = substr($content, 1); - } - - if ($token['content'][0] === '#') { - // The # character is not a comment in CSS files, so - // determine what it means in this context. - $firstContent = $commentTokens[0]['content']; - - // If the first content is just a number, it is probably a - // colour like 8FB7DB, which PHP splits into 8 and FB7DB. - if (($commentTokens[0]['code'] === T_LNUMBER - || $commentTokens[0]['code'] === T_DNUMBER) - && $commentTokens[1]['code'] === T_STRING - ) { - $firstContent .= $commentTokens[1]['content']; - array_shift($commentTokens); - } - - // If the first content looks like a colour and not a class - // definition, join the tokens together. - if (preg_match('/^[ABCDEF0-9]+$/i', $firstContent) === 1 - && $commentTokens[1]['content'] !== '-' - ) { - array_shift($commentTokens); - // Work out what we trimmed off above and remember to re-add it. - $trimmed = substr($token['content'], 0, (strlen($token['content']) - strlen($content))); - $finalTokens[$newStackPtr] = [ - 'type' => 'T_COLOUR', - 'code' => T_COLOUR, - 'content' => $trimmed.$firstContent, - ]; - } else { - $finalTokens[$newStackPtr] = [ - 'type' => 'T_HASH', - 'code' => T_HASH, - 'content' => '#', - ]; - } - } else { - $finalTokens[$newStackPtr] = [ - 'type' => 'T_STRING', - 'code' => T_STRING, - 'content' => '//', - ]; - }//end if - - $newStackPtr++; - - array_splice($tokens, $stackPtr, 1, $commentTokens); - $numTokens = count($tokens); - $stackPtr--; - continue; - }//end if - - if ($token['code'] === T_COMMENT - && substr($token['content'], -2) === '*/' - ) { - // Multi-line comment is done. - $multiLineComment = false; - } - - $finalTokens[$newStackPtr] = $token; - $newStackPtr++; - }//end for - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t*** END CSS TOKENIZING 1ST PASS ***".PHP_EOL; - echo "\t*** START CSS TOKENIZING 2ND PASS ***".PHP_EOL; - } - - // A flag to indicate if we are inside a style definition, - // which is defined using curly braces. - $inStyleDef = false; - - // A flag to indicate if an At-rule like "@media" is used, which will result - // in nested curly brackets. - $asperandStart = false; - - $numTokens = count($finalTokens); - for ($stackPtr = 0; $stackPtr < $numTokens; $stackPtr++) { - $token = $finalTokens[$stackPtr]; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $type = $token['type']; - $content = Util\Common::prepareForOutput($token['content']); - echo "\tProcess token $stackPtr: $type => $content".PHP_EOL; - } - - switch ($token['code']) { - case T_OPEN_CURLY_BRACKET: - // Opening curly brackets for an At-rule do not start a style - // definition. We also reset the asperand flag here because the next - // opening curly bracket could be indeed the start of a style - // definition. - if ($asperandStart === true) { - if (PHP_CODESNIFFER_VERBOSITY > 1) { - if ($inStyleDef === true) { - echo "\t\t* style definition closed *".PHP_EOL; - } - - if ($asperandStart === true) { - echo "\t\t* at-rule definition closed *".PHP_EOL; - } - } - - $inStyleDef = false; - $asperandStart = false; - } else { - $inStyleDef = true; - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t\t* style definition opened *".PHP_EOL; - } - } - break; - case T_CLOSE_CURLY_BRACKET: - if (PHP_CODESNIFFER_VERBOSITY > 1) { - if ($inStyleDef === true) { - echo "\t\t* style definition closed *".PHP_EOL; - } - - if ($asperandStart === true) { - echo "\t\t* at-rule definition closed *".PHP_EOL; - } - } - - $inStyleDef = false; - $asperandStart = false; - break; - case T_MINUS: - // Minus signs are often used instead of spaces inside - // class names, IDs and styles. - if ($finalTokens[($stackPtr + 1)]['code'] === T_STRING) { - if ($finalTokens[($stackPtr - 1)]['code'] === T_STRING) { - $newContent = $finalTokens[($stackPtr - 1)]['content'].'-'.$finalTokens[($stackPtr + 1)]['content']; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t\t* token is a string joiner; ignoring this and previous token".PHP_EOL; - $old = Util\Common::prepareForOutput($finalTokens[($stackPtr + 1)]['content']); - $new = Util\Common::prepareForOutput($newContent); - echo "\t\t=> token ".($stackPtr + 1)." content changed from \"$old\" to \"$new\"".PHP_EOL; - } - - $finalTokens[($stackPtr + 1)]['content'] = $newContent; - unset($finalTokens[$stackPtr]); - unset($finalTokens[($stackPtr - 1)]); - } else { - $newContent = '-'.$finalTokens[($stackPtr + 1)]['content']; - - $finalTokens[($stackPtr + 1)]['content'] = $newContent; - unset($finalTokens[$stackPtr]); - } - } else if ($finalTokens[($stackPtr + 1)]['code'] === T_LNUMBER) { - // They can also be used to provide negative numbers. - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t\t* token is part of a negative number; adding content to next token and ignoring *".PHP_EOL; - $content = Util\Common::prepareForOutput($finalTokens[($stackPtr + 1)]['content']); - echo "\t\t=> token ".($stackPtr + 1)." content changed from \"$content\" to \"-$content\"".PHP_EOL; - } - - $finalTokens[($stackPtr + 1)]['content'] = '-'.$finalTokens[($stackPtr + 1)]['content']; - unset($finalTokens[$stackPtr]); - }//end if - break; - case T_COLON: - // Only interested in colons that are defining styles. - if ($inStyleDef === false) { - break; - } - - for ($x = ($stackPtr - 1); $x >= 0; $x--) { - if (isset(Util\Tokens::$emptyTokens[$finalTokens[$x]['code']]) === false) { - break; - } - } - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $type = $finalTokens[$x]['type']; - echo "\t\t=> token $x changed from $type to T_STYLE".PHP_EOL; - } - - $finalTokens[$x]['type'] = 'T_STYLE'; - $finalTokens[$x]['code'] = T_STYLE; - break; - case T_STRING: - if (strtolower($token['content']) === 'url') { - // Find the next content. - for ($x = ($stackPtr + 1); $x < $numTokens; $x++) { - if (isset(Util\Tokens::$emptyTokens[$finalTokens[$x]['code']]) === false) { - break; - } - } - - // Needs to be in the format "url(" for it to be a URL. - if ($finalTokens[$x]['code'] !== T_OPEN_PARENTHESIS) { - continue 2; - } - - // Make sure the content isn't empty. - for ($y = ($x + 1); $y < $numTokens; $y++) { - if (isset(Util\Tokens::$emptyTokens[$finalTokens[$y]['code']]) === false) { - break; - } - } - - if ($finalTokens[$y]['code'] === T_CLOSE_PARENTHESIS) { - continue 2; - } - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - for ($i = ($stackPtr + 1); $i <= $y; $i++) { - $type = $finalTokens[$i]['type']; - $content = Util\Common::prepareForOutput($finalTokens[$i]['content']); - echo "\tProcess token $i: $type => $content".PHP_EOL; - } - - echo "\t\t* token starts a URL *".PHP_EOL; - } - - // Join all the content together inside the url() statement. - $newContent = ''; - for ($i = ($x + 2); $i < $numTokens; $i++) { - if ($finalTokens[$i]['code'] === T_CLOSE_PARENTHESIS) { - break; - } - - $newContent .= $finalTokens[$i]['content']; - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $content = Util\Common::prepareForOutput($finalTokens[$i]['content']); - echo "\t\t=> token $i added to URL string and ignored: $content".PHP_EOL; - } - - unset($finalTokens[$i]); - } - - $stackPtr = $i; - - // If the content inside the "url()" is in double quotes - // there will only be one token and so we don't have to do - // anything except change its type. If it is not empty, - // we need to do some token merging. - $finalTokens[($x + 1)]['type'] = 'T_URL'; - $finalTokens[($x + 1)]['code'] = T_URL; - - if ($newContent !== '') { - $finalTokens[($x + 1)]['content'] .= $newContent; - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $content = Util\Common::prepareForOutput($finalTokens[($x + 1)]['content']); - echo "\t\t=> token content changed to: $content".PHP_EOL; - } - } - } else if ($finalTokens[$stackPtr]['content'][0] === '-' - && $finalTokens[($stackPtr + 1)]['code'] === T_STRING - ) { - if (isset($finalTokens[($stackPtr - 1)]) === true - && $finalTokens[($stackPtr - 1)]['code'] === T_STRING - ) { - $newContent = $finalTokens[($stackPtr - 1)]['content'].$finalTokens[$stackPtr]['content'].$finalTokens[($stackPtr + 1)]['content']; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t\t* token is a string joiner; ignoring this and previous token".PHP_EOL; - $old = Util\Common::prepareForOutput($finalTokens[($stackPtr + 1)]['content']); - $new = Util\Common::prepareForOutput($newContent); - echo "\t\t=> token ".($stackPtr + 1)." content changed from \"$old\" to \"$new\"".PHP_EOL; - } - - $finalTokens[($stackPtr + 1)]['content'] = $newContent; - unset($finalTokens[$stackPtr]); - unset($finalTokens[($stackPtr - 1)]); - } else { - $newContent = $finalTokens[$stackPtr]['content'].$finalTokens[($stackPtr + 1)]['content']; - - $finalTokens[($stackPtr + 1)]['content'] = $newContent; - unset($finalTokens[$stackPtr]); - } - }//end if - break; - case T_ASPERAND: - $asperandStart = true; - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t\t* at-rule definition opened *".PHP_EOL; - } - break; - default: - // Nothing special to be done with this token. - break; - }//end switch - }//end for - - // Reset the array keys to avoid gaps. - $finalTokens = array_values($finalTokens); - $numTokens = count($finalTokens); - - // Blank out the content of the end tag. - $finalTokens[($numTokens - 1)]['content'] = ''; - - if ($eolAdded === true) { - // Strip off the extra EOL char we added for tokenizing. - $finalTokens[($numTokens - 2)]['content'] = substr( - $finalTokens[($numTokens - 2)]['content'], - 0, - (strlen($this->eolChar) * -1) - ); - - if ($finalTokens[($numTokens - 2)]['content'] === '') { - unset($finalTokens[($numTokens - 2)]); - $finalTokens = array_values($finalTokens); - $numTokens = count($finalTokens); - } - } - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t*** END CSS TOKENIZING 2ND PASS ***".PHP_EOL; - } - - return $finalTokens; - - }//end tokenize() - - - /** - * Performs additional processing after main tokenizing. - * - * @return void - */ - public function processAdditional() - { - /* - We override this method because we don't want the PHP version to - run during CSS processing because it is wasted processing time. - */ - - }//end processAdditional() - - -}//end class diff --git a/src/Tokenizers/JS.php b/src/Tokenizers/JS.php deleted file mode 100644 index c7249fcd93..0000000000 --- a/src/Tokenizers/JS.php +++ /dev/null @@ -1,1256 +0,0 @@ - - * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Tokenizers; - -use PHP_CodeSniffer\Config; -use PHP_CodeSniffer\Exceptions\TokenizerException; -use PHP_CodeSniffer\Util; - -class JS extends Tokenizer -{ - - /** - * A list of tokens that are allowed to open a scope. - * - * This array also contains information about what kind of token the scope - * opener uses to open and close the scope, if the token strictly requires - * an opener, if the token can share a scope closer, and who it can be shared - * with. An example of a token that shares a scope closer is a CASE scope. - * - * @var array - */ - public $scopeOpeners = [ - T_IF => [ - 'start' => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET], - 'end' => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET], - 'strict' => false, - 'shared' => false, - 'with' => [], - ], - T_TRY => [ - 'start' => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET], - 'end' => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET], - 'strict' => true, - 'shared' => false, - 'with' => [], - ], - T_CATCH => [ - 'start' => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET], - 'end' => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET], - 'strict' => true, - 'shared' => false, - 'with' => [], - ], - T_ELSE => [ - 'start' => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET], - 'end' => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET], - 'strict' => false, - 'shared' => false, - 'with' => [], - ], - T_FOR => [ - 'start' => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET], - 'end' => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET], - 'strict' => false, - 'shared' => false, - 'with' => [], - ], - T_CLASS => [ - 'start' => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET], - 'end' => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET], - 'strict' => true, - 'shared' => false, - 'with' => [], - ], - T_FUNCTION => [ - 'start' => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET], - 'end' => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET], - 'strict' => false, - 'shared' => false, - 'with' => [], - ], - T_WHILE => [ - 'start' => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET], - 'end' => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET], - 'strict' => false, - 'shared' => false, - 'with' => [], - ], - T_DO => [ - 'start' => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET], - 'end' => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET], - 'strict' => true, - 'shared' => false, - 'with' => [], - ], - T_SWITCH => [ - 'start' => [T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET], - 'end' => [T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET], - 'strict' => true, - 'shared' => false, - 'with' => [], - ], - T_CASE => [ - 'start' => [T_COLON => T_COLON], - 'end' => [ - T_BREAK => T_BREAK, - T_RETURN => T_RETURN, - T_CONTINUE => T_CONTINUE, - T_THROW => T_THROW, - ], - 'strict' => true, - 'shared' => true, - 'with' => [ - T_DEFAULT => T_DEFAULT, - T_CASE => T_CASE, - T_SWITCH => T_SWITCH, - ], - ], - T_DEFAULT => [ - 'start' => [T_COLON => T_COLON], - 'end' => [ - T_BREAK => T_BREAK, - T_RETURN => T_RETURN, - T_CONTINUE => T_CONTINUE, - T_THROW => T_THROW, - ], - 'strict' => true, - 'shared' => true, - 'with' => [ - T_CASE => T_CASE, - T_SWITCH => T_SWITCH, - ], - ], - ]; - - /** - * A list of tokens that end the scope. - * - * This array is just a unique collection of the end tokens - * from the _scopeOpeners array. The data is duplicated here to - * save time during parsing of the file. - * - * @var array - */ - public $endScopeTokens = [ - T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET, - T_BREAK => T_BREAK, - ]; - - /** - * A list of special JS tokens and their types. - * - * @var array - */ - protected $tokenValues = [ - 'class' => 'T_CLASS', - 'function' => 'T_FUNCTION', - 'prototype' => 'T_PROTOTYPE', - 'try' => 'T_TRY', - 'catch' => 'T_CATCH', - 'return' => 'T_RETURN', - 'throw' => 'T_THROW', - 'break' => 'T_BREAK', - 'switch' => 'T_SWITCH', - 'continue' => 'T_CONTINUE', - 'if' => 'T_IF', - 'else' => 'T_ELSE', - 'do' => 'T_DO', - 'while' => 'T_WHILE', - 'for' => 'T_FOR', - 'var' => 'T_VAR', - 'case' => 'T_CASE', - 'default' => 'T_DEFAULT', - 'true' => 'T_TRUE', - 'false' => 'T_FALSE', - 'null' => 'T_NULL', - 'this' => 'T_THIS', - 'typeof' => 'T_TYPEOF', - '(' => 'T_OPEN_PARENTHESIS', - ')' => 'T_CLOSE_PARENTHESIS', - '{' => 'T_OPEN_CURLY_BRACKET', - '}' => 'T_CLOSE_CURLY_BRACKET', - '[' => 'T_OPEN_SQUARE_BRACKET', - ']' => 'T_CLOSE_SQUARE_BRACKET', - '?' => 'T_INLINE_THEN', - '.' => 'T_OBJECT_OPERATOR', - '+' => 'T_PLUS', - '-' => 'T_MINUS', - '*' => 'T_MULTIPLY', - '%' => 'T_MODULUS', - '/' => 'T_DIVIDE', - '^' => 'T_LOGICAL_XOR', - ',' => 'T_COMMA', - ';' => 'T_SEMICOLON', - ':' => 'T_COLON', - '<' => 'T_LESS_THAN', - '>' => 'T_GREATER_THAN', - '<<' => 'T_SL', - '>>' => 'T_SR', - '>>>' => 'T_ZSR', - '<<=' => 'T_SL_EQUAL', - '>>=' => 'T_SR_EQUAL', - '>>>=' => 'T_ZSR_EQUAL', - '<=' => 'T_IS_SMALLER_OR_EQUAL', - '>=' => 'T_IS_GREATER_OR_EQUAL', - '=>' => 'T_DOUBLE_ARROW', - '!' => 'T_BOOLEAN_NOT', - '||' => 'T_BOOLEAN_OR', - '&&' => 'T_BOOLEAN_AND', - '|' => 'T_BITWISE_OR', - '&' => 'T_BITWISE_AND', - '!=' => 'T_IS_NOT_EQUAL', - '!==' => 'T_IS_NOT_IDENTICAL', - '=' => 'T_EQUAL', - '==' => 'T_IS_EQUAL', - '===' => 'T_IS_IDENTICAL', - '-=' => 'T_MINUS_EQUAL', - '+=' => 'T_PLUS_EQUAL', - '*=' => 'T_MUL_EQUAL', - '/=' => 'T_DIV_EQUAL', - '%=' => 'T_MOD_EQUAL', - '++' => 'T_INC', - '--' => 'T_DEC', - '//' => 'T_COMMENT', - '/*' => 'T_COMMENT', - '/**' => 'T_DOC_COMMENT', - '*/' => 'T_COMMENT', - ]; - - /** - * A list string delimiters. - * - * @var array - */ - protected $stringTokens = [ - '\'' => '\'', - '"' => '"', - ]; - - /** - * A list tokens that start and end comments. - * - * @var array - */ - protected $commentTokens = [ - '//' => null, - '/*' => '*/', - '/**' => '*/', - ]; - - - /** - * Initialise the tokenizer. - * - * Pre-checks the content to see if it looks minified. - * - * @param string $content The content to tokenize. - * @param \PHP_CodeSniffer\Config $config The config data for the run. - * @param string $eolChar The EOL char used in the content. - * - * @return void - * @throws \PHP_CodeSniffer\Exceptions\TokenizerException If the file appears to be minified. - */ - public function __construct($content, Config $config, $eolChar='\n') - { - if ($this->isMinifiedContent($content, $eolChar) === true) { - throw new TokenizerException('File appears to be minified and cannot be processed'); - } - - parent::__construct($content, $config, $eolChar); - - }//end __construct() - - - /** - * Creates an array of tokens when given some JS code. - * - * @param string $string The string to tokenize. - * - * @return array - */ - public function tokenize($string) - { - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t*** START JS TOKENIZING ***".PHP_EOL; - } - - $maxTokenLength = 0; - foreach ($this->tokenValues as $token => $values) { - if (strlen($token) > $maxTokenLength) { - $maxTokenLength = strlen($token); - } - } - - $tokens = []; - $inString = ''; - $stringChar = null; - $inComment = ''; - $buffer = ''; - $preStringBuffer = ''; - $cleanBuffer = false; - - $commentTokenizer = new Comment(); - - $tokens[] = [ - 'code' => T_OPEN_TAG, - 'type' => 'T_OPEN_TAG', - 'content' => '', - ]; - - // Convert newlines to single characters for ease of - // processing. We will change them back later. - $string = str_replace($this->eolChar, "\n", $string); - - $chars = str_split($string); - $numChars = count($chars); - for ($i = 0; $i < $numChars; $i++) { - $char = $chars[$i]; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $content = Util\Common::prepareForOutput($char); - $bufferContent = Util\Common::prepareForOutput($buffer); - - if ($inString !== '') { - echo "\t"; - } - - if ($inComment !== '') { - echo "\t"; - } - - echo "\tProcess char $i => $content (buffer: $bufferContent)".PHP_EOL; - }//end if - - if ($inString === '' && $inComment === '' && $buffer !== '') { - // If the buffer only has whitespace and we are about to - // add a character, store the whitespace first. - if (trim($char) !== '' && trim($buffer) === '') { - $tokens[] = [ - 'code' => T_WHITESPACE, - 'type' => 'T_WHITESPACE', - 'content' => str_replace("\n", $this->eolChar, $buffer), - ]; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $content = Util\Common::prepareForOutput($buffer); - echo "\t=> Added token T_WHITESPACE ($content)".PHP_EOL; - } - - $buffer = ''; - } - - // If the buffer is not whitespace and we are about to - // add a whitespace character, store the content first. - if ($inString === '' - && $inComment === '' - && trim($char) === '' - && trim($buffer) !== '' - ) { - $tokens[] = [ - 'code' => T_STRING, - 'type' => 'T_STRING', - 'content' => str_replace("\n", $this->eolChar, $buffer), - ]; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $content = Util\Common::prepareForOutput($buffer); - echo "\t=> Added token T_STRING ($content)".PHP_EOL; - } - - $buffer = ''; - } - }//end if - - // Process strings. - if ($inComment === '' && isset($this->stringTokens[$char]) === true) { - if ($inString === $char) { - // This could be the end of the string, but make sure it - // is not escaped first. - $escapes = 0; - for ($x = ($i - 1); $x >= 0; $x--) { - if ($chars[$x] !== '\\') { - break; - } - - $escapes++; - } - - if ($escapes === 0 || ($escapes % 2) === 0) { - // There is an even number escape chars, - // so this is not escaped, it is the end of the string. - $tokens[] = [ - 'code' => T_CONSTANT_ENCAPSED_STRING, - 'type' => 'T_CONSTANT_ENCAPSED_STRING', - 'content' => str_replace("\n", $this->eolChar, $buffer).$char, - ]; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t\t* found end of string *".PHP_EOL; - $content = Util\Common::prepareForOutput($buffer.$char); - echo "\t=> Added token T_CONSTANT_ENCAPSED_STRING ($content)".PHP_EOL; - } - - $buffer = ''; - $preStringBuffer = ''; - $inString = ''; - $stringChar = null; - continue; - }//end if - } else if ($inString === '') { - $inString = $char; - $stringChar = $i; - $preStringBuffer = $buffer; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t\t* looking for string closer *".PHP_EOL; - } - }//end if - }//end if - - if ($inString !== '' && $char === "\n") { - // Unless this newline character is escaped, the string did not - // end before the end of the line, which means it probably - // wasn't a string at all (maybe a regex). - if ($chars[($i - 1)] !== '\\') { - $i = $stringChar; - $buffer = $preStringBuffer; - $preStringBuffer = ''; - $inString = ''; - $stringChar = null; - $char = $chars[$i]; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t\t* found newline before end of string, bailing *".PHP_EOL; - } - } - } - - $buffer .= $char; - - // We don't look for special tokens inside strings, - // so if we are in a string, we can continue here now - // that the current char is in the buffer. - if ($inString !== '') { - continue; - } - - // Special case for T_DIVIDE which can actually be - // the start of a regular expression. - if ($buffer === $char && $char === '/' && $chars[($i + 1)] !== '*') { - $regex = $this->getRegexToken($i, $string, $chars, $tokens); - if ($regex !== null) { - $tokens[] = [ - 'code' => T_REGULAR_EXPRESSION, - 'type' => 'T_REGULAR_EXPRESSION', - 'content' => $regex['content'], - ]; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $content = Util\Common::prepareForOutput($regex['content']); - echo "\t=> Added token T_REGULAR_EXPRESSION ($content)".PHP_EOL; - } - - $i = $regex['end']; - $buffer = ''; - $cleanBuffer = false; - continue; - }//end if - }//end if - - // Check for known tokens, but ignore tokens found that are not at - // the end of a string, like FOR and this.FORmat. - if (isset($this->tokenValues[strtolower($buffer)]) === true - && (preg_match('|[a-zA-z0-9_]|', $char) === 0 - || isset($chars[($i + 1)]) === false - || preg_match('|[a-zA-z0-9_]|', $chars[($i + 1)]) === 0) - ) { - $matchedToken = false; - $lookAheadLength = ($maxTokenLength - strlen($buffer)); - - if ($lookAheadLength > 0) { - // The buffer contains a token type, but we need - // to look ahead at the next chars to see if this is - // actually part of a larger token. For example, - // FOR and FOREACH. - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t\t* buffer possibly contains token, looking ahead $lookAheadLength chars *".PHP_EOL; - } - - $charBuffer = $buffer; - for ($x = 1; $x <= $lookAheadLength; $x++) { - if (isset($chars[($i + $x)]) === false) { - break; - } - - $charBuffer .= $chars[($i + $x)]; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $content = Util\Common::prepareForOutput($charBuffer); - echo "\t\t=> Looking ahead $x chars => $content".PHP_EOL; - } - - if (isset($this->tokenValues[strtolower($charBuffer)]) === true) { - // We've found something larger that matches - // so we can ignore this char. Except for 1 very specific - // case where a comment like /**/ needs to tokenize as - // T_COMMENT and not T_DOC_COMMENT. - $oldType = $this->tokenValues[strtolower($buffer)]; - $newType = $this->tokenValues[strtolower($charBuffer)]; - if ($oldType === 'T_COMMENT' - && $newType === 'T_DOC_COMMENT' - && $chars[($i + $x + 1)] === '/' - ) { - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t\t* look ahead ignored T_DOC_COMMENT, continuing *".PHP_EOL; - } - } else { - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t\t* look ahead found more specific token ($newType), ignoring $i *".PHP_EOL; - } - - $matchedToken = true; - break; - } - }//end if - }//end for - }//end if - - if ($matchedToken === false) { - if (PHP_CODESNIFFER_VERBOSITY > 1 && $lookAheadLength > 0) { - echo "\t\t* look ahead found nothing *".PHP_EOL; - } - - $value = $this->tokenValues[strtolower($buffer)]; - - if ($value === 'T_FUNCTION' && $buffer !== 'function') { - // The function keyword needs to be all lowercase or else - // it is just a function called "Function". - $value = 'T_STRING'; - } - - $tokens[] = [ - 'code' => constant($value), - 'type' => $value, - 'content' => $buffer, - ]; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $content = Util\Common::prepareForOutput($buffer); - echo "\t=> Added token $value ($content)".PHP_EOL; - } - - $cleanBuffer = true; - }//end if - } else if (isset($this->tokenValues[strtolower($char)]) === true) { - // No matter what token we end up using, we don't - // need the content in the buffer any more because we have - // found a valid token. - $newContent = substr(str_replace("\n", $this->eolChar, $buffer), 0, -1); - if ($newContent !== '') { - $tokens[] = [ - 'code' => T_STRING, - 'type' => 'T_STRING', - 'content' => $newContent, - ]; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $content = Util\Common::prepareForOutput(substr($buffer, 0, -1)); - echo "\t=> Added token T_STRING ($content)".PHP_EOL; - } - } - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t\t* char is token, looking ahead ".($maxTokenLength - 1).' chars *'.PHP_EOL; - } - - // The char is a token type, but we need to look ahead at the - // next chars to see if this is actually part of a larger token. - // For example, = and ===. - $charBuffer = $char; - $matchedToken = false; - for ($x = 1; $x <= $maxTokenLength; $x++) { - if (isset($chars[($i + $x)]) === false) { - break; - } - - $charBuffer .= $chars[($i + $x)]; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $content = Util\Common::prepareForOutput($charBuffer); - echo "\t\t=> Looking ahead $x chars => $content".PHP_EOL; - } - - if (isset($this->tokenValues[strtolower($charBuffer)]) === true) { - // We've found something larger that matches - // so we can ignore this char. - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $type = $this->tokenValues[strtolower($charBuffer)]; - echo "\t\t* look ahead found more specific token ($type), ignoring $i *".PHP_EOL; - } - - $matchedToken = true; - break; - } - }//end for - - if ($matchedToken === false) { - $value = $this->tokenValues[strtolower($char)]; - $tokens[] = [ - 'code' => constant($value), - 'type' => $value, - 'content' => $char, - ]; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t\t* look ahead found nothing *".PHP_EOL; - $content = Util\Common::prepareForOutput($char); - echo "\t=> Added token $value ($content)".PHP_EOL; - } - - $cleanBuffer = true; - } else { - $buffer = $char; - }//end if - }//end if - - // Keep track of content inside comments. - if ($inComment === '' - && array_key_exists($buffer, $this->commentTokens) === true - ) { - // This is not really a comment if the content - // looks like \// (i.e., it is escaped). - if (isset($chars[($i - 2)]) === true && $chars[($i - 2)] === '\\') { - $lastToken = array_pop($tokens); - $lastContent = $lastToken['content']; - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $value = $this->tokenValues[strtolower($lastContent)]; - $content = Util\Common::prepareForOutput($lastContent); - echo "\t=> Removed token $value ($content)".PHP_EOL; - } - - $lastChars = str_split($lastContent); - $lastNumChars = count($lastChars); - for ($x = 0; $x < $lastNumChars; $x++) { - $lastChar = $lastChars[$x]; - $value = $this->tokenValues[strtolower($lastChar)]; - $tokens[] = [ - 'code' => constant($value), - 'type' => $value, - 'content' => $lastChar, - ]; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $content = Util\Common::prepareForOutput($lastChar); - echo "\t=> Added token $value ($content)".PHP_EOL; - } - } - } else { - // We have started a comment. - $inComment = $buffer; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t\t* looking for end of comment *".PHP_EOL; - } - }//end if - } else if ($inComment !== '') { - if ($this->commentTokens[$inComment] === null) { - // Comment ends at the next newline. - if (strpos($buffer, "\n") !== false) { - $inComment = ''; - } - } else { - if ($this->commentTokens[$inComment] === $buffer) { - $inComment = ''; - } - } - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - if ($inComment === '') { - echo "\t\t* found end of comment *".PHP_EOL; - } - } - - if ($inComment === '' && $cleanBuffer === false) { - $tokens[] = [ - 'code' => T_STRING, - 'type' => 'T_STRING', - 'content' => str_replace("\n", $this->eolChar, $buffer), - ]; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $content = Util\Common::prepareForOutput($buffer); - echo "\t=> Added token T_STRING ($content)".PHP_EOL; - } - - $buffer = ''; - } - }//end if - - if ($cleanBuffer === true) { - $buffer = ''; - $cleanBuffer = false; - } - }//end for - - if (empty($buffer) === false) { - if ($inString !== '') { - // The string did not end before the end of the file, - // which means there was probably a syntax error somewhere. - $tokens[] = [ - 'code' => T_STRING, - 'type' => 'T_STRING', - 'content' => str_replace("\n", $this->eolChar, $buffer), - ]; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $content = Util\Common::prepareForOutput($buffer); - echo "\t=> Added token T_STRING ($content)".PHP_EOL; - } - } else { - // Buffer contains whitespace from the end of the file. - $tokens[] = [ - 'code' => T_WHITESPACE, - 'type' => 'T_WHITESPACE', - 'content' => str_replace("\n", $this->eolChar, $buffer), - ]; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $content = Util\Common::prepareForOutput($buffer); - echo "\t=> Added token T_WHITESPACE ($content)".PHP_EOL; - } - }//end if - }//end if - - $tokens[] = [ - 'code' => T_CLOSE_TAG, - 'type' => 'T_CLOSE_TAG', - 'content' => '', - ]; - - /* - Now that we have done some basic tokenizing, we need to - modify the tokens to join some together and split some apart - so they match what the PHP tokenizer does. - */ - - $finalTokens = []; - $newStackPtr = 0; - $numTokens = count($tokens); - for ($stackPtr = 0; $stackPtr < $numTokens; $stackPtr++) { - $token = $tokens[$stackPtr]; - - /* - Look for comments and join the tokens together. - */ - - if ($token['code'] === T_COMMENT || $token['code'] === T_DOC_COMMENT) { - $newContent = ''; - $tokenContent = $token['content']; - - $endContent = null; - if (isset($this->commentTokens[$tokenContent]) === true) { - $endContent = $this->commentTokens[$tokenContent]; - } - - while ($tokenContent !== $endContent) { - if ($endContent === null - && strpos($tokenContent, $this->eolChar) !== false - ) { - // A null end token means the comment ends at the end of - // the line so we look for newlines and split the token. - $tokens[$stackPtr]['content'] = substr( - $tokenContent, - (strpos($tokenContent, $this->eolChar) + strlen($this->eolChar)) - ); - - $tokenContent = substr( - $tokenContent, - 0, - (strpos($tokenContent, $this->eolChar) + strlen($this->eolChar)) - ); - - // If the substr failed, skip the token as the content - // will now be blank. - if ($tokens[$stackPtr]['content'] !== false - && $tokens[$stackPtr]['content'] !== '' - ) { - $stackPtr--; - } - - break; - }//end if - - $stackPtr++; - $newContent .= $tokenContent; - if (isset($tokens[$stackPtr]) === false) { - break; - } - - $tokenContent = $tokens[$stackPtr]['content']; - }//end while - - if ($token['code'] === T_DOC_COMMENT) { - $commentTokens = $commentTokenizer->tokenizeString($newContent.$tokenContent, $this->eolChar, $newStackPtr); - foreach ($commentTokens as $commentToken) { - $finalTokens[$newStackPtr] = $commentToken; - $newStackPtr++; - } - - continue; - } else { - // Save the new content in the current token so - // the code below can chop it up on newlines. - $token['content'] = $newContent.$tokenContent; - } - }//end if - - /* - If this token has newlines in its content, split each line up - and create a new token for each line. We do this so it's easier - to ascertain where errors occur on a line. - Note that $token[1] is the token's content. - */ - - if (strpos($token['content'], $this->eolChar) !== false) { - $tokenLines = explode($this->eolChar, $token['content']); - $numLines = count($tokenLines); - - for ($i = 0; $i < $numLines; $i++) { - $newToken = ['content' => $tokenLines[$i]]; - if ($i === ($numLines - 1)) { - if ($tokenLines[$i] === '') { - break; - } - } else { - $newToken['content'] .= $this->eolChar; - } - - $newToken['type'] = $token['type']; - $newToken['code'] = $token['code']; - $finalTokens[$newStackPtr] = $newToken; - $newStackPtr++; - } - } else { - $finalTokens[$newStackPtr] = $token; - $newStackPtr++; - }//end if - - // Convert numbers, including decimals. - if ($token['code'] === T_STRING - || $token['code'] === T_OBJECT_OPERATOR - ) { - $newContent = ''; - $oldStackPtr = $stackPtr; - while (preg_match('|^[0-9\.]+$|', $tokens[$stackPtr]['content']) !== 0) { - $newContent .= $tokens[$stackPtr]['content']; - $stackPtr++; - } - - if ($newContent !== '' && $newContent !== '.') { - $finalTokens[($newStackPtr - 1)]['content'] = $newContent; - if (ctype_digit($newContent) === true) { - $finalTokens[($newStackPtr - 1)]['code'] = constant('T_LNUMBER'); - $finalTokens[($newStackPtr - 1)]['type'] = 'T_LNUMBER'; - } else { - $finalTokens[($newStackPtr - 1)]['code'] = constant('T_DNUMBER'); - $finalTokens[($newStackPtr - 1)]['type'] = 'T_DNUMBER'; - } - - $stackPtr--; - continue; - } else { - $stackPtr = $oldStackPtr; - } - }//end if - - // Convert the token after an object operator into a string, in most cases. - if ($token['code'] === T_OBJECT_OPERATOR) { - for ($i = ($stackPtr + 1); $i < $numTokens; $i++) { - if (isset(Util\Tokens::$emptyTokens[$tokens[$i]['code']]) === true) { - continue; - } - - if ($tokens[$i]['code'] !== T_PROTOTYPE - && $tokens[$i]['code'] !== T_LNUMBER - && $tokens[$i]['code'] !== T_DNUMBER - ) { - $tokens[$i]['code'] = T_STRING; - $tokens[$i]['type'] = 'T_STRING'; - } - - break; - } - } - }//end for - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t*** END TOKENIZING ***".PHP_EOL; - } - - return $finalTokens; - - }//end tokenize() - - - /** - * Tokenizes a regular expression if one is found. - * - * If a regular expression is not found, NULL is returned. - * - * @param int $char The index of the possible regex start character. - * @param string $string The complete content of the string being tokenized. - * @param array $chars An array of characters being tokenized. - * @param array $tokens The current array of tokens found in the string. - * - * @return array|null - */ - public function getRegexToken($char, $string, $chars, $tokens) - { - $beforeTokens = [ - T_EQUAL => true, - T_IS_NOT_EQUAL => true, - T_IS_IDENTICAL => true, - T_IS_NOT_IDENTICAL => true, - T_OPEN_PARENTHESIS => true, - T_OPEN_SQUARE_BRACKET => true, - T_RETURN => true, - T_BOOLEAN_OR => true, - T_BOOLEAN_AND => true, - T_BOOLEAN_NOT => true, - T_BITWISE_OR => true, - T_BITWISE_AND => true, - T_COMMA => true, - T_COLON => true, - T_TYPEOF => true, - T_INLINE_THEN => true, - T_INLINE_ELSE => true, - ]; - - $afterTokens = [ - ',' => true, - ')' => true, - ']' => true, - ';' => true, - ' ' => true, - '.' => true, - ':' => true, - $this->eolChar => true, - ]; - - // Find the last non-whitespace token that was added - // to the tokens array. - $numTokens = count($tokens); - for ($prev = ($numTokens - 1); $prev >= 0; $prev--) { - if (isset(Util\Tokens::$emptyTokens[$tokens[$prev]['code']]) === false) { - break; - } - } - - if (isset($beforeTokens[$tokens[$prev]['code']]) === false) { - return null; - } - - // This is probably a regular expression, so look for the end of it. - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t* token possibly starts a regular expression *".PHP_EOL; - } - - $numChars = count($chars); - for ($next = ($char + 1); $next < $numChars; $next++) { - if ($chars[$next] === '/') { - // Just make sure this is not escaped first. - if ($chars[($next - 1)] !== '\\') { - // In the simple form: /.../ so we found the end. - break; - } else if ($chars[($next - 2)] === '\\') { - // In the form: /...\\/ so we found the end. - break; - } - } else { - $possibleEolChar = substr($string, $next, strlen($this->eolChar)); - if ($possibleEolChar === $this->eolChar) { - // This is the last token on the line and regular - // expressions need to be defined on a single line, - // so this is not a regular expression. - break; - } - } - } - - if ($chars[$next] !== '/') { - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t* could not find end of regular expression *".PHP_EOL; - } - - return null; - } - - while (preg_match('|[a-zA-Z]|', $chars[($next + 1)]) !== 0) { - // The token directly after the end of the regex can - // be modifiers like global and case insensitive - // (.e.g, /pattern/gi). - $next++; - } - - $regexEnd = $next; - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t* found end of regular expression at token $regexEnd *".PHP_EOL; - } - - for ($next += 1; $next < $numChars; $next++) { - if ($chars[$next] !== ' ') { - break; - } else { - $possibleEolChar = substr($string, $next, strlen($this->eolChar)); - if ($possibleEolChar === $this->eolChar) { - // This is the last token on the line. - break; - } - } - } - - if (isset($afterTokens[$chars[$next]]) === false) { - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t* tokens after regular expression do not look correct *".PHP_EOL; - } - - return null; - } - - // This is a regular expression, so join all the tokens together. - $content = ''; - for ($x = $char; $x <= $regexEnd; $x++) { - $content .= $chars[$x]; - } - - $token = [ - 'start' => $char, - 'end' => $regexEnd, - 'content' => $content, - ]; - - return $token; - - }//end getRegexToken() - - - /** - * Performs additional processing after main tokenizing. - * - * This additional processing looks for properties, closures, labels and objects. - * - * @return void - */ - public function processAdditional() - { - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t*** START ADDITIONAL JS PROCESSING ***".PHP_EOL; - } - - $numTokens = count($this->tokens); - $classStack = []; - - for ($i = 0; $i < $numTokens; $i++) { - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $type = $this->tokens[$i]['type']; - $content = Util\Common::prepareForOutput($this->tokens[$i]['content']); - - echo str_repeat("\t", count($classStack)); - echo "\tProcess token $i: $type => $content".PHP_EOL; - } - - // Looking for functions that are actually closures. - if ($this->tokens[$i]['code'] === T_FUNCTION && isset($this->tokens[$i]['scope_opener']) === true) { - for ($x = ($i + 1); $x < $numTokens; $x++) { - if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false) { - break; - } - } - - if ($this->tokens[$x]['code'] === T_OPEN_PARENTHESIS) { - $this->tokens[$i]['code'] = T_CLOSURE; - $this->tokens[$i]['type'] = 'T_CLOSURE'; - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $line = $this->tokens[$i]['line']; - echo str_repeat("\t", count($classStack)); - echo "\t* token $i on line $line changed from T_FUNCTION to T_CLOSURE *".PHP_EOL; - } - - for ($x = ($this->tokens[$i]['scope_opener'] + 1); $x < $this->tokens[$i]['scope_closer']; $x++) { - if (isset($this->tokens[$x]['conditions'][$i]) === false) { - continue; - } - - $this->tokens[$x]['conditions'][$i] = T_CLOSURE; - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $type = $this->tokens[$x]['type']; - echo str_repeat("\t", count($classStack)); - echo "\t\t* cleaned $x ($type) *".PHP_EOL; - } - } - }//end if - - continue; - } else if ($this->tokens[$i]['code'] === T_OPEN_CURLY_BRACKET - && isset($this->tokens[$i]['scope_condition']) === false - && isset($this->tokens[$i]['bracket_closer']) === true - ) { - $condition = $this->tokens[$i]['conditions']; - $condition = end($condition); - if ($condition === T_CLASS) { - // Possibly an ES6 method. To be classified as one, the previous - // non-empty tokens need to be a set of parenthesis, and then a string - // (the method name). - for ($parenCloser = ($i - 1); $parenCloser > 0; $parenCloser--) { - if (isset(Util\Tokens::$emptyTokens[$this->tokens[$parenCloser]['code']]) === false) { - break; - } - } - - if ($this->tokens[$parenCloser]['code'] === T_CLOSE_PARENTHESIS) { - $parenOpener = $this->tokens[$parenCloser]['parenthesis_opener']; - for ($name = ($parenOpener - 1); $name > 0; $name--) { - if (isset(Util\Tokens::$emptyTokens[$this->tokens[$name]['code']]) === false) { - break; - } - } - - if ($this->tokens[$name]['code'] === T_STRING) { - // We found a method name. - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $line = $this->tokens[$name]['line']; - echo str_repeat("\t", count($classStack)); - echo "\t* token $name on line $line changed from T_STRING to T_FUNCTION *".PHP_EOL; - } - - $closer = $this->tokens[$i]['bracket_closer']; - - $this->tokens[$name]['code'] = T_FUNCTION; - $this->tokens[$name]['type'] = 'T_FUNCTION'; - - foreach ([$name, $i, $closer] as $token) { - $this->tokens[$token]['scope_condition'] = $name; - $this->tokens[$token]['scope_opener'] = $i; - $this->tokens[$token]['scope_closer'] = $closer; - $this->tokens[$token]['parenthesis_opener'] = $parenOpener; - $this->tokens[$token]['parenthesis_closer'] = $parenCloser; - $this->tokens[$token]['parenthesis_owner'] = $name; - } - - $this->tokens[$parenOpener]['parenthesis_owner'] = $name; - $this->tokens[$parenCloser]['parenthesis_owner'] = $name; - - for ($x = ($i + 1); $x < $closer; $x++) { - $this->tokens[$x]['conditions'][$name] = T_FUNCTION; - ksort($this->tokens[$x]['conditions'], SORT_NUMERIC); - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $type = $this->tokens[$x]['type']; - echo str_repeat("\t", count($classStack)); - echo "\t\t* added T_FUNCTION condition to $x ($type) *".PHP_EOL; - } - } - - continue; - }//end if - }//end if - }//end if - - $classStack[] = $i; - - $closer = $this->tokens[$i]['bracket_closer']; - $this->tokens[$i]['code'] = T_OBJECT; - $this->tokens[$i]['type'] = 'T_OBJECT'; - $this->tokens[$closer]['code'] = T_CLOSE_OBJECT; - $this->tokens[$closer]['type'] = 'T_CLOSE_OBJECT'; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo str_repeat("\t", count($classStack)); - echo "\t* token $i converted from T_OPEN_CURLY_BRACKET to T_OBJECT *".PHP_EOL; - echo str_repeat("\t", count($classStack)); - echo "\t* token $closer converted from T_CLOSE_CURLY_BRACKET to T_CLOSE_OBJECT *".PHP_EOL; - } - - for ($x = ($i + 1); $x < $closer; $x++) { - $this->tokens[$x]['conditions'][$i] = T_OBJECT; - ksort($this->tokens[$x]['conditions'], SORT_NUMERIC); - if (PHP_CODESNIFFER_VERBOSITY > 1) { - $type = $this->tokens[$x]['type']; - echo str_repeat("\t", count($classStack)); - echo "\t\t* added T_OBJECT condition to $x ($type) *".PHP_EOL; - } - } - } else if ($this->tokens[$i]['code'] === T_CLOSE_OBJECT) { - array_pop($classStack); - } else if ($this->tokens[$i]['code'] === T_COLON) { - // If it is a scope opener, it belongs to a - // DEFAULT or CASE statement. - if (isset($this->tokens[$i]['scope_condition']) === true) { - continue; - } - - // Make sure this is not part of an inline IF statement. - for ($x = ($i - 1); $x >= 0; $x--) { - if ($this->tokens[$x]['code'] === T_INLINE_THEN) { - $this->tokens[$i]['code'] = T_INLINE_ELSE; - $this->tokens[$i]['type'] = 'T_INLINE_ELSE'; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo str_repeat("\t", count($classStack)); - echo "\t* token $i converted from T_COLON to T_INLINE_THEN *".PHP_EOL; - } - - continue(2); - } else if ($this->tokens[$x]['line'] < $this->tokens[$i]['line']) { - break; - } - } - - // The string to the left of the colon is either a property or label. - for ($label = ($i - 1); $label >= 0; $label--) { - if (isset(Util\Tokens::$emptyTokens[$this->tokens[$label]['code']]) === false) { - break; - } - } - - if ($this->tokens[$label]['code'] !== T_STRING - && $this->tokens[$label]['code'] !== T_CONSTANT_ENCAPSED_STRING - ) { - continue; - } - - if (empty($classStack) === false) { - $this->tokens[$label]['code'] = T_PROPERTY; - $this->tokens[$label]['type'] = 'T_PROPERTY'; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo str_repeat("\t", count($classStack)); - echo "\t* token $label converted from T_STRING to T_PROPERTY *".PHP_EOL; - } - } else { - $this->tokens[$label]['code'] = T_LABEL; - $this->tokens[$label]['type'] = 'T_LABEL'; - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo str_repeat("\t", count($classStack)); - echo "\t* token $label converted from T_STRING to T_LABEL *".PHP_EOL; - } - }//end if - }//end if - }//end for - - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t*** END ADDITIONAL JS PROCESSING ***".PHP_EOL; - } - - }//end processAdditional() - - -}//end class diff --git a/src/Tokenizers/PHP.php b/src/Tokenizers/PHP.php index dde3beab92..beff3e43d3 100644 --- a/src/Tokenizers/PHP.php +++ b/src/Tokenizers/PHP.php @@ -459,7 +459,6 @@ class PHP extends Tokenizer T_SELF => 4, T_PARENT => 6, T_COMMA => 1, - T_THIS => 4, T_CLOSURE => 8, T_BACKTICK => 1, T_OPEN_SHORT_ARRAY => 1, diff --git a/src/Util/Help.php b/src/Util/Help.php index 68d7976782..480c266d1b 100644 --- a/src/Util/Help.php +++ b/src/Util/Help.php @@ -412,8 +412,7 @@ private function getAllOptions() ], 'extensions' => [ 'argument' => '--extensions=', - 'description' => 'Check files with the specified file extensions (comma-separated list). Defaults to php,inc/php,js,css.'."\n" - .'The type of the file can be specified using: ext/type; e.g. module/php,es/js.', + 'description' => 'Check files with the specified file extensions (comma-separated list). Defaults to "php,inc".', ], 'l' => [ 'argument' => '-l', diff --git a/src/Util/Tokens.php b/src/Util/Tokens.php index 553775f06b..04adf1d0a4 100644 --- a/src/Util/Tokens.php +++ b/src/Util/Tokens.php @@ -43,20 +43,8 @@ define('T_DOUBLE_QUOTED_STRING', 'PHPCS_T_DOUBLE_QUOTED_STRING'); define('T_COMMA', 'PHPCS_T_COMMA'); define('T_HEREDOC', 'PHPCS_T_HEREDOC'); -define('T_PROTOTYPE', 'PHPCS_T_PROTOTYPE'); -define('T_THIS', 'PHPCS_T_THIS'); -define('T_REGULAR_EXPRESSION', 'PHPCS_T_REGULAR_EXPRESSION'); -define('T_PROPERTY', 'PHPCS_T_PROPERTY'); -define('T_LABEL', 'PHPCS_T_LABEL'); -define('T_OBJECT', 'PHPCS_T_OBJECT'); -define('T_CLOSE_OBJECT', 'PHPCS_T_CLOSE_OBJECT'); -define('T_COLOUR', 'PHPCS_T_COLOUR'); -define('T_HASH', 'PHPCS_T_HASH'); -define('T_URL', 'PHPCS_T_URL'); -define('T_STYLE', 'PHPCS_T_STYLE'); define('T_ASPERAND', 'PHPCS_T_ASPERAND'); define('T_DOLLAR', 'PHPCS_T_DOLLAR'); -define('T_TYPEOF', 'PHPCS_T_TYPEOF'); define('T_CLOSURE', 'PHPCS_T_CLOSURE'); define('T_ANON_CLASS', 'PHPCS_T_ANON_CLASS'); define('T_BACKTICK', 'PHPCS_T_BACKTICK'); @@ -67,11 +55,8 @@ define('T_CLOSE_SHORT_ARRAY', 'PHPCS_T_CLOSE_SHORT_ARRAY'); define('T_GOTO_LABEL', 'PHPCS_T_GOTO_LABEL'); define('T_BINARY_CAST', 'PHPCS_T_BINARY_CAST'); -define('T_EMBEDDED_PHP', 'PHPCS_T_EMBEDDED_PHP'); define('T_OPEN_USE_GROUP', 'PHPCS_T_OPEN_USE_GROUP'); define('T_CLOSE_USE_GROUP', 'PHPCS_T_CLOSE_USE_GROUP'); -define('T_ZSR', 'PHPCS_T_ZSR'); -define('T_ZSR_EQUAL', 'PHPCS_T_ZSR_EQUAL'); define('T_FN_ARROW', 'PHPCS_T_FN_ARROW'); define('T_TYPE_UNION', 'PHPCS_T_TYPE_UNION'); define('T_PARAM_NAME', 'PHPCS_T_PARAM_NAME'); @@ -265,7 +250,6 @@ final class Tokens T_SL_EQUAL => T_SL_EQUAL, T_SR_EQUAL => T_SR_EQUAL, T_COALESCE_EQUAL => T_COALESCE_EQUAL, - T_ZSR_EQUAL => T_ZSR_EQUAL, ]; /** @@ -414,8 +398,6 @@ final class Tokens T_TRY => T_TRY, T_CATCH => T_CATCH, T_FINALLY => T_FINALLY, - T_PROPERTY => T_PROPERTY, - T_OBJECT => T_OBJECT, T_USE => T_USE, T_MATCH => T_MATCH, ]; @@ -454,7 +436,6 @@ final class Tokens T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET, T_OPEN_SQUARE_BRACKET => T_OPEN_SQUARE_BRACKET, T_OPEN_PARENTHESIS => T_OPEN_PARENTHESIS, - T_OBJECT => T_OBJECT, ]; /** diff --git a/tests/Core/AbstractMethodUnitTest.php b/tests/Core/AbstractMethodUnitTest.php index 3418be498f..c4c86c3e4e 100644 --- a/tests/Core/AbstractMethodUnitTest.php +++ b/tests/Core/AbstractMethodUnitTest.php @@ -19,16 +19,6 @@ abstract class AbstractMethodUnitTest extends TestCase { - /** - * The file extension of the test case file (without leading dot). - * - * This allows child classes to overrule the default `inc` with, for instance, - * `js` or `css` when applicable. - * - * @var string - */ - protected static $fileExtension = 'inc'; - /** * The tab width setting to use when tokenizing the file. * @@ -68,7 +58,7 @@ public static function initializeFile() // Default to a file with the same name as the test class. Extension is property based. $relativeCN = str_replace(__NAMESPACE__, '', get_called_class()); $relativePath = str_replace('\\', DIRECTORY_SEPARATOR, $relativeCN); - $pathToTestFile = realpath(__DIR__).$relativePath.'.'.static::$fileExtension; + $pathToTestFile = realpath(__DIR__).$relativePath.'.inc'; // Make sure the file gets parsed correctly based on the file type. $contents = 'phpcs_input_file: '.$pathToTestFile.PHP_EOL; @@ -100,9 +90,8 @@ public static function reset() self::$phpcsFile->config->__destruct(); } - self::$fileExtension = 'inc'; - self::$tabWidth = 4; - self::$phpcsFile = null; + self::$tabWidth = 4; + self::$phpcsFile = null; }//end reset() diff --git a/tests/Core/Config/ExtensionsArgTest.php b/tests/Core/Config/ExtensionsArgTest.php index e63b1fef9c..eaf408fe75 100644 --- a/tests/Core/Config/ExtensionsArgTest.php +++ b/tests/Core/Config/ExtensionsArgTest.php @@ -69,29 +69,23 @@ public static function dataValidExtensions() 'py' => 'PHP', ], ], - // This would likely result in a problem when PHPCS can't find a "PY" tokenizer class, - // but that's not our concern at this moment. Support for non-PHP tokenizers is being dropped soon anyway. - 'Single extension passed with language: py/py' => [ - 'passedValue' => 'py/py', - 'expected' => [ - 'py' => 'PY', - ], - ], 'Multiple extensions passed: php,js,css' => [ 'passedValue' => 'php,js,css', 'expected' => [ 'php' => 'PHP', - 'js' => 'JS', - 'css' => 'CSS', + 'js' => 'PHP', + 'css' => 'PHP', ], ], - 'Multiple extensions passed, some with language: php,inc/php,phpt/php,js' => [ + // While setting the language is no longer supported, we are being tolerant to the language + // being set to PHP as that doesn't break anything. + 'Multiple extensions passed, some with language PHP: php,inc/php,phpt/php,js' => [ 'passedValue' => 'php,inc/php,phpt/php,js', 'expected' => [ 'php' => 'PHP', 'inc' => 'PHP', 'phpt' => 'PHP', - 'js' => 'JS', + 'js' => 'PHP', ], ], 'File extensions are set case sensitively (and filtering is case sensitive too)' => [ @@ -125,4 +119,51 @@ public function testOnlySetOnce() }//end testOnlySetOnce() + /** + * Ensure that an exception is thrown for an invalid extension. + * + * @param string $passedValue Extensions as passed on the command line. + * + * @dataProvider dataInvalidExtensions + * + * @return void + */ + public function testInvalidExtensions($passedValue) + { + $message = 'ERROR: Specifying the tokenizer to use for an extension is no longer supported.'.PHP_EOL; + $message .= 'PHP_CodeSniffer >= 4.0 only supports scanning PHP files.'.PHP_EOL; + $message .= 'Received: '.$passedValue.PHP_EOL.PHP_EOL; + + $this->expectException('PHP_CodeSniffer\Exceptions\DeepExitException'); + $this->expectExceptionMessage($message); + + new ConfigDouble(["--extensions={$passedValue}"]); + + }//end testInvalidExtensions() + + + /** + * Data provider. + * + * @see self::testInvalidExtensions() + * + * @return array> + */ + public static function dataInvalidExtensions() + { + return [ + 'Single extension passed with language: py/py' => [ + 'passedValue' => 'py/py', + ], + 'Multiple extensions passed, all setting non-PHP language: ts/js,less/css' => [ + 'passedValue' => 'ts/js,less/css', + ], + 'Multiple extensions passed, some with non-PHP language: js/js,phpt/php' => [ + 'passedValue' => 'php,js/js,phpt/php', + ], + ]; + + }//end dataInvalidExtensions() + + }//end class diff --git a/tests/Core/File/GetConditionTest.php b/tests/Core/File/GetConditionTest.php index 656bd64bb7..1f9d9a3454 100644 --- a/tests/Core/File/GetConditionTest.php +++ b/tests/Core/File/GetConditionTest.php @@ -99,8 +99,6 @@ final class GetConditionTest extends AbstractMethodUnitTest 'T_TRY' => false, 'T_CATCH' => false, 'T_FINALLY' => false, - 'T_PROPERTY' => false, - 'T_OBJECT' => false, 'T_USE' => false, ]; diff --git a/tests/Core/File/GetDeclarationNameJSTest.js b/tests/Core/File/GetDeclarationNameJSTest.js deleted file mode 100644 index ee0a76a44f..0000000000 --- a/tests/Core/File/GetDeclarationNameJSTest.js +++ /dev/null @@ -1,23 +0,0 @@ -/* testInvalidTokenPassed */ -print something; - -var object = -{ - /* testClosure */ - propertyName: function () {} -} - -/* testFunction */ -function functionName() {} - -/* testClass */ -class ClassName -{ - /* testMethod */ - methodName() { - return false; - } -} - -/* testFunctionUnicode */ -function π() {} diff --git a/tests/Core/File/GetDeclarationNameJSTest.php b/tests/Core/File/GetDeclarationNameJSTest.php deleted file mode 100644 index af3fe56d2d..0000000000 --- a/tests/Core/File/GetDeclarationNameJSTest.php +++ /dev/null @@ -1,158 +0,0 @@ - - * @copyright 2022-2024 PHPCSStandards Contributors - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Tests\Core\File; - -use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; - -/** - * Tests for the \PHP_CodeSniffer\Files\File:getDeclarationName method. - * - * @covers \PHP_CodeSniffer\Files\File::getDeclarationName - */ -final class GetDeclarationNameJSTest extends AbstractMethodUnitTest -{ - - /** - * The file extension of the test case file (without leading dot). - * - * @var string - */ - protected static $fileExtension = 'js'; - - - /** - * Test receiving an expected exception when a non-supported token is passed. - * - * @return void - */ - public function testInvalidTokenPassed() - { - $this->expectRunTimeException('Token type "T_STRING" is not T_FUNCTION, T_CLASS, T_INTERFACE, T_TRAIT or T_ENUM'); - - $target = $this->getTargetToken('/* testInvalidTokenPassed */', T_STRING); - self::$phpcsFile->getDeclarationName($target); - - }//end testInvalidTokenPassed() - - - /** - * Test receiving "null" when passed an anonymous construct or in case of a parse error. - * - * @param string $testMarker The comment which prefaces the target token in the test file. - * @param int|string $targetType Token type of the token to get as stackPtr. - * - * @dataProvider dataGetDeclarationNameNull - * - * @return void - */ - public function testGetDeclarationNameNull($testMarker, $targetType) - { - $target = $this->getTargetToken($testMarker, $targetType); - $result = self::$phpcsFile->getDeclarationName($target); - $this->assertNull($result); - - }//end testGetDeclarationNameNull() - - - /** - * Data provider. - * - * @see GetDeclarationNameTest::testGetDeclarationNameNull() - * - * @return array> - */ - public static function dataGetDeclarationNameNull() - { - return [ - 'closure' => [ - 'testMarker' => '/* testClosure */', - 'targetType' => T_CLOSURE, - ], - ]; - - }//end dataGetDeclarationNameNull() - - - /** - * Test retrieving the name of a function or OO structure. - * - * @param string $testMarker The comment which prefaces the target token in the test file. - * @param string $expected Expected function output. - * @param array|null $targetType Token type of the token to get as stackPtr. - * - * @dataProvider dataGetDeclarationName - * - * @return void - */ - public function testGetDeclarationName($testMarker, $expected, $targetType=null) - { - if (isset($targetType) === false) { - $targetType = [ - T_CLASS, - T_INTERFACE, - T_TRAIT, - T_ENUM, - T_FUNCTION, - ]; - } - - $target = $this->getTargetToken($testMarker, $targetType); - $result = self::$phpcsFile->getDeclarationName($target); - $this->assertSame($expected, $result); - - }//end testGetDeclarationName() - - - /** - * Data provider. - * - * @see GetDeclarationNameTest::testGetDeclarationName() - * - * @return array>> - */ - public static function dataGetDeclarationName() - { - return [ - 'function' => [ - 'testMarker' => '/* testFunction */', - 'expected' => 'functionName', - ], - 'class' => [ - 'testMarker' => '/* testClass */', - 'expected' => 'ClassName', - 'targetType' => [ - T_CLASS, - T_STRING, - ], - ], - 'function-unicode-name' => [ - 'testMarker' => '/* testFunctionUnicode */', - 'expected' => 'π', - ], - ]; - - }//end dataGetDeclarationName() - - - /** - * Test retrieving the name of JS ES6 class method. - * - * @return void - */ - public function testGetDeclarationNameES6Method() - { - $target = $this->getTargetToken('/* testMethod */', [T_CLASS, T_INTERFACE, T_TRAIT, T_FUNCTION]); - $result = self::$phpcsFile->getDeclarationName($target); - $this->assertSame('methodName', $result); - - }//end testGetDeclarationNameES6Method() - - -}//end class diff --git a/tests/Core/Filters/AbstractFilterTestCase.php b/tests/Core/Filters/AbstractFilterTestCase.php index 3627d4aa2b..1087a22623 100644 --- a/tests/Core/Filters/AbstractFilterTestCase.php +++ b/tests/Core/Filters/AbstractFilterTestCase.php @@ -45,7 +45,7 @@ abstract class AbstractFilterTestCase extends TestCase */ public static function initializeConfigAndRuleset() { - self::$config = new ConfigDouble(['--extensions=php,inc/php,js,css']); + self::$config = new ConfigDouble(); self::$ruleset = new Ruleset(self::$config); }//end initializeConfigAndRuleset() diff --git a/tests/Core/Filters/Filter/AcceptTest.xml b/tests/Core/Filters/Filter/AcceptTest.xml index 2800298ebf..3d3e1de080 100644 --- a/tests/Core/Filters/Filter/AcceptTest.xml +++ b/tests/Core/Filters/Filter/AcceptTest.xml @@ -8,8 +8,6 @@ */Other/Main\.php$ - - /anything/* diff --git a/tests/Core/Filters/GitModifiedTest.php b/tests/Core/Filters/GitModifiedTest.php index 4d8f83d22b..4f51c9f86f 100644 --- a/tests/Core/Filters/GitModifiedTest.php +++ b/tests/Core/Filters/GitModifiedTest.php @@ -139,7 +139,7 @@ public static function dataAcceptOnlyGitModified() 'outputGitModified' => [ '.gitignore', 'phpcs.xml.dist', - 'src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js.fixed', + 'src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.1.inc.fixed', ], 'expectedOutput' => [ $basedir.'/src', @@ -177,8 +177,6 @@ public static function dataAcceptOnlyGitModified() 'src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php', 'src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.1.inc', 'src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.1.inc.fixed', - 'src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js', - 'src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js.fixed', 'src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php', ], 'expectedOutput' => [ @@ -192,7 +190,6 @@ public static function dataAcceptOnlyGitModified() $basedir.'/src/Standards/Squiz/Tests', $basedir.'/src/Standards/Squiz/Tests/WhiteSpace', $basedir.'/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.1.inc', - $basedir.'/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js', $basedir.'/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php', ], ], diff --git a/tests/Core/Filters/GitStagedTest.php b/tests/Core/Filters/GitStagedTest.php index ce64794fb7..b3c440a41c 100644 --- a/tests/Core/Filters/GitStagedTest.php +++ b/tests/Core/Filters/GitStagedTest.php @@ -139,7 +139,7 @@ public static function dataAcceptOnlyGitStaged() 'outputGitStaged' => [ '.gitignore', 'phpcs.xml.dist', - 'src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js.fixed', + 'src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.1.inc.fixed', ], 'expectedOutput' => [ $basedir.'/src', @@ -177,8 +177,6 @@ public static function dataAcceptOnlyGitStaged() 'src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php', 'src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.1.inc', 'src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.1.inc.fixed', - 'src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js', - 'src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js.fixed', 'src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php', ], 'expectedOutput' => [ @@ -192,7 +190,6 @@ public static function dataAcceptOnlyGitStaged() $basedir.'/src/Standards/Squiz/Tests', $basedir.'/src/Standards/Squiz/Tests/WhiteSpace', $basedir.'/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.1.inc', - $basedir.'/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js', $basedir.'/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php', ], ], diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ImplementsDeprecatedInterfaceSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ImplementsDeprecatedInterfaceSniff.php index af095072bd..6a12eda8d1 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ImplementsDeprecatedInterfaceSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ImplementsDeprecatedInterfaceSniff.php @@ -2,7 +2,7 @@ /** * Test fixture. * - * @see \PHP_CodeSniffer\Tests\Core\Ruleset\PopulateTokenListenersSupportedTokenizersTest + * @see \PHP_CodeSniffer\Tests\Core\Ruleset\RegisterSniffsRemovedTokenizersTest */ namespace Fixtures\TestStandard\Sniffs\SupportedTokenizers; diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForCSSAndJSSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForCSSAndJSSniff.php index c92abc9708..37d754f0bd 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForCSSAndJSSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForCSSAndJSSniff.php @@ -2,7 +2,7 @@ /** * Test fixture. * - * @see \PHP_CodeSniffer\Tests\Core\Ruleset\PopulateTokenListenersSupportedTokenizersTest + * @see \PHP_CodeSniffer\Tests\Core\Ruleset\RegisterSniffsRemovedTokenizersTest */ namespace Fixtures\TestStandard\Sniffs\SupportedTokenizers; diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForCSSAndUnrecognizedSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForCSSAndUnrecognizedSniff.php index f0379a5bd6..a2560ad103 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForCSSAndUnrecognizedSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForCSSAndUnrecognizedSniff.php @@ -2,7 +2,7 @@ /** * Test fixture. * - * @see \PHP_CodeSniffer\Tests\Core\Ruleset\PopulateTokenListenersSupportedTokenizersTest + * @see \PHP_CodeSniffer\Tests\Core\Ruleset\RegisterSniffsRemovedTokenizersTest */ namespace Fixtures\TestStandard\Sniffs\SupportedTokenizers; diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForCSSSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForCSSSniff.php index a24135d3fa..98e30a3f07 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForCSSSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForCSSSniff.php @@ -2,7 +2,7 @@ /** * Test fixture. * - * @see \PHP_CodeSniffer\Tests\Core\Ruleset\PopulateTokenListenersSupportedTokenizersTest + * @see \PHP_CodeSniffer\Tests\Core\Ruleset\RegisterSniffsRemovedTokenizersTest */ namespace Fixtures\TestStandard\Sniffs\SupportedTokenizers; diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForEmptySniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForEmptySniff.php index 599764ee7f..244a6e0979 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForEmptySniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForEmptySniff.php @@ -2,7 +2,7 @@ /** * Test fixture. * - * @see \PHP_CodeSniffer\Tests\Core\Ruleset\PopulateTokenListenersSupportedTokenizersTest + * @see \PHP_CodeSniffer\Tests\Core\Ruleset\RegisterSniffsRemovedTokenizersTest */ namespace Fixtures\TestStandard\Sniffs\SupportedTokenizers; diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForJSSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForJSSniff.php index c892ecc22c..e675498d1d 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForJSSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForJSSniff.php @@ -2,7 +2,7 @@ /** * Test fixture. * - * @see \PHP_CodeSniffer\Tests\Core\Ruleset\PopulateTokenListenersSupportedTokenizersTest + * @see \PHP_CodeSniffer\Tests\Core\Ruleset\RegisterSniffsRemovedTokenizersTest */ namespace Fixtures\TestStandard\Sniffs\SupportedTokenizers; diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForPHPAndCSSAndJSSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForPHPAndCSSAndJSSniff.php index 1f12b493a5..3e04961414 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForPHPAndCSSAndJSSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForPHPAndCSSAndJSSniff.php @@ -2,7 +2,7 @@ /** * Test fixture. * - * @see \PHP_CodeSniffer\Tests\Core\Ruleset\PopulateTokenListenersSupportedTokenizersTest + * @see \PHP_CodeSniffer\Tests\Core\Ruleset\RegisterSniffsRemovedTokenizersTest */ namespace Fixtures\TestStandard\Sniffs\SupportedTokenizers; diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForUnrecognizedTokenizersSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForUnrecognizedTokenizersSniff.php index 2f164cc8c1..5958156034 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForUnrecognizedTokenizersSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForUnrecognizedTokenizersSniff.php @@ -2,7 +2,7 @@ /** * Test fixture. * - * @see \PHP_CodeSniffer\Tests\Core\Ruleset\PopulateTokenListenersSupportedTokenizersTest + * @see \PHP_CodeSniffer\Tests\Core\Ruleset\RegisterSniffsRemovedTokenizersTest */ namespace Fixtures\TestStandard\Sniffs\SupportedTokenizers; diff --git a/tests/Core/Ruleset/PopulateTokenListenersSupportedTokenizersTest.php b/tests/Core/Ruleset/PopulateTokenListenersSupportedTokenizersTest.php deleted file mode 100644 index 87e6da802b..0000000000 --- a/tests/Core/Ruleset/PopulateTokenListenersSupportedTokenizersTest.php +++ /dev/null @@ -1,111 +0,0 @@ - - * @copyright 2025 PHPCSStandards and contributors - * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - */ - -namespace PHP_CodeSniffer\Tests\Core\Ruleset; - -use PHP_CodeSniffer\Ruleset; -use PHP_CodeSniffer\Tests\ConfigDouble; -use PHP_CodeSniffer\Tests\Core\Ruleset\AbstractRulesetTestCase; - -/** - * Test the Ruleset::populateTokenListeners() method shows a deprecation notice for sniffs supporting JS and/or CSS tokenizers. - * - * @covers \PHP_CodeSniffer\Ruleset::populateTokenListeners - */ -final class PopulateTokenListenersSupportedTokenizersTest extends AbstractRulesetTestCase -{ - - /** - * The Config object. - * - * @var \PHP_CodeSniffer\Config - */ - private static $config; - - - /** - * Initialize the config and ruleset objects for this test. - * - * @beforeClass - * - * @return void - */ - public static function initializeConfig() - { - // Set up the ruleset. - $standard = __DIR__.'/PopulateTokenListenersSupportedTokenizersTest.xml'; - self::$config = new ConfigDouble(["--standard=$standard"]); - - }//end initializeConfig() - - - /** - * Verify that a deprecation notice is shown if a non-deprecated sniff supports the JS/CSS tokenizer(s). - * - * Additionally, this test verifies that: - * - No deprecation notice is thrown if the complete sniff is deprecated. - * - No deprecation notice is thrown when the sniff _also_ supports PHP. - * - No deprecation notice is thrown when no tokenizers are supported (not sure why anyone would do that, but :shrug:). - * - * {@internal The test uses a data provider to verify the messages as the _order_ of the messages depends - * on the OS on which the tests are run (order in which files are retrieved), which makes the order within the - * complete message too unpredictable to test in one go.} - * - * @param string $expected The expected message output in regex format. - * - * @dataProvider dataDeprecatedTokenizersTriggerDeprecationNotice - * - * @return void - */ - public function testDeprecatedTokenizersTriggerDeprecationNotice($expected) - { - $this->expectOutputRegex($expected); - - new Ruleset(self::$config); - - }//end testDeprecatedTokenizersTriggerDeprecationNotice() - - - /** - * Data provider. - * - * @see testDeprecatedTokenizersTriggerDeprecationNotice() - * - * @return array> - */ - public static function dataDeprecatedTokenizersTriggerDeprecationNotice() - { - $cssJsDeprecated = '`DEPRECATED: Scanning CSS/JS files is deprecated and support will be removed in PHP_CodeSniffer 4\.0\.\R'; - $cssJsDeprecated .= 'The %1$s sniff is listening for %2$s\.\R`'; - - $customTokenizer = '`DEPRECATED: Support for custom tokenizers will be removed in PHP_CodeSniffer 4\.0\.\R'; - $customTokenizer .= 'The %1$s sniff is listening for %2$s\.\R`'; - - return [ - 'Listens for CSS' => [ - 'expected' => sprintf($cssJsDeprecated, 'TestStandard.SupportedTokenizers.ListensForCSS', 'CSS'), - ], - 'Listens for JS' => [ - 'expected' => sprintf($cssJsDeprecated, 'TestStandard.SupportedTokenizers.ListensForJS', 'JS'), - ], - 'Listens for both CSS and JS' => [ - 'expected' => sprintf($cssJsDeprecated, 'TestStandard.SupportedTokenizers.ListensForCSSAndJS', 'CSS, JS'), - ], - 'Listens for CSS and something unrecognized' => [ - 'expected' => sprintf($cssJsDeprecated, 'TestStandard.SupportedTokenizers.ListensForCSSAndUnrecognized', 'CSS, Unrecognized'), - ], - 'Listens for only unrecognized tokenizers' => [ - 'expected' => sprintf($customTokenizer, 'TestStandard.SupportedTokenizers.ListensForUnrecognizedTokenizers', 'SCSS, TypeScript'), - ], - ]; - - }//end dataDeprecatedTokenizersTriggerDeprecationNotice() - - -}//end class diff --git a/tests/Core/Ruleset/PopulateTokenListenersTest.php b/tests/Core/Ruleset/PopulateTokenListenersTest.php index 347ffddee7..db494b9590 100644 --- a/tests/Core/Ruleset/PopulateTokenListenersTest.php +++ b/tests/Core/Ruleset/PopulateTokenListenersTest.php @@ -131,31 +131,27 @@ public function testRegistersSniffsToListenToTokens($sniffClass, $expectedCount) public static function dataSniffListensToTokenss() { return [ - 'TestStandard.SupportedTokenizers.ListensForPHPAndCSSAndJS' => [ - 'sniffClass' => 'Fixtures\\TestStandard\\Sniffs\\SupportedTokenizers\\ListensForPHPAndCSSAndJSSniff', - 'expectedCount' => 2, - ], - 'Generic.NamingConventions.UpperCaseConstantName' => [ + 'Generic.NamingConventions.UpperCaseConstantName' => [ 'sniffClass' => 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\NamingConventions\\UpperCaseConstantNameSniff', 'expectedCount' => 2, ], - 'PSR1.Files.SideEffects' => [ + 'PSR1.Files.SideEffects' => [ 'sniffClass' => 'PHP_CodeSniffer\\Standards\\PSR1\\Sniffs\\Files\\SideEffectsSniff', 'expectedCount' => 1, ], - 'PSR12.ControlStructures.BooleanOperatorPlacement' => [ + 'PSR12.ControlStructures.BooleanOperatorPlacement' => [ 'sniffClass' => 'PHP_CodeSniffer\\Standards\\PSR12\\Sniffs\\ControlStructures\\BooleanOperatorPlacementSniff', 'expectedCount' => 5, ], - 'Squiz.ControlStructures.ForEachLoopDeclaration' => [ + 'Squiz.ControlStructures.ForEachLoopDeclaration' => [ 'sniffClass' => 'PHP_CodeSniffer\\Standards\\Squiz\\Sniffs\\ControlStructures\\ForEachLoopDeclarationSniff', 'expectedCount' => 1, ], - 'TestStandard.Deprecated.WithReplacement' => [ + 'TestStandard.Deprecated.WithReplacement' => [ 'sniffClass' => 'Fixtures\\TestStandard\\Sniffs\\Deprecated\\WithReplacementSniff', 'expectedCount' => 1, ], - 'TestStandard.ValidSniffs.RegisterEmptyArray' => [ + 'TestStandard.ValidSniffs.RegisterEmptyArray' => [ 'sniffClass' => 'Fixtures\\TestStandard\\Sniffs\\ValidSniffs\\RegisterEmptyArraySniff', 'expectedCount' => 0, ], @@ -306,103 +302,6 @@ public function testSetsClassAndSourceIndexes() }//end testSetsClassAndSourceIndexes() - /** - * Verifies that sniffs by default are listening for PHP files only. - * - * @return void - */ - public function testSetsSupportedTokenizersToPHPByDefault() - { - $exclude = 'Fixtures\\TestStandard\\Sniffs\\SupportedTokenizers\\ListensForPHPAndCSSAndJSSniff'; - $expected = ['PHP' => 'PHP']; - - foreach (self::$ruleset->tokenListeners as $token => $listeners) { - $this->assertTrue(is_array($listeners), 'No listeners registered for token'.Tokens::tokenName($token)); - - foreach ($listeners as $className => $details) { - if ($className === $exclude) { - // Skip this one as it is the one sniff for which things will be different. - continue; - } - - $this->assertArrayHasKey( - 'tokenizers', - $details, - sprintf('"tokenizers" key missing for sniff class %s for token %s', $className, Tokens::tokenName($token)) - ); - - $this->assertSame( - $expected, - $details['tokenizers'], - sprintf('Unexpected value for "tokenizers" key for sniff class %s for token %s', $className, Tokens::tokenName($token)) - ); - } - }//end foreach - - }//end testSetsSupportedTokenizersToPHPByDefault() - - - /** - * Test that if a sniff has the $supportedTokenizers property set, the tokenizers listed there - * will be registered in the listeners array. - * - * @param int $token The token constant for which the sniff should be registered. - * - * @dataProvider dataSetsSupportedTokenizersWhenProvidedBySniff - * - * @return void - */ - public function testSetsSupportedTokenizersWhenProvidedBySniff($token) - { - $sniffClass = 'Fixtures\\TestStandard\\Sniffs\\SupportedTokenizers\\ListensForPHPAndCSSAndJSSniff'; - $expected = [ - 'PHP' => 'PHP', - 'JS' => 'JS', - 'CSS' => 'CSS', - ]; - - $this->assertArrayHasKey( - $token, - self::$ruleset->tokenListeners, - sprintf('The token constant %s is not registered to the listeners array', Tokens::tokenName($token)) - ); - $this->assertArrayHasKey( - $sniffClass, - self::$ruleset->tokenListeners[$token], - sprintf('The sniff class %s is not registered for token %s', $sniffClass, Tokens::tokenName($token)) - ); - $this->assertArrayHasKey( - 'tokenizers', - self::$ruleset->tokenListeners[$token][$sniffClass], - sprintf('"tokenizers" key missing for sniff class %s for token %s', $sniffClass, Tokens::tokenName($token)) - ); - - $this->assertSame( - $expected, - self::$ruleset->tokenListeners[$token][$sniffClass]['tokenizers'], - sprintf('Unexpected value for "tokenizers" key for sniff class %s for token %s', $sniffClass, Tokens::tokenName($token)) - ); - - }//end testSetsSupportedTokenizersWhenProvidedBySniff() - - - /** - * Data provider. - * - * @see testSetsSupportedTokenizersWhenProvidedBySniff() - * - * @return array> - */ - public static function dataSetsSupportedTokenizersWhenProvidedBySniff() - { - return [ - 'T_OPEN_TAG' => [T_OPEN_TAG], - 'T_OPEN_TAG_WITH_ECHO' => [T_OPEN_TAG_WITH_ECHO], - ]; - - }//end dataSetsSupportedTokenizersWhenProvidedBySniff() - - /** * Verifies that by default no explicit include patterns are registered for sniffs. * @@ -491,7 +390,7 @@ public function testSetsIncludeAndIgnorePatterns($token, $sniffClass, $patternTy $expected = [ '/no-transformation/', '/simple.*transformation/.*', - '/escaped\\,comma/becomes/comma/to/allow/commas/in/filenames.css', + '/escaped\\,comma/becomes/comma/to/allow/commas/in/filenames.inc', '/pat?tern(is|regex)\\.php$', ]; diff --git a/tests/Core/Ruleset/PopulateTokenListenersTest.xml b/tests/Core/Ruleset/PopulateTokenListenersTest.xml index 2116048ad0..370c600099 100644 --- a/tests/Core/Ruleset/PopulateTokenListenersTest.xml +++ b/tests/Core/Ruleset/PopulateTokenListenersTest.xml @@ -20,9 +20,6 @@ - - - @@ -30,7 +27,7 @@ /no-transformation/ /simple*transformation/* - /escaped\\,comma/becomes/comma/to/allow/commas/in/filenames.css + /escaped\\,comma/becomes/comma/to/allow/commas/in/filenames.inc /pat?tern(is|regex)\.php$ @@ -38,7 +35,7 @@ /no-transformation/ /simple*transformation/* - /escaped\\,comma/becomes/comma/to/allow/commas/in/filenames.css + /escaped\\,comma/becomes/comma/to/allow/commas/in/filenames.inc /pat?tern(is|regex)\.php$ diff --git a/tests/Core/Ruleset/RegisterSniffsRemovedTokenizersTest.php b/tests/Core/Ruleset/RegisterSniffsRemovedTokenizersTest.php new file mode 100644 index 0000000000..4d12bf43f7 --- /dev/null +++ b/tests/Core/Ruleset/RegisterSniffsRemovedTokenizersTest.php @@ -0,0 +1,108 @@ + + * @copyright 2025 PHPCSStandards and contributors + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Ruleset; + +use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Tests\ConfigDouble; +use PHP_CodeSniffer\Tests\Core\Ruleset\AbstractRulesetTestCase; + +/** + * Test the Ruleset::registerSniffs() method shows a warning for sniffs expecting the removed JS and/or CSS tokenizers. + * + * @covers \PHP_CodeSniffer\Ruleset::registerSniffs + */ +final class RegisterSniffsRemovedTokenizersTest extends AbstractRulesetTestCase +{ + + /** + * The Config object. + * + * @var \PHP_CodeSniffer\Config + */ + private static $config; + + + /** + * Initialize the config and ruleset objects for this test. + * + * @beforeClass + * + * @return void + */ + public static function initializeConfig() + { + // Set up the ruleset. + $standard = __DIR__.'/RegisterSniffsRemovedTokenizersTest.xml'; + self::$config = new ConfigDouble(["--standard=$standard"]); + + }//end initializeConfig() + + + /** + * Verify that an error is shown if a non-deprecated sniff supports the JS/CSS tokenizer(s). + * + * Additionally, this test verifies that: + * - No error is thrown if the sniff is deprecated. + * - No error is thrown when the sniff _also_ supports PHP. + * - No error is thrown when no tokenizers are supported (not sure why anyone would do that, but :shrug:). + * + * {@internal The test uses a data provider to verify the messages as the _order_ of the messages depends + * on the OS on which the tests are run (order in which files are retrieved), which makes the order within the + * complete message too unpredictable to test in one go.} + * + * @param string $expected The expected message output in regex format. + * + * @dataProvider dataUnsupportedTokenizersTriggerError + * + * @return void + */ + public function testUnsupportedTokenizersTriggerError($expected) + { + $this->expectRuntimeExceptionRegex($expected); + + new Ruleset(self::$config); + + }//end testUnsupportedTokenizersTriggerError() + + + /** + * Data provider. + * + * @see testUnsupportedTokenizersTriggerError() + * + * @return array> + */ + public static function dataUnsupportedTokenizersTriggerError() + { + $message = '`ERROR: Support for scanning files other than PHP, like CSS/JS files, has been removed in PHP_CodeSniffer 4\.0\.\R'; + $message .= 'The %1$s sniff is listening for %2$s\.\R`'; + + return [ + 'Listens for CSS' => [ + 'expected' => sprintf($message, 'TestStandard.SupportedTokenizers.ListensForCSS', 'CSS'), + ], + 'Listens for JS' => [ + 'expected' => sprintf($message, 'TestStandard.SupportedTokenizers.ListensForJS', 'JS'), + ], + 'Listens for both CSS and JS' => [ + 'expected' => sprintf($message, 'TestStandard.SupportedTokenizers.ListensForCSSAndJS', 'CSS, JS'), + ], + 'Listens for CSS and something unrecognized' => [ + 'expected' => sprintf($message, 'TestStandard.SupportedTokenizers.ListensForCSSAndUnrecognized', 'CSS, Unrecognized'), + ], + 'Listens for only unrecognized tokenizers' => [ + 'expected' => sprintf($message, 'TestStandard.SupportedTokenizers.ListensForUnrecognizedTokenizers', 'SCSS, TypeScript'), + ], + ]; + + }//end dataUnsupportedTokenizersTriggerError() + + +}//end class diff --git a/tests/Core/Ruleset/PopulateTokenListenersSupportedTokenizersTest.xml b/tests/Core/Ruleset/RegisterSniffsRemovedTokenizersTest.xml similarity index 58% rename from tests/Core/Ruleset/PopulateTokenListenersSupportedTokenizersTest.xml rename to tests/Core/Ruleset/RegisterSniffsRemovedTokenizersTest.xml index 1a02eba182..93d8dda507 100644 --- a/tests/Core/Ruleset/PopulateTokenListenersSupportedTokenizersTest.xml +++ b/tests/Core/Ruleset/RegisterSniffsRemovedTokenizersTest.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/Core/Ruleset/SetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForStandardTest.xml b/tests/Core/Ruleset/SetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForStandardTest.xml index a7c05017d0..8ce97e2dd3 100644 --- a/tests/Core/Ruleset/SetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForStandardTest.xml +++ b/tests/Core/Ruleset/SetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForStandardTest.xml @@ -2,7 +2,6 @@ - diff --git a/tests/Core/Tokenizers/AbstractTokenizerTestCase.php b/tests/Core/Tokenizers/AbstractTokenizerTestCase.php index f3daf2bf21..ac9f8e3e9f 100644 --- a/tests/Core/Tokenizers/AbstractTokenizerTestCase.php +++ b/tests/Core/Tokenizers/AbstractTokenizerTestCase.php @@ -22,16 +22,6 @@ abstract class AbstractTokenizerTestCase extends TestCase { - /** - * The file extension of the test case file (without leading dot). - * - * This allows child classes to overrule the default `inc` with, for instance, - * `js` or `css` when applicable. - * - * @var string - */ - protected $fileExtension = 'inc'; - /** * The tab width setting to use when tokenizing the file. * @@ -73,7 +63,7 @@ protected function initializeFile() // Default to a file with the same name as the test class. Extension is property based. $relativeCN = str_replace(__NAMESPACE__, '', get_called_class()); $relativePath = str_replace('\\', DIRECTORY_SEPARATOR, $relativeCN); - $pathToTestFile = realpath(__DIR__).$relativePath.'.'.$this->fileExtension; + $pathToTestFile = realpath(__DIR__).$relativePath.'.inc'; // Make sure the file gets parsed correctly based on the file type. $contents = 'phpcs_input_file: '.$pathToTestFile.PHP_EOL;