Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Giraud <g.nicolas_89@hotmail.fr>2014-01-07 22:03:20 +0400
committerHugues Peccatte <hugues.peccatte@gmail.com>2014-01-07 22:03:20 +0400
commit80448a1fd83c030302905f2afc4ea5bbec2a68b1 (patch)
tree2dd20eec1ba72aa7734fc0bb10d980906a45a2a6 /PMAStandard
parentca35186ea499932f23321ab1607762933d325c39 (diff)
New phpcs rule for concatenation.
Signed-off-by: Hugues Peccatte <hugues.peccatte@gmail.com>
Diffstat (limited to 'PMAStandard')
-rw-r--r--PMAStandard/Sniffs/Files/SpacesAroundConcatSniff.php82
1 files changed, 82 insertions, 0 deletions
diff --git a/PMAStandard/Sniffs/Files/SpacesAroundConcatSniff.php b/PMAStandard/Sniffs/Files/SpacesAroundConcatSniff.php
new file mode 100644
index 0000000000..1d6e276bed
--- /dev/null
+++ b/PMAStandard/Sniffs/Files/SpacesAroundConcatSniff.php
@@ -0,0 +1,82 @@
+<?php
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+/**
+ * Class for a sniff to oblige whitespaces before and after a concatenation operator
+ *
+ * This Sniff check if a whitespace is missing before or after any concatenation
+ * operator.
+ * The concatenation operator is identified by the PHP token T_STRING_CONCAT
+ * The whitespace is identified by the PHP token T_WHITESPACE
+ *
+ * PHP version 5
+ *
+ * @category PHP
+ * @package PHP_CodeSniffer
+ * @author Nicolas Giraud <g.nicolas_89@hotmail.fr>
+ * @since September, the 12th 2013
+ */
+
+/// {{{ PMAStandard_Sniffs_Files_SpacesAroundConcatSniff
+/**
+ * Sniff to oblige whitespaces before and after a concatenation operator
+ *
+ * @category PHP
+ * @package PHP_CodeSniffer
+ * @name SpacesAroundConcatSniff
+ * @author Nicolas Giraud <g.nicolas_89@hotmail.fr>
+ * @version Release: 1.0
+ */
+class PMAStandard_Sniffs_Files_SpacesAroundConcatSniff implements PHP_CodeSniffer_Sniff
+{
+
+ // {{{ register()
+
+ /**
+ * Returns the token types that this sniff is interested in.
+ *
+ * @name register
+ * @access public
+ * @see PHP_CodeSniffer_Sniff::register()
+ *
+ * @return array(int)
+ */
+ public function register()
+ {
+ return array(T_STRING_CONCAT);
+
+ }//end register()
+
+ // }}}
+ // {{{ process()
+
+ /**
+ * Processes the tokens that this sniff is interested in.
+ *
+ * @name process
+ * @access public
+ * @see PHP_CodeSniffer_Sniff::process()
+ * @param PHP_CodeSniffer_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(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
+ {
+ $tokens = $phpcsFile->getTokens();
+ if ($tokens[$stackPtr-1]['type'] !== 'T_WHITESPACE') {
+ $warning = 'Whitespace is expected before any concat operator "."';
+ $phpcsFile->addWarning($warning, $stackPtr, 'Found');
+ }
+ if ($tokens[$stackPtr+1]['type'] !== 'T_WHITESPACE') {
+ $warning = 'Whitespace is expected after any concat operator "."';
+ $phpcsFile->addWarning($warning, $stackPtr, 'Found');
+ }
+ }//end process()
+
+ // }}}
+
+}//end class
+
+// }}}
+
+?>