diff options
author | Jesús <heckyel@hyperbola.info> | 2019-08-18 21:14:58 -0500 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2019-08-18 21:14:58 -0500 |
commit | 2eed7b082f83630301e51f57ca8394de228a8605 (patch) | |
tree | 1d19962d22d30f99317d9276e4bae7744fc93fc2 /tests/phpcs/OpenCart/Sniffs/Spacing/ConcatenationSniff.php | |
download | librecart-2eed7b082f83630301e51f57ca8394de228a8605.tar.lz librecart-2eed7b082f83630301e51f57ca8394de228a8605.tar.xz librecart-2eed7b082f83630301e51f57ca8394de228a8605.zip |
first commit
Diffstat (limited to 'tests/phpcs/OpenCart/Sniffs/Spacing/ConcatenationSniff.php')
-rw-r--r-- | tests/phpcs/OpenCart/Sniffs/Spacing/ConcatenationSniff.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/phpcs/OpenCart/Sniffs/Spacing/ConcatenationSniff.php b/tests/phpcs/OpenCart/Sniffs/Spacing/ConcatenationSniff.php new file mode 100644 index 0000000..432c921 --- /dev/null +++ b/tests/phpcs/OpenCart/Sniffs/Spacing/ConcatenationSniff.php @@ -0,0 +1,34 @@ +<?php +/** + * Makes sure there are the needed spaces between the concatenation operator (.) and + * the strings being concatenated. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Peter Philipp <peter.philipp@cando-image.com> + * @link http://pear.php.net/package/PHP_CodeSniffer + * @Licence http://www.gnu.org/licenses/gpl-2.0.html + */ +class OpenCart_Sniffs_Spacing_ConcatenationSniff implements PHP_CodeSniffer_Sniff { + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() { + return array(T_STRING_CONCAT); + + }//end register() + + + /** + * Processes this test, when one of its tokens is encountered. + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) { + $tokens = $phpcsFile->getTokens(); + if ($tokens[($stackPtr - 1)]['code'] !== T_WHITESPACE || $tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) { + $message = 'PHP concat operator must be surrounded by spaces'; + $phpcsFile->addError($message, $stackPtr, 'Missing'); + } + } +}//end class
\ No newline at end of file |