Completed
Pull Request — develop (#1492)
by Zack
28:58 queued 09:00
created
PHPCompatibility/Sniffs/ParameterValues/RemovedHashAlgorithmsSniff.php 3 patches
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -30,82 +30,82 @@
 block discarded – undo
30 30
 class RemovedHashAlgorithmsSniff extends AbstractRemovedFeatureSniff
31 31
 {
32 32
 
33
-    /**
34
-     * A list of removed hash algorithms, which were present in older versions.
35
-     *
36
-     * The array lists : version number with false (deprecated) and true (removed).
37
-     * If's sufficient to list the first version where the hash algorithm was deprecated/removed.
38
-     *
39
-     * @var array(string => array(string => bool))
40
-     */
41
-    protected $removedAlgorithms = array(
42
-        'salsa10' => array(
43
-            '5.4' => true,
44
-        ),
45
-        'salsa20' => array(
46
-            '5.4' => true,
47
-        ),
48
-    );
33
+	/**
34
+	 * A list of removed hash algorithms, which were present in older versions.
35
+	 *
36
+	 * The array lists : version number with false (deprecated) and true (removed).
37
+	 * If's sufficient to list the first version where the hash algorithm was deprecated/removed.
38
+	 *
39
+	 * @var array(string => array(string => bool))
40
+	 */
41
+	protected $removedAlgorithms = array(
42
+		'salsa10' => array(
43
+			'5.4' => true,
44
+		),
45
+		'salsa20' => array(
46
+			'5.4' => true,
47
+		),
48
+	);
49 49
 
50
-    /**
51
-     * Returns an array of tokens this test wants to listen for.
52
-     *
53
-     * @return array
54
-     */
55
-    public function register()
56
-    {
57
-        return array(\T_STRING);
58
-    }
50
+	/**
51
+	 * Returns an array of tokens this test wants to listen for.
52
+	 *
53
+	 * @return array
54
+	 */
55
+	public function register()
56
+	{
57
+		return array(\T_STRING);
58
+	}
59 59
 
60 60
 
61
-    /**
62
-     * Processes this test, when one of its tokens is encountered.
63
-     *
64
-     * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
65
-     * @param int                   $stackPtr  The position of the current token in the
66
-     *                                         stack passed in $tokens.
67
-     *
68
-     * @return void
69
-     */
70
-    public function process(File $phpcsFile, $stackPtr)
71
-    {
72
-        $algo = $this->getHashAlgorithmParameter($phpcsFile, $stackPtr);
73
-        if (empty($algo) || \is_string($algo) === false) {
74
-            return;
75
-        }
61
+	/**
62
+	 * Processes this test, when one of its tokens is encountered.
63
+	 *
64
+	 * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
65
+	 * @param int                   $stackPtr  The position of the current token in the
66
+	 *                                         stack passed in $tokens.
67
+	 *
68
+	 * @return void
69
+	 */
70
+	public function process(File $phpcsFile, $stackPtr)
71
+	{
72
+		$algo = $this->getHashAlgorithmParameter($phpcsFile, $stackPtr);
73
+		if (empty($algo) || \is_string($algo) === false) {
74
+			return;
75
+		}
76 76
 
77
-        // Bow out if not one of the algorithms we're targetting.
78
-        if (isset($this->removedAlgorithms[$algo]) === false) {
79
-            return;
80
-        }
77
+		// Bow out if not one of the algorithms we're targetting.
78
+		if (isset($this->removedAlgorithms[$algo]) === false) {
79
+			return;
80
+		}
81 81
 
82
-        $itemInfo = array(
83
-            'name' => $algo,
84
-        );
85
-        $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
86
-    }
82
+		$itemInfo = array(
83
+			'name' => $algo,
84
+		);
85
+		$this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
86
+	}
87 87
 
88 88
 
89
-    /**
90
-     * Get the relevant sub-array for a specific item from a multi-dimensional array.
91
-     *
92
-     * @param array $itemInfo Base information about the item.
93
-     *
94
-     * @return array Version and other information about the item.
95
-     */
96
-    public function getItemArray(array $itemInfo)
97
-    {
98
-        return $this->removedAlgorithms[$itemInfo['name']];
99
-    }
89
+	/**
90
+	 * Get the relevant sub-array for a specific item from a multi-dimensional array.
91
+	 *
92
+	 * @param array $itemInfo Base information about the item.
93
+	 *
94
+	 * @return array Version and other information about the item.
95
+	 */
96
+	public function getItemArray(array $itemInfo)
97
+	{
98
+		return $this->removedAlgorithms[$itemInfo['name']];
99
+	}
100 100
 
101 101
 
102
-    /**
103
-     * Get the error message template for this sniff.
104
-     *
105
-     * @return string
106
-     */
107
-    protected function getErrorMsgTemplate()
108
-    {
109
-        return 'The %s hash algorithm is ';
110
-    }
102
+	/**
103
+	 * Get the error message template for this sniff.
104
+	 *
105
+	 * @return string
106
+	 */
107
+	protected function getErrorMsgTemplate()
108
+	{
109
+		return 'The %s hash algorithm is ';
110
+	}
111 111
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      */
55 55
     public function register()
56 56
     {
57
-        return array(\T_STRING);
57
+        return array( \T_STRING );
58 58
     }
59 59
 
60 60
 
@@ -67,22 +67,22 @@  discard block
 block discarded – undo
67 67
      *
68 68
      * @return void
69 69
      */
70
-    public function process(File $phpcsFile, $stackPtr)
70
+    public function process( File $phpcsFile, $stackPtr )
71 71
     {
72
-        $algo = $this->getHashAlgorithmParameter($phpcsFile, $stackPtr);
73
-        if (empty($algo) || \is_string($algo) === false) {
72
+        $algo = $this->getHashAlgorithmParameter( $phpcsFile, $stackPtr );
73
+        if ( empty( $algo ) || \is_string( $algo ) === false ) {
74 74
             return;
75 75
         }
76 76
 
77 77
         // Bow out if not one of the algorithms we're targetting.
78
-        if (isset($this->removedAlgorithms[$algo]) === false) {
78
+        if ( isset( $this->removedAlgorithms[ $algo ] ) === false ) {
79 79
             return;
80 80
         }
81 81
 
82 82
         $itemInfo = array(
83 83
             'name' => $algo,
84 84
         );
85
-        $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
85
+        $this->handleFeature( $phpcsFile, $stackPtr, $itemInfo );
86 86
     }
87 87
 
88 88
 
@@ -93,9 +93,9 @@  discard block
 block discarded – undo
93 93
      *
94 94
      * @return array Version and other information about the item.
95 95
      */
96
-    public function getItemArray(array $itemInfo)
96
+    public function getItemArray( array $itemInfo )
97 97
     {
98
-        return $this->removedAlgorithms[$itemInfo['name']];
98
+        return $this->removedAlgorithms[ $itemInfo[ 'name' ] ];
99 99
     }
100 100
 
101 101
 
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -27,8 +27,7 @@  discard block
 block discarded – undo
27 27
  * @author    Wim Godden <[email protected]>
28 28
  * @copyright 2012 Cu.be Solutions bvba
29 29
  */
30
-class RemovedHashAlgorithmsSniff extends AbstractRemovedFeatureSniff
31
-{
30
+class RemovedHashAlgorithmsSniff extends AbstractRemovedFeatureSniff {
32 31
 
33 32
     /**
34 33
      * A list of removed hash algorithms, which were present in older versions.
@@ -52,8 +51,7 @@  discard block
 block discarded – undo
52 51
      *
53 52
      * @return array
54 53
      */
55
-    public function register()
56
-    {
54
+    public function register() {
57 55
         return array(\T_STRING);
58 56
     }
59 57
 
@@ -67,8 +65,7 @@  discard block
 block discarded – undo
67 65
      *
68 66
      * @return void
69 67
      */
70
-    public function process(File $phpcsFile, $stackPtr)
71
-    {
68
+    public function process(File $phpcsFile, $stackPtr) {
72 69
         $algo = $this->getHashAlgorithmParameter($phpcsFile, $stackPtr);
73 70
         if (empty($algo) || \is_string($algo) === false) {
74 71
             return;
@@ -93,8 +90,7 @@  discard block
 block discarded – undo
93 90
      *
94 91
      * @return array Version and other information about the item.
95 92
      */
96
-    public function getItemArray(array $itemInfo)
97
-    {
93
+    public function getItemArray(array $itemInfo) {
98 94
         return $this->removedAlgorithms[$itemInfo['name']];
99 95
     }
100 96
 
@@ -104,8 +100,7 @@  discard block
 block discarded – undo
104 100
      *
105 101
      * @return string
106 102
      */
107
-    protected function getErrorMsgTemplate()
108
-    {
103
+    protected function getErrorMsgTemplate() {
109 104
         return 'The %s hash algorithm is ';
110 105
     }
111 106
 }
Please login to merge, or discard this patch.
PHPCompatibility/Sniffs/ParameterValues/NewArrayReduceInitialTypeSniff.php 3 patches
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -24,83 +24,83 @@
 block discarded – undo
24 24
 class NewArrayReduceInitialTypeSniff extends AbstractFunctionCallParameterSniff
25 25
 {
26 26
 
27
-    /**
28
-     * Functions to check for.
29
-     *
30
-     * @var array
31
-     */
32
-    protected $targetFunctions = array(
33
-        'array_reduce' => true,
34
-    );
27
+	/**
28
+	 * Functions to check for.
29
+	 *
30
+	 * @var array
31
+	 */
32
+	protected $targetFunctions = array(
33
+		'array_reduce' => true,
34
+	);
35 35
 
36
-    /**
37
-     * Tokens which, for the purposes of this sniff, indicate that there is
38
-     * a variable element to the value passed.
39
-     *
40
-     * @var array
41
-     */
42
-    private $variableValueTokens = array(
43
-        \T_VARIABLE,
44
-        \T_STRING,
45
-        \T_SELF,
46
-        \T_PARENT,
47
-        \T_STATIC,
48
-        \T_DOUBLE_QUOTED_STRING,
49
-    );
36
+	/**
37
+	 * Tokens which, for the purposes of this sniff, indicate that there is
38
+	 * a variable element to the value passed.
39
+	 *
40
+	 * @var array
41
+	 */
42
+	private $variableValueTokens = array(
43
+		\T_VARIABLE,
44
+		\T_STRING,
45
+		\T_SELF,
46
+		\T_PARENT,
47
+		\T_STATIC,
48
+		\T_DOUBLE_QUOTED_STRING,
49
+	);
50 50
 
51 51
 
52
-    /**
53
-     * Do a version check to determine if this sniff needs to run at all.
54
-     *
55
-     * @return bool
56
-     */
57
-    protected function bowOutEarly()
58
-    {
59
-        return ($this->supportsBelow('5.2') === false);
60
-    }
52
+	/**
53
+	 * Do a version check to determine if this sniff needs to run at all.
54
+	 *
55
+	 * @return bool
56
+	 */
57
+	protected function bowOutEarly()
58
+	{
59
+		return ($this->supportsBelow('5.2') === false);
60
+	}
61 61
 
62 62
 
63
-    /**
64
-     * Process the parameters of a matched function.
65
-     *
66
-     * @param \PHP_CodeSniffer_File $phpcsFile    The file being scanned.
67
-     * @param int                   $stackPtr     The position of the current token in the stack.
68
-     * @param string                $functionName The token content (function name) which was matched.
69
-     * @param array                 $parameters   Array with information about the parameters.
70
-     *
71
-     * @return int|void Integer stack pointer to skip forward or void to continue
72
-     *                  normal file processing.
73
-     */
74
-    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
75
-    {
76
-        if (isset($parameters[3]) === false) {
77
-            return;
78
-        }
63
+	/**
64
+	 * Process the parameters of a matched function.
65
+	 *
66
+	 * @param \PHP_CodeSniffer_File $phpcsFile    The file being scanned.
67
+	 * @param int                   $stackPtr     The position of the current token in the stack.
68
+	 * @param string                $functionName The token content (function name) which was matched.
69
+	 * @param array                 $parameters   Array with information about the parameters.
70
+	 *
71
+	 * @return int|void Integer stack pointer to skip forward or void to continue
72
+	 *                  normal file processing.
73
+	 */
74
+	public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
75
+	{
76
+		if (isset($parameters[3]) === false) {
77
+			return;
78
+		}
79 79
 
80
-        $targetParam = $parameters[3];
81
-        if ($this->isNumber($phpcsFile, $targetParam['start'], $targetParam['end'], true) !== false) {
82
-            return;
83
-        }
80
+		$targetParam = $parameters[3];
81
+		if ($this->isNumber($phpcsFile, $targetParam['start'], $targetParam['end'], true) !== false) {
82
+			return;
83
+		}
84 84
 
85
-        if ($this->isNumericCalculation($phpcsFile, $targetParam['start'], $targetParam['end']) === true) {
86
-            return;
87
-        }
85
+		if ($this->isNumericCalculation($phpcsFile, $targetParam['start'], $targetParam['end']) === true) {
86
+			return;
87
+		}
88 88
 
89
-        $error = 'Passing a non-integer as the value for $initial to array_reduce() is not supported in PHP 5.2 or lower.';
90
-        if ($phpcsFile->findNext($this->variableValueTokens, $targetParam['start'], ($targetParam['end'] + 1)) === false) {
91
-            $phpcsFile->addError(
92
-                $error . ' Found %s',
93
-                $targetParam['start'],
94
-                'InvalidTypeFound',
95
-                array($targetParam['raw'])
96
-            );
97
-        } else {
98
-            $phpcsFile->addWarning(
99
-                $error . ' Variable value found. Found %s',
100
-                $targetParam['start'],
101
-                'VariableFound',
102
-                array($targetParam['raw'])
103
-            );
104
-        }
105
-    }
89
+		$error = 'Passing a non-integer as the value for $initial to array_reduce() is not supported in PHP 5.2 or lower.';
90
+		if ($phpcsFile->findNext($this->variableValueTokens, $targetParam['start'], ($targetParam['end'] + 1)) === false) {
91
+			$phpcsFile->addError(
92
+				$error . ' Found %s',
93
+				$targetParam['start'],
94
+				'InvalidTypeFound',
95
+				array($targetParam['raw'])
96
+			);
97
+		} else {
98
+			$phpcsFile->addWarning(
99
+				$error . ' Variable value found. Found %s',
100
+				$targetParam['start'],
101
+				'VariableFound',
102
+				array($targetParam['raw'])
103
+			);
104
+		}
105
+	}
106 106
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
      */
57 57
     protected function bowOutEarly()
58 58
     {
59
-        return ($this->supportsBelow('5.2') === false);
59
+        return ( $this->supportsBelow( '5.2' ) === false );
60 60
     }
61 61
 
62 62
 
@@ -71,35 +71,35 @@  discard block
 block discarded – undo
71 71
      * @return int|void Integer stack pointer to skip forward or void to continue
72 72
      *                  normal file processing.
73 73
      */
74
-    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
74
+    public function processParameters( File $phpcsFile, $stackPtr, $functionName, $parameters )
75 75
     {
76
-        if (isset($parameters[3]) === false) {
76
+        if ( isset( $parameters[ 3 ] ) === false ) {
77 77
             return;
78 78
         }
79 79
 
80
-        $targetParam = $parameters[3];
81
-        if ($this->isNumber($phpcsFile, $targetParam['start'], $targetParam['end'], true) !== false) {
80
+        $targetParam = $parameters[ 3 ];
81
+        if ( $this->isNumber( $phpcsFile, $targetParam[ 'start' ], $targetParam[ 'end' ], true ) !== false ) {
82 82
             return;
83 83
         }
84 84
 
85
-        if ($this->isNumericCalculation($phpcsFile, $targetParam['start'], $targetParam['end']) === true) {
85
+        if ( $this->isNumericCalculation( $phpcsFile, $targetParam[ 'start' ], $targetParam[ 'end' ] ) === true ) {
86 86
             return;
87 87
         }
88 88
 
89 89
         $error = 'Passing a non-integer as the value for $initial to array_reduce() is not supported in PHP 5.2 or lower.';
90
-        if ($phpcsFile->findNext($this->variableValueTokens, $targetParam['start'], ($targetParam['end'] + 1)) === false) {
90
+        if ( $phpcsFile->findNext( $this->variableValueTokens, $targetParam[ 'start' ], ( $targetParam[ 'end' ] + 1 ) ) === false ) {
91 91
             $phpcsFile->addError(
92 92
                 $error . ' Found %s',
93
-                $targetParam['start'],
93
+                $targetParam[ 'start' ],
94 94
                 'InvalidTypeFound',
95
-                array($targetParam['raw'])
95
+                array( $targetParam[ 'raw' ] )
96 96
             );
97 97
         } else {
98 98
             $phpcsFile->addWarning(
99 99
                 $error . ' Variable value found. Found %s',
100
-                $targetParam['start'],
100
+                $targetParam[ 'start' ],
101 101
                 'VariableFound',
102
-                array($targetParam['raw'])
102
+                array( $targetParam[ 'raw' ] )
103 103
             );
104 104
         }
105 105
     }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,8 +21,7 @@  discard block
 block discarded – undo
21 21
  * @package  PHPCompatibility
22 22
  * @author   Juliette Reinders Folmer <[email protected]>
23 23
  */
24
-class NewArrayReduceInitialTypeSniff extends AbstractFunctionCallParameterSniff
25
-{
24
+class NewArrayReduceInitialTypeSniff extends AbstractFunctionCallParameterSniff {
26 25
 
27 26
     /**
28 27
      * Functions to check for.
@@ -54,8 +53,7 @@  discard block
 block discarded – undo
54 53
      *
55 54
      * @return bool
56 55
      */
57
-    protected function bowOutEarly()
58
-    {
56
+    protected function bowOutEarly() {
59 57
         return ($this->supportsBelow('5.2') === false);
60 58
     }
61 59
 
@@ -71,8 +69,7 @@  discard block
 block discarded – undo
71 69
      * @return int|void Integer stack pointer to skip forward or void to continue
72 70
      *                  normal file processing.
73 71
      */
74
-    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
75
-    {
72
+    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters) {
76 73
         if (isset($parameters[3]) === false) {
77 74
             return;
78 75
         }
Please login to merge, or discard this patch.
PHPCompatibility/Sniffs/ParameterValues/NewPackFormatSniff.php 3 patches
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -24,100 +24,100 @@
 block discarded – undo
24 24
 class NewPackFormatSniff extends AbstractFunctionCallParameterSniff
25 25
 {
26 26
 
27
-    /**
28
-     * Functions to check for.
29
-     *
30
-     * @var array
31
-     */
32
-    protected $targetFunctions = array(
33
-        'pack' => true,
34
-    );
27
+	/**
28
+	 * Functions to check for.
29
+	 *
30
+	 * @var array
31
+	 */
32
+	protected $targetFunctions = array(
33
+		'pack' => true,
34
+	);
35 35
 
36
-    /**
37
-     * List of new format character codes added to pack().
38
-     *
39
-     * @var array Regex pattern => Version array.
40
-     */
41
-    protected $newFormats = array(
42
-        '`([Z])`'    => array(
43
-            '5.4' => false,
44
-            '5.5' => true,
45
-        ),
46
-        '`([qQJP])`' => array(
47
-            '5.6.2' => false,
48
-            '5.6.3' => true,
49
-        ),
50
-        '`([eEgG])`' => array(
51
-            '7.0.14' => false,
52
-            '7.0.15' => true, // And 7.1.1.
53
-        ),
54
-    );
36
+	/**
37
+	 * List of new format character codes added to pack().
38
+	 *
39
+	 * @var array Regex pattern => Version array.
40
+	 */
41
+	protected $newFormats = array(
42
+		'`([Z])`'    => array(
43
+			'5.4' => false,
44
+			'5.5' => true,
45
+		),
46
+		'`([qQJP])`' => array(
47
+			'5.6.2' => false,
48
+			'5.6.3' => true,
49
+		),
50
+		'`([eEgG])`' => array(
51
+			'7.0.14' => false,
52
+			'7.0.15' => true, // And 7.1.1.
53
+		),
54
+	);
55 55
 
56 56
 
57
-    /**
58
-     * Do a version check to determine if this sniff needs to run at all.
59
-     *
60
-     * @return bool
61
-     */
62
-    protected function bowOutEarly()
63
-    {
64
-        return ($this->supportsBelow('7.1') === false);
65
-    }
57
+	/**
58
+	 * Do a version check to determine if this sniff needs to run at all.
59
+	 *
60
+	 * @return bool
61
+	 */
62
+	protected function bowOutEarly()
63
+	{
64
+		return ($this->supportsBelow('7.1') === false);
65
+	}
66 66
 
67 67
 
68
-    /**
69
-     * Process the parameters of a matched function.
70
-     *
71
-     * @param \PHP_CodeSniffer_File $phpcsFile    The file being scanned.
72
-     * @param int                   $stackPtr     The position of the current token in the stack.
73
-     * @param string                $functionName The token content (function name) which was matched.
74
-     * @param array                 $parameters   Array with information about the parameters.
75
-     *
76
-     * @return int|void Integer stack pointer to skip forward or void to continue
77
-     *                  normal file processing.
78
-     */
79
-    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
80
-    {
81
-        if (isset($parameters[1]) === false) {
82
-            return;
83
-        }
68
+	/**
69
+	 * Process the parameters of a matched function.
70
+	 *
71
+	 * @param \PHP_CodeSniffer_File $phpcsFile    The file being scanned.
72
+	 * @param int                   $stackPtr     The position of the current token in the stack.
73
+	 * @param string                $functionName The token content (function name) which was matched.
74
+	 * @param array                 $parameters   Array with information about the parameters.
75
+	 *
76
+	 * @return int|void Integer stack pointer to skip forward or void to continue
77
+	 *                  normal file processing.
78
+	 */
79
+	public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
80
+	{
81
+		if (isset($parameters[1]) === false) {
82
+			return;
83
+		}
84 84
 
85
-        $tokens      = $phpcsFile->getTokens();
86
-        $targetParam = $parameters[1];
85
+		$tokens      = $phpcsFile->getTokens();
86
+		$targetParam = $parameters[1];
87 87
 
88
-        for ($i = $targetParam['start']; $i <= $targetParam['end']; $i++) {
89
-            if ($tokens[$i]['code'] !== \T_CONSTANT_ENCAPSED_STRING
90
-                && $tokens[$i]['code'] !== \T_DOUBLE_QUOTED_STRING
91
-            ) {
92
-                continue;
93
-            }
88
+		for ($i = $targetParam['start']; $i <= $targetParam['end']; $i++) {
89
+			if ($tokens[$i]['code'] !== \T_CONSTANT_ENCAPSED_STRING
90
+				&& $tokens[$i]['code'] !== \T_DOUBLE_QUOTED_STRING
91
+			) {
92
+				continue;
93
+			}
94 94
 
95
-            $content = $tokens[$i]['content'];
96
-            if ($tokens[$i]['code'] === \T_DOUBLE_QUOTED_STRING) {
97
-                $content = $this->stripVariables($content);
98
-            }
95
+			$content = $tokens[$i]['content'];
96
+			if ($tokens[$i]['code'] === \T_DOUBLE_QUOTED_STRING) {
97
+				$content = $this->stripVariables($content);
98
+			}
99 99
 
100
-            foreach ($this->newFormats as $pattern => $versionArray) {
101
-                if (preg_match($pattern, $content, $matches) !== 1) {
102
-                    continue;
103
-                }
100
+			foreach ($this->newFormats as $pattern => $versionArray) {
101
+				if (preg_match($pattern, $content, $matches) !== 1) {
102
+					continue;
103
+				}
104 104
 
105
-                foreach ($versionArray as $version => $present) {
106
-                    if ($present === false && $this->supportsBelow($version) === true) {
107
-                        $phpcsFile->addError(
108
-                            'Passing the $format(s) "%s" to pack() is not supported in PHP %s or lower. Found %s',
109
-                            $targetParam['start'],
110
-                            'NewFormatFound',
111
-                            array(
112
-                                $matches[1],
113
-                                $version,
114
-                                $targetParam['raw'],
115
-                            )
116
-                        );
117
-                        continue 2;
118
-                    }
119
-                }
120
-            }
121
-        }
122
-    }
105
+				foreach ($versionArray as $version => $present) {
106
+					if ($present === false && $this->supportsBelow($version) === true) {
107
+						$phpcsFile->addError(
108
+							'Passing the $format(s) "%s" to pack() is not supported in PHP %s or lower. Found %s',
109
+							$targetParam['start'],
110
+							'NewFormatFound',
111
+							array(
112
+								$matches[1],
113
+								$version,
114
+								$targetParam['raw'],
115
+							)
116
+						);
117
+						continue 2;
118
+					}
119
+				}
120
+			}
121
+		}
122
+	}
123 123
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      */
62 62
     protected function bowOutEarly()
63 63
     {
64
-        return ($this->supportsBelow('7.1') === false);
64
+        return ( $this->supportsBelow( '7.1' ) === false );
65 65
     }
66 66
 
67 67
 
@@ -76,42 +76,42 @@  discard block
 block discarded – undo
76 76
      * @return int|void Integer stack pointer to skip forward or void to continue
77 77
      *                  normal file processing.
78 78
      */
79
-    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
79
+    public function processParameters( File $phpcsFile, $stackPtr, $functionName, $parameters )
80 80
     {
81
-        if (isset($parameters[1]) === false) {
81
+        if ( isset( $parameters[ 1 ] ) === false ) {
82 82
             return;
83 83
         }
84 84
 
85 85
         $tokens      = $phpcsFile->getTokens();
86
-        $targetParam = $parameters[1];
86
+        $targetParam = $parameters[ 1 ];
87 87
 
88
-        for ($i = $targetParam['start']; $i <= $targetParam['end']; $i++) {
89
-            if ($tokens[$i]['code'] !== \T_CONSTANT_ENCAPSED_STRING
90
-                && $tokens[$i]['code'] !== \T_DOUBLE_QUOTED_STRING
88
+        for ( $i = $targetParam[ 'start' ]; $i <= $targetParam[ 'end' ]; $i++ ) {
89
+            if ( $tokens[ $i ][ 'code' ] !== \T_CONSTANT_ENCAPSED_STRING
90
+                && $tokens[ $i ][ 'code' ] !== \T_DOUBLE_QUOTED_STRING
91 91
             ) {
92 92
                 continue;
93 93
             }
94 94
 
95
-            $content = $tokens[$i]['content'];
96
-            if ($tokens[$i]['code'] === \T_DOUBLE_QUOTED_STRING) {
97
-                $content = $this->stripVariables($content);
95
+            $content = $tokens[ $i ][ 'content' ];
96
+            if ( $tokens[ $i ][ 'code' ] === \T_DOUBLE_QUOTED_STRING ) {
97
+                $content = $this->stripVariables( $content );
98 98
             }
99 99
 
100
-            foreach ($this->newFormats as $pattern => $versionArray) {
101
-                if (preg_match($pattern, $content, $matches) !== 1) {
100
+            foreach ( $this->newFormats as $pattern => $versionArray ) {
101
+                if ( preg_match( $pattern, $content, $matches ) !== 1 ) {
102 102
                     continue;
103 103
                 }
104 104
 
105
-                foreach ($versionArray as $version => $present) {
106
-                    if ($present === false && $this->supportsBelow($version) === true) {
105
+                foreach ( $versionArray as $version => $present ) {
106
+                    if ( $present === false && $this->supportsBelow( $version ) === true ) {
107 107
                         $phpcsFile->addError(
108 108
                             'Passing the $format(s) "%s" to pack() is not supported in PHP %s or lower. Found %s',
109
-                            $targetParam['start'],
109
+                            $targetParam[ 'start' ],
110 110
                             'NewFormatFound',
111 111
                             array(
112
-                                $matches[1],
112
+                                $matches[ 1 ],
113 113
                                 $version,
114
-                                $targetParam['raw'],
114
+                                $targetParam[ 'raw' ],
115 115
                             )
116 116
                         );
117 117
                         continue 2;
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,8 +21,7 @@  discard block
 block discarded – undo
21 21
  * @package  PHPCompatibility
22 22
  * @author   Juliette Reinders Folmer <[email protected]>
23 23
  */
24
-class NewPackFormatSniff extends AbstractFunctionCallParameterSniff
25
-{
24
+class NewPackFormatSniff extends AbstractFunctionCallParameterSniff {
26 25
 
27 26
     /**
28 27
      * Functions to check for.
@@ -59,8 +58,7 @@  discard block
 block discarded – undo
59 58
      *
60 59
      * @return bool
61 60
      */
62
-    protected function bowOutEarly()
63
-    {
61
+    protected function bowOutEarly() {
64 62
         return ($this->supportsBelow('7.1') === false);
65 63
     }
66 64
 
@@ -76,8 +74,7 @@  discard block
 block discarded – undo
76 74
      * @return int|void Integer stack pointer to skip forward or void to continue
77 75
      *                  normal file processing.
78 76
      */
79
-    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
80
-    {
77
+    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters) {
81 78
         if (isset($parameters[1]) === false) {
82 79
             return;
83 80
         }
Please login to merge, or discard this patch.
PHPCompatibility/Sniffs/ParameterValues/NewFopenModesSniff.php 3 patches
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -24,89 +24,89 @@
 block discarded – undo
24 24
 class NewFopenModesSniff extends AbstractFunctionCallParameterSniff
25 25
 {
26 26
 
27
-    /**
28
-     * Functions to check for.
29
-     *
30
-     * @var array
31
-     */
32
-    protected $targetFunctions = array(
33
-        'fopen' => true,
34
-    );
27
+	/**
28
+	 * Functions to check for.
29
+	 *
30
+	 * @var array
31
+	 */
32
+	protected $targetFunctions = array(
33
+		'fopen' => true,
34
+	);
35 35
 
36 36
 
37
-    /**
38
-     * Do a version check to determine if this sniff needs to run at all.
39
-     *
40
-     * @return bool
41
-     */
42
-    protected function bowOutEarly()
43
-    {
44
-        // Version used here should be (above) the highest version from the `newModes` control,
45
-        // structure below, i.e. the last PHP version in which a new mode was introduced.
46
-        return ($this->supportsBelow('7.1') === false);
47
-    }
37
+	/**
38
+	 * Do a version check to determine if this sniff needs to run at all.
39
+	 *
40
+	 * @return bool
41
+	 */
42
+	protected function bowOutEarly()
43
+	{
44
+		// Version used here should be (above) the highest version from the `newModes` control,
45
+		// structure below, i.e. the last PHP version in which a new mode was introduced.
46
+		return ($this->supportsBelow('7.1') === false);
47
+	}
48 48
 
49 49
 
50
-    /**
51
-     * Process the parameters of a matched function.
52
-     *
53
-     * @param \PHP_CodeSniffer_File $phpcsFile    The file being scanned.
54
-     * @param int                   $stackPtr     The position of the current token in the stack.
55
-     * @param string                $functionName The token content (function name) which was matched.
56
-     * @param array                 $parameters   Array with information about the parameters.
57
-     *
58
-     * @return int|void Integer stack pointer to skip forward or void to continue
59
-     *                  normal file processing.
60
-     */
61
-    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
62
-    {
63
-        if (isset($parameters[2]) === false) {
64
-            return;
65
-        }
50
+	/**
51
+	 * Process the parameters of a matched function.
52
+	 *
53
+	 * @param \PHP_CodeSniffer_File $phpcsFile    The file being scanned.
54
+	 * @param int                   $stackPtr     The position of the current token in the stack.
55
+	 * @param string                $functionName The token content (function name) which was matched.
56
+	 * @param array                 $parameters   Array with information about the parameters.
57
+	 *
58
+	 * @return int|void Integer stack pointer to skip forward or void to continue
59
+	 *                  normal file processing.
60
+	 */
61
+	public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
62
+	{
63
+		if (isset($parameters[2]) === false) {
64
+			return;
65
+		}
66 66
 
67
-        $tokens      = $phpcsFile->getTokens();
68
-        $targetParam = $parameters[2];
69
-        $errors      = array();
67
+		$tokens      = $phpcsFile->getTokens();
68
+		$targetParam = $parameters[2];
69
+		$errors      = array();
70 70
 
71
-        for ($i = $targetParam['start']; $i <= $targetParam['end']; $i++) {
72
-            if ($tokens[$i]['code'] !== \T_CONSTANT_ENCAPSED_STRING) {
73
-                continue;
74
-            }
71
+		for ($i = $targetParam['start']; $i <= $targetParam['end']; $i++) {
72
+			if ($tokens[$i]['code'] !== \T_CONSTANT_ENCAPSED_STRING) {
73
+				continue;
74
+			}
75 75
 
76
-            if (strpos($tokens[$i]['content'], 'c+') !== false && $this->supportsBelow('5.2.5')) {
77
-                $errors['cplusFound'] = array(
78
-                    'c+',
79
-                    '5.2.5',
80
-                    $targetParam['raw'],
81
-                );
82
-            } elseif (strpos($tokens[$i]['content'], 'c') !== false && $this->supportsBelow('5.2.5')) {
83
-                $errors['cFound'] = array(
84
-                    'c',
85
-                    '5.2.5',
86
-                    $targetParam['raw'],
87
-                );
88
-            }
76
+			if (strpos($tokens[$i]['content'], 'c+') !== false && $this->supportsBelow('5.2.5')) {
77
+				$errors['cplusFound'] = array(
78
+					'c+',
79
+					'5.2.5',
80
+					$targetParam['raw'],
81
+				);
82
+			} elseif (strpos($tokens[$i]['content'], 'c') !== false && $this->supportsBelow('5.2.5')) {
83
+				$errors['cFound'] = array(
84
+					'c',
85
+					'5.2.5',
86
+					$targetParam['raw'],
87
+				);
88
+			}
89 89
 
90
-            if (strpos($tokens[$i]['content'], 'e') !== false && $this->supportsBelow('7.0.15')) {
91
-                $errors['eFound'] = array(
92
-                    'e',
93
-                    '7.0.15',
94
-                    $targetParam['raw'],
95
-                );
96
-            }
97
-        }
90
+			if (strpos($tokens[$i]['content'], 'e') !== false && $this->supportsBelow('7.0.15')) {
91
+				$errors['eFound'] = array(
92
+					'e',
93
+					'7.0.15',
94
+					$targetParam['raw'],
95
+				);
96
+			}
97
+		}
98 98
 
99
-        if (empty($errors) === true) {
100
-            return;
101
-        }
99
+		if (empty($errors) === true) {
100
+			return;
101
+		}
102 102
 
103
-        foreach ($errors as $errorCode => $errorData) {
104
-            $phpcsFile->addError(
105
-                'Passing "%s" as the $mode to fopen() is not supported in PHP %s or lower. Found %s',
106
-                $targetParam['start'],
107
-                $errorCode,
108
-                $errorData
109
-            );
110
-        }
111
-    }
103
+		foreach ($errors as $errorCode => $errorData) {
104
+			$phpcsFile->addError(
105
+				'Passing "%s" as the $mode to fopen() is not supported in PHP %s or lower. Found %s',
106
+				$targetParam['start'],
107
+				$errorCode,
108
+				$errorData
109
+			);
110
+		}
111
+	}
112 112
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     {
44 44
         // Version used here should be (above) the highest version from the `newModes` control,
45 45
         // structure below, i.e. the last PHP version in which a new mode was introduced.
46
-        return ($this->supportsBelow('7.1') === false);
46
+        return ( $this->supportsBelow( '7.1' ) === false );
47 47
     }
48 48
 
49 49
 
@@ -58,52 +58,52 @@  discard block
 block discarded – undo
58 58
      * @return int|void Integer stack pointer to skip forward or void to continue
59 59
      *                  normal file processing.
60 60
      */
61
-    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
61
+    public function processParameters( File $phpcsFile, $stackPtr, $functionName, $parameters )
62 62
     {
63
-        if (isset($parameters[2]) === false) {
63
+        if ( isset( $parameters[ 2 ] ) === false ) {
64 64
             return;
65 65
         }
66 66
 
67 67
         $tokens      = $phpcsFile->getTokens();
68
-        $targetParam = $parameters[2];
68
+        $targetParam = $parameters[ 2 ];
69 69
         $errors      = array();
70 70
 
71
-        for ($i = $targetParam['start']; $i <= $targetParam['end']; $i++) {
72
-            if ($tokens[$i]['code'] !== \T_CONSTANT_ENCAPSED_STRING) {
71
+        for ( $i = $targetParam[ 'start' ]; $i <= $targetParam[ 'end' ]; $i++ ) {
72
+            if ( $tokens[ $i ][ 'code' ] !== \T_CONSTANT_ENCAPSED_STRING ) {
73 73
                 continue;
74 74
             }
75 75
 
76
-            if (strpos($tokens[$i]['content'], 'c+') !== false && $this->supportsBelow('5.2.5')) {
77
-                $errors['cplusFound'] = array(
76
+            if ( strpos( $tokens[ $i ][ 'content' ], 'c+' ) !== false && $this->supportsBelow( '5.2.5' ) ) {
77
+                $errors[ 'cplusFound' ] = array(
78 78
                     'c+',
79 79
                     '5.2.5',
80
-                    $targetParam['raw'],
80
+                    $targetParam[ 'raw' ],
81 81
                 );
82
-            } elseif (strpos($tokens[$i]['content'], 'c') !== false && $this->supportsBelow('5.2.5')) {
83
-                $errors['cFound'] = array(
82
+            } elseif ( strpos( $tokens[ $i ][ 'content' ], 'c' ) !== false && $this->supportsBelow( '5.2.5' ) ) {
83
+                $errors[ 'cFound' ] = array(
84 84
                     'c',
85 85
                     '5.2.5',
86
-                    $targetParam['raw'],
86
+                    $targetParam[ 'raw' ],
87 87
                 );
88 88
             }
89 89
 
90
-            if (strpos($tokens[$i]['content'], 'e') !== false && $this->supportsBelow('7.0.15')) {
91
-                $errors['eFound'] = array(
90
+            if ( strpos( $tokens[ $i ][ 'content' ], 'e' ) !== false && $this->supportsBelow( '7.0.15' ) ) {
91
+                $errors[ 'eFound' ] = array(
92 92
                     'e',
93 93
                     '7.0.15',
94
-                    $targetParam['raw'],
94
+                    $targetParam[ 'raw' ],
95 95
                 );
96 96
             }
97 97
         }
98 98
 
99
-        if (empty($errors) === true) {
99
+        if ( empty( $errors ) === true ) {
100 100
             return;
101 101
         }
102 102
 
103
-        foreach ($errors as $errorCode => $errorData) {
103
+        foreach ( $errors as $errorCode => $errorData ) {
104 104
             $phpcsFile->addError(
105 105
                 'Passing "%s" as the $mode to fopen() is not supported in PHP %s or lower. Found %s',
106
-                $targetParam['start'],
106
+                $targetParam[ 'start' ],
107 107
                 $errorCode,
108 108
                 $errorData
109 109
             );
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,8 +21,7 @@  discard block
 block discarded – undo
21 21
  * @package  PHPCompatibility
22 22
  * @author   Juliette Reinders Folmer <[email protected]>
23 23
  */
24
-class NewFopenModesSniff extends AbstractFunctionCallParameterSniff
25
-{
24
+class NewFopenModesSniff extends AbstractFunctionCallParameterSniff {
26 25
 
27 26
     /**
28 27
      * Functions to check for.
@@ -39,8 +38,7 @@  discard block
 block discarded – undo
39 38
      *
40 39
      * @return bool
41 40
      */
42
-    protected function bowOutEarly()
43
-    {
41
+    protected function bowOutEarly() {
44 42
         // Version used here should be (above) the highest version from the `newModes` control,
45 43
         // structure below, i.e. the last PHP version in which a new mode was introduced.
46 44
         return ($this->supportsBelow('7.1') === false);
@@ -58,8 +56,7 @@  discard block
 block discarded – undo
58 56
      * @return int|void Integer stack pointer to skip forward or void to continue
59 57
      *                  normal file processing.
60 58
      */
61
-    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
62
-    {
59
+    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters) {
63 60
         if (isset($parameters[2]) === false) {
64 61
             return;
65 62
         }
Please login to merge, or discard this patch.
PHPCompatibility/Sniffs/ParameterValues/RemovedMbstringModifiersSniff.php 3 patches
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -27,96 +27,96 @@
 block discarded – undo
27 27
 class RemovedMbstringModifiersSniff extends AbstractFunctionCallParameterSniff
28 28
 {
29 29
 
30
-    /**
31
-     * Functions to check for.
32
-     *
33
-     * Key is the function name, value the parameter position of the options parameter.
34
-     *
35
-     * @var array
36
-     */
37
-    protected $targetFunctions = array(
38
-        'mb_ereg_replace'      => 4,
39
-        'mb_eregi_replace'     => 4,
40
-        'mb_regex_set_options' => 1,
41
-        'mbereg_replace'       => 4, // Undocumented, but valid function alias.
42
-        'mberegi_replace'      => 4, // Undocumented, but valid function alias.
43
-    );
44
-
45
-
46
-    /**
47
-     * Do a version check to determine if this sniff needs to run at all.
48
-     *
49
-     * @return bool
50
-     */
51
-    protected function bowOutEarly()
52
-    {
53
-        // Version used here should be the highest version from the `$newModifiers` array,
54
-        // i.e. the last PHP version in which a new modifier was introduced.
55
-        return ($this->supportsAbove('7.1') === false);
56
-    }
57
-
58
-
59
-    /**
60
-     * Process the parameters of a matched function.
61
-     *
62
-     * This method has to be made concrete in child classes.
63
-     *
64
-     * @param \PHP_CodeSniffer_File $phpcsFile    The file being scanned.
65
-     * @param int                   $stackPtr     The position of the current token in the stack.
66
-     * @param string                $functionName The token content (function name) which was matched.
67
-     * @param array                 $parameters   Array with information about the parameters.
68
-     *
69
-     * @return int|void Integer stack pointer to skip forward or void to continue
70
-     *                  normal file processing.
71
-     */
72
-    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
73
-    {
74
-        $tokens         = $phpcsFile->getTokens();
75
-        $functionNameLc = strtolower($functionName);
76
-
77
-        // Check whether the options parameter in the function call is passed.
78
-        if (isset($parameters[$this->targetFunctions[$functionNameLc]]) === false) {
79
-            return;
80
-        }
81
-
82
-        $optionsParam = $parameters[$this->targetFunctions[$functionNameLc]];
83
-
84
-        $stringToken = $phpcsFile->findNext(Tokens::$stringTokens, $optionsParam['start'], $optionsParam['end'] + 1);
85
-        if ($stringToken === false) {
86
-            // No string token found in the options parameter, so skip it (e.g. variable passed in).
87
-            return;
88
-        }
89
-
90
-        $options = '';
91
-
92
-        /*
30
+	/**
31
+	 * Functions to check for.
32
+	 *
33
+	 * Key is the function name, value the parameter position of the options parameter.
34
+	 *
35
+	 * @var array
36
+	 */
37
+	protected $targetFunctions = array(
38
+		'mb_ereg_replace'      => 4,
39
+		'mb_eregi_replace'     => 4,
40
+		'mb_regex_set_options' => 1,
41
+		'mbereg_replace'       => 4, // Undocumented, but valid function alias.
42
+		'mberegi_replace'      => 4, // Undocumented, but valid function alias.
43
+	);
44
+
45
+
46
+	/**
47
+	 * Do a version check to determine if this sniff needs to run at all.
48
+	 *
49
+	 * @return bool
50
+	 */
51
+	protected function bowOutEarly()
52
+	{
53
+		// Version used here should be the highest version from the `$newModifiers` array,
54
+		// i.e. the last PHP version in which a new modifier was introduced.
55
+		return ($this->supportsAbove('7.1') === false);
56
+	}
57
+
58
+
59
+	/**
60
+	 * Process the parameters of a matched function.
61
+	 *
62
+	 * This method has to be made concrete in child classes.
63
+	 *
64
+	 * @param \PHP_CodeSniffer_File $phpcsFile    The file being scanned.
65
+	 * @param int                   $stackPtr     The position of the current token in the stack.
66
+	 * @param string                $functionName The token content (function name) which was matched.
67
+	 * @param array                 $parameters   Array with information about the parameters.
68
+	 *
69
+	 * @return int|void Integer stack pointer to skip forward or void to continue
70
+	 *                  normal file processing.
71
+	 */
72
+	public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
73
+	{
74
+		$tokens         = $phpcsFile->getTokens();
75
+		$functionNameLc = strtolower($functionName);
76
+
77
+		// Check whether the options parameter in the function call is passed.
78
+		if (isset($parameters[$this->targetFunctions[$functionNameLc]]) === false) {
79
+			return;
80
+		}
81
+
82
+		$optionsParam = $parameters[$this->targetFunctions[$functionNameLc]];
83
+
84
+		$stringToken = $phpcsFile->findNext(Tokens::$stringTokens, $optionsParam['start'], $optionsParam['end'] + 1);
85
+		if ($stringToken === false) {
86
+			// No string token found in the options parameter, so skip it (e.g. variable passed in).
87
+			return;
88
+		}
89
+
90
+		$options = '';
91
+
92
+		/*
93 93
          * Get the content of any string tokens in the options parameter and remove the quotes and variables.
94 94
          */
95
-        for ($i = $stringToken; $i <= $optionsParam['end']; $i++) {
96
-            if (isset(Tokens::$stringTokens[$tokens[$i]['code']]) === false) {
97
-                continue;
98
-            }
99
-
100
-            $content = $this->stripQuotes($tokens[$i]['content']);
101
-            if ($tokens[$i]['code'] === \T_DOUBLE_QUOTED_STRING) {
102
-                $content = $this->stripVariables($content);
103
-            }
104
-            $content = trim($content);
105
-
106
-            if (empty($content) === false) {
107
-                $options .= $content;
108
-            }
109
-        }
110
-
111
-        if (strpos($options, 'e') !== false) {
112
-            $error = 'The Mbstring regex "e" modifier is deprecated since PHP 7.1.';
113
-
114
-            // The alternative mb_ereg_replace_callback() function is only available since 5.4.1.
115
-            if ($this->supportsBelow('5.4.1') === false) {
116
-                $error .= ' Use mb_ereg_replace_callback() instead (PHP 5.4.1+).';
117
-            }
118
-
119
-            $phpcsFile->addWarning($error, $stackPtr, 'Deprecated');
120
-        }
121
-    }
95
+		for ($i = $stringToken; $i <= $optionsParam['end']; $i++) {
96
+			if (isset(Tokens::$stringTokens[$tokens[$i]['code']]) === false) {
97
+				continue;
98
+			}
99
+
100
+			$content = $this->stripQuotes($tokens[$i]['content']);
101
+			if ($tokens[$i]['code'] === \T_DOUBLE_QUOTED_STRING) {
102
+				$content = $this->stripVariables($content);
103
+			}
104
+			$content = trim($content);
105
+
106
+			if (empty($content) === false) {
107
+				$options .= $content;
108
+			}
109
+		}
110
+
111
+		if (strpos($options, 'e') !== false) {
112
+			$error = 'The Mbstring regex "e" modifier is deprecated since PHP 7.1.';
113
+
114
+			// The alternative mb_ereg_replace_callback() function is only available since 5.4.1.
115
+			if ($this->supportsBelow('5.4.1') === false) {
116
+				$error .= ' Use mb_ereg_replace_callback() instead (PHP 5.4.1+).';
117
+			}
118
+
119
+			$phpcsFile->addWarning($error, $stackPtr, 'Deprecated');
120
+		}
121
+	}
122 122
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
     {
53 53
         // Version used here should be the highest version from the `$newModifiers` array,
54 54
         // i.e. the last PHP version in which a new modifier was introduced.
55
-        return ($this->supportsAbove('7.1') === false);
55
+        return ( $this->supportsAbove( '7.1' ) === false );
56 56
     }
57 57
 
58 58
 
@@ -69,20 +69,20 @@  discard block
 block discarded – undo
69 69
      * @return int|void Integer stack pointer to skip forward or void to continue
70 70
      *                  normal file processing.
71 71
      */
72
-    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
72
+    public function processParameters( File $phpcsFile, $stackPtr, $functionName, $parameters )
73 73
     {
74 74
         $tokens         = $phpcsFile->getTokens();
75
-        $functionNameLc = strtolower($functionName);
75
+        $functionNameLc = strtolower( $functionName );
76 76
 
77 77
         // Check whether the options parameter in the function call is passed.
78
-        if (isset($parameters[$this->targetFunctions[$functionNameLc]]) === false) {
78
+        if ( isset( $parameters[ $this->targetFunctions[ $functionNameLc ] ] ) === false ) {
79 79
             return;
80 80
         }
81 81
 
82
-        $optionsParam = $parameters[$this->targetFunctions[$functionNameLc]];
82
+        $optionsParam = $parameters[ $this->targetFunctions[ $functionNameLc ] ];
83 83
 
84
-        $stringToken = $phpcsFile->findNext(Tokens::$stringTokens, $optionsParam['start'], $optionsParam['end'] + 1);
85
-        if ($stringToken === false) {
84
+        $stringToken = $phpcsFile->findNext( Tokens::$stringTokens, $optionsParam[ 'start' ], $optionsParam[ 'end' ] + 1 );
85
+        if ( $stringToken === false ) {
86 86
             // No string token found in the options parameter, so skip it (e.g. variable passed in).
87 87
             return;
88 88
         }
@@ -92,31 +92,31 @@  discard block
 block discarded – undo
92 92
         /*
93 93
          * Get the content of any string tokens in the options parameter and remove the quotes and variables.
94 94
          */
95
-        for ($i = $stringToken; $i <= $optionsParam['end']; $i++) {
96
-            if (isset(Tokens::$stringTokens[$tokens[$i]['code']]) === false) {
95
+        for ( $i = $stringToken; $i <= $optionsParam[ 'end' ]; $i++ ) {
96
+            if ( isset( Tokens::$stringTokens[ $tokens[ $i ][ 'code' ] ] ) === false ) {
97 97
                 continue;
98 98
             }
99 99
 
100
-            $content = $this->stripQuotes($tokens[$i]['content']);
101
-            if ($tokens[$i]['code'] === \T_DOUBLE_QUOTED_STRING) {
102
-                $content = $this->stripVariables($content);
100
+            $content = $this->stripQuotes( $tokens[ $i ][ 'content' ] );
101
+            if ( $tokens[ $i ][ 'code' ] === \T_DOUBLE_QUOTED_STRING ) {
102
+                $content = $this->stripVariables( $content );
103 103
             }
104
-            $content = trim($content);
104
+            $content = trim( $content );
105 105
 
106
-            if (empty($content) === false) {
106
+            if ( empty( $content ) === false ) {
107 107
                 $options .= $content;
108 108
             }
109 109
         }
110 110
 
111
-        if (strpos($options, 'e') !== false) {
111
+        if ( strpos( $options, 'e' ) !== false ) {
112 112
             $error = 'The Mbstring regex "e" modifier is deprecated since PHP 7.1.';
113 113
 
114 114
             // The alternative mb_ereg_replace_callback() function is only available since 5.4.1.
115
-            if ($this->supportsBelow('5.4.1') === false) {
115
+            if ( $this->supportsBelow( '5.4.1' ) === false ) {
116 116
                 $error .= ' Use mb_ereg_replace_callback() instead (PHP 5.4.1+).';
117 117
             }
118 118
 
119
-            $phpcsFile->addWarning($error, $stackPtr, 'Deprecated');
119
+            $phpcsFile->addWarning( $error, $stackPtr, 'Deprecated' );
120 120
         }
121 121
     }
122 122
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -24,8 +24,7 @@  discard block
 block discarded – undo
24 24
  * @package  PHPCompatibility
25 25
  * @author   Juliette Reinders Folmer <[email protected]>
26 26
  */
27
-class RemovedMbstringModifiersSniff extends AbstractFunctionCallParameterSniff
28
-{
27
+class RemovedMbstringModifiersSniff extends AbstractFunctionCallParameterSniff {
29 28
 
30 29
     /**
31 30
      * Functions to check for.
@@ -48,8 +47,7 @@  discard block
 block discarded – undo
48 47
      *
49 48
      * @return bool
50 49
      */
51
-    protected function bowOutEarly()
52
-    {
50
+    protected function bowOutEarly() {
53 51
         // Version used here should be the highest version from the `$newModifiers` array,
54 52
         // i.e. the last PHP version in which a new modifier was introduced.
55 53
         return ($this->supportsAbove('7.1') === false);
@@ -69,8 +67,7 @@  discard block
 block discarded – undo
69 67
      * @return int|void Integer stack pointer to skip forward or void to continue
70 68
      *                  normal file processing.
71 69
      */
72
-    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
73
-    {
70
+    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters) {
74 71
         $tokens         = $phpcsFile->getTokens();
75 72
         $functionNameLc = strtolower($functionName);
76 73
 
Please login to merge, or discard this patch.
PHPCompatibility/Sniffs/ParameterValues/ForbiddenGetClassNullSniff.php 3 patches
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -29,52 +29,52 @@
 block discarded – undo
29 29
 class ForbiddenGetClassNullSniff extends AbstractFunctionCallParameterSniff
30 30
 {
31 31
 
32
-    /**
33
-     * Functions to check for.
34
-     *
35
-     * @var array
36
-     */
37
-    protected $targetFunctions = array(
38
-        'get_class' => true,
39
-    );
32
+	/**
33
+	 * Functions to check for.
34
+	 *
35
+	 * @var array
36
+	 */
37
+	protected $targetFunctions = array(
38
+		'get_class' => true,
39
+	);
40 40
 
41 41
 
42
-    /**
43
-     * Do a version check to determine if this sniff needs to run at all.
44
-     *
45
-     * @return bool
46
-     */
47
-    protected function bowOutEarly()
48
-    {
49
-        return ($this->supportsAbove('7.2') === false);
50
-    }
42
+	/**
43
+	 * Do a version check to determine if this sniff needs to run at all.
44
+	 *
45
+	 * @return bool
46
+	 */
47
+	protected function bowOutEarly()
48
+	{
49
+		return ($this->supportsAbove('7.2') === false);
50
+	}
51 51
 
52 52
 
53
-    /**
54
-     * Process the parameters of a matched function.
55
-     *
56
-     * @param \PHP_CodeSniffer_File $phpcsFile    The file being scanned.
57
-     * @param int                   $stackPtr     The position of the current token in the stack.
58
-     * @param string                $functionName The token content (function name) which was matched.
59
-     * @param array                 $parameters   Array with information about the parameters.
60
-     *
61
-     * @return int|void Integer stack pointer to skip forward or void to continue
62
-     *                  normal file processing.
63
-     */
64
-    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
65
-    {
66
-        if (isset($parameters[1]) === false) {
67
-            return;
68
-        }
53
+	/**
54
+	 * Process the parameters of a matched function.
55
+	 *
56
+	 * @param \PHP_CodeSniffer_File $phpcsFile    The file being scanned.
57
+	 * @param int                   $stackPtr     The position of the current token in the stack.
58
+	 * @param string                $functionName The token content (function name) which was matched.
59
+	 * @param array                 $parameters   Array with information about the parameters.
60
+	 *
61
+	 * @return int|void Integer stack pointer to skip forward or void to continue
62
+	 *                  normal file processing.
63
+	 */
64
+	public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
65
+	{
66
+		if (isset($parameters[1]) === false) {
67
+			return;
68
+		}
69 69
 
70
-        if ($parameters[1]['raw'] !== 'null') {
71
-            return;
72
-        }
70
+		if ($parameters[1]['raw'] !== 'null') {
71
+			return;
72
+		}
73 73
 
74
-        $phpcsFile->addError(
75
-            'Passing "null" as the $object to get_class() is not allowed since PHP 7.2.',
76
-            $parameters[1]['start'],
77
-            'Found'
78
-        );
79
-    }
74
+		$phpcsFile->addError(
75
+			'Passing "null" as the $object to get_class() is not allowed since PHP 7.2.',
76
+			$parameters[1]['start'],
77
+			'Found'
78
+		);
79
+	}
80 80
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      */
47 47
     protected function bowOutEarly()
48 48
     {
49
-        return ($this->supportsAbove('7.2') === false);
49
+        return ( $this->supportsAbove( '7.2' ) === false );
50 50
     }
51 51
 
52 52
 
@@ -61,19 +61,19 @@  discard block
 block discarded – undo
61 61
      * @return int|void Integer stack pointer to skip forward or void to continue
62 62
      *                  normal file processing.
63 63
      */
64
-    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
64
+    public function processParameters( File $phpcsFile, $stackPtr, $functionName, $parameters )
65 65
     {
66
-        if (isset($parameters[1]) === false) {
66
+        if ( isset( $parameters[ 1 ] ) === false ) {
67 67
             return;
68 68
         }
69 69
 
70
-        if ($parameters[1]['raw'] !== 'null') {
70
+        if ( $parameters[ 1 ][ 'raw' ] !== 'null' ) {
71 71
             return;
72 72
         }
73 73
 
74 74
         $phpcsFile->addError(
75 75
             'Passing "null" as the $object to get_class() is not allowed since PHP 7.2.',
76
-            $parameters[1]['start'],
76
+            $parameters[ 1 ][ 'start' ],
77 77
             'Found'
78 78
         );
79 79
     }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -26,8 +26,7 @@  discard block
 block discarded – undo
26 26
  * @package  PHPCompatibility
27 27
  * @author   Juliette Reinders Folmer <[email protected]>
28 28
  */
29
-class ForbiddenGetClassNullSniff extends AbstractFunctionCallParameterSniff
30
-{
29
+class ForbiddenGetClassNullSniff extends AbstractFunctionCallParameterSniff {
31 30
 
32 31
     /**
33 32
      * Functions to check for.
@@ -44,8 +43,7 @@  discard block
 block discarded – undo
44 43
      *
45 44
      * @return bool
46 45
      */
47
-    protected function bowOutEarly()
48
-    {
46
+    protected function bowOutEarly() {
49 47
         return ($this->supportsAbove('7.2') === false);
50 48
     }
51 49
 
@@ -61,8 +59,7 @@  discard block
 block discarded – undo
61 59
      * @return int|void Integer stack pointer to skip forward or void to continue
62 60
      *                  normal file processing.
63 61
      */
64
-    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
65
-    {
62
+    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters) {
66 63
         if (isset($parameters[1]) === false) {
67 64
             return;
68 65
         }
Please login to merge, or discard this patch.
PHPCompatibility/Sniffs/ParameterValues/RemovedPCREModifiersSniff.php 3 patches
Indentation   +181 added lines, -181 removed lines patch added patch discarded remove patch
@@ -32,188 +32,188 @@
 block discarded – undo
32 32
 class RemovedPCREModifiersSniff extends AbstractFunctionCallParameterSniff
33 33
 {
34 34
 
35
-    /**
36
-     * Functions to check for.
37
-     *
38
-     * @var array
39
-     */
40
-    protected $targetFunctions = array(
41
-        'preg_replace' => true,
42
-        'preg_filter'  => true,
43
-    );
44
-
45
-    /**
46
-     * Regex bracket delimiters.
47
-     *
48
-     * @var array
49
-     */
50
-    protected $doublesSeparators = array(
51
-        '{' => '}',
52
-        '[' => ']',
53
-        '(' => ')',
54
-        '<' => '>',
55
-    );
56
-
57
-
58
-    /**
59
-     * Process the parameters of a matched function.
60
-     *
61
-     * @param \PHP_CodeSniffer_File $phpcsFile    The file being scanned.
62
-     * @param int                   $stackPtr     The position of the current token in the stack.
63
-     * @param string                $functionName The token content (function name) which was matched.
64
-     * @param array                 $parameters   Array with information about the parameters.
65
-     *
66
-     * @return int|void Integer stack pointer to skip forward or void to continue
67
-     *                  normal file processing.
68
-     */
69
-    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
70
-    {
71
-        // Check the first parameter in the function call as that should contain the regex(es).
72
-        if (isset($parameters[1]) === false) {
73
-            return;
74
-        }
75
-
76
-        $tokens         = $phpcsFile->getTokens();
77
-        $functionNameLc = strtolower($functionName);
78
-        $firstParam     = $parameters[1];
79
-
80
-        // Differentiate between an array of patterns passed and a single pattern.
81
-        $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, $firstParam['start'], ($firstParam['end'] + 1), true);
82
-        if ($nextNonEmpty !== false && ($tokens[$nextNonEmpty]['code'] === \T_ARRAY || $tokens[$nextNonEmpty]['code'] === \T_OPEN_SHORT_ARRAY)) {
83
-            $arrayValues = $this->getFunctionCallParameters($phpcsFile, $nextNonEmpty);
84
-            if ($functionNameLc === 'preg_replace_callback_array') {
85
-                // For preg_replace_callback_array(), the patterns will be in the array keys.
86
-                foreach ($arrayValues as $value) {
87
-                    $hasKey = $phpcsFile->findNext(\T_DOUBLE_ARROW, $value['start'], ($value['end'] + 1));
88
-                    if ($hasKey === false) {
89
-                        continue;
90
-                    }
91
-
92
-                    $value['end'] = ($hasKey - 1);
93
-                    $value['raw'] = trim($phpcsFile->getTokensAsString($value['start'], ($hasKey - $value['start'])));
94
-                    $this->processRegexPattern($value, $phpcsFile, $value['end'], $functionName);
95
-                }
96
-
97
-            } else {
98
-                // Otherwise, the patterns will be in the array values.
99
-                foreach ($arrayValues as $value) {
100
-                    $hasKey = $phpcsFile->findNext(\T_DOUBLE_ARROW, $value['start'], ($value['end'] + 1));
101
-                    if ($hasKey !== false) {
102
-                        $value['start'] = ($hasKey + 1);
103
-                        $value['raw']   = trim($phpcsFile->getTokensAsString($value['start'], (($value['end'] + 1) - $value['start'])));
104
-                    }
105
-
106
-                    $this->processRegexPattern($value, $phpcsFile, $value['end'], $functionName);
107
-                }
108
-            }
109
-
110
-        } else {
111
-            $this->processRegexPattern($firstParam, $phpcsFile, $stackPtr, $functionName);
112
-        }
113
-    }
114
-
115
-
116
-    /**
117
-     * Do a version check to determine if this sniff needs to run at all.
118
-     *
119
-     * @return bool
120
-     */
121
-    protected function bowOutEarly()
122
-    {
123
-        return ($this->supportsAbove('5.5') === false);
124
-    }
125
-
126
-
127
-    /**
128
-     * Analyse a potential regex pattern for usage of the /e modifier.
129
-     *
130
-     * @param array                 $pattern      Array containing the start and end token
131
-     *                                            pointer of the potential regex pattern and
132
-     *                                            the raw string value of the pattern.
133
-     * @param \PHP_CodeSniffer_File $phpcsFile    The file being scanned.
134
-     * @param int                   $stackPtr     The position of the current token in the
135
-     *                                            stack passed in $tokens.
136
-     * @param string                $functionName The function which contained the pattern.
137
-     *
138
-     * @return void
139
-     */
140
-    protected function processRegexPattern($pattern, File $phpcsFile, $stackPtr, $functionName)
141
-    {
142
-        $tokens = $phpcsFile->getTokens();
143
-
144
-        /*
35
+	/**
36
+	 * Functions to check for.
37
+	 *
38
+	 * @var array
39
+	 */
40
+	protected $targetFunctions = array(
41
+		'preg_replace' => true,
42
+		'preg_filter'  => true,
43
+	);
44
+
45
+	/**
46
+	 * Regex bracket delimiters.
47
+	 *
48
+	 * @var array
49
+	 */
50
+	protected $doublesSeparators = array(
51
+		'{' => '}',
52
+		'[' => ']',
53
+		'(' => ')',
54
+		'<' => '>',
55
+	);
56
+
57
+
58
+	/**
59
+	 * Process the parameters of a matched function.
60
+	 *
61
+	 * @param \PHP_CodeSniffer_File $phpcsFile    The file being scanned.
62
+	 * @param int                   $stackPtr     The position of the current token in the stack.
63
+	 * @param string                $functionName The token content (function name) which was matched.
64
+	 * @param array                 $parameters   Array with information about the parameters.
65
+	 *
66
+	 * @return int|void Integer stack pointer to skip forward or void to continue
67
+	 *                  normal file processing.
68
+	 */
69
+	public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
70
+	{
71
+		// Check the first parameter in the function call as that should contain the regex(es).
72
+		if (isset($parameters[1]) === false) {
73
+			return;
74
+		}
75
+
76
+		$tokens         = $phpcsFile->getTokens();
77
+		$functionNameLc = strtolower($functionName);
78
+		$firstParam     = $parameters[1];
79
+
80
+		// Differentiate between an array of patterns passed and a single pattern.
81
+		$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, $firstParam['start'], ($firstParam['end'] + 1), true);
82
+		if ($nextNonEmpty !== false && ($tokens[$nextNonEmpty]['code'] === \T_ARRAY || $tokens[$nextNonEmpty]['code'] === \T_OPEN_SHORT_ARRAY)) {
83
+			$arrayValues = $this->getFunctionCallParameters($phpcsFile, $nextNonEmpty);
84
+			if ($functionNameLc === 'preg_replace_callback_array') {
85
+				// For preg_replace_callback_array(), the patterns will be in the array keys.
86
+				foreach ($arrayValues as $value) {
87
+					$hasKey = $phpcsFile->findNext(\T_DOUBLE_ARROW, $value['start'], ($value['end'] + 1));
88
+					if ($hasKey === false) {
89
+						continue;
90
+					}
91
+
92
+					$value['end'] = ($hasKey - 1);
93
+					$value['raw'] = trim($phpcsFile->getTokensAsString($value['start'], ($hasKey - $value['start'])));
94
+					$this->processRegexPattern($value, $phpcsFile, $value['end'], $functionName);
95
+				}
96
+
97
+			} else {
98
+				// Otherwise, the patterns will be in the array values.
99
+				foreach ($arrayValues as $value) {
100
+					$hasKey = $phpcsFile->findNext(\T_DOUBLE_ARROW, $value['start'], ($value['end'] + 1));
101
+					if ($hasKey !== false) {
102
+						$value['start'] = ($hasKey + 1);
103
+						$value['raw']   = trim($phpcsFile->getTokensAsString($value['start'], (($value['end'] + 1) - $value['start'])));
104
+					}
105
+
106
+					$this->processRegexPattern($value, $phpcsFile, $value['end'], $functionName);
107
+				}
108
+			}
109
+
110
+		} else {
111
+			$this->processRegexPattern($firstParam, $phpcsFile, $stackPtr, $functionName);
112
+		}
113
+	}
114
+
115
+
116
+	/**
117
+	 * Do a version check to determine if this sniff needs to run at all.
118
+	 *
119
+	 * @return bool
120
+	 */
121
+	protected function bowOutEarly()
122
+	{
123
+		return ($this->supportsAbove('5.5') === false);
124
+	}
125
+
126
+
127
+	/**
128
+	 * Analyse a potential regex pattern for usage of the /e modifier.
129
+	 *
130
+	 * @param array                 $pattern      Array containing the start and end token
131
+	 *                                            pointer of the potential regex pattern and
132
+	 *                                            the raw string value of the pattern.
133
+	 * @param \PHP_CodeSniffer_File $phpcsFile    The file being scanned.
134
+	 * @param int                   $stackPtr     The position of the current token in the
135
+	 *                                            stack passed in $tokens.
136
+	 * @param string                $functionName The function which contained the pattern.
137
+	 *
138
+	 * @return void
139
+	 */
140
+	protected function processRegexPattern($pattern, File $phpcsFile, $stackPtr, $functionName)
141
+	{
142
+		$tokens = $phpcsFile->getTokens();
143
+
144
+		/*
145 145
          * The pattern might be build up of a combination of strings, variables
146 146
          * and function calls. We are only concerned with the strings.
147 147
          */
148
-        $regex = '';
149
-        for ($i = $pattern['start']; $i <= $pattern['end']; $i++) {
150
-            if (isset(Tokens::$stringTokens[$tokens[$i]['code']]) === true) {
151
-                $content = $this->stripQuotes($tokens[$i]['content']);
152
-                if ($tokens[$i]['code'] === \T_DOUBLE_QUOTED_STRING) {
153
-                    $content = $this->stripVariables($content);
154
-                }
155
-
156
-                $regex .= trim($content);
157
-            }
158
-        }
159
-
160
-        // Deal with multi-line regexes which were broken up in several string tokens.
161
-        if ($tokens[$pattern['start']]['line'] !== $tokens[$pattern['end']]['line']) {
162
-            $regex = $this->stripQuotes($regex);
163
-        }
164
-
165
-        if ($regex === '') {
166
-            // No string token found in the first parameter, so skip it (e.g. if variable passed in).
167
-            return;
168
-        }
169
-
170
-        $regexFirstChar = substr($regex, 0, 1);
171
-
172
-        // Make sure that the character identified as the delimiter is valid.
173
-        // Otherwise, it is a false positive caused by the string concatenation.
174
-        if (preg_match('`[a-z0-9\\\\ ]`i', $regexFirstChar) === 1) {
175
-            return;
176
-        }
177
-
178
-        if (isset($this->doublesSeparators[$regexFirstChar])) {
179
-            $regexEndPos = strrpos($regex, $this->doublesSeparators[$regexFirstChar]);
180
-        } else {
181
-            $regexEndPos = strrpos($regex, $regexFirstChar);
182
-        }
183
-
184
-        if ($regexEndPos !== false) {
185
-            $modifiers = substr($regex, $regexEndPos + 1);
186
-            $this->examineModifiers($phpcsFile, $stackPtr, $functionName, $modifiers);
187
-        }
188
-    }
189
-
190
-
191
-    /**
192
-     * Examine the regex modifier string.
193
-     *
194
-     * @param \PHP_CodeSniffer_File $phpcsFile    The file being scanned.
195
-     * @param int                   $stackPtr     The position of the current token in the
196
-     *                                            stack passed in $tokens.
197
-     * @param string                $functionName The function which contained the pattern.
198
-     * @param string                $modifiers    The regex modifiers found.
199
-     *
200
-     * @return void
201
-     */
202
-    protected function examineModifiers(File $phpcsFile, $stackPtr, $functionName, $modifiers)
203
-    {
204
-        if (strpos($modifiers, 'e') !== false) {
205
-            $error     = '%s() - /e modifier is deprecated since PHP 5.5';
206
-            $isError   = false;
207
-            $errorCode = 'Deprecated';
208
-            $data      = array($functionName);
209
-
210
-            if ($this->supportsAbove('7.0')) {
211
-                $error    .= ' and removed since PHP 7.0';
212
-                $isError   = true;
213
-                $errorCode = 'Removed';
214
-            }
215
-
216
-            $this->addMessage($phpcsFile, $error, $stackPtr, $isError, $errorCode, $data);
217
-        }
218
-    }
148
+		$regex = '';
149
+		for ($i = $pattern['start']; $i <= $pattern['end']; $i++) {
150
+			if (isset(Tokens::$stringTokens[$tokens[$i]['code']]) === true) {
151
+				$content = $this->stripQuotes($tokens[$i]['content']);
152
+				if ($tokens[$i]['code'] === \T_DOUBLE_QUOTED_STRING) {
153
+					$content = $this->stripVariables($content);
154
+				}
155
+
156
+				$regex .= trim($content);
157
+			}
158
+		}
159
+
160
+		// Deal with multi-line regexes which were broken up in several string tokens.
161
+		if ($tokens[$pattern['start']]['line'] !== $tokens[$pattern['end']]['line']) {
162
+			$regex = $this->stripQuotes($regex);
163
+		}
164
+
165
+		if ($regex === '') {
166
+			// No string token found in the first parameter, so skip it (e.g. if variable passed in).
167
+			return;
168
+		}
169
+
170
+		$regexFirstChar = substr($regex, 0, 1);
171
+
172
+		// Make sure that the character identified as the delimiter is valid.
173
+		// Otherwise, it is a false positive caused by the string concatenation.
174
+		if (preg_match('`[a-z0-9\\\\ ]`i', $regexFirstChar) === 1) {
175
+			return;
176
+		}
177
+
178
+		if (isset($this->doublesSeparators[$regexFirstChar])) {
179
+			$regexEndPos = strrpos($regex, $this->doublesSeparators[$regexFirstChar]);
180
+		} else {
181
+			$regexEndPos = strrpos($regex, $regexFirstChar);
182
+		}
183
+
184
+		if ($regexEndPos !== false) {
185
+			$modifiers = substr($regex, $regexEndPos + 1);
186
+			$this->examineModifiers($phpcsFile, $stackPtr, $functionName, $modifiers);
187
+		}
188
+	}
189
+
190
+
191
+	/**
192
+	 * Examine the regex modifier string.
193
+	 *
194
+	 * @param \PHP_CodeSniffer_File $phpcsFile    The file being scanned.
195
+	 * @param int                   $stackPtr     The position of the current token in the
196
+	 *                                            stack passed in $tokens.
197
+	 * @param string                $functionName The function which contained the pattern.
198
+	 * @param string                $modifiers    The regex modifiers found.
199
+	 *
200
+	 * @return void
201
+	 */
202
+	protected function examineModifiers(File $phpcsFile, $stackPtr, $functionName, $modifiers)
203
+	{
204
+		if (strpos($modifiers, 'e') !== false) {
205
+			$error     = '%s() - /e modifier is deprecated since PHP 5.5';
206
+			$isError   = false;
207
+			$errorCode = 'Deprecated';
208
+			$data      = array($functionName);
209
+
210
+			if ($this->supportsAbove('7.0')) {
211
+				$error    .= ' and removed since PHP 7.0';
212
+				$isError   = true;
213
+				$errorCode = 'Removed';
214
+			}
215
+
216
+			$this->addMessage($phpcsFile, $error, $stackPtr, $isError, $errorCode, $data);
217
+		}
218
+	}
219 219
 }
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -66,49 +66,49 @@  discard block
 block discarded – undo
66 66
      * @return int|void Integer stack pointer to skip forward or void to continue
67 67
      *                  normal file processing.
68 68
      */
69
-    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
69
+    public function processParameters( File $phpcsFile, $stackPtr, $functionName, $parameters )
70 70
     {
71 71
         // Check the first parameter in the function call as that should contain the regex(es).
72
-        if (isset($parameters[1]) === false) {
72
+        if ( isset( $parameters[ 1 ] ) === false ) {
73 73
             return;
74 74
         }
75 75
 
76 76
         $tokens         = $phpcsFile->getTokens();
77
-        $functionNameLc = strtolower($functionName);
78
-        $firstParam     = $parameters[1];
77
+        $functionNameLc = strtolower( $functionName );
78
+        $firstParam     = $parameters[ 1 ];
79 79
 
80 80
         // Differentiate between an array of patterns passed and a single pattern.
81
-        $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, $firstParam['start'], ($firstParam['end'] + 1), true);
82
-        if ($nextNonEmpty !== false && ($tokens[$nextNonEmpty]['code'] === \T_ARRAY || $tokens[$nextNonEmpty]['code'] === \T_OPEN_SHORT_ARRAY)) {
83
-            $arrayValues = $this->getFunctionCallParameters($phpcsFile, $nextNonEmpty);
84
-            if ($functionNameLc === 'preg_replace_callback_array') {
81
+        $nextNonEmpty = $phpcsFile->findNext( Tokens::$emptyTokens, $firstParam[ 'start' ], ( $firstParam[ 'end' ] + 1 ), true );
82
+        if ( $nextNonEmpty !== false && ( $tokens[ $nextNonEmpty ][ 'code' ] === \T_ARRAY || $tokens[ $nextNonEmpty ][ 'code' ] === \T_OPEN_SHORT_ARRAY ) ) {
83
+            $arrayValues = $this->getFunctionCallParameters( $phpcsFile, $nextNonEmpty );
84
+            if ( $functionNameLc === 'preg_replace_callback_array' ) {
85 85
                 // For preg_replace_callback_array(), the patterns will be in the array keys.
86
-                foreach ($arrayValues as $value) {
87
-                    $hasKey = $phpcsFile->findNext(\T_DOUBLE_ARROW, $value['start'], ($value['end'] + 1));
88
-                    if ($hasKey === false) {
86
+                foreach ( $arrayValues as $value ) {
87
+                    $hasKey = $phpcsFile->findNext( \T_DOUBLE_ARROW, $value[ 'start' ], ( $value[ 'end' ] + 1 ) );
88
+                    if ( $hasKey === false ) {
89 89
                         continue;
90 90
                     }
91 91
 
92
-                    $value['end'] = ($hasKey - 1);
93
-                    $value['raw'] = trim($phpcsFile->getTokensAsString($value['start'], ($hasKey - $value['start'])));
94
-                    $this->processRegexPattern($value, $phpcsFile, $value['end'], $functionName);
92
+                    $value[ 'end' ] = ( $hasKey - 1 );
93
+                    $value[ 'raw' ] = trim( $phpcsFile->getTokensAsString( $value[ 'start' ], ( $hasKey - $value[ 'start' ] ) ) );
94
+                    $this->processRegexPattern( $value, $phpcsFile, $value[ 'end' ], $functionName );
95 95
                 }
96 96
 
97 97
             } else {
98 98
                 // Otherwise, the patterns will be in the array values.
99
-                foreach ($arrayValues as $value) {
100
-                    $hasKey = $phpcsFile->findNext(\T_DOUBLE_ARROW, $value['start'], ($value['end'] + 1));
101
-                    if ($hasKey !== false) {
102
-                        $value['start'] = ($hasKey + 1);
103
-                        $value['raw']   = trim($phpcsFile->getTokensAsString($value['start'], (($value['end'] + 1) - $value['start'])));
99
+                foreach ( $arrayValues as $value ) {
100
+                    $hasKey = $phpcsFile->findNext( \T_DOUBLE_ARROW, $value[ 'start' ], ( $value[ 'end' ] + 1 ) );
101
+                    if ( $hasKey !== false ) {
102
+                        $value[ 'start' ] = ( $hasKey + 1 );
103
+                        $value[ 'raw' ]   = trim( $phpcsFile->getTokensAsString( $value[ 'start' ], ( ( $value[ 'end' ] + 1 ) - $value[ 'start' ] ) ) );
104 104
                     }
105 105
 
106
-                    $this->processRegexPattern($value, $phpcsFile, $value['end'], $functionName);
106
+                    $this->processRegexPattern( $value, $phpcsFile, $value[ 'end' ], $functionName );
107 107
                 }
108 108
             }
109 109
 
110 110
         } else {
111
-            $this->processRegexPattern($firstParam, $phpcsFile, $stackPtr, $functionName);
111
+            $this->processRegexPattern( $firstParam, $phpcsFile, $stackPtr, $functionName );
112 112
         }
113 113
     }
114 114
 
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
      */
121 121
     protected function bowOutEarly()
122 122
     {
123
-        return ($this->supportsAbove('5.5') === false);
123
+        return ( $this->supportsAbove( '5.5' ) === false );
124 124
     }
125 125
 
126 126
 
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
      *
138 138
      * @return void
139 139
      */
140
-    protected function processRegexPattern($pattern, File $phpcsFile, $stackPtr, $functionName)
140
+    protected function processRegexPattern( $pattern, File $phpcsFile, $stackPtr, $functionName )
141 141
     {
142 142
         $tokens = $phpcsFile->getTokens();
143 143
 
@@ -146,44 +146,44 @@  discard block
 block discarded – undo
146 146
          * and function calls. We are only concerned with the strings.
147 147
          */
148 148
         $regex = '';
149
-        for ($i = $pattern['start']; $i <= $pattern['end']; $i++) {
150
-            if (isset(Tokens::$stringTokens[$tokens[$i]['code']]) === true) {
151
-                $content = $this->stripQuotes($tokens[$i]['content']);
152
-                if ($tokens[$i]['code'] === \T_DOUBLE_QUOTED_STRING) {
153
-                    $content = $this->stripVariables($content);
149
+        for ( $i = $pattern[ 'start' ]; $i <= $pattern[ 'end' ]; $i++ ) {
150
+            if ( isset( Tokens::$stringTokens[ $tokens[ $i ][ 'code' ] ] ) === true ) {
151
+                $content = $this->stripQuotes( $tokens[ $i ][ 'content' ] );
152
+                if ( $tokens[ $i ][ 'code' ] === \T_DOUBLE_QUOTED_STRING ) {
153
+                    $content = $this->stripVariables( $content );
154 154
                 }
155 155
 
156
-                $regex .= trim($content);
156
+                $regex .= trim( $content );
157 157
             }
158 158
         }
159 159
 
160 160
         // Deal with multi-line regexes which were broken up in several string tokens.
161
-        if ($tokens[$pattern['start']]['line'] !== $tokens[$pattern['end']]['line']) {
162
-            $regex = $this->stripQuotes($regex);
161
+        if ( $tokens[ $pattern[ 'start' ] ][ 'line' ] !== $tokens[ $pattern[ 'end' ] ][ 'line' ] ) {
162
+            $regex = $this->stripQuotes( $regex );
163 163
         }
164 164
 
165
-        if ($regex === '') {
165
+        if ( $regex === '' ) {
166 166
             // No string token found in the first parameter, so skip it (e.g. if variable passed in).
167 167
             return;
168 168
         }
169 169
 
170
-        $regexFirstChar = substr($regex, 0, 1);
170
+        $regexFirstChar = substr( $regex, 0, 1 );
171 171
 
172 172
         // Make sure that the character identified as the delimiter is valid.
173 173
         // Otherwise, it is a false positive caused by the string concatenation.
174
-        if (preg_match('`[a-z0-9\\\\ ]`i', $regexFirstChar) === 1) {
174
+        if ( preg_match( '`[a-z0-9\\\\ ]`i', $regexFirstChar ) === 1 ) {
175 175
             return;
176 176
         }
177 177
 
178
-        if (isset($this->doublesSeparators[$regexFirstChar])) {
179
-            $regexEndPos = strrpos($regex, $this->doublesSeparators[$regexFirstChar]);
178
+        if ( isset( $this->doublesSeparators[ $regexFirstChar ] ) ) {
179
+            $regexEndPos = strrpos( $regex, $this->doublesSeparators[ $regexFirstChar ] );
180 180
         } else {
181
-            $regexEndPos = strrpos($regex, $regexFirstChar);
181
+            $regexEndPos = strrpos( $regex, $regexFirstChar );
182 182
         }
183 183
 
184
-        if ($regexEndPos !== false) {
185
-            $modifiers = substr($regex, $regexEndPos + 1);
186
-            $this->examineModifiers($phpcsFile, $stackPtr, $functionName, $modifiers);
184
+        if ( $regexEndPos !== false ) {
185
+            $modifiers = substr( $regex, $regexEndPos + 1 );
186
+            $this->examineModifiers( $phpcsFile, $stackPtr, $functionName, $modifiers );
187 187
         }
188 188
     }
189 189
 
@@ -199,21 +199,21 @@  discard block
 block discarded – undo
199 199
      *
200 200
      * @return void
201 201
      */
202
-    protected function examineModifiers(File $phpcsFile, $stackPtr, $functionName, $modifiers)
202
+    protected function examineModifiers( File $phpcsFile, $stackPtr, $functionName, $modifiers )
203 203
     {
204
-        if (strpos($modifiers, 'e') !== false) {
204
+        if ( strpos( $modifiers, 'e' ) !== false ) {
205 205
             $error     = '%s() - /e modifier is deprecated since PHP 5.5';
206 206
             $isError   = false;
207 207
             $errorCode = 'Deprecated';
208
-            $data      = array($functionName);
208
+            $data      = array( $functionName );
209 209
 
210
-            if ($this->supportsAbove('7.0')) {
210
+            if ( $this->supportsAbove( '7.0' ) ) {
211 211
                 $error    .= ' and removed since PHP 7.0';
212 212
                 $isError   = true;
213 213
                 $errorCode = 'Removed';
214 214
             }
215 215
 
216
-            $this->addMessage($phpcsFile, $error, $stackPtr, $isError, $errorCode, $data);
216
+            $this->addMessage( $phpcsFile, $error, $stackPtr, $isError, $errorCode, $data );
217 217
         }
218 218
     }
219 219
 }
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -29,8 +29,7 @@  discard block
 block discarded – undo
29 29
  * @author    Wim Godden <[email protected]>
30 30
  * @copyright 2014 Cu.be Solutions bvba
31 31
  */
32
-class RemovedPCREModifiersSniff extends AbstractFunctionCallParameterSniff
33
-{
32
+class RemovedPCREModifiersSniff extends AbstractFunctionCallParameterSniff {
34 33
 
35 34
     /**
36 35
      * Functions to check for.
@@ -66,8 +65,7 @@  discard block
 block discarded – undo
66 65
      * @return int|void Integer stack pointer to skip forward or void to continue
67 66
      *                  normal file processing.
68 67
      */
69
-    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
70
-    {
68
+    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters) {
71 69
         // Check the first parameter in the function call as that should contain the regex(es).
72 70
         if (isset($parameters[1]) === false) {
73 71
             return;
@@ -118,8 +116,7 @@  discard block
 block discarded – undo
118 116
      *
119 117
      * @return bool
120 118
      */
121
-    protected function bowOutEarly()
122
-    {
119
+    protected function bowOutEarly() {
123 120
         return ($this->supportsAbove('5.5') === false);
124 121
     }
125 122
 
@@ -137,8 +134,7 @@  discard block
 block discarded – undo
137 134
      *
138 135
      * @return void
139 136
      */
140
-    protected function processRegexPattern($pattern, File $phpcsFile, $stackPtr, $functionName)
141
-    {
137
+    protected function processRegexPattern($pattern, File $phpcsFile, $stackPtr, $functionName) {
142 138
         $tokens = $phpcsFile->getTokens();
143 139
 
144 140
         /*
@@ -199,8 +195,7 @@  discard block
 block discarded – undo
199 195
      *
200 196
      * @return void
201 197
      */
202
-    protected function examineModifiers(File $phpcsFile, $stackPtr, $functionName, $modifiers)
203
-    {
198
+    protected function examineModifiers(File $phpcsFile, $stackPtr, $functionName, $modifiers) {
204 199
         if (strpos($modifiers, 'e') !== false) {
205 200
             $error     = '%s() - /e modifier is deprecated since PHP 5.5';
206 201
             $isError   = false;
Please login to merge, or discard this patch.
PHPCompatibility/Sniffs/ParameterValues/RemovedIconvEncodingSniff.php 3 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -32,49 +32,49 @@
 block discarded – undo
32 32
 class RemovedIconvEncodingSniff extends AbstractFunctionCallParameterSniff
33 33
 {
34 34
 
35
-    /**
36
-     * Functions to check for.
37
-     *
38
-     * @var array
39
-     */
40
-    protected $targetFunctions = array(
41
-        'iconv_set_encoding' => true,
42
-    );
35
+	/**
36
+	 * Functions to check for.
37
+	 *
38
+	 * @var array
39
+	 */
40
+	protected $targetFunctions = array(
41
+		'iconv_set_encoding' => true,
42
+	);
43 43
 
44 44
 
45
-    /**
46
-     * Do a version check to determine if this sniff needs to run at all.
47
-     *
48
-     * @return bool
49
-     */
50
-    protected function bowOutEarly()
51
-    {
52
-        return ($this->supportsAbove('5.6') === false);
53
-    }
45
+	/**
46
+	 * Do a version check to determine if this sniff needs to run at all.
47
+	 *
48
+	 * @return bool
49
+	 */
50
+	protected function bowOutEarly()
51
+	{
52
+		return ($this->supportsAbove('5.6') === false);
53
+	}
54 54
 
55 55
 
56
-    /**
57
-     * Process the parameters of a matched function.
58
-     *
59
-     * @param \PHP_CodeSniffer_File $phpcsFile    The file being scanned.
60
-     * @param int                   $stackPtr     The position of the current token in the stack.
61
-     * @param string                $functionName The token content (function name) which was matched.
62
-     * @param array                 $parameters   Array with information about the parameters.
63
-     *
64
-     * @return int|void Integer stack pointer to skip forward or void to continue
65
-     *                  normal file processing.
66
-     */
67
-    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
68
-    {
69
-        if (isset($parameters[1]) === false) {
70
-            return;
71
-        }
56
+	/**
57
+	 * Process the parameters of a matched function.
58
+	 *
59
+	 * @param \PHP_CodeSniffer_File $phpcsFile    The file being scanned.
60
+	 * @param int                   $stackPtr     The position of the current token in the stack.
61
+	 * @param string                $functionName The token content (function name) which was matched.
62
+	 * @param array                 $parameters   Array with information about the parameters.
63
+	 *
64
+	 * @return int|void Integer stack pointer to skip forward or void to continue
65
+	 *                  normal file processing.
66
+	 */
67
+	public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
68
+	{
69
+		if (isset($parameters[1]) === false) {
70
+			return;
71
+		}
72 72
 
73
-        $phpcsFile->addWarning(
74
-            'All previously accepted values for the $type parameter of iconv_set_encoding() have been deprecated since PHP 5.6. Found %s',
75
-            $parameters[1]['start'],
76
-            'DeprecatedValueFound',
77
-            $parameters[1]['raw']
78
-        );
79
-    }
73
+		$phpcsFile->addWarning(
74
+			'All previously accepted values for the $type parameter of iconv_set_encoding() have been deprecated since PHP 5.6. Found %s',
75
+			$parameters[1]['start'],
76
+			'DeprecatedValueFound',
77
+			$parameters[1]['raw']
78
+		);
79
+	}
80 80
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
      */
50 50
     protected function bowOutEarly()
51 51
     {
52
-        return ($this->supportsAbove('5.6') === false);
52
+        return ( $this->supportsAbove( '5.6' ) === false );
53 53
     }
54 54
 
55 55
 
@@ -64,17 +64,17 @@  discard block
 block discarded – undo
64 64
      * @return int|void Integer stack pointer to skip forward or void to continue
65 65
      *                  normal file processing.
66 66
      */
67
-    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
67
+    public function processParameters( File $phpcsFile, $stackPtr, $functionName, $parameters )
68 68
     {
69
-        if (isset($parameters[1]) === false) {
69
+        if ( isset( $parameters[ 1 ] ) === false ) {
70 70
             return;
71 71
         }
72 72
 
73 73
         $phpcsFile->addWarning(
74 74
             'All previously accepted values for the $type parameter of iconv_set_encoding() have been deprecated since PHP 5.6. Found %s',
75
-            $parameters[1]['start'],
75
+            $parameters[ 1 ][ 'start' ],
76 76
             'DeprecatedValueFound',
77
-            $parameters[1]['raw']
77
+            $parameters[ 1 ][ 'raw' ]
78 78
         );
79 79
     }
80 80
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -29,8 +29,7 @@  discard block
 block discarded – undo
29 29
  * @package  PHPCompatibility
30 30
  * @author   Juliette Reinders Folmer <[email protected]>
31 31
  */
32
-class RemovedIconvEncodingSniff extends AbstractFunctionCallParameterSniff
33
-{
32
+class RemovedIconvEncodingSniff extends AbstractFunctionCallParameterSniff {
34 33
 
35 34
     /**
36 35
      * Functions to check for.
@@ -47,8 +46,7 @@  discard block
 block discarded – undo
47 46
      *
48 47
      * @return bool
49 48
      */
50
-    protected function bowOutEarly()
51
-    {
49
+    protected function bowOutEarly() {
52 50
         return ($this->supportsAbove('5.6') === false);
53 51
     }
54 52
 
@@ -64,8 +62,7 @@  discard block
 block discarded – undo
64 62
      * @return int|void Integer stack pointer to skip forward or void to continue
65 63
      *                  normal file processing.
66 64
      */
67
-    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
68
-    {
65
+    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters) {
69 66
         if (isset($parameters[1]) === false) {
70 67
             return;
71 68
         }
Please login to merge, or discard this patch.
PHPCompatibility/Sniffs/ParameterValues/RemovedSetlocaleStringSniff.php 3 patches
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -31,69 +31,69 @@
 block discarded – undo
31 31
 class RemovedSetlocaleStringSniff extends AbstractFunctionCallParameterSniff
32 32
 {
33 33
 
34
-    /**
35
-     * Functions to check for.
36
-     *
37
-     * @var array
38
-     */
39
-    protected $targetFunctions = array(
40
-        'setlocale' => true,
41
-    );
34
+	/**
35
+	 * Functions to check for.
36
+	 *
37
+	 * @var array
38
+	 */
39
+	protected $targetFunctions = array(
40
+		'setlocale' => true,
41
+	);
42 42
 
43 43
 
44
-    /**
45
-     * Do a version check to determine if this sniff needs to run at all.
46
-     *
47
-     * @return bool
48
-     */
49
-    protected function bowOutEarly()
50
-    {
51
-        return ($this->supportsAbove('4.2') === false);
52
-    }
44
+	/**
45
+	 * Do a version check to determine if this sniff needs to run at all.
46
+	 *
47
+	 * @return bool
48
+	 */
49
+	protected function bowOutEarly()
50
+	{
51
+		return ($this->supportsAbove('4.2') === false);
52
+	}
53 53
 
54 54
 
55
-    /**
56
-     * Process the parameters of a matched function.
57
-     *
58
-     * @param \PHP_CodeSniffer_File $phpcsFile    The file being scanned.
59
-     * @param int                   $stackPtr     The position of the current token in the stack.
60
-     * @param string                $functionName The token content (function name) which was matched.
61
-     * @param array                 $parameters   Array with information about the parameters.
62
-     *
63
-     * @return int|void Integer stack pointer to skip forward or void to continue
64
-     *                  normal file processing.
65
-     */
66
-    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
67
-    {
68
-        if (isset($parameters[1]) === false) {
69
-            return;
70
-        }
55
+	/**
56
+	 * Process the parameters of a matched function.
57
+	 *
58
+	 * @param \PHP_CodeSniffer_File $phpcsFile    The file being scanned.
59
+	 * @param int                   $stackPtr     The position of the current token in the stack.
60
+	 * @param string                $functionName The token content (function name) which was matched.
61
+	 * @param array                 $parameters   Array with information about the parameters.
62
+	 *
63
+	 * @return int|void Integer stack pointer to skip forward or void to continue
64
+	 *                  normal file processing.
65
+	 */
66
+	public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
67
+	{
68
+		if (isset($parameters[1]) === false) {
69
+			return;
70
+		}
71 71
 
72
-        $tokens      = $phpcsFile->getTokens();
73
-        $targetParam = $parameters[1];
72
+		$tokens      = $phpcsFile->getTokens();
73
+		$targetParam = $parameters[1];
74 74
 
75
-        for ($i = $targetParam['start']; $i <= $targetParam['end']; $i++) {
76
-            if ($tokens[$i]['code'] !== \T_CONSTANT_ENCAPSED_STRING
77
-                && $tokens[$i]['code'] !== \T_DOUBLE_QUOTED_STRING
78
-            ) {
79
-                continue;
80
-            }
75
+		for ($i = $targetParam['start']; $i <= $targetParam['end']; $i++) {
76
+			if ($tokens[$i]['code'] !== \T_CONSTANT_ENCAPSED_STRING
77
+				&& $tokens[$i]['code'] !== \T_DOUBLE_QUOTED_STRING
78
+			) {
79
+				continue;
80
+			}
81 81
 
82
-            $message   = 'Passing the $category as a string to setlocale() has been deprecated since PHP 4.2';
83
-            $isError   = false;
84
-            $errorCode = 'Deprecated';
85
-            $data      = array($targetParam['raw']);
82
+			$message   = 'Passing the $category as a string to setlocale() has been deprecated since PHP 4.2';
83
+			$isError   = false;
84
+			$errorCode = 'Deprecated';
85
+			$data      = array($targetParam['raw']);
86 86
 
87
-            if ($this->supportsAbove('7.0') === true) {
88
-                $message  .= ' and is removed since PHP 7.0';
89
-                $isError   = true;
90
-                $errorCode = 'Removed';
91
-            }
87
+			if ($this->supportsAbove('7.0') === true) {
88
+				$message  .= ' and is removed since PHP 7.0';
89
+				$isError   = true;
90
+				$errorCode = 'Removed';
91
+			}
92 92
 
93
-            $message .= '; Pass one of the LC_* constants instead. Found: %s';
93
+			$message .= '; Pass one of the LC_* constants instead. Found: %s';
94 94
 
95
-            $this->addMessage($phpcsFile, $message, $i, $isError, $errorCode, $data);
96
-            break;
97
-        }
98
-    }
95
+			$this->addMessage($phpcsFile, $message, $i, $isError, $errorCode, $data);
96
+			break;
97
+		}
98
+	}
99 99
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      */
49 49
     protected function bowOutEarly()
50 50
     {
51
-        return ($this->supportsAbove('4.2') === false);
51
+        return ( $this->supportsAbove( '4.2' ) === false );
52 52
     }
53 53
 
54 54
 
@@ -63,18 +63,18 @@  discard block
 block discarded – undo
63 63
      * @return int|void Integer stack pointer to skip forward or void to continue
64 64
      *                  normal file processing.
65 65
      */
66
-    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
66
+    public function processParameters( File $phpcsFile, $stackPtr, $functionName, $parameters )
67 67
     {
68
-        if (isset($parameters[1]) === false) {
68
+        if ( isset( $parameters[ 1 ] ) === false ) {
69 69
             return;
70 70
         }
71 71
 
72 72
         $tokens      = $phpcsFile->getTokens();
73
-        $targetParam = $parameters[1];
73
+        $targetParam = $parameters[ 1 ];
74 74
 
75
-        for ($i = $targetParam['start']; $i <= $targetParam['end']; $i++) {
76
-            if ($tokens[$i]['code'] !== \T_CONSTANT_ENCAPSED_STRING
77
-                && $tokens[$i]['code'] !== \T_DOUBLE_QUOTED_STRING
75
+        for ( $i = $targetParam[ 'start' ]; $i <= $targetParam[ 'end' ]; $i++ ) {
76
+            if ( $tokens[ $i ][ 'code' ] !== \T_CONSTANT_ENCAPSED_STRING
77
+                && $tokens[ $i ][ 'code' ] !== \T_DOUBLE_QUOTED_STRING
78 78
             ) {
79 79
                 continue;
80 80
             }
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
             $message   = 'Passing the $category as a string to setlocale() has been deprecated since PHP 4.2';
83 83
             $isError   = false;
84 84
             $errorCode = 'Deprecated';
85
-            $data      = array($targetParam['raw']);
85
+            $data      = array( $targetParam[ 'raw' ] );
86 86
 
87
-            if ($this->supportsAbove('7.0') === true) {
87
+            if ( $this->supportsAbove( '7.0' ) === true ) {
88 88
                 $message  .= ' and is removed since PHP 7.0';
89 89
                 $isError   = true;
90 90
                 $errorCode = 'Removed';
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 
93 93
             $message .= '; Pass one of the LC_* constants instead. Found: %s';
94 94
 
95
-            $this->addMessage($phpcsFile, $message, $i, $isError, $errorCode, $data);
95
+            $this->addMessage( $phpcsFile, $message, $i, $isError, $errorCode, $data );
96 96
             break;
97 97
         }
98 98
     }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -28,8 +28,7 @@  discard block
 block discarded – undo
28 28
  * @package  PHPCompatibility
29 29
  * @author   Juliette Reinders Folmer <[email protected]>
30 30
  */
31
-class RemovedSetlocaleStringSniff extends AbstractFunctionCallParameterSniff
32
-{
31
+class RemovedSetlocaleStringSniff extends AbstractFunctionCallParameterSniff {
33 32
 
34 33
     /**
35 34
      * Functions to check for.
@@ -46,8 +45,7 @@  discard block
 block discarded – undo
46 45
      *
47 46
      * @return bool
48 47
      */
49
-    protected function bowOutEarly()
50
-    {
48
+    protected function bowOutEarly() {
51 49
         return ($this->supportsAbove('4.2') === false);
52 50
     }
53 51
 
@@ -63,8 +61,7 @@  discard block
 block discarded – undo
63 61
      * @return int|void Integer stack pointer to skip forward or void to continue
64 62
      *                  normal file processing.
65 63
      */
66
-    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
67
-    {
64
+    public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters) {
68 65
         if (isset($parameters[1]) === false) {
69 66
             return;
70 67
         }
Please login to merge, or discard this patch.