From 2eed7b082f83630301e51f57ca8394de228a8605 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs?= Date: Sun, 18 Aug 2019 21:14:58 -0500 Subject: first commit --- .../OpenCart/Sniffs/Spacing/ConcatenationSniff.php | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/phpcs/OpenCart/Sniffs/Spacing/ConcatenationSniff.php (limited to 'tests/phpcs/OpenCart/Sniffs/Spacing/ConcatenationSniff.php') 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 @@ + + * @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 -- cgit v1.2.3