Completed
Pull Request — develop (#1492)
by Zack
17:43
created
Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php 3 patches
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -15,67 +15,67 @@
 block discarded – undo
15 15
 {
16 16
 
17 17
 
18
-    /**
19
-     * Returns the lines where errors should occur.
20
-     *
21
-     * The key of the array should represent the line number and the value
22
-     * should represent the number of errors that should occur on that line.
23
-     *
24
-     * @return array<int, int>
25
-     */
26
-    public function getErrorList()
27
-    {
28
-        return [
29
-            4   => 1,
30
-            13  => 1,
31
-            19  => 1,
32
-            24  => 1,
33
-            30  => 1,
34
-            40  => 1,
35
-            44  => 1,
36
-            50  => 1,
37
-            55  => 1,
38
-            67  => 1,
39
-            78  => 1,
40
-            85  => 1,
41
-            91  => 1,
42
-            98  => 1,
43
-            110 => 1,
44
-            115 => 1,
45
-            122 => 1,
46
-            128 => 1,
47
-            155 => 1,
48
-            158 => 1,
49
-            164 => 1,
50
-            168 => 1,
51
-            172 => 1,
52
-            176 => 1,
53
-            196 => 1,
54
-            201 => 1,
55
-            205 => 2,
56
-            210 => 2,
57
-            215 => 1,
58
-            220 => 1,
59
-            231 => 1,
60
-            236 => 1,
61
-        ];
18
+	/**
19
+	 * Returns the lines where errors should occur.
20
+	 *
21
+	 * The key of the array should represent the line number and the value
22
+	 * should represent the number of errors that should occur on that line.
23
+	 *
24
+	 * @return array<int, int>
25
+	 */
26
+	public function getErrorList()
27
+	{
28
+		return [
29
+			4   => 1,
30
+			13  => 1,
31
+			19  => 1,
32
+			24  => 1,
33
+			30  => 1,
34
+			40  => 1,
35
+			44  => 1,
36
+			50  => 1,
37
+			55  => 1,
38
+			67  => 1,
39
+			78  => 1,
40
+			85  => 1,
41
+			91  => 1,
42
+			98  => 1,
43
+			110 => 1,
44
+			115 => 1,
45
+			122 => 1,
46
+			128 => 1,
47
+			155 => 1,
48
+			158 => 1,
49
+			164 => 1,
50
+			168 => 1,
51
+			172 => 1,
52
+			176 => 1,
53
+			196 => 1,
54
+			201 => 1,
55
+			205 => 2,
56
+			210 => 2,
57
+			215 => 1,
58
+			220 => 1,
59
+			231 => 1,
60
+			236 => 1,
61
+		];
62 62
 
63
-    }//end getErrorList()
63
+	}//end getErrorList()
64 64
 
65 65
 
66
-    /**
67
-     * Returns the lines where warnings should occur.
68
-     *
69
-     * The key of the array should represent the line number and the value
70
-     * should represent the number of warnings that should occur on that line.
71
-     *
72
-     * @return array<int, int>
73
-     */
74
-    public function getWarningList()
75
-    {
76
-        return [];
66
+	/**
67
+	 * Returns the lines where warnings should occur.
68
+	 *
69
+	 * The key of the array should represent the line number and the value
70
+	 * should represent the number of warnings that should occur on that line.
71
+	 *
72
+	 * @return array<int, int>
73
+	 */
74
+	public function getWarningList()
75
+	{
76
+		return [];
77 77
 
78
-    }//end getWarningList()
78
+	}//end getWarningList()
79 79
 
80 80
 
81 81
 }//end class
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,8 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
13 13
 
14
-class OpeningFunctionBraceBsdAllmanUnitTest extends AbstractSniffUnitTest
15
-{
14
+class OpeningFunctionBraceBsdAllmanUnitTest extends AbstractSniffUnitTest {
16 15
 
17 16
 
18 17
     /**
@@ -23,8 +22,7 @@  discard block
 block discarded – undo
23 22
      *
24 23
      * @return array<int, int>
25 24
      */
26
-    public function getErrorList()
27
-    {
25
+    public function getErrorList() {
28 26
         return [
29 27
             4   => 1,
30 28
             13  => 1,
@@ -71,8 +69,7 @@  discard block
 block discarded – undo
71 69
      *
72 70
      * @return array<int, int>
73 71
      */
74
-    public function getWarningList()
75
-    {
72
+    public function getWarningList() {
76 73
         return [];
77 74
 
78 75
     }//end getWarningList()
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
      */
65 65
     public function getWarningList()
66 66
     {
67
-        return [];
67
+        return [ ];
68 68
 
69 69
     }//end getWarningList()
70 70
 
Please login to merge, or discard this patch.
Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php 3 patches
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -15,62 +15,62 @@
 block discarded – undo
15 15
 {
16 16
 
17 17
 
18
-    /**
19
-     * Returns the lines where errors should occur.
20
-     *
21
-     * The key of the array should represent the line number and the value
22
-     * should represent the number of errors that should occur on that line.
23
-     *
24
-     * @return array<int, int>
25
-     */
26
-    public function getErrorList()
27
-    {
28
-        return [
29
-            5   => 1,
30
-            6   => 1,
31
-            7   => 2,
32
-            8   => 1,
33
-            11  => 2,
34
-            12  => 2,
35
-            13  => 3,
36
-            42  => 3,
37
-            43  => 3,
38
-            45  => 1,
39
-            46  => 2,
40
-            79  => 1,
41
-            82  => 1,
42
-            93  => 1,
43
-            105 => 1,
44
-            107 => 1,
45
-            108 => 2,
46
-            114 => 1,
47
-            115 => 1,
48
-            119 => 1,
49
-            125 => 2,
50
-            130 => 2,
51
-            131 => 1,
52
-            132 => 2,
53
-            133 => 2,
54
-            134 => 1,
55
-            150 => 2,
56
-        ];
18
+	/**
19
+	 * Returns the lines where errors should occur.
20
+	 *
21
+	 * The key of the array should represent the line number and the value
22
+	 * should represent the number of errors that should occur on that line.
23
+	 *
24
+	 * @return array<int, int>
25
+	 */
26
+	public function getErrorList()
27
+	{
28
+		return [
29
+			5   => 1,
30
+			6   => 1,
31
+			7   => 2,
32
+			8   => 1,
33
+			11  => 2,
34
+			12  => 2,
35
+			13  => 3,
36
+			42  => 3,
37
+			43  => 3,
38
+			45  => 1,
39
+			46  => 2,
40
+			79  => 1,
41
+			82  => 1,
42
+			93  => 1,
43
+			105 => 1,
44
+			107 => 1,
45
+			108 => 2,
46
+			114 => 1,
47
+			115 => 1,
48
+			119 => 1,
49
+			125 => 2,
50
+			130 => 2,
51
+			131 => 1,
52
+			132 => 2,
53
+			133 => 2,
54
+			134 => 1,
55
+			150 => 2,
56
+		];
57 57
 
58
-    }//end getErrorList()
58
+	}//end getErrorList()
59 59
 
60 60
 
61
-    /**
62
-     * Returns the lines where warnings should occur.
63
-     *
64
-     * The key of the array should represent the line number and the value
65
-     * should represent the number of warnings that should occur on that line.
66
-     *
67
-     * @return array<int, int>
68
-     */
69
-    public function getWarningList()
70
-    {
71
-        return [];
61
+	/**
62
+	 * Returns the lines where warnings should occur.
63
+	 *
64
+	 * The key of the array should represent the line number and the value
65
+	 * should represent the number of warnings that should occur on that line.
66
+	 *
67
+	 * @return array<int, int>
68
+	 */
69
+	public function getWarningList()
70
+	{
71
+		return [];
72 72
 
73
-    }//end getWarningList()
73
+	}//end getWarningList()
74 74
 
75 75
 
76 76
 }//end class
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,8 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
13 13
 
14
-class FunctionCallArgumentSpacingUnitTest extends AbstractSniffUnitTest
15
-{
14
+class FunctionCallArgumentSpacingUnitTest extends AbstractSniffUnitTest {
16 15
 
17 16
 
18 17
     /**
@@ -23,8 +22,7 @@  discard block
 block discarded – undo
23 22
      *
24 23
      * @return array<int, int>
25 24
      */
26
-    public function getErrorList()
27
-    {
25
+    public function getErrorList() {
28 26
         return [
29 27
             5   => 1,
30 28
             6   => 1,
@@ -66,8 +64,7 @@  discard block
 block discarded – undo
66 64
      *
67 65
      * @return array<int, int>
68 66
      */
69
-    public function getWarningList()
70
-    {
67
+    public function getWarningList() {
71 68
         return [];
72 69
 
73 70
     }//end getWarningList()
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
      */
65 65
     public function getWarningList()
66 66
     {
67
-        return [];
67
+        return [ ];
68 68
 
69 69
     }//end getWarningList()
70 70
 
Please login to merge, or discard this patch.
Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.inc 4 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -13,13 +13,13 @@  discard block
 block discarded – undo
13 13
 $result = myFunction($arg1 , $arg2=array());
14 14
 
15 15
 $result = myFunction($arg1, 
16
-                     $arg2 = array(), 
17
-                     $arg3, 
18
-                     $arg4, 
19
-                     $arg5);
16
+					 $arg2 = array(), 
17
+					 $arg3, 
18
+					 $arg4, 
19
+					 $arg5);
20 20
 
21 21
 throw new Exception("This is some massive string for a message", 
22
-                         $cause);
22
+						 $cause);
23 23
 
24 24
 // Function definitions are ignored
25 25
 function myFunction($arg1,$arg2)
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
 make_foo($string /*the string*/, /*test*/ true);
48 48
 
49 49
 class MyClass {
50
-    function myFunction() {
51
-        blah($foo, "{{$config['host']}}", "{$config}", "hi there{}{}{{{}{}{}}");
52
-    }
50
+	function myFunction() {
51
+		blah($foo, "{{$config['host']}}", "{$config}", "hi there{}{}{{{}{}{}}");
52
+	}
53 53
 }
54 54
 
55 55
 // Function definition, not function call, so should be ignored
@@ -58,12 +58,12 @@  discard block
 block discarded – undo
58 58
 }
59 59
 
60 60
 return array_udiff(
61
-    $foo,
62
-    $bar,
63
-    function($a, $b) {
64
-        $foo='bar';
65
-        return $foo;
66
-    }
61
+	$foo,
62
+	$bar,
63
+	function($a, $b) {
64
+		$foo='bar';
65
+		return $foo;
66
+	}
67 67
 );
68 68
 
69 69
 var_dump(<<<FOO
@@ -88,18 +88,18 @@  discard block
 block discarded – undo
88 88
 if (in_array($arg1, array('foo','bar'))) {}
89 89
 
90 90
 $b = foo(
91
-    "1", // this is a comment
92
-    "2",  // this is a comment
93
-    "3",// this is a comment
94
-    "4"
91
+	"1", // this is a comment
92
+	"2",  // this is a comment
93
+	"3",// this is a comment
94
+	"4"
95 95
 );
96 96
 
97 97
 var_dump(
98
-    <<<TEXT
98
+	<<<TEXT
99 99
 foo
100 100
 TEXT
101
-    ,
102
-    'bar'
101
+	,
102
+	'bar'
103 103
 );
104 104
 
105 105
 unset($foo,$bar);
@@ -109,38 +109,38 @@  discard block
 block discarded – undo
109 109
 
110 110
 class Test
111 111
 {
112
-    public static function baz($foo, $bar)
113
-    {
114
-        $a = new self($foo,$bar);
115
-        $b = new static($foo,$bar);
116
-    }
112
+	public static function baz($foo, $bar)
113
+	{
114
+		$a = new self($foo,$bar);
115
+		$b = new static($foo,$bar);
116
+	}
117 117
 }
118 118
 
119 119
 $obj->{$var}($foo,$bar);
120 120
 
121 121
 (function ($a, $b) {
122
-    return function ($c, $d) use ($a, $b) {
123
-        echo $a, $b, $c, $d;
124
-    };
122
+	return function ($c, $d) use ($a, $b) {
123
+		echo $a, $b, $c, $d;
124
+	};
125 125
 })('a','b')('c','d');
126 126
 
127 127
 my_function_call(
128
-    'a'
129
-    /* Comment */
130
-    ,'b'
131
-    , 'c' // Comment.
132
-    ,'d'
133
-    ,'e' // phpcs:ignore Standard.Category.Sniff -- for reasons.
134
-    , 'f'
128
+	'a'
129
+	/* Comment */
130
+	,'b'
131
+	, 'c' // Comment.
132
+	,'d'
133
+	,'e' // phpcs:ignore Standard.Category.Sniff -- for reasons.
134
+	, 'f'
135 135
 );
136 136
 
137 137
 $foobar = php73_function_call_trailing_comma(
138
-    $foo,
139
-    $bar,
138
+	$foo,
139
+	$bar,
140 140
 );
141 141
 
142 142
 $foobar = functionCallAnonClassParam(
143
-    new class() {
143
+	new class() {
144 144
 		public $foo=1;
145 145
 		public function methodName($param='foo',$paramTwo='bar') {
146 146
 			$bar=false;
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -1,72 +1,72 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 $result = myFunction();
4
-$result = myFunction($arg1, $arg2);
5
-$result = myFunction($arg1,$arg2);
6
-$result = myFunction($arg1 , $arg2);
7
-$result = myFunction($arg1 ,  $arg2);
8
-$result = myFunction($arg1, $arg2, $arg3,$arg4, $arg5);
9
-$result = myFunction($arg1, $arg2, $arg3, $arg4, $arg5);
10
-$result = myFunction($arg1, $arg2 = array());
11
-$result = myFunction($arg1 , $arg2 =array());
12
-$result = myFunction($arg1 , $arg2= array());
13
-$result = myFunction($arg1 , $arg2=array());
14
-
15
-$result = myFunction($arg1, 
4
+$result = myFunction( $arg1, $arg2 );
5
+$result = myFunction( $arg1, $arg2 );
6
+$result = myFunction( $arg1, $arg2 );
7
+$result = myFunction( $arg1, $arg2 );
8
+$result = myFunction( $arg1, $arg2, $arg3, $arg4, $arg5 );
9
+$result = myFunction( $arg1, $arg2, $arg3, $arg4, $arg5 );
10
+$result = myFunction( $arg1, $arg2 = array() );
11
+$result = myFunction( $arg1, $arg2 = array() );
12
+$result = myFunction( $arg1, $arg2 = array() );
13
+$result = myFunction( $arg1, $arg2 = array() );
14
+
15
+$result = myFunction( $arg1, 
16 16
                      $arg2 = array(), 
17 17
                      $arg3, 
18 18
                      $arg4, 
19
-                     $arg5);
19
+                     $arg5 );
20 20
 
21
-throw new Exception("This is some massive string for a message", 
22
-                         $cause);
21
+throw new Exception( "This is some massive string for a message", 
22
+                         $cause );
23 23
 
24 24
 // Function definitions are ignored
25
-function myFunction($arg1,$arg2)
25
+function myFunction( $arg1, $arg2 )
26 26
 {
27 27
 }
28 28
 
29
-function myFunction    ($arg1,$arg2)
29
+function myFunction( $arg1, $arg2 )
30 30
 {
31 31
 }
32 32
 
33
-function myFunction($arg1=1,$arg2=2)
33
+function myFunction( $arg1 = 1, $arg2 = 2 )
34 34
 {
35 35
 }
36 36
 
37 37
 
38
-function myFunction($arg1 = 1,$arg2 = 2)
38
+function myFunction( $arg1 = 1, $arg2 = 2 )
39 39
 {
40 40
 }
41 41
 
42
-$key = array_search($this->getArray($one,  $two,$three),$this->arrayMap);
43
-$this->error($obj->getCode(),$obj->getMessage(),$obj->getFile(),$obj->getLine());
42
+$key = array_search( $this->getArray( $one, $two, $three ), $this->arrayMap );
43
+$this->error( $obj->getCode(), $obj->getMessage(), $obj->getFile(), $obj->getLine() );
44 44
 
45
-make_foo($string /*the string*/ , true /*test*/);
46
-make_foo($string/*the string*/ ,   /*test*/ true);
47
-make_foo($string /*the string*/, /*test*/ true);
45
+make_foo( $string /*the string*/, true /*test*/ );
46
+make_foo( $string/*the string*/, /*test*/ true );
47
+make_foo( $string /*the string*/, /*test*/ true );
48 48
 
49 49
 class MyClass {
50 50
     function myFunction() {
51
-        blah($foo, "{{$config['host']}}", "{$config}", "hi there{}{}{{{}{}{}}");
51
+        blah( $foo, "{{$config[ 'host' ]}}", "{$config}", "hi there{}{}{{{}{}{}}" );
52 52
     }
53 53
 }
54 54
 
55 55
 // Function definition, not function call, so should be ignored
56
-function &myFunction($arg1=1,$arg2=2)
56
+function &myFunction( $arg1 = 1, $arg2 = 2 )
57 57
 {
58 58
 }
59 59
 
60 60
 return array_udiff(
61 61
     $foo,
62 62
     $bar,
63
-    function($a, $b) {
64
-        $foo='bar';
63
+    function( $a, $b ) {
64
+        $foo = 'bar';
65 65
         return $foo;
66 66
     }
67 67
 );
68 68
 
69
-var_dump(<<<FOO
69
+var_dump( <<<FOO
70 70
 foo
71 71
 FOO
72 72
 ,
@@ -84,13 +84,13 @@  discard block
 block discarded – undo
84 84
 THEN
85 85
 );
86 86
 
87
-if (in_array($arg1, ['foo','bar'])) {}
88
-if (in_array($arg1, array('foo','bar'))) {}
87
+if ( in_array( $arg1, [ 'foo', 'bar' ] ) ) {}
88
+if ( in_array( $arg1, array( 'foo', 'bar' ) ) ) {}
89 89
 
90 90
 $b = foo(
91 91
     "1", // this is a comment
92
-    "2",  // this is a comment
93
-    "3",// this is a comment
92
+    "2", // this is a comment
93
+    "3", // this is a comment
94 94
     "4"
95 95
 );
96 96
 
@@ -102,27 +102,27 @@  discard block
 block discarded – undo
102 102
     'bar'
103 103
 );
104 104
 
105
-unset($foo,$bar);
105
+unset( $foo, $bar );
106 106
 
107
-$closure($foo,$bar);
108
-$var = $closure() + $closure($foo,$bar) + self::$closure($foo,$bar);
107
+$closure( $foo, $bar );
108
+$var = $closure() + $closure( $foo, $bar ) + self::$closure( $foo, $bar );
109 109
 
110 110
 class Test
111 111
 {
112
-    public static function baz($foo, $bar)
112
+    public static function baz( $foo, $bar )
113 113
     {
114
-        $a = new self($foo,$bar);
115
-        $b = new static($foo,$bar);
114
+        $a = new self( $foo, $bar );
115
+        $b = new static( $foo, $bar );
116 116
     }
117 117
 }
118 118
 
119
-$obj->{$var}($foo,$bar);
119
+$obj->{$var}( $foo, $bar );
120 120
 
121
-(function ($a, $b) {
122
-    return function ($c, $d) use ($a, $b) {
121
+( function( $a, $b ) {
122
+    return function( $c, $d ) use ( $a, $b ) {
123 123
         echo $a, $b, $c, $d;
124 124
     };
125
-})('a','b')('c','d');
125
+})( 'a', 'b' )( 'c', 'd' );
126 126
 
127 127
 my_function_call(
128 128
     'a'
@@ -141,11 +141,11 @@  discard block
 block discarded – undo
141 141
 
142 142
 $foobar = functionCallAnonClassParam(
143 143
     new class() {
144
-		public $foo=1;
145
-		public function methodName($param='foo',$paramTwo='bar') {
146
-			$bar=false;
147
-			$foo = array(1,2,3);
144
+		public $foo = 1;
145
+		public function methodName( $param = 'foo', $paramTwo = 'bar' ) {
146
+			$bar = false;
147
+			$foo = array( 1, 2, 3 );
148 148
 		}
149 149
 	},
150
-	$args=array(),
150
+	$args = array(),
151 151
 );
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -22,21 +22,17 @@  discard block
 block discarded – undo
22 22
                          $cause);
23 23
 
24 24
 // Function definitions are ignored
25
-function myFunction($arg1,$arg2)
26
-{
25
+function myFunction($arg1,$arg2) {
27 26
 }
28 27
 
29
-function myFunction    ($arg1,$arg2)
30
-{
28
+function myFunction    ($arg1,$arg2) {
31 29
 }
32 30
 
33
-function myFunction($arg1=1,$arg2=2)
34
-{
31
+function myFunction($arg1=1,$arg2=2) {
35 32
 }
36 33
 
37 34
 
38
-function myFunction($arg1 = 1,$arg2 = 2)
39
-{
35
+function myFunction($arg1 = 1,$arg2 = 2) {
40 36
 }
41 37
 
42 38
 $key = array_search($this->getArray($one,  $two,$three),$this->arrayMap);
@@ -107,10 +103,8 @@  discard block
 block discarded – undo
107 103
 $closure($foo,$bar);
108 104
 $var = $closure() + $closure($foo,$bar) + self::$closure($foo,$bar);
109 105
 
110
-class Test
111
-{
112
-    public static function baz($foo, $bar)
113
-    {
106
+class Test {
107
+    public static function baz($foo, $bar) {
114 108
         $a = new self($foo,$bar);
115 109
         $b = new static($foo,$bar);
116 110
     }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -68,20 +68,20 @@  discard block
 block discarded – undo
68 68
 
69 69
 var_dump(<<<FOO
70 70
 foo
71
-FOO
71
+foo
72 72
 ,
73 73
 <<<BAR
74 74
 bar
75
-BAR
75
+bar
76 76
 , <<<BAZ
77 77
 baz
78
-BAZ
78
+baz
79 79
 ,<<<'NOW'
80 80
 now
81
-NOW
81
+now
82 82
 ,  <<<'THEN'
83 83
 then
84
-THEN
84
+then
85 85
 );
86 86
 
87 87
 if (in_array($arg1, ['foo','bar'])) {}
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 var_dump(
98 98
     <<<TEXT
99 99
 foo
100
-TEXT
100
+text
101 101
     ,
102 102
     'bar'
103 103
 );
Please login to merge, or discard this patch.
src/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.inc 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 class myclass extends yourclass implements someint {
3
-    function myfunc($var) {
4
-        echo $var;
5
-    }
3
+	function myfunc($var) {
4
+		echo $var;
5
+	}
6 6
 }
7 7
 
8 8
 $myvar = true;
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,39 +1,39 @@
 block discarded – undo
1 1
 <?php
2 2
 class myclass extends yourclass implements someint {
3
-    function myfunc($var) {
3
+    function myfunc( $var ) {
4 4
         echo $var;
5 5
     }
6 6
 }
7 7
 
8 8
 $myvar = true;
9
-myfunc(&$myvar);
10
-myfunc($myvar);
9
+myfunc( &$myvar );
10
+myfunc( $myvar );
11 11
 
12
-$this->myfunc(&$myvar);
13
-$this->myfunc($myvar);
12
+$this->myfunc( &$myvar );
13
+$this->myfunc( $myvar );
14 14
 
15
-myclass::myfunc(&$myvar);
16
-myclass::myfunc($myvar);
15
+myclass::myfunc( &$myvar );
16
+myclass::myfunc( $myvar );
17 17
 
18
-while(testfunc($var1, &$var2, $var3, &$var4) === false) {
18
+while ( testfunc( $var1, &$var2, $var3, &$var4 ) === false ) {
19 19
 }
20 20
 
21
-sprintf("0%o", 0777 & $p);
21
+sprintf( "0%o", 0777 & $p );
22 22
 
23
-$foo(&$myvar);
23
+$foo( &$myvar );
24 24
 
25
-if (is_array($foo = &$this->bar())) {
25
+if ( is_array( $foo = &$this->bar() ) ) {
26 26
 }
27 27
 
28 28
 Hooks::run( 'SecondaryDataUpdates', [ $title, $old, $recursive, $parserOutput, &$updates ] );
29 29
 
30
-$foo = Bar(&$fooBar);
30
+$foo = Bar( &$fooBar );
31 31
 
32
-myfunc($myvar&$myvar);
33
-myfunc($myvar[0]&$myvar);
32
+myfunc( $myvar & $myvar );
33
+myfunc( $myvar[ 0 ] & $myvar );
34 34
 
35
-myfunc(myclass::MY_CONST&$myvar);
36
-myfunc(MY_CONST&$myvar);
35
+myfunc( myclass::MY_CONST&$myvar );
36
+myfunc( MY_CONST&$myvar );
37 37
 
38 38
 efg( true == &$b );
39 39
 efg( true === &$b );
Please login to merge, or discard this patch.
Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.inc 3 patches
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -26,34 +26,34 @@  discard block
 block discarded – undo
26 26
 
27 27
 class myClass
28 28
 {
29
-    // Brace should be on new line.
30
-    function myFunction() {
31
-    }
29
+	// Brace should be on new line.
30
+	function myFunction() {
31
+	}
32 32
     
33
-    // Good.
34
-    function myFunction()
35
-    {
36
-    }
33
+	// Good.
34
+	function myFunction()
35
+	{
36
+	}
37 37
 
38
-    // No aligned correctly.
39
-    function myFunction()
38
+	// No aligned correctly.
39
+	function myFunction()
40 40
 {
41 41
 }
42 42
     
43
-    // Too many spaces.
44
-    function myFunction()   {
45
-    }
43
+	// Too many spaces.
44
+	function myFunction()   {
45
+	}
46 46
     
47
-    // Too many newlines.
48
-    function myFunction()
47
+	// Too many newlines.
48
+	function myFunction()
49 49
 
50
-    {
51
-    }
50
+	{
51
+	}
52 52
     
53
-    // Space before brace.
54
-    function myFunction()
55
-     {
56
-    }
53
+	// Space before brace.
54
+	function myFunction()
55
+	 {
56
+	}
57 57
 }
58 58
 
59 59
 
@@ -64,95 +64,95 @@  discard block
 block discarded – undo
64 64
 
65 65
 // Brace should be on new line.
66 66
 function myFunction($variable1, $variable2,
67
-    $variable3, $variable4) {
67
+	$variable3, $variable4) {
68 68
 }
69 69
 
70 70
 // Good.
71 71
 function myFunction($variable1, $variable2,
72
-    $variable3, $variable4)
72
+	$variable3, $variable4)
73 73
 {
74 74
 }
75 75
 
76 76
 // Too many spaces.
77 77
 function myFunction($variable1, $variable2,
78
-    $variable3, $variable4)   {
78
+	$variable3, $variable4)   {
79 79
 }
80 80
 
81 81
 // Too many newlines.
82 82
 function myFunction($variable1, $variable2,
83
-    $variable3, $variable4)
83
+	$variable3, $variable4)
84 84
 
85 85
 {
86 86
 }
87 87
 
88 88
 // Space before brace.
89 89
 function myFunction($variable1, $variable2,
90
-    $variable3, $variable4)
90
+	$variable3, $variable4)
91 91
  {
92 92
 }
93 93
 
94 94
 class myClass
95 95
 {
96
-    // Brace should be on new line.
97
-    function myFunction($variable1, $variable2,
98
-    $variable3, $variable4) {
99
-    }
96
+	// Brace should be on new line.
97
+	function myFunction($variable1, $variable2,
98
+	$variable3, $variable4) {
99
+	}
100 100
     
101
-    // Good.
102
-    function myFunction($variable1, $variable2,
103
-    $variable3, $variable4)
104
-    {
105
-    }
106
-
107
-    // No aligned correctly.
108
-    function myFunction($variable1, $variable2,
109
-    $variable3, $variable4)
101
+	// Good.
102
+	function myFunction($variable1, $variable2,
103
+	$variable3, $variable4)
104
+	{
105
+	}
106
+
107
+	// No aligned correctly.
108
+	function myFunction($variable1, $variable2,
109
+	$variable3, $variable4)
110 110
 {
111 111
 }
112 112
     
113
-    // Too many spaces.
114
-    function myFunction($variable1, $variable2,
115
-    $variable3, $variable4)   {
116
-    }
113
+	// Too many spaces.
114
+	function myFunction($variable1, $variable2,
115
+	$variable3, $variable4)   {
116
+	}
117 117
     
118
-    // Too many newlines.
119
-    function myFunction($variable1, $variable2,
120
-    $variable3, $variable4)
118
+	// Too many newlines.
119
+	function myFunction($variable1, $variable2,
120
+	$variable3, $variable4)
121 121
 
122
-    {
123
-    }
122
+	{
123
+	}
124 124
     
125
-    // Space before brace.
126
-    function myFunction($variable1, $variable2,
127
-    $variable3, $variable4)
128
-     {
129
-    }
125
+	// Space before brace.
126
+	function myFunction($variable1, $variable2,
127
+	$variable3, $variable4)
128
+	 {
129
+	}
130 130
 }
131 131
 
132 132
 interface MyInterface
133 133
 {
134
-    function myFunction();
134
+	function myFunction();
135 135
 }
136 136
 
137 137
 function myFunction(
138
-                    $arg1,
139
-                    $arg2,
140
-                    $arg3,
141
-                    $arg4,
142
-                    $arg5,
143
-                    $arg6
144
-                    )
138
+					$arg1,
139
+					$arg2,
140
+					$arg3,
141
+					$arg4,
142
+					$arg5,
143
+					$arg6
144
+					)
145 145
 {
146 146
 }
147 147
 
148 148
 function myFunction(
149
-                    $arg1,
150
-                    $arg2,
151
-                    $arg3,
152
-                    $arg4,
153
-                    $arg5,
154
-                    $arg6
155
-                    ) {
149
+					$arg1,
150
+					$arg2,
151
+					$arg3,
152
+					$arg4,
153
+					$arg5,
154
+					$arg6
155
+					) {
156 156
 }
157 157
 
158 158
 function myFunction() {}
@@ -162,77 +162,77 @@  discard block
 block discarded – undo
162 162
 // phpcs:set Generic.Functions.OpeningFunctionBraceBsdAllman checkClosures 1
163 163
 
164 164
 $closureWithArgs = function ($arg1, $arg2) {
165
-    // body
165
+	// body
166 166
 };
167 167
 
168 168
 $closureWithArgsAndVars = function ($arg1, $arg2) use ($var1, $var2) {
169
-    // body
169
+	// body
170 170
 };
171 171
 
172 172
 $test = function ($param) use ($result) {
173
-    return null;
173
+	return null;
174 174
 };
175 175
 
176 176
 $test = function ($param) use ($result) : Something {
177
-    return null;
177
+	return null;
178 178
 };
179 179
 
180 180
 // phpcs:set Generic.Functions.OpeningFunctionBraceBsdAllman checkClosures 0
181 181
 
182 182
 $closureWithArgs = function ($arg1, $arg2) {
183
-    // body
183
+	// body
184 184
 };
185 185
 
186 186
 class Foo
187 187
 {
188 188
 //Comments should not affect code
189
-    public function bar()
190
-    {
189
+	public function bar()
190
+	{
191 191
 
192
-    }
192
+	}
193 193
 //Comments should not affect code
194 194
 }
195 195
 
196 196
 function myFunction() : Something {
197
-    return null;
197
+	return null;
198 198
 }
199 199
 
200 200
 function myFunction($a, $lot, $of, $params)
201
-    : array {
202
-    return null;
201
+	: array {
202
+	return null;
203 203
 }
204 204
 
205 205
 function myFunction($a, $lot, $of, $params) { // comment
206
-    return null;
206
+	return null;
207 207
 }
208 208
 
209 209
 function myFunction($a, $lot, $of, $params)
210
-    : array { // comment
211
-    return null;
210
+	: array { // comment
211
+	return null;
212 212
 }
213 213
 
214 214
 function myFunction($a, $lot, $of, $params)
215
-    : array { // phpcs:ignore Standard.Category.Sniff -- for reasons.
216
-    return null;
215
+	: array { // phpcs:ignore Standard.Category.Sniff -- for reasons.
216
+	return null;
217 217
 }
218 218
 
219 219
 function myFunction($a, $lot, $of, $params)
220
-    : array {// phpcs:ignore Standard.Category.Sniff -- for reasons.
221
-    return null;
220
+	: array {// phpcs:ignore Standard.Category.Sniff -- for reasons.
221
+	return null;
222 222
 }
223 223
 
224 224
 function myFunction($a, $lot, $of, $params)
225
-    : array
225
+	: array
226 226
 { // phpcs:ignore Standard.Category.Sniff -- for reasons.
227
-    return null;
227
+	return null;
228 228
 }
229 229
 
230 230
 function myFunction($a, $lot, $of, $params)
231
-    : array /* phpcs:ignore Standard.Category.Sniff -- for reasons */ {
232
-    return null;
231
+	: array /* phpcs:ignore Standard.Category.Sniff -- for reasons */ {
232
+	return null;
233 233
 }
234 234
 
235 235
 function myFunction($a, $lot, $of, $params)
236
-    : array /* comment */ {
237
-    return null;
236
+	: array /* comment */ {
237
+	return null;
238 238
 }
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 }
11 11
 
12 12
 // Too many spaces.
13
-function myFunction()   {
13
+function myFunction() {
14 14
 }
15 15
 
16 16
 // Too many newlines.
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 }
42 42
     
43 43
     // Too many spaces.
44
-    function myFunction()   {
44
+    function myFunction() {
45 45
     }
46 46
     
47 47
     // Too many newlines.
@@ -63,68 +63,68 @@  discard block
 block discarded – undo
63 63
 
64 64
 
65 65
 // Brace should be on new line.
66
-function myFunction($variable1, $variable2,
67
-    $variable3, $variable4) {
66
+function myFunction( $variable1, $variable2,
67
+    $variable3, $variable4 ) {
68 68
 }
69 69
 
70 70
 // Good.
71
-function myFunction($variable1, $variable2,
72
-    $variable3, $variable4)
71
+function myFunction( $variable1, $variable2,
72
+    $variable3, $variable4 )
73 73
 {
74 74
 }
75 75
 
76 76
 // Too many spaces.
77
-function myFunction($variable1, $variable2,
78
-    $variable3, $variable4)   {
77
+function myFunction( $variable1, $variable2,
78
+    $variable3, $variable4 ) {
79 79
 }
80 80
 
81 81
 // Too many newlines.
82
-function myFunction($variable1, $variable2,
83
-    $variable3, $variable4)
82
+function myFunction( $variable1, $variable2,
83
+    $variable3, $variable4 )
84 84
 
85 85
 {
86 86
 }
87 87
 
88 88
 // Space before brace.
89
-function myFunction($variable1, $variable2,
90
-    $variable3, $variable4)
89
+function myFunction( $variable1, $variable2,
90
+    $variable3, $variable4 )
91 91
  {
92 92
 }
93 93
 
94 94
 class myClass
95 95
 {
96 96
     // Brace should be on new line.
97
-    function myFunction($variable1, $variable2,
98
-    $variable3, $variable4) {
97
+    function myFunction( $variable1, $variable2,
98
+    $variable3, $variable4 ) {
99 99
     }
100 100
     
101 101
     // Good.
102
-    function myFunction($variable1, $variable2,
103
-    $variable3, $variable4)
102
+    function myFunction( $variable1, $variable2,
103
+    $variable3, $variable4 )
104 104
     {
105 105
     }
106 106
 
107 107
     // No aligned correctly.
108
-    function myFunction($variable1, $variable2,
109
-    $variable3, $variable4)
108
+    function myFunction( $variable1, $variable2,
109
+    $variable3, $variable4 )
110 110
 {
111 111
 }
112 112
     
113 113
     // Too many spaces.
114
-    function myFunction($variable1, $variable2,
115
-    $variable3, $variable4)   {
114
+    function myFunction( $variable1, $variable2,
115
+    $variable3, $variable4 ) {
116 116
     }
117 117
     
118 118
     // Too many newlines.
119
-    function myFunction($variable1, $variable2,
120
-    $variable3, $variable4)
119
+    function myFunction( $variable1, $variable2,
120
+    $variable3, $variable4 )
121 121
 
122 122
     {
123 123
     }
124 124
     
125 125
     // Space before brace.
126
-    function myFunction($variable1, $variable2,
127
-    $variable3, $variable4)
126
+    function myFunction( $variable1, $variable2,
127
+    $variable3, $variable4 )
128 128
      {
129 129
     }
130 130
 }
@@ -161,25 +161,25 @@  discard block
 block discarded – undo
161 161
 
162 162
 // phpcs:set Generic.Functions.OpeningFunctionBraceBsdAllman checkClosures 1
163 163
 
164
-$closureWithArgs = function ($arg1, $arg2) {
164
+$closureWithArgs = function( $arg1, $arg2 ) {
165 165
     // body
166 166
 };
167 167
 
168
-$closureWithArgsAndVars = function ($arg1, $arg2) use ($var1, $var2) {
168
+$closureWithArgsAndVars = function( $arg1, $arg2 ) use ( $var1, $var2 ) {
169 169
     // body
170 170
 };
171 171
 
172
-$test = function ($param) use ($result) {
172
+$test = function( $param ) use ( $result ) {
173 173
     return null;
174 174
 };
175 175
 
176
-$test = function ($param) use ($result) : Something {
176
+$test = function( $param ) use ( $result ) : Something {
177 177
     return null;
178 178
 };
179 179
 
180 180
 // phpcs:set Generic.Functions.OpeningFunctionBraceBsdAllman checkClosures 0
181 181
 
182
-$closureWithArgs = function ($arg1, $arg2) {
182
+$closureWithArgs = function( $arg1, $arg2 ) {
183 183
     // body
184 184
 };
185 185
 
@@ -197,42 +197,42 @@  discard block
 block discarded – undo
197 197
     return null;
198 198
 }
199 199
 
200
-function myFunction($a, $lot, $of, $params)
200
+function myFunction( $a, $lot, $of, $params )
201 201
     : array {
202 202
     return null;
203 203
 }
204 204
 
205
-function myFunction($a, $lot, $of, $params) { // comment
205
+function myFunction( $a, $lot, $of, $params ) { // comment
206 206
     return null;
207 207
 }
208 208
 
209
-function myFunction($a, $lot, $of, $params)
209
+function myFunction( $a, $lot, $of, $params )
210 210
     : array { // comment
211 211
     return null;
212 212
 }
213 213
 
214
-function myFunction($a, $lot, $of, $params)
214
+function myFunction( $a, $lot, $of, $params )
215 215
     : array { // phpcs:ignore Standard.Category.Sniff -- for reasons.
216 216
     return null;
217 217
 }
218 218
 
219
-function myFunction($a, $lot, $of, $params)
219
+function myFunction( $a, $lot, $of, $params )
220 220
     : array {// phpcs:ignore Standard.Category.Sniff -- for reasons.
221 221
     return null;
222 222
 }
223 223
 
224
-function myFunction($a, $lot, $of, $params)
224
+function myFunction( $a, $lot, $of, $params )
225 225
     : array
226 226
 { // phpcs:ignore Standard.Category.Sniff -- for reasons.
227 227
     return null;
228 228
 }
229 229
 
230
-function myFunction($a, $lot, $of, $params)
230
+function myFunction( $a, $lot, $of, $params )
231 231
     : array /* phpcs:ignore Standard.Category.Sniff -- for reasons */ {
232 232
     return null;
233 233
 }
234 234
 
235
-function myFunction($a, $lot, $of, $params)
235
+function myFunction( $a, $lot, $of, $params )
236 236
     : array /* comment */ {
237 237
     return null;
238 238
 }
Please login to merge, or discard this patch.
Braces   +26 added lines, -49 removed lines patch added patch discarded remove patch
@@ -5,54 +5,44 @@  discard block
 block discarded – undo
5 5
 }
6 6
 
7 7
 // Good.
8
-function myFunction()
9
-{
8
+function myFunction() {
10 9
 }
11 10
 
12 11
 // Too many spaces.
13
-function myFunction()   {
12
+function myFunction() {
14 13
 }
15 14
 
16 15
 // Too many newlines.
17
-function myFunction()
18
-
19
-{
16
+function myFunction() {
20 17
 }
21 18
 
22 19
 // Space before brace.
23
-function myFunction()
24
- {
20
+function myFunction() {
25 21
 }
26 22
 
27
-class myClass
28
-{
23
+class myClass {
29 24
     // Brace should be on new line.
30 25
     function myFunction() {
31 26
     }
32 27
     
33 28
     // Good.
34
-    function myFunction()
35
-    {
29
+    function myFunction() {
36 30
     }
37 31
 
38 32
     // No aligned correctly.
39
-    function myFunction()
40
-{
33
+    function myFunction() {
41 34
 }
42 35
     
43 36
     // Too many spaces.
44
-    function myFunction()   {
37
+    function myFunction() {
45 38
     }
46 39
     
47 40
     // Too many newlines.
48
-    function myFunction()
49
-
50
-    {
41
+    function myFunction() {
51 42
     }
52 43
     
53 44
     // Space before brace.
54
-    function myFunction()
55
-     {
45
+    function myFunction() {
56 46
     }
57 47
 }
58 48
 
@@ -69,30 +59,25 @@  discard block
 block discarded – undo
69 59
 
70 60
 // Good.
71 61
 function myFunction($variable1, $variable2,
72
-    $variable3, $variable4)
73
-{
62
+    $variable3, $variable4) {
74 63
 }
75 64
 
76 65
 // Too many spaces.
77 66
 function myFunction($variable1, $variable2,
78
-    $variable3, $variable4)   {
67
+    $variable3, $variable4) {
79 68
 }
80 69
 
81 70
 // Too many newlines.
82 71
 function myFunction($variable1, $variable2,
83
-    $variable3, $variable4)
84
-
85
-{
72
+    $variable3, $variable4) {
86 73
 }
87 74
 
88 75
 // Space before brace.
89 76
 function myFunction($variable1, $variable2,
90
-    $variable3, $variable4)
91
- {
77
+    $variable3, $variable4) {
92 78
 }
93 79
 
94
-class myClass
95
-{
80
+class myClass {
96 81
     // Brace should be on new line.
97 82
     function myFunction($variable1, $variable2,
98 83
     $variable3, $variable4) {
@@ -100,37 +85,31 @@  discard block
 block discarded – undo
100 85
     
101 86
     // Good.
102 87
     function myFunction($variable1, $variable2,
103
-    $variable3, $variable4)
104
-    {
88
+    $variable3, $variable4) {
105 89
     }
106 90
 
107 91
     // No aligned correctly.
108 92
     function myFunction($variable1, $variable2,
109
-    $variable3, $variable4)
110
-{
93
+    $variable3, $variable4) {
111 94
 }
112 95
     
113 96
     // Too many spaces.
114 97
     function myFunction($variable1, $variable2,
115
-    $variable3, $variable4)   {
98
+    $variable3, $variable4) {
116 99
     }
117 100
     
118 101
     // Too many newlines.
119 102
     function myFunction($variable1, $variable2,
120
-    $variable3, $variable4)
121
-
122
-    {
103
+    $variable3, $variable4) {
123 104
     }
124 105
     
125 106
     // Space before brace.
126 107
     function myFunction($variable1, $variable2,
127
-    $variable3, $variable4)
128
-     {
108
+    $variable3, $variable4) {
129 109
     }
130 110
 }
131 111
 
132
-interface MyInterface
133
-{
112
+interface MyInterface {
134 113
     function myFunction();
135 114
 }
136 115
 
@@ -141,8 +120,7 @@  discard block
 block discarded – undo
141 120
                     $arg4,
142 121
                     $arg5,
143 122
                     $arg6
144
-                    )
145
-{
123
+                    ) {
146 124
 }
147 125
 
148 126
 function myFunction(
@@ -183,11 +161,9 @@  discard block
 block discarded – undo
183 161
     // body
184 162
 };
185 163
 
186
-class Foo
187
-{
164
+class Foo {
188 165
 //Comments should not affect code
189
-    public function bar()
190
-    {
166
+    public function bar() {
191 167
 
192 168
     }
193 169
 //Comments should not affect code
@@ -202,7 +178,8 @@  discard block
 block discarded – undo
202 178
     return null;
203 179
 }
204 180
 
205
-function myFunction($a, $lot, $of, $params) { // comment
181
+function myFunction($a, $lot, $of, $params) {
182
+// comment
206 183
     return null;
207 184
 }
208 185
 
Please login to merge, or discard this patch.
Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php 3 patches
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -15,61 +15,61 @@
 block discarded – undo
15 15
 {
16 16
 
17 17
 
18
-    /**
19
-     * Returns the lines where errors should occur.
20
-     *
21
-     * The key of the array should represent the line number and the value
22
-     * should represent the number of errors that should occur on that line.
23
-     *
24
-     * @return array<int, int>
25
-     */
26
-    public function getErrorList()
27
-    {
28
-        return [
29
-            9   => 1,
30
-            13  => 1,
31
-            17  => 1,
32
-            29  => 1,
33
-            33  => 1,
34
-            37  => 1,
35
-            53  => 1,
36
-            58  => 1,
37
-            63  => 1,
38
-            77  => 1,
39
-            82  => 1,
40
-            87  => 1,
41
-            104 => 1,
42
-            119 => 1,
43
-            123 => 1,
44
-            127 => 1,
45
-            132 => 1,
46
-            137 => 1,
47
-            142 => 1,
48
-            157 => 1,
49
-            162 => 1,
50
-            171 => 1,
51
-            181 => 1,
52
-            191 => 1,
53
-            197 => 1,
54
-            203 => 1,
55
-        ];
18
+	/**
19
+	 * Returns the lines where errors should occur.
20
+	 *
21
+	 * The key of the array should represent the line number and the value
22
+	 * should represent the number of errors that should occur on that line.
23
+	 *
24
+	 * @return array<int, int>
25
+	 */
26
+	public function getErrorList()
27
+	{
28
+		return [
29
+			9   => 1,
30
+			13  => 1,
31
+			17  => 1,
32
+			29  => 1,
33
+			33  => 1,
34
+			37  => 1,
35
+			53  => 1,
36
+			58  => 1,
37
+			63  => 1,
38
+			77  => 1,
39
+			82  => 1,
40
+			87  => 1,
41
+			104 => 1,
42
+			119 => 1,
43
+			123 => 1,
44
+			127 => 1,
45
+			132 => 1,
46
+			137 => 1,
47
+			142 => 1,
48
+			157 => 1,
49
+			162 => 1,
50
+			171 => 1,
51
+			181 => 1,
52
+			191 => 1,
53
+			197 => 1,
54
+			203 => 1,
55
+		];
56 56
 
57
-    }//end getErrorList()
57
+	}//end getErrorList()
58 58
 
59 59
 
60
-    /**
61
-     * Returns the lines where warnings should occur.
62
-     *
63
-     * The key of the array should represent the line number and the value
64
-     * should represent the number of warnings that should occur on that line.
65
-     *
66
-     * @return array<int, int>
67
-     */
68
-    public function getWarningList()
69
-    {
70
-        return [];
60
+	/**
61
+	 * Returns the lines where warnings should occur.
62
+	 *
63
+	 * The key of the array should represent the line number and the value
64
+	 * should represent the number of warnings that should occur on that line.
65
+	 *
66
+	 * @return array<int, int>
67
+	 */
68
+	public function getWarningList()
69
+	{
70
+		return [];
71 71
 
72
-    }//end getWarningList()
72
+	}//end getWarningList()
73 73
 
74 74
 
75 75
 }//end class
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,8 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
13 13
 
14
-class OpeningFunctionBraceKernighanRitchieUnitTest extends AbstractSniffUnitTest
15
-{
14
+class OpeningFunctionBraceKernighanRitchieUnitTest extends AbstractSniffUnitTest {
16 15
 
17 16
 
18 17
     /**
@@ -23,8 +22,7 @@  discard block
 block discarded – undo
23 22
      *
24 23
      * @return array<int, int>
25 24
      */
26
-    public function getErrorList()
27
-    {
25
+    public function getErrorList() {
28 26
         return [
29 27
             9   => 1,
30 28
             13  => 1,
@@ -65,8 +63,7 @@  discard block
 block discarded – undo
65 63
      *
66 64
      * @return array<int, int>
67 65
      */
68
-    public function getWarningList()
69
-    {
66
+    public function getWarningList() {
70 67
         return [];
71 68
 
72 69
     }//end getWarningList()
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
      */
65 65
     public function getWarningList()
66 66
     {
67
-        return [];
67
+        return [ ];
68 68
 
69 69
     }//end getWarningList()
70 70
 
Please login to merge, or discard this patch.
Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.inc 3 patches
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -20,22 +20,22 @@  discard block
 block discarded – undo
20 20
 
21 21
 class myClass
22 22
 {
23
-    // Good.
24
-    function myFunction() {
25
-    }
23
+	// Good.
24
+	function myFunction() {
25
+	}
26 26
     
27
-    // Brace should be on same line.
28
-    function myFunction()
29
-    {
30
-    }
27
+	// Brace should be on same line.
28
+	function myFunction()
29
+	{
30
+	}
31 31
     
32
-    // Too many spaces.
33
-    function myFunction()   {
34
-    }
32
+	// Too many spaces.
33
+	function myFunction()   {
34
+	}
35 35
     
36
-    // Uses tab.
37
-    function myFunction()	{
38
-    }
36
+	// Uses tab.
37
+	function myFunction()	{
38
+	}
39 39
 }
40 40
 
41 41
 
@@ -44,74 +44,74 @@  discard block
 block discarded – undo
44 44
 
45 45
 // Good.
46 46
 function myFunction($variable1, $variable2,
47
-    $variable3, $variable4) {
47
+	$variable3, $variable4) {
48 48
 }
49 49
 
50 50
 // Brace should be on same line.
51 51
 function myFunction($variable1, $variable2,
52
-    $variable3, $variable4)
52
+	$variable3, $variable4)
53 53
 {
54 54
 }
55 55
 
56 56
 // Too many spaces.
57 57
 function myFunction($variable1, $variable2,
58
-    $variable3, $variable4)   {
58
+	$variable3, $variable4)   {
59 59
 }
60 60
 
61 61
 // Uses tab.
62 62
 function myFunction($variable1, $variable2,
63
-    $variable3, $variable4)	{
63
+	$variable3, $variable4)	{
64 64
 }
65 65
 
66 66
 
67 67
 class myClass
68 68
 {
69
-    // Good.
70
-    function myFunction($variable1, $variable2,
71
-        $variable3, $variable4) {
72
-    }
69
+	// Good.
70
+	function myFunction($variable1, $variable2,
71
+		$variable3, $variable4) {
72
+	}
73 73
     
74
-    // Brace should be on same line.
75
-    function myFunction($variable1, $variable2,
76
-        $variable3, $variable4)
77
-    {
78
-    }
74
+	// Brace should be on same line.
75
+	function myFunction($variable1, $variable2,
76
+		$variable3, $variable4)
77
+	{
78
+	}
79 79
     
80
-    // Too many spaces.
81
-    function myFunction($variable1, $variable2,
82
-        $variable3, $variable4)   {
83
-    }
80
+	// Too many spaces.
81
+	function myFunction($variable1, $variable2,
82
+		$variable3, $variable4)   {
83
+	}
84 84
     
85
-    // Uses tab.
86
-    function myFunction($variable1, $variable2,
87
-        $variable3, $variable4)	{
88
-    }
85
+	// Uses tab.
86
+	function myFunction($variable1, $variable2,
87
+		$variable3, $variable4)	{
88
+	}
89 89
 }
90 90
 
91 91
 interface MyInterface
92 92
 {
93
-    function myFunction();
93
+	function myFunction();
94 94
 }
95 95
 
96 96
 function myFunction(
97
-                    $arg1,
98
-                    $arg2,
99
-                    $arg3,
100
-                    $arg4,
101
-                    $arg5,
102
-                    $arg6
103
-                    )
97
+					$arg1,
98
+					$arg2,
99
+					$arg3,
100
+					$arg4,
101
+					$arg5,
102
+					$arg6
103
+					)
104 104
 {
105 105
 }
106 106
 
107 107
 function myFunction(
108
-                    $arg1,
109
-                    $arg2,
110
-                    $arg3,
111
-                    $arg4,
112
-                    $arg5,
113
-                    $arg6
114
-                    ) {
108
+					$arg1,
109
+					$arg2,
110
+					$arg3,
111
+					$arg4,
112
+					$arg5,
113
+					$arg6
114
+					) {
115 115
 }
116 116
 
117 117
 function myFunction() {}
@@ -121,26 +121,26 @@  discard block
 block discarded – undo
121 121
 // phpcs:set Generic.Functions.OpeningFunctionBraceKernighanRitchie checkClosures 1
122 122
 
123 123
 $closureWithArgs = function ($arg1, $arg2){
124
-    // body
124
+	// body
125 125
 };
126 126
 
127 127
 $closureWithArgsAndVars = function ($arg1, $arg2) use ($var1, $var2){
128
-    // body
128
+	// body
129 129
 };
130 130
 
131 131
 $test = function ($param) use ($result)
132 132
 {
133
-    return null;
133
+	return null;
134 134
 };
135 135
 
136 136
 $test = function ($param) use ($result) : Something
137 137
 {
138
-    return null;
138
+	return null;
139 139
 };
140 140
 
141 141
 $test = function ($param) use ($result): Something
142 142
 {
143
-    return null;
143
+	return null;
144 144
 };
145 145
 
146 146
 foo(function ($bar) { ?>
@@ -150,26 +150,26 @@  discard block
 block discarded – undo
150 150
 // phpcs:set Generic.Functions.OpeningFunctionBraceKernighanRitchie checkClosures 0
151 151
 
152 152
 $closureWithArgs = function ($arg1, $arg2){
153
-    // body
153
+	// body
154 154
 };
155 155
 
156 156
 function myFunction() : Something
157 157
 {
158
-    return null;
158
+	return null;
159 159
 }
160 160
 
161 161
 function myFunction() : Something // Break me
162 162
 {
163
-    return null;
163
+	return null;
164 164
 }
165 165
 
166 166
 function myFunction(): Something {
167
-    return null;
167
+	return null;
168 168
 }
169 169
 
170 170
 function myFunction(): Something
171 171
 {
172
-    return null;
172
+	return null;
173 173
 }
174 174
 
175 175
 function myFunction($bar) { ?>
@@ -177,34 +177,34 @@  discard block
 block discarded – undo
177 177
 <?php }
178 178
 
179 179
 function myFunction($a, $lot, $of, $params)
180
-    : array
180
+	: array
181 181
 {
182
-    return null;
182
+	return null;
183 183
 }
184 184
 
185 185
 function myFunction($a, $lot, $of, $params)
186
-    : array {
187
-    return null;
186
+	: array {
187
+	return null;
188 188
 }
189 189
 
190 190
 function myFunction($a, $lot, $of, $params) // comment
191 191
 {
192
-    return null;
192
+	return null;
193 193
 }
194 194
 
195 195
 function myFunction($a, $lot, $of, $params)
196
-    : array // comment
196
+	: array // comment
197 197
 {
198
-    return null;
198
+	return null;
199 199
 }
200 200
 
201 201
 function myFunction($a, $lot, $of, $params)
202
-    : array // phpcs:ignore Standard.Category.Sniff -- for reasons.
202
+	: array // phpcs:ignore Standard.Category.Sniff -- for reasons.
203 203
 {
204
-    return null;
204
+	return null;
205 205
 }
206 206
 
207 207
 function myFunction($a, $lot, $of, $params)
208
-    : array { // phpcs:ignore Standard.Category.Sniff -- for reasons.
209
-    return null;
208
+	: array { // phpcs:ignore Standard.Category.Sniff -- for reasons.
209
+	return null;
210 210
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  discard block
 block discarded – undo
10 10
 }
11 11
 
12 12
 // Too many spaces.
13
-function myFunction()   {
13
+function myFunction() {
14 14
 }
15 15
 
16 16
 // Uses tab.
17
-function myFunction()	{
17
+function myFunction() {
18 18
 }
19 19
 
20 20
 
@@ -30,11 +30,11 @@  discard block
 block discarded – undo
30 30
     }
31 31
     
32 32
     // Too many spaces.
33
-    function myFunction()   {
33
+    function myFunction() {
34 34
     }
35 35
     
36 36
     // Uses tab.
37
-    function myFunction()	{
37
+    function myFunction() {
38 38
     }
39 39
 }
40 40
 
@@ -43,48 +43,48 @@  discard block
 block discarded – undo
43 43
 /* Multi-line declarations */
44 44
 
45 45
 // Good.
46
-function myFunction($variable1, $variable2,
47
-    $variable3, $variable4) {
46
+function myFunction( $variable1, $variable2,
47
+    $variable3, $variable4 ) {
48 48
 }
49 49
 
50 50
 // Brace should be on same line.
51
-function myFunction($variable1, $variable2,
52
-    $variable3, $variable4)
51
+function myFunction( $variable1, $variable2,
52
+    $variable3, $variable4 )
53 53
 {
54 54
 }
55 55
 
56 56
 // Too many spaces.
57
-function myFunction($variable1, $variable2,
58
-    $variable3, $variable4)   {
57
+function myFunction( $variable1, $variable2,
58
+    $variable3, $variable4 ) {
59 59
 }
60 60
 
61 61
 // Uses tab.
62
-function myFunction($variable1, $variable2,
63
-    $variable3, $variable4)	{
62
+function myFunction( $variable1, $variable2,
63
+    $variable3, $variable4 ) {
64 64
 }
65 65
 
66 66
 
67 67
 class myClass
68 68
 {
69 69
     // Good.
70
-    function myFunction($variable1, $variable2,
71
-        $variable3, $variable4) {
70
+    function myFunction( $variable1, $variable2,
71
+        $variable3, $variable4 ) {
72 72
     }
73 73
     
74 74
     // Brace should be on same line.
75
-    function myFunction($variable1, $variable2,
76
-        $variable3, $variable4)
75
+    function myFunction( $variable1, $variable2,
76
+        $variable3, $variable4 )
77 77
     {
78 78
     }
79 79
     
80 80
     // Too many spaces.
81
-    function myFunction($variable1, $variable2,
82
-        $variable3, $variable4)   {
81
+    function myFunction( $variable1, $variable2,
82
+        $variable3, $variable4 ) {
83 83
     }
84 84
     
85 85
     // Uses tab.
86
-    function myFunction($variable1, $variable2,
87
-        $variable3, $variable4)	{
86
+    function myFunction( $variable1, $variable2,
87
+        $variable3, $variable4 ) {
88 88
     }
89 89
 }
90 90
 
@@ -120,36 +120,36 @@  discard block
 block discarded – undo
120 120
 
121 121
 // phpcs:set Generic.Functions.OpeningFunctionBraceKernighanRitchie checkClosures 1
122 122
 
123
-$closureWithArgs = function ($arg1, $arg2){
123
+$closureWithArgs = function( $arg1, $arg2 ) {
124 124
     // body
125 125
 };
126 126
 
127
-$closureWithArgsAndVars = function ($arg1, $arg2) use ($var1, $var2){
127
+$closureWithArgsAndVars = function( $arg1, $arg2 ) use ( $var1, $var2 ){
128 128
     // body
129 129
 };
130 130
 
131
-$test = function ($param) use ($result)
131
+$test = function( $param ) use ( $result )
132 132
 {
133 133
     return null;
134 134
 };
135 135
 
136
-$test = function ($param) use ($result) : Something
136
+$test = function( $param ) use ( $result ) : Something
137 137
 {
138 138
     return null;
139 139
 };
140 140
 
141
-$test = function ($param) use ($result): Something
141
+$test = function( $param ) use ( $result ): Something
142 142
 {
143 143
     return null;
144 144
 };
145 145
 
146
-foo(function ($bar) { ?>
146
+foo( function( $bar ) { ?>
147 147
     <div><?php echo $bar; ?></div>
148 148
 <?php });
149 149
 
150 150
 // phpcs:set Generic.Functions.OpeningFunctionBraceKernighanRitchie checkClosures 0
151 151
 
152
-$closureWithArgs = function ($arg1, $arg2){
152
+$closureWithArgs = function( $arg1, $arg2 ) {
153 153
     // body
154 154
 };
155 155
 
@@ -172,39 +172,39 @@  discard block
 block discarded – undo
172 172
     return null;
173 173
 }
174 174
 
175
-function myFunction($bar) { ?>
175
+function myFunction( $bar ) { ?>
176 176
     <div><?php echo $bar; ?></div>
177 177
 <?php }
178 178
 
179
-function myFunction($a, $lot, $of, $params)
179
+function myFunction( $a, $lot, $of, $params )
180 180
     : array
181 181
 {
182 182
     return null;
183 183
 }
184 184
 
185
-function myFunction($a, $lot, $of, $params)
185
+function myFunction( $a, $lot, $of, $params )
186 186
     : array {
187 187
     return null;
188 188
 }
189 189
 
190
-function myFunction($a, $lot, $of, $params) // comment
190
+function myFunction( $a, $lot, $of, $params ) // comment
191 191
 {
192 192
     return null;
193 193
 }
194 194
 
195
-function myFunction($a, $lot, $of, $params)
195
+function myFunction( $a, $lot, $of, $params )
196 196
     : array // comment
197 197
 {
198 198
     return null;
199 199
 }
200 200
 
201
-function myFunction($a, $lot, $of, $params)
201
+function myFunction( $a, $lot, $of, $params )
202 202
     : array // phpcs:ignore Standard.Category.Sniff -- for reasons.
203 203
 {
204 204
     return null;
205 205
 }
206 206
 
207
-function myFunction($a, $lot, $of, $params)
207
+function myFunction( $a, $lot, $of, $params )
208 208
     : array { // phpcs:ignore Standard.Category.Sniff -- for reasons.
209 209
     return null;
210 210
 }
Please login to merge, or discard this patch.
Braces   +20 added lines, -29 removed lines patch added patch discarded remove patch
@@ -5,36 +5,33 @@  discard block
 block discarded – undo
5 5
 }
6 6
 
7 7
 // Brace should be on same line.
8
-function myFunction()
9
-{
8
+function myFunction() {
10 9
 }
11 10
 
12 11
 // Too many spaces.
13
-function myFunction()   {
12
+function myFunction() {
14 13
 }
15 14
 
16 15
 // Uses tab.
17
-function myFunction()	{
16
+function myFunction() {
18 17
 }
19 18
 
20 19
 
21
-class myClass
22
-{
20
+class myClass {
23 21
     // Good.
24 22
     function myFunction() {
25 23
     }
26 24
     
27 25
     // Brace should be on same line.
28
-    function myFunction()
29
-    {
26
+    function myFunction() {
30 27
     }
31 28
     
32 29
     // Too many spaces.
33
-    function myFunction()   {
30
+    function myFunction() {
34 31
     }
35 32
     
36 33
     // Uses tab.
37
-    function myFunction()	{
34
+    function myFunction() {
38 35
     }
39 36
 }
40 37
 
@@ -49,23 +46,21 @@  discard block
 block discarded – undo
49 46
 
50 47
 // Brace should be on same line.
51 48
 function myFunction($variable1, $variable2,
52
-    $variable3, $variable4)
53
-{
49
+    $variable3, $variable4) {
54 50
 }
55 51
 
56 52
 // Too many spaces.
57 53
 function myFunction($variable1, $variable2,
58
-    $variable3, $variable4)   {
54
+    $variable3, $variable4) {
59 55
 }
60 56
 
61 57
 // Uses tab.
62 58
 function myFunction($variable1, $variable2,
63
-    $variable3, $variable4)	{
59
+    $variable3, $variable4) {
64 60
 }
65 61
 
66 62
 
67
-class myClass
68
-{
63
+class myClass {
69 64
     // Good.
70 65
     function myFunction($variable1, $variable2,
71 66
         $variable3, $variable4) {
@@ -73,23 +68,21 @@  discard block
 block discarded – undo
73 68
     
74 69
     // Brace should be on same line.
75 70
     function myFunction($variable1, $variable2,
76
-        $variable3, $variable4)
77
-    {
71
+        $variable3, $variable4) {
78 72
     }
79 73
     
80 74
     // Too many spaces.
81 75
     function myFunction($variable1, $variable2,
82
-        $variable3, $variable4)   {
76
+        $variable3, $variable4) {
83 77
     }
84 78
     
85 79
     // Uses tab.
86 80
     function myFunction($variable1, $variable2,
87
-        $variable3, $variable4)	{
81
+        $variable3, $variable4) {
88 82
     }
89 83
 }
90 84
 
91
-interface MyInterface
92
-{
85
+interface MyInterface {
93 86
     function myFunction();
94 87
 }
95 88
 
@@ -100,8 +93,7 @@  discard block
 block discarded – undo
100 93
                     $arg4,
101 94
                     $arg5,
102 95
                     $arg6
103
-                    )
104
-{
96
+                    ) {
105 97
 }
106 98
 
107 99
 function myFunction(
@@ -120,16 +112,15 @@  discard block
 block discarded – undo
120 112
 
121 113
 // phpcs:set Generic.Functions.OpeningFunctionBraceKernighanRitchie checkClosures 1
122 114
 
123
-$closureWithArgs = function ($arg1, $arg2){
115
+$closureWithArgs = function ($arg1, $arg2) {
124 116
     // body
125 117
 };
126 118
 
127
-$closureWithArgsAndVars = function ($arg1, $arg2) use ($var1, $var2){
119
+$closureWithArgsAndVars = function ($arg1, $arg2) use ($var1, $var2) {
128 120
     // body
129 121
 };
130 122
 
131
-$test = function ($param) use ($result)
132
-{
123
+$test = function ($param) use ($result) {
133 124
     return null;
134 125
 };
135 126
 
@@ -149,7 +140,7 @@  discard block
 block discarded – undo
149 140
 
150 141
 // phpcs:set Generic.Functions.OpeningFunctionBraceKernighanRitchie checkClosures 0
151 142
 
152
-$closureWithArgs = function ($arg1, $arg2){
143
+$closureWithArgs = function ($arg1, $arg2) {
153 144
     // body
154 145
 };
155 146
 
Please login to merge, or discard this patch.
src/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php 3 patches
Indentation   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -16,138 +16,138 @@
 block discarded – undo
16 16
 class SpaceAfterCastSniff implements Sniff
17 17
 {
18 18
 
19
-    /**
20
-     * The number of spaces desired after a cast token.
21
-     *
22
-     * @var integer
23
-     */
24
-    public $spacing = 1;
25
-
26
-    /**
27
-     * Allow newlines instead of spaces.
28
-     *
29
-     * @var boolean
30
-     */
31
-    public $ignoreNewlines = false;
32
-
33
-
34
-    /**
35
-     * Returns an array of tokens this test wants to listen for.
36
-     *
37
-     * @return array
38
-     */
39
-    public function register()
40
-    {
41
-        return Tokens::$castTokens;
42
-
43
-    }//end register()
44
-
45
-
46
-    /**
47
-     * Processes this test, when one of its tokens is encountered.
48
-     *
49
-     * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
50
-     * @param int                         $stackPtr  The position of the current token in
51
-     *                                               the stack passed in $tokens.
52
-     *
53
-     * @return void
54
-     */
55
-    public function process(File $phpcsFile, $stackPtr)
56
-    {
57
-        $tokens        = $phpcsFile->getTokens();
58
-        $this->spacing = (int) $this->spacing;
59
-
60
-        if ($tokens[$stackPtr]['code'] === T_BINARY_CAST
61
-            && $tokens[$stackPtr]['content'] === 'b'
62
-        ) {
63
-            // You can't replace a space after this type of binary casting.
64
-            return;
65
-        }
66
-
67
-        $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
68
-        if ($nextNonEmpty === false) {
69
-            return;
70
-        }
71
-
72
-        if ($this->ignoreNewlines === true
73
-            && $tokens[$stackPtr]['line'] !== $tokens[$nextNonEmpty]['line']
74
-        ) {
75
-            $phpcsFile->recordMetric($stackPtr, 'Spacing after cast statement', 'newline');
76
-            return;
77
-        }
78
-
79
-        if ($this->spacing === 0 && $nextNonEmpty === ($stackPtr + 1)) {
80
-            $phpcsFile->recordMetric($stackPtr, 'Spacing after cast statement', 0);
81
-            return;
82
-        }
83
-
84
-        $nextNonWhitespace = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
85
-        if ($nextNonEmpty !== $nextNonWhitespace) {
86
-            $error = 'Expected %s space(s) after cast statement; comment found';
87
-            $data  = [$this->spacing];
88
-            $phpcsFile->addError($error, $stackPtr, 'CommentFound', $data);
89
-
90
-            if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) {
91
-                $phpcsFile->recordMetric($stackPtr, 'Spacing after cast statement', $tokens[($stackPtr + 1)]['length']);
92
-            } else {
93
-                $phpcsFile->recordMetric($stackPtr, 'Spacing after cast statement', 0);
94
-            }
95
-
96
-            return;
97
-        }
98
-
99
-        $found = 0;
100
-        if ($tokens[$stackPtr]['line'] !== $tokens[$nextNonEmpty]['line']) {
101
-            $found = 'newline';
102
-        } else if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) {
103
-            $found = $tokens[($stackPtr + 1)]['length'];
104
-        }
105
-
106
-        $phpcsFile->recordMetric($stackPtr, 'Spacing after cast statement', $found);
107
-
108
-        if ($found === $this->spacing) {
109
-            return;
110
-        }
111
-
112
-        $error = 'Expected %s space(s) after cast statement; %s found';
113
-        $data  = [
114
-            $this->spacing,
115
-            $found,
116
-        ];
117
-
118
-        $errorCode = 'TooMuchSpace';
119
-        if ($this->spacing !== 0) {
120
-            if ($found === 0) {
121
-                $errorCode = 'NoSpace';
122
-            } else if ($found !== 'newline' && $found < $this->spacing) {
123
-                $errorCode = 'TooLittleSpace';
124
-            }
125
-        }
126
-
127
-        $fix = $phpcsFile->addFixableError($error, $stackPtr, $errorCode, $data);
128
-
129
-        if ($fix === true) {
130
-            $padding = str_repeat(' ', $this->spacing);
131
-            if ($found === 0) {
132
-                $phpcsFile->fixer->addContent($stackPtr, $padding);
133
-            } else {
134
-                $phpcsFile->fixer->beginChangeset();
135
-                $start = ($stackPtr + 1);
136
-
137
-                if ($this->spacing > 0) {
138
-                    $phpcsFile->fixer->replaceToken($start, $padding);
139
-                    ++$start;
140
-                }
141
-
142
-                for ($i = $start; $i < $nextNonWhitespace; $i++) {
143
-                    $phpcsFile->fixer->replaceToken($i, '');
144
-                }
145
-
146
-                $phpcsFile->fixer->endChangeset();
147
-            }
148
-        }
149
-
150
-    }//end process()
19
+	/**
20
+	 * The number of spaces desired after a cast token.
21
+	 *
22
+	 * @var integer
23
+	 */
24
+	public $spacing = 1;
25
+
26
+	/**
27
+	 * Allow newlines instead of spaces.
28
+	 *
29
+	 * @var boolean
30
+	 */
31
+	public $ignoreNewlines = false;
32
+
33
+
34
+	/**
35
+	 * Returns an array of tokens this test wants to listen for.
36
+	 *
37
+	 * @return array
38
+	 */
39
+	public function register()
40
+	{
41
+		return Tokens::$castTokens;
42
+
43
+	}//end register()
44
+
45
+
46
+	/**
47
+	 * Processes this test, when one of its tokens is encountered.
48
+	 *
49
+	 * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
50
+	 * @param int                         $stackPtr  The position of the current token in
51
+	 *                                               the stack passed in $tokens.
52
+	 *
53
+	 * @return void
54
+	 */
55
+	public function process(File $phpcsFile, $stackPtr)
56
+	{
57
+		$tokens        = $phpcsFile->getTokens();
58
+		$this->spacing = (int) $this->spacing;
59
+
60
+		if ($tokens[$stackPtr]['code'] === T_BINARY_CAST
61
+			&& $tokens[$stackPtr]['content'] === 'b'
62
+		) {
63
+			// You can't replace a space after this type of binary casting.
64
+			return;
65
+		}
66
+
67
+		$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
68
+		if ($nextNonEmpty === false) {
69
+			return;
70
+		}
71
+
72
+		if ($this->ignoreNewlines === true
73
+			&& $tokens[$stackPtr]['line'] !== $tokens[$nextNonEmpty]['line']
74
+		) {
75
+			$phpcsFile->recordMetric($stackPtr, 'Spacing after cast statement', 'newline');
76
+			return;
77
+		}
78
+
79
+		if ($this->spacing === 0 && $nextNonEmpty === ($stackPtr + 1)) {
80
+			$phpcsFile->recordMetric($stackPtr, 'Spacing after cast statement', 0);
81
+			return;
82
+		}
83
+
84
+		$nextNonWhitespace = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
85
+		if ($nextNonEmpty !== $nextNonWhitespace) {
86
+			$error = 'Expected %s space(s) after cast statement; comment found';
87
+			$data  = [$this->spacing];
88
+			$phpcsFile->addError($error, $stackPtr, 'CommentFound', $data);
89
+
90
+			if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) {
91
+				$phpcsFile->recordMetric($stackPtr, 'Spacing after cast statement', $tokens[($stackPtr + 1)]['length']);
92
+			} else {
93
+				$phpcsFile->recordMetric($stackPtr, 'Spacing after cast statement', 0);
94
+			}
95
+
96
+			return;
97
+		}
98
+
99
+		$found = 0;
100
+		if ($tokens[$stackPtr]['line'] !== $tokens[$nextNonEmpty]['line']) {
101
+			$found = 'newline';
102
+		} else if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) {
103
+			$found = $tokens[($stackPtr + 1)]['length'];
104
+		}
105
+
106
+		$phpcsFile->recordMetric($stackPtr, 'Spacing after cast statement', $found);
107
+
108
+		if ($found === $this->spacing) {
109
+			return;
110
+		}
111
+
112
+		$error = 'Expected %s space(s) after cast statement; %s found';
113
+		$data  = [
114
+			$this->spacing,
115
+			$found,
116
+		];
117
+
118
+		$errorCode = 'TooMuchSpace';
119
+		if ($this->spacing !== 0) {
120
+			if ($found === 0) {
121
+				$errorCode = 'NoSpace';
122
+			} else if ($found !== 'newline' && $found < $this->spacing) {
123
+				$errorCode = 'TooLittleSpace';
124
+			}
125
+		}
126
+
127
+		$fix = $phpcsFile->addFixableError($error, $stackPtr, $errorCode, $data);
128
+
129
+		if ($fix === true) {
130
+			$padding = str_repeat(' ', $this->spacing);
131
+			if ($found === 0) {
132
+				$phpcsFile->fixer->addContent($stackPtr, $padding);
133
+			} else {
134
+				$phpcsFile->fixer->beginChangeset();
135
+				$start = ($stackPtr + 1);
136
+
137
+				if ($this->spacing > 0) {
138
+					$phpcsFile->fixer->replaceToken($start, $padding);
139
+					++$start;
140
+				}
141
+
142
+				for ($i = $start; $i < $nextNonWhitespace; $i++) {
143
+					$phpcsFile->fixer->replaceToken($i, '');
144
+				}
145
+
146
+				$phpcsFile->fixer->endChangeset();
147
+			}
148
+		}
149
+
150
+	}//end process()
151 151
 
152 152
 
153 153
 }//end class
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -52,60 +52,60 @@  discard block
 block discarded – undo
52 52
      *
53 53
      * @return void
54 54
      */
55
-    public function process(File $phpcsFile, $stackPtr)
55
+    public function process( File $phpcsFile, $stackPtr )
56 56
     {
57 57
         $tokens        = $phpcsFile->getTokens();
58
-        $this->spacing = (int) $this->spacing;
58
+        $this->spacing = (int)$this->spacing;
59 59
 
60
-        if ($tokens[$stackPtr]['code'] === T_BINARY_CAST
61
-            && $tokens[$stackPtr]['content'] === 'b'
60
+        if ( $tokens[ $stackPtr ][ 'code' ] === T_BINARY_CAST
61
+            && $tokens[ $stackPtr ][ 'content' ] === 'b'
62 62
         ) {
63 63
             // You can't replace a space after this type of binary casting.
64 64
             return;
65 65
         }
66 66
 
67
-        $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
68
-        if ($nextNonEmpty === false) {
67
+        $nextNonEmpty = $phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
68
+        if ( $nextNonEmpty === false ) {
69 69
             return;
70 70
         }
71 71
 
72
-        if ($this->ignoreNewlines === true
73
-            && $tokens[$stackPtr]['line'] !== $tokens[$nextNonEmpty]['line']
72
+        if ( $this->ignoreNewlines === true
73
+            && $tokens[ $stackPtr ][ 'line' ] !== $tokens[ $nextNonEmpty ][ 'line' ]
74 74
         ) {
75
-            $phpcsFile->recordMetric($stackPtr, 'Spacing after cast statement', 'newline');
75
+            $phpcsFile->recordMetric( $stackPtr, 'Spacing after cast statement', 'newline' );
76 76
             return;
77 77
         }
78 78
 
79
-        if ($this->spacing === 0 && $nextNonEmpty === ($stackPtr + 1)) {
80
-            $phpcsFile->recordMetric($stackPtr, 'Spacing after cast statement', 0);
79
+        if ( $this->spacing === 0 && $nextNonEmpty === ( $stackPtr + 1 ) ) {
80
+            $phpcsFile->recordMetric( $stackPtr, 'Spacing after cast statement', 0 );
81 81
             return;
82 82
         }
83 83
 
84
-        $nextNonWhitespace = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
85
-        if ($nextNonEmpty !== $nextNonWhitespace) {
84
+        $nextNonWhitespace = $phpcsFile->findNext( T_WHITESPACE, ( $stackPtr + 1 ), null, true );
85
+        if ( $nextNonEmpty !== $nextNonWhitespace ) {
86 86
             $error = 'Expected %s space(s) after cast statement; comment found';
87
-            $data  = [$this->spacing];
88
-            $phpcsFile->addError($error, $stackPtr, 'CommentFound', $data);
87
+            $data  = [ $this->spacing ];
88
+            $phpcsFile->addError( $error, $stackPtr, 'CommentFound', $data );
89 89
 
90
-            if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) {
91
-                $phpcsFile->recordMetric($stackPtr, 'Spacing after cast statement', $tokens[($stackPtr + 1)]['length']);
90
+            if ( $tokens[ ( $stackPtr + 1 ) ][ 'code' ] === T_WHITESPACE ) {
91
+                $phpcsFile->recordMetric( $stackPtr, 'Spacing after cast statement', $tokens[ ( $stackPtr + 1 ) ][ 'length' ] );
92 92
             } else {
93
-                $phpcsFile->recordMetric($stackPtr, 'Spacing after cast statement', 0);
93
+                $phpcsFile->recordMetric( $stackPtr, 'Spacing after cast statement', 0 );
94 94
             }
95 95
 
96 96
             return;
97 97
         }
98 98
 
99 99
         $found = 0;
100
-        if ($tokens[$stackPtr]['line'] !== $tokens[$nextNonEmpty]['line']) {
100
+        if ( $tokens[ $stackPtr ][ 'line' ] !== $tokens[ $nextNonEmpty ][ 'line' ] ) {
101 101
             $found = 'newline';
102
-        } else if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) {
103
-            $found = $tokens[($stackPtr + 1)]['length'];
102
+        } else if ( $tokens[ ( $stackPtr + 1 ) ][ 'code' ] === T_WHITESPACE ) {
103
+            $found = $tokens[ ( $stackPtr + 1 ) ][ 'length' ];
104 104
         }
105 105
 
106
-        $phpcsFile->recordMetric($stackPtr, 'Spacing after cast statement', $found);
106
+        $phpcsFile->recordMetric( $stackPtr, 'Spacing after cast statement', $found );
107 107
 
108
-        if ($found === $this->spacing) {
108
+        if ( $found === $this->spacing ) {
109 109
             return;
110 110
         }
111 111
 
@@ -116,31 +116,31 @@  discard block
 block discarded – undo
116 116
         ];
117 117
 
118 118
         $errorCode = 'TooMuchSpace';
119
-        if ($this->spacing !== 0) {
120
-            if ($found === 0) {
119
+        if ( $this->spacing !== 0 ) {
120
+            if ( $found === 0 ) {
121 121
                 $errorCode = 'NoSpace';
122
-            } else if ($found !== 'newline' && $found < $this->spacing) {
122
+            } else if ( $found !== 'newline' && $found < $this->spacing ) {
123 123
                 $errorCode = 'TooLittleSpace';
124 124
             }
125 125
         }
126 126
 
127
-        $fix = $phpcsFile->addFixableError($error, $stackPtr, $errorCode, $data);
127
+        $fix = $phpcsFile->addFixableError( $error, $stackPtr, $errorCode, $data );
128 128
 
129
-        if ($fix === true) {
130
-            $padding = str_repeat(' ', $this->spacing);
131
-            if ($found === 0) {
132
-                $phpcsFile->fixer->addContent($stackPtr, $padding);
129
+        if ( $fix === true ) {
130
+            $padding = str_repeat( ' ', $this->spacing );
131
+            if ( $found === 0 ) {
132
+                $phpcsFile->fixer->addContent( $stackPtr, $padding );
133 133
             } else {
134 134
                 $phpcsFile->fixer->beginChangeset();
135
-                $start = ($stackPtr + 1);
135
+                $start = ( $stackPtr + 1 );
136 136
 
137
-                if ($this->spacing > 0) {
138
-                    $phpcsFile->fixer->replaceToken($start, $padding);
137
+                if ( $this->spacing > 0 ) {
138
+                    $phpcsFile->fixer->replaceToken( $start, $padding );
139 139
                     ++$start;
140 140
                 }
141 141
 
142
-                for ($i = $start; $i < $nextNonWhitespace; $i++) {
143
-                    $phpcsFile->fixer->replaceToken($i, '');
142
+                for ( $i = $start; $i < $nextNonWhitespace; $i++ ) {
143
+                    $phpcsFile->fixer->replaceToken( $i, '' );
144 144
                 }
145 145
 
146 146
                 $phpcsFile->fixer->endChangeset();
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,8 +13,7 @@  discard block
 block discarded – undo
13 13
 use PHP_CodeSniffer\Files\File;
14 14
 use PHP_CodeSniffer\Util\Tokens;
15 15
 
16
-class SpaceAfterCastSniff implements Sniff
17
-{
16
+class SpaceAfterCastSniff implements Sniff {
18 17
 
19 18
     /**
20 19
      * The number of spaces desired after a cast token.
@@ -36,8 +35,7 @@  discard block
 block discarded – undo
36 35
      *
37 36
      * @return array
38 37
      */
39
-    public function register()
40
-    {
38
+    public function register() {
41 39
         return Tokens::$castTokens;
42 40
 
43 41
     }//end register()
@@ -52,8 +50,7 @@  discard block
 block discarded – undo
52 50
      *
53 51
      * @return void
54 52
      */
55
-    public function process(File $phpcsFile, $stackPtr)
56
-    {
53
+    public function process(File $phpcsFile, $stackPtr) {
57 54
         $tokens        = $phpcsFile->getTokens();
58 55
         $this->spacing = (int) $this->spacing;
59 56
 
Please login to merge, or discard this patch.
src/Standards/Generic/Sniffs/Formatting/NoSpaceAfterCastSniff.php 3 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -20,42 +20,42 @@
 block discarded – undo
20 20
 {
21 21
 
22 22
 
23
-    /**
24
-     * Returns an array of tokens this test wants to listen for.
25
-     *
26
-     * @return array
27
-     */
28
-    public function register()
29
-    {
30
-        return Tokens::$castTokens;
31
-
32
-    }//end register()
33
-
34
-
35
-    /**
36
-     * Processes this test, when one of its tokens is encountered.
37
-     *
38
-     * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
39
-     * @param int                         $stackPtr  The position of the current token in
40
-     *                                               the stack passed in $tokens.
41
-     *
42
-     * @return void
43
-     */
44
-    public function process(File $phpcsFile, $stackPtr)
45
-    {
46
-        $tokens = $phpcsFile->getTokens();
47
-
48
-        if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) {
49
-            return;
50
-        }
51
-
52
-        $error = 'A cast statement must not be followed by a space';
53
-        $fix   = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceFound');
54
-        if ($fix === true) {
55
-            $phpcsFile->fixer->replaceToken(($stackPtr + 1), '');
56
-        }
57
-
58
-    }//end process()
23
+	/**
24
+	 * Returns an array of tokens this test wants to listen for.
25
+	 *
26
+	 * @return array
27
+	 */
28
+	public function register()
29
+	{
30
+		return Tokens::$castTokens;
31
+
32
+	}//end register()
33
+
34
+
35
+	/**
36
+	 * Processes this test, when one of its tokens is encountered.
37
+	 *
38
+	 * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
39
+	 * @param int                         $stackPtr  The position of the current token in
40
+	 *                                               the stack passed in $tokens.
41
+	 *
42
+	 * @return void
43
+	 */
44
+	public function process(File $phpcsFile, $stackPtr)
45
+	{
46
+		$tokens = $phpcsFile->getTokens();
47
+
48
+		if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) {
49
+			return;
50
+		}
51
+
52
+		$error = 'A cast statement must not be followed by a space';
53
+		$fix   = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceFound');
54
+		if ($fix === true) {
55
+			$phpcsFile->fixer->replaceToken(($stackPtr + 1), '');
56
+		}
57
+
58
+	}//end process()
59 59
 
60 60
 
61 61
 }//end class
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -41,18 +41,18 @@
 block discarded – undo
41 41
      *
42 42
      * @return void
43 43
      */
44
-    public function process(File $phpcsFile, $stackPtr)
44
+    public function process( File $phpcsFile, $stackPtr )
45 45
     {
46 46
         $tokens = $phpcsFile->getTokens();
47 47
 
48
-        if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) {
48
+        if ( $tokens[ ( $stackPtr + 1 ) ][ 'code' ] !== T_WHITESPACE ) {
49 49
             return;
50 50
         }
51 51
 
52 52
         $error = 'A cast statement must not be followed by a space';
53
-        $fix   = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceFound');
54
-        if ($fix === true) {
55
-            $phpcsFile->fixer->replaceToken(($stackPtr + 1), '');
53
+        $fix   = $phpcsFile->addFixableError( $error, $stackPtr, 'SpaceFound' );
54
+        if ( $fix === true ) {
55
+            $phpcsFile->fixer->replaceToken( ( $stackPtr + 1 ), '' );
56 56
         }
57 57
 
58 58
     }//end process()
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -16,8 +16,7 @@  discard block
 block discarded – undo
16 16
 use PHP_CodeSniffer\Files\File;
17 17
 use PHP_CodeSniffer\Util\Tokens;
18 18
 
19
-class NoSpaceAfterCastSniff implements Sniff
20
-{
19
+class NoSpaceAfterCastSniff implements Sniff {
21 20
 
22 21
 
23 22
     /**
@@ -25,8 +24,7 @@  discard block
 block discarded – undo
25 24
      *
26 25
      * @return array
27 26
      */
28
-    public function register()
29
-    {
27
+    public function register() {
30 28
         return Tokens::$castTokens;
31 29
 
32 30
     }//end register()
@@ -41,8 +39,7 @@  discard block
 block discarded – undo
41 39
      *
42 40
      * @return void
43 41
      */
44
-    public function process(File $phpcsFile, $stackPtr)
45
-    {
42
+    public function process(File $phpcsFile, $stackPtr) {
46 43
         $tokens = $phpcsFile->getTokens();
47 44
 
48 45
         if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) {
Please login to merge, or discard this patch.