Passed
Pull Request — release-2.1 (#6272)
by Mathias
03:55
created
Themes/default/Calendar.template.php 1 patch
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -425,7 +425,8 @@  discard block
 block discarded – undo
425 425
 					if (!empty($day['events']))
426 426
 					{
427 427
 						// Sort events by start time (all day events will be listed first)
428
-						uasort($day['events'], function($a, $b) {
428
+						uasort($day['events'], function($a, $b)
429
+						{
429 430
 							if ($a['start_timestamp'] == $b['start_timestamp'])
430 431
 								return 0;
431 432
 
@@ -619,7 +620,8 @@  discard block
 block discarded – undo
619 620
 			if (!empty($day['events']))
620 621
 			{
621 622
 				// Sort events by start time (all day events will be listed first)
622
-				uasort($day['events'], function($a, $b) {
623
+				uasort($day['events'], function($a, $b)
624
+				{
623 625
 					if ($a['start_timestamp'] == $b['start_timestamp'])
624 626
 						return 0;
625 627
 					return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
Please login to merge, or discard this patch.
Sources/Subs-BoardIndex.php 1 patch
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -419,7 +419,7 @@
 block discarded – undo
419 419
 					$board['last_post']['last_post_message'] = sprintf($txt['last_post_message'], $board['last_post']['member']['link'], $board['last_post']['link'], $board['last_post']['time'] > 0 ? timeformat($board['last_post']['time']) : $txt['not_applicable']);
420 420
 			}
421 421
 		}
422
-	else
422
+		else
423 423
 		foreach ($this_category as &$board)
424 424
 		{
425 425
 			if (!empty($moderators[$board['id']]))
Please login to merge, or discard this patch.
Sources/Subs-Editor.php 1 patch
Braces   -3 removed lines patch added patch discarded remove patch
@@ -332,7 +332,6 @@  discard block
 block discarded – undo
332 332
 					$replacement .= $precedingStyle . $extra_attr . $afterStyle;
333 333
 			}
334 334
 		}
335
-
336 335
 		elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1)
337 336
 		{
338 337
 			// Is this the element that we've been waiting for to be closed?
@@ -592,7 +591,6 @@  discard block
 block discarded – undo
592 591
 							$parts[$i + 2] = str_repeat("\t", $listDepth) . '[/list]';
593 592
 							$parts[$i + 3] = '';
594 593
 						}
595
-
596 594
 						else
597 595
 						{
598 596
 							// We're in a list item.
@@ -631,7 +629,6 @@  discard block
 block discarded – undo
631 629
 							$parts[$i + 2] = '';
632 630
 							$parts[$i + 3] = '';
633 631
 						}
634
-
635 632
 						else
636 633
 						{
637 634
 							// Remove the trailing breaks from the list item.
Please login to merge, or discard this patch.
Sources/Class-Punycode.php 1 patch
Braces   +20 added lines, -10 removed lines patch added patch discarded remove patch
@@ -94,7 +94,8 @@  discard block
 block discarded – undo
94 94
 	{
95 95
 		$input = mb_strtolower($input, $this->encoding);
96 96
 		$parts = explode('.', $input);
97
-		foreach ($parts as &$part) {
97
+		foreach ($parts as &$part)
98
+		{
98 99
 			$part = $this->encodePart($part);
99 100
 		}
100 101
 		$output = implode('.', $parts);
@@ -119,13 +120,16 @@  discard block
 block discarded – undo
119 120
 		$h = $b = count($codePoints['basic']);
120 121
 
121 122
 		$output = '';
122
-		foreach ($codePoints['basic'] as $code) {
123
+		foreach ($codePoints['basic'] as $code)
124
+		{
123 125
 			$output .= $this->codePointToChar($code);
124 126
 		}
125
-		if ($input === $output) {
127
+		if ($input === $output)
128
+		{
126 129
 			return $output;
127 130
 		}
128
-		if ($b > 0) {
131
+		if ($b > 0)
132
+		{
129 133
 			$output .= static::DELIMITER;
130 134
 		}
131 135
 
@@ -134,20 +138,26 @@  discard block
 block discarded – undo
134 138
 
135 139
 		$i = 0;
136 140
 		$length = mb_strlen($input, $this->encoding);
137
-		while ($h < $length) {
141
+		while ($h < $length)
142
+		{
138 143
 			$m = $codePoints['nonBasic'][$i++];
139 144
 			$delta = $delta + ($m - $n) * ($h + 1);
140 145
 			$n = $m;
141 146
 
142
-			foreach ($codePoints['all'] as $c) {
143
-				if ($c < $n || $c < static::INITIAL_N) {
147
+			foreach ($codePoints['all'] as $c)
148
+			{
149
+				if ($c < $n || $c < static::INITIAL_N)
150
+				{
144 151
 					$delta++;
145 152
 				}
146
-				if ($c === $n) {
153
+				if ($c === $n)
154
+				{
147 155
 					$q = $delta;
148
-					for ($k = static::BASE;; $k += static::BASE) {
156
+					for ($k = static::BASE;; $k += static::BASE)
157
+					{
149 158
 						$t = $this->calculateThreshold($k, $bias);
150
-						if ($q < $t) {
159
+						if ($q < $t)
160
+						{
151 161
 							break;
152 162
 						}
153 163
 
Please login to merge, or discard this patch.
Sources/Subs-Db-postgresql.php 1 patch
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -979,7 +979,8 @@  discard block
 block discarded – undo
979 979
 		$error_array[2] = null;
980 980
 
981 981
 	if(empty($db_persist))
982
-	{ // without pooling
982
+	{
983
+// without pooling
983 984
 		if (empty($pg_error_data_prep))
984 985
 			$pg_error_data_prep = pg_prepare($db_connection, 'smf_log_errors',
985 986
 				'INSERT INTO ' . $db_prefix . 'log_errors
@@ -990,7 +991,8 @@  discard block
 block discarded – undo
990 991
 		pg_execute($db_connection, 'smf_log_errors', $error_array);
991 992
 	}
992 993
 	else
993
-	{ //with pooling
994
+	{
995
+//with pooling
994 996
 		$pg_error_data_prep = pg_prepare($db_connection, '',
995 997
 			'INSERT INTO ' . $db_prefix . 'log_errors
996 998
 				(id_member, log_time, ip, url, message, session, error_type, file, line, backtrace)
Please login to merge, or discard this patch.
Sources/random_compat/random_bytes_mcrypt.php 1 patch
Braces   +9 added lines, -4 removed lines patch added patch discarded remove patch
@@ -26,7 +26,8 @@  discard block
 block discarded – undo
26 26
  * SOFTWARE.
27 27
  */
28 28
 
29
-if (!is_callable('random_bytes')) {
29
+if (!is_callable('random_bytes'))
30
+{
30 31
     /**
31 32
      * Powered by ext/mcrypt (and thankfully NOT libmcrypt)
32 33
      *
@@ -41,16 +42,20 @@  discard block
 block discarded – undo
41 42
      */
42 43
     function random_bytes($bytes)
43 44
     {
44
-        try {
45
+        try
46
+        {
45 47
             /** @var int $bytes */
46 48
             $bytes = RandomCompat_intval($bytes);
47
-        } catch (TypeError $ex) {
49
+        }
50
+        catch (TypeError $ex)
51
+        {
48 52
             throw new TypeError(
49 53
                 'random_bytes(): $bytes must be an integer'
50 54
             );
51 55
         }
52 56
 
53
-        if ($bytes < 1) {
57
+        if ($bytes < 1)
58
+        {
54 59
             throw new Error(
55 60
                 'Length must be greater than 0'
56 61
             );
Please login to merge, or discard this patch.
Sources/random_compat/random_bytes_dev_urandom.php 1 patch
Braces   +33 added lines, -16 removed lines patch added patch discarded remove patch
@@ -26,11 +26,13 @@  discard block
 block discarded – undo
26 26
  * SOFTWARE.
27 27
  */
28 28
 
29
-if (!defined('RANDOM_COMPAT_READ_BUFFER')) {
29
+if (!defined('RANDOM_COMPAT_READ_BUFFER'))
30
+{
30 31
     define('RANDOM_COMPAT_READ_BUFFER', 8);
31 32
 }
32 33
 
33
-if (!is_callable('random_bytes')) {
34
+if (!is_callable('random_bytes'))
35
+{
34 36
     /**
35 37
      * Unless open_basedir is enabled, use /dev/urandom for
36 38
      * random numbers in accordance with best practices
@@ -52,23 +54,27 @@  discard block
 block discarded – undo
52 54
         /**
53 55
          * This block should only be run once
54 56
          */
55
-        if (empty($fp)) {
57
+        if (empty($fp))
58
+        {
56 59
             /**
57 60
              * We use /dev/urandom if it is a char device.
58 61
              * We never fall back to /dev/random
59 62
              */
60 63
             /** @var resource|bool $fp */
61 64
             $fp = fopen('/dev/urandom', 'rb');
62
-            if (is_resource($fp)) {
65
+            if (is_resource($fp))
66
+            {
63 67
                 /** @var array<string, int> $st */
64 68
                 $st = fstat($fp);
65
-                if (($st['mode'] & 0170000) !== 020000) {
69
+                if (($st['mode'] & 0170000) !== 020000)
70
+                {
66 71
                     fclose($fp);
67 72
                     $fp = false;
68 73
                 }
69 74
             }
70 75
 
71
-            if (is_resource($fp)) {
76
+            if (is_resource($fp))
77
+            {
72 78
                 /**
73 79
                  * stream_set_read_buffer() does not exist in HHVM
74 80
                  *
@@ -77,25 +83,31 @@  discard block
 block discarded – undo
77 83
                  *
78 84
                  * stream_set_read_buffer returns 0 on success
79 85
                  */
80
-                if (is_callable('stream_set_read_buffer')) {
86
+                if (is_callable('stream_set_read_buffer'))
87
+                {
81 88
                     stream_set_read_buffer($fp, RANDOM_COMPAT_READ_BUFFER);
82 89
                 }
83
-                if (is_callable('stream_set_chunk_size')) {
90
+                if (is_callable('stream_set_chunk_size'))
91
+                {
84 92
                     stream_set_chunk_size($fp, RANDOM_COMPAT_READ_BUFFER);
85 93
                 }
86 94
             }
87 95
         }
88 96
 
89
-        try {
97
+        try
98
+        {
90 99
             /** @var int $bytes */
91 100
             $bytes = RandomCompat_intval($bytes);
92
-        } catch (TypeError $ex) {
101
+        }
102
+        catch (TypeError $ex)
103
+        {
93 104
             throw new TypeError(
94 105
                 'random_bytes(): $bytes must be an integer'
95 106
             );
96 107
         }
97 108
 
98
-        if ($bytes < 1) {
109
+        if ($bytes < 1)
110
+        {
99 111
             throw new Error(
100 112
                 'Length must be greater than 0'
101 113
             );
@@ -108,7 +120,8 @@  discard block
 block discarded – undo
108 120
          * if (empty($fp)) line is logic that should only be run once per
109 121
          * page load.
110 122
          */
111
-        if (is_resource($fp)) {
123
+        if (is_resource($fp))
124
+        {
112 125
             /**
113 126
              * @var int
114 127
              */
@@ -127,8 +140,10 @@  discard block
 block discarded – undo
127 140
                  * @var string|bool
128 141
                  */
129 142
                 $read = fread($fp, $remaining);
130
-                if (!is_string($read)) {
131
-                    if ($read === false) {
143
+                if (!is_string($read))
144
+                {
145
+                    if ($read === false)
146
+                    {
132 147
                         /**
133 148
                          * We cannot safely read from the file. Exit the
134 149
                          * do-while loop and trigger the exception condition
@@ -152,8 +167,10 @@  discard block
 block discarded – undo
152 167
             /**
153 168
              * Is our result valid?
154 169
              */
155
-            if (is_string($buf)) {
156
-                if (RandomCompat_strlen($buf) === $bytes) {
170
+            if (is_string($buf))
171
+            {
172
+                if (RandomCompat_strlen($buf) === $bytes)
173
+                {
157 174
                     /**
158 175
                      * Return our random entropy buffer here:
159 176
                      */
Please login to merge, or discard this patch.
Sources/random_compat/byte_safe_strings.php 1 patch
Braces   +35 added lines, -16 removed lines patch added patch discarded remove patch
@@ -26,7 +26,8 @@  discard block
 block discarded – undo
26 26
  * SOFTWARE.
27 27
  */
28 28
 
29
-if (!is_callable('RandomCompat_strlen')) {
29
+if (!is_callable('RandomCompat_strlen'))
30
+{
30 31
     if (
31 32
         defined('MB_OVERLOAD_STRING')
32 33
             &&
@@ -46,7 +47,8 @@  discard block
 block discarded – undo
46 47
          */
47 48
         function RandomCompat_strlen($binary_string)
48 49
         {
49
-            if (!is_string($binary_string)) {
50
+            if (!is_string($binary_string))
51
+            {
50 52
                 throw new TypeError(
51 53
                     'RandomCompat_strlen() expects a string'
52 54
                 );
@@ -55,7 +57,9 @@  discard block
 block discarded – undo
55 57
             return (int) mb_strlen($binary_string, '8bit');
56 58
         }
57 59
 
58
-    } else {
60
+    }
61
+    else
62
+    {
59 63
         /**
60 64
          * strlen() implementation that isn't brittle to mbstring.func_overload
61 65
          *
@@ -69,7 +73,8 @@  discard block
 block discarded – undo
69 73
          */
70 74
         function RandomCompat_strlen($binary_string)
71 75
         {
72
-            if (!is_string($binary_string)) {
76
+            if (!is_string($binary_string))
77
+            {
73 78
                 throw new TypeError(
74 79
                     'RandomCompat_strlen() expects a string'
75 80
                 );
@@ -79,7 +84,8 @@  discard block
 block discarded – undo
79 84
     }
80 85
 }
81 86
 
82
-if (!is_callable('RandomCompat_substr')) {
87
+if (!is_callable('RandomCompat_substr'))
88
+{
83 89
 
84 90
     if (
85 91
         defined('MB_OVERLOAD_STRING')
@@ -102,36 +108,43 @@  discard block
 block discarded – undo
102 108
          */
103 109
         function RandomCompat_substr($binary_string, $start, $length = null)
104 110
         {
105
-            if (!is_string($binary_string)) {
111
+            if (!is_string($binary_string))
112
+            {
106 113
                 throw new TypeError(
107 114
                     'RandomCompat_substr(): First argument should be a string'
108 115
                 );
109 116
             }
110 117
 
111
-            if (!is_int($start)) {
118
+            if (!is_int($start))
119
+            {
112 120
                 throw new TypeError(
113 121
                     'RandomCompat_substr(): Second argument should be an integer'
114 122
                 );
115 123
             }
116 124
 
117
-            if ($length === null) {
125
+            if ($length === null)
126
+            {
118 127
                 /**
119 128
                  * mb_substr($str, 0, NULL, '8bit') returns an empty string on
120 129
                  * PHP 5.3, so we have to find the length ourselves.
121 130
                  */
122 131
                 /** @var int $length */
123 132
                 $length = RandomCompat_strlen($binary_string) - $start;
124
-            } elseif (!is_int($length)) {
133
+            }
134
+            elseif (!is_int($length))
135
+            {
125 136
                 throw new TypeError(
126 137
                     'RandomCompat_substr(): Third argument should be an integer, or omitted'
127 138
                 );
128 139
             }
129 140
 
130 141
             // Consistency with PHP's behavior
131
-            if ($start === RandomCompat_strlen($binary_string) && $length === 0) {
142
+            if ($start === RandomCompat_strlen($binary_string) && $length === 0)
143
+            {
132 144
                 return '';
133 145
             }
134
-            if ($start > RandomCompat_strlen($binary_string)) {
146
+            if ($start > RandomCompat_strlen($binary_string))
147
+            {
135 148
                 return '';
136 149
             }
137 150
 
@@ -143,7 +156,9 @@  discard block
 block discarded – undo
143 156
             );
144 157
         }
145 158
 
146
-    } else {
159
+    }
160
+    else
161
+    {
147 162
 
148 163
         /**
149 164
          * substr() implementation that isn't brittle to mbstring.func_overload
@@ -160,20 +175,24 @@  discard block
 block discarded – undo
160 175
          */
161 176
         function RandomCompat_substr($binary_string, $start, $length = null)
162 177
         {
163
-            if (!is_string($binary_string)) {
178
+            if (!is_string($binary_string))
179
+            {
164 180
                 throw new TypeError(
165 181
                     'RandomCompat_substr(): First argument should be a string'
166 182
                 );
167 183
             }
168 184
 
169
-            if (!is_int($start)) {
185
+            if (!is_int($start))
186
+            {
170 187
                 throw new TypeError(
171 188
                     'RandomCompat_substr(): Second argument should be an integer'
172 189
                 );
173 190
             }
174 191
 
175
-            if ($length !== null) {
176
-                if (!is_int($length)) {
192
+            if ($length !== null)
193
+            {
194
+                if (!is_int($length))
195
+                {
177 196
                     throw new TypeError(
178 197
                         'RandomCompat_substr(): Third argument should be an integer, or omitted'
179 198
                     );
Please login to merge, or discard this patch.
Sources/random_compat/random_int.php 1 patch
Braces   +29 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,6 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!is_callable('random_int')) {
3
+if (!is_callable('random_int'))
4
+{
4 5
     /**
5 6
      * Random_* Compatibility Library
6 7
      * for using the new PHP 7 random_* API in PHP 5 projects
@@ -50,19 +51,25 @@  discard block
 block discarded – undo
50 51
          * through.
51 52
          */
52 53
 
53
-        try {
54
+        try
55
+        {
54 56
             /** @var int $min */
55 57
             $min = RandomCompat_intval($min);
56
-        } catch (TypeError $ex) {
58
+        }
59
+        catch (TypeError $ex)
60
+        {
57 61
             throw new TypeError(
58 62
                 'random_int(): $min must be an integer'
59 63
             );
60 64
         }
61 65
 
62
-        try {
66
+        try
67
+        {
63 68
             /** @var int $max */
64 69
             $max = RandomCompat_intval($max);
65
-        } catch (TypeError $ex) {
70
+        }
71
+        catch (TypeError $ex)
72
+        {
66 73
             throw new TypeError(
67 74
                 'random_int(): $max must be an integer'
68 75
             );
@@ -73,13 +80,15 @@  discard block
 block discarded – undo
73 80
          * let's validate the logic then we can move forward with generating random
74 81
          * integers along a given range.
75 82
          */
76
-        if ($min > $max) {
83
+        if ($min > $max)
84
+        {
77 85
             throw new Error(
78 86
                 'Minimum value must be less than or equal to the maximum value'
79 87
             );
80 88
         }
81 89
 
82
-        if ($max === $min) {
90
+        if ($max === $min)
91
+        {
83 92
             return (int) $min;
84 93
         }
85 94
 
@@ -110,7 +119,8 @@  discard block
 block discarded – undo
110 119
         /**
111 120
          * Test for integer overflow:
112 121
          */
113
-        if (!is_int($range)) {
122
+        if (!is_int($range))
123
+        {
114 124
 
115 125
             /**
116 126
              * Still safely calculate wider ranges.
@@ -127,14 +137,18 @@  discard block
 block discarded – undo
127 137
             /** @var int $mask */
128 138
             $mask = ~0;
129 139
 
130
-        } else {
140
+        }
141
+        else
142
+        {
131 143
 
132 144
             /**
133 145
              * $bits is effectively ceil(log($range, 2)) without dealing with
134 146
              * type juggling
135 147
              */
136
-            while ($range > 0) {
137
-                if ($bits % 8 === 0) {
148
+            while ($range > 0)
149
+            {
150
+                if ($bits % 8 === 0)
151
+                {
138 152
                     ++$bytes;
139 153
                 }
140 154
                 ++$bits;
@@ -157,7 +171,8 @@  discard block
 block discarded – undo
157 171
              * The rejection probability is at most 0.5, so this corresponds
158 172
              * to a failure probability of 2^-128 for a working RNG
159 173
              */
160
-            if ($attempts > 128) {
174
+            if ($attempts > 128)
175
+            {
161 176
                 throw new Exception(
162 177
                     'random_int: RNG is broken - too many rejections'
163 178
                 );
@@ -179,7 +194,8 @@  discard block
 block discarded – undo
179 194
              *   204631455
180 195
              */
181 196
             $val &= 0;
182
-            for ($i = 0; $i < $bytes; ++$i) {
197
+            for ($i = 0; $i < $bytes; ++$i)
198
+            {
183 199
                 $val |= ord($randomByteString[$i]) << ($i * 8);
184 200
             }
185 201
             /** @var int $val */
Please login to merge, or discard this patch.