Passed
Push — master ( 84c1d9...4b5f27 )
by Michael
15:53 queued 12:17
created
include/JSON.php 2 patches
Indentation   +676 added lines, -676 removed lines patch added patch discarded remove patch
@@ -76,271 +76,271 @@  discard block
 block discarded – undo
76 76
  */
77 77
 class ServicesJSON
78 78
 {
79
-    /**
80
-     * constructs a new JSON instance
81
-     *
82
-     * @param int $use object behavior flags; combine with boolean-OR
83
-     *
84
-     *                           possible values:
85
-     *                           - SERVICES_JSON_LOOSE_TYPE:  loose typing.
86
-     *                                   "{...}" syntax creates associative arrays
87
-     *                                   instead of objects in decode().
88
-     *                           - SERVICES_JSON_SUPPRESS_ERRORS:  error suppression.
89
-     *                                   Values which can't be encoded (e.g. resources)
90
-     *                                   appear as NULL instead of throwing errors.
91
-     *                                   By default, a deeply-nested resource will
92
-     *                                   bubble up with an error, so all return values
93
-     *                                   from encode() should be checked with isError()
94
-     */
95
-    public function __construct($use = 0)
96
-    {
97
-        $this->use = $use;
98
-    }
99
-
100
-    /**
101
-     * convert a string from one UTF-16 char to one UTF-8 char
102
-     *
103
-     * Normally should be handled by mb_convert_encoding, but
104
-     * provides a slower PHP-only method for installations
105
-     * that lack the multibye string extension.
106
-     *
107
-     * @param string $utf16 UTF-16 character
108
-     * @return   string  UTF-8 character
109
-     */
110
-    public function utf162utf8($utf16): string
111
-    {
112
-        // oh please oh please oh please oh please oh please
113
-        if (function_exists('mb_convert_encoding')) {
114
-            return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
115
-        }
116
-
117
-        $bytes = (ord($utf16[0]) << 8) | ord($utf16[1]);
118
-
119
-        switch (true) {
120
-            case ((0x7F & $bytes) == $bytes):
121
-                // this case should never be reached, because we are in ASCII range
122
-                // see: https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
123
-                return chr(0x7F & $bytes);
124
-            case (0x07FF & $bytes) == $bytes:
125
-                // return a 2-byte UTF-8 character
126
-                // see: https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
127
-                return chr(0xC0 | (($bytes >> 6) & 0x1F)) . chr(0x80 | ($bytes & 0x3F));
128
-            case (0xFFFF & $bytes) == $bytes:
129
-                // return a 3-byte UTF-8 character
130
-                // see: https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
131
-                return chr(0xE0 | (($bytes >> 12) & 0x0F)) . chr(0x80 | (($bytes >> 6) & 0x3F)) . chr(0x80 | ($bytes & 0x3F));
132
-        }
133
-
134
-        // ignoring UTF-32 for now, sorry
135
-        return '';
136
-    }
137
-
138
-    /**
139
-     * convert a string from one UTF-8 char to one UTF-16 char
140
-     *
141
-     * Normally should be handled by mb_convert_encoding, but
142
-     * provides a slower PHP-only method for installations
143
-     * that lack the multibye string extension.
144
-     *
145
-     * @param string $utf8 UTF-8 character
146
-     * @return   string  UTF-16 character
147
-     */
148
-    public function utf82utf16($utf8): string
149
-    {
150
-        // oh please oh please oh please oh please oh please
151
-        if (function_exists('mb_convert_encoding')) {
152
-            return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
153
-        }
154
-
155
-        switch (mb_strlen($utf8)) {
156
-            case 1:
157
-                // this case should never be reached, because we are in ASCII range
158
-                // see: https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
159
-                return $utf8;
160
-            case 2:
161
-                // return a UTF-16 character from a 2-byte UTF-8 char
162
-                // see: https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
163
-                return chr(0x07 & (ord($utf8[0]) >> 2)) . chr((0xC0 & (ord($utf8[0]) << 6)) | (0x3F & ord($utf8[1])));
164
-            case 3:
165
-                // return a UTF-16 character from a 3-byte UTF-8 char
166
-                // see: https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
167
-                return chr((0xF0 & (ord($utf8[0]) << 4)) | (0x0F & (ord($utf8[1]) >> 2))) . chr((0xC0 & (ord($utf8[1]) << 6)) | (0x7F & ord($utf8[2])));
168
-        }
169
-
170
-        // ignoring UTF-32 for now, sorry
171
-        return '';
172
-    }
173
-
174
-    /**
175
-     * encodes an arbitrary variable into JSON format (and sends JSON Header)
176
-     *
177
-     * @param mixed $var         any number, boolean, string, array, or object to be encoded.
178
-     *                           see argument 1 to ServicesJSON() above for array-parsing behavior.
179
-     *                           if var is a strng, note that encode() always expects it
180
-     *                           to be in ASCII or UTF-8 format!
181
-     *
182
-     * @return   mixed   JSON string representation of input var or an error if a problem occurs
183
-     */
184
-    public function encode($var)
185
-    {
186
-        header('Document-type: application/json');
187
-
188
-        return $this->encodeUnsafe($var);
189
-    }
190
-
191
-    /**
192
-     * encodes an arbitrary variable into JSON format without JSON Header - warning - may allow CSS!!!!)
193
-     *
194
-     * @param mixed $var         any number, boolean, string, array, or object to be encoded.
195
-     *                           see argument 1 to ServicesJSON() above for array-parsing behavior.
196
-     *                           if var is a strng, note that encode() always expects it
197
-     *                           to be in ASCII or UTF-8 format!
198
-     *
199
-     * @return   mixed   JSON string representation of input var or an error if a problem occurs
200
-     */
201
-    public function encodeUnsafe($var)
202
-    {
203
-        // see bug #16908 - regarding numeric locale printing
204
-        $lc = setlocale(LC_NUMERIC, 0);
205
-        setlocale(LC_NUMERIC, 'C');
206
-        $ret = $this->_encode($var);
207
-        setlocale(LC_NUMERIC, $lc);
208
-
209
-        return $ret;
210
-    }
211
-
212
-    /**
213
-     * PRIVATE CODE that does the work of encodes an arbitrary variable into JSON format
214
-     *
215
-     * @param mixed $var         any number, boolean, string, array, or object to be encoded.
216
-     *                           see argument 1 to ServicesJSON() above for array-parsing behavior.
217
-     *                           if var is a strng, note that encode() always expects it
218
-     *                           to be in ASCII or UTF-8 format!
219
-     *
220
-     * @return   mixed   JSON string representation of input var or an error if a problem occurs
221
-     */
222
-    public function _encode($var)
223
-    {
224
-        switch (gettype($var)) {
225
-            case 'boolean':
226
-                return $var ? 'true' : 'false';
227
-            case 'NULL':
228
-                return 'null';
229
-            case 'integer':
230
-                return (int)$var;
231
-            case 'double':
232
-            case 'float':
233
-                return (float)$var;
234
-            case 'string':
235
-                // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
236
-                $ascii      = '';
237
-                $strlen_var = mb_strlen($var);
238
-
239
-                /*
79
+	/**
80
+	 * constructs a new JSON instance
81
+	 *
82
+	 * @param int $use object behavior flags; combine with boolean-OR
83
+	 *
84
+	 *                           possible values:
85
+	 *                           - SERVICES_JSON_LOOSE_TYPE:  loose typing.
86
+	 *                                   "{...}" syntax creates associative arrays
87
+	 *                                   instead of objects in decode().
88
+	 *                           - SERVICES_JSON_SUPPRESS_ERRORS:  error suppression.
89
+	 *                                   Values which can't be encoded (e.g. resources)
90
+	 *                                   appear as NULL instead of throwing errors.
91
+	 *                                   By default, a deeply-nested resource will
92
+	 *                                   bubble up with an error, so all return values
93
+	 *                                   from encode() should be checked with isError()
94
+	 */
95
+	public function __construct($use = 0)
96
+	{
97
+		$this->use = $use;
98
+	}
99
+
100
+	/**
101
+	 * convert a string from one UTF-16 char to one UTF-8 char
102
+	 *
103
+	 * Normally should be handled by mb_convert_encoding, but
104
+	 * provides a slower PHP-only method for installations
105
+	 * that lack the multibye string extension.
106
+	 *
107
+	 * @param string $utf16 UTF-16 character
108
+	 * @return   string  UTF-8 character
109
+	 */
110
+	public function utf162utf8($utf16): string
111
+	{
112
+		// oh please oh please oh please oh please oh please
113
+		if (function_exists('mb_convert_encoding')) {
114
+			return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
115
+		}
116
+
117
+		$bytes = (ord($utf16[0]) << 8) | ord($utf16[1]);
118
+
119
+		switch (true) {
120
+			case ((0x7F & $bytes) == $bytes):
121
+				// this case should never be reached, because we are in ASCII range
122
+				// see: https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
123
+				return chr(0x7F & $bytes);
124
+			case (0x07FF & $bytes) == $bytes:
125
+				// return a 2-byte UTF-8 character
126
+				// see: https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
127
+				return chr(0xC0 | (($bytes >> 6) & 0x1F)) . chr(0x80 | ($bytes & 0x3F));
128
+			case (0xFFFF & $bytes) == $bytes:
129
+				// return a 3-byte UTF-8 character
130
+				// see: https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
131
+				return chr(0xE0 | (($bytes >> 12) & 0x0F)) . chr(0x80 | (($bytes >> 6) & 0x3F)) . chr(0x80 | ($bytes & 0x3F));
132
+		}
133
+
134
+		// ignoring UTF-32 for now, sorry
135
+		return '';
136
+	}
137
+
138
+	/**
139
+	 * convert a string from one UTF-8 char to one UTF-16 char
140
+	 *
141
+	 * Normally should be handled by mb_convert_encoding, but
142
+	 * provides a slower PHP-only method for installations
143
+	 * that lack the multibye string extension.
144
+	 *
145
+	 * @param string $utf8 UTF-8 character
146
+	 * @return   string  UTF-16 character
147
+	 */
148
+	public function utf82utf16($utf8): string
149
+	{
150
+		// oh please oh please oh please oh please oh please
151
+		if (function_exists('mb_convert_encoding')) {
152
+			return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
153
+		}
154
+
155
+		switch (mb_strlen($utf8)) {
156
+			case 1:
157
+				// this case should never be reached, because we are in ASCII range
158
+				// see: https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
159
+				return $utf8;
160
+			case 2:
161
+				// return a UTF-16 character from a 2-byte UTF-8 char
162
+				// see: https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
163
+				return chr(0x07 & (ord($utf8[0]) >> 2)) . chr((0xC0 & (ord($utf8[0]) << 6)) | (0x3F & ord($utf8[1])));
164
+			case 3:
165
+				// return a UTF-16 character from a 3-byte UTF-8 char
166
+				// see: https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
167
+				return chr((0xF0 & (ord($utf8[0]) << 4)) | (0x0F & (ord($utf8[1]) >> 2))) . chr((0xC0 & (ord($utf8[1]) << 6)) | (0x7F & ord($utf8[2])));
168
+		}
169
+
170
+		// ignoring UTF-32 for now, sorry
171
+		return '';
172
+	}
173
+
174
+	/**
175
+	 * encodes an arbitrary variable into JSON format (and sends JSON Header)
176
+	 *
177
+	 * @param mixed $var         any number, boolean, string, array, or object to be encoded.
178
+	 *                           see argument 1 to ServicesJSON() above for array-parsing behavior.
179
+	 *                           if var is a strng, note that encode() always expects it
180
+	 *                           to be in ASCII or UTF-8 format!
181
+	 *
182
+	 * @return   mixed   JSON string representation of input var or an error if a problem occurs
183
+	 */
184
+	public function encode($var)
185
+	{
186
+		header('Document-type: application/json');
187
+
188
+		return $this->encodeUnsafe($var);
189
+	}
190
+
191
+	/**
192
+	 * encodes an arbitrary variable into JSON format without JSON Header - warning - may allow CSS!!!!)
193
+	 *
194
+	 * @param mixed $var         any number, boolean, string, array, or object to be encoded.
195
+	 *                           see argument 1 to ServicesJSON() above for array-parsing behavior.
196
+	 *                           if var is a strng, note that encode() always expects it
197
+	 *                           to be in ASCII or UTF-8 format!
198
+	 *
199
+	 * @return   mixed   JSON string representation of input var or an error if a problem occurs
200
+	 */
201
+	public function encodeUnsafe($var)
202
+	{
203
+		// see bug #16908 - regarding numeric locale printing
204
+		$lc = setlocale(LC_NUMERIC, 0);
205
+		setlocale(LC_NUMERIC, 'C');
206
+		$ret = $this->_encode($var);
207
+		setlocale(LC_NUMERIC, $lc);
208
+
209
+		return $ret;
210
+	}
211
+
212
+	/**
213
+	 * PRIVATE CODE that does the work of encodes an arbitrary variable into JSON format
214
+	 *
215
+	 * @param mixed $var         any number, boolean, string, array, or object to be encoded.
216
+	 *                           see argument 1 to ServicesJSON() above for array-parsing behavior.
217
+	 *                           if var is a strng, note that encode() always expects it
218
+	 *                           to be in ASCII or UTF-8 format!
219
+	 *
220
+	 * @return   mixed   JSON string representation of input var or an error if a problem occurs
221
+	 */
222
+	public function _encode($var)
223
+	{
224
+		switch (gettype($var)) {
225
+			case 'boolean':
226
+				return $var ? 'true' : 'false';
227
+			case 'NULL':
228
+				return 'null';
229
+			case 'integer':
230
+				return (int)$var;
231
+			case 'double':
232
+			case 'float':
233
+				return (float)$var;
234
+			case 'string':
235
+				// STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
236
+				$ascii      = '';
237
+				$strlen_var = mb_strlen($var);
238
+
239
+				/*
240 240
                  * Iterate over every character in the string,
241 241
                  * escaping with a slash or encoding to UTF-8 where necessary
242 242
                  */
243
-                for ($c = 0; $c < $strlen_var; ++$c) {
244
-                    $ord_var_c = ord($var[$c]);
245
-
246
-                    switch (true) {
247
-                        case 0x08 == $ord_var_c:
248
-                            $ascii .= '\b';
249
-                            break;
250
-                        case 0x09 == $ord_var_c:
251
-                            $ascii .= '\t';
252
-                            break;
253
-                        case 0x0A == $ord_var_c:
254
-                            $ascii .= '\n';
255
-                            break;
256
-                        case 0x0C == $ord_var_c:
257
-                            $ascii .= '\f';
258
-                            break;
259
-                        case 0x0D == $ord_var_c:
260
-                            $ascii .= '\r';
261
-                            break;
262
-                        case 0x22 == $ord_var_c:
263
-                        case 0x2F == $ord_var_c:
264
-                        case 0x5C == $ord_var_c:
265
-                            // double quote, slash, slosh
266
-                            $ascii .= '\\' . $var[$c];
267
-                            break;
268
-                        case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
269
-                            // characters U-00000000 - U-0000007F (same as ASCII)
270
-                            $ascii .= $var[$c];
271
-                            break;
272
-                        case (0xC0 == ($ord_var_c & 0xE0)):
273
-                            // characters U-00000080 - U-000007FF, mask 110SONGLIST
274
-                            // see https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
275
-                            if ($c + 1 >= $strlen_var) {
276
-                                ++$c;
277
-                                $ascii .= '?';
278
-                                break;
279
-                            }
280
-
281
-                            $char = pack('C*', $ord_var_c, ord($var[$c + 1]));
282
-                            ++$c;
283
-                            $utf16 = $this->utf82utf16($char);
284
-                            $ascii .= sprintf('\u%04s', bin2hex($utf16));
285
-                            break;
286
-                        case (0xE0 == ($ord_var_c & 0xF0)):
287
-                            if ($c + 2 >= $strlen_var) {
288
-                                $c     += 2;
289
-                                $ascii .= '?';
290
-                                break;
291
-                            }
292
-                            // characters U-00000800 - U-0000FFFF, mask 1110XXXX
293
-                            // see https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
294
-                            $char  = pack('C*', $ord_var_c, @ord($var[$c + 1]), @ord($var[$c + 2]));
295
-                            $c     += 2;
296
-                            $utf16 = $this->utf82utf16($char);
297
-                            $ascii .= sprintf('\u%04s', bin2hex($utf16));
298
-                            break;
299
-                        case (0xF0 == ($ord_var_c & 0xF8)):
300
-                            if ($c + 3 >= $strlen_var) {
301
-                                $c     += 3;
302
-                                $ascii .= '?';
303
-                                break;
304
-                            }
305
-                            // characters U-00010000 - U-001FFFFF, mask 11110XXX
306
-                            // see https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
307
-                            $char  = pack('C*', $ord_var_c, ord($var[$c + 1]), ord($var[$c + 2]), ord($var[$c + 3]));
308
-                            $c     += 3;
309
-                            $utf16 = $this->utf82utf16($char);
310
-                            $ascii .= sprintf('\u%04s', bin2hex($utf16));
311
-                            break;
312
-                        case (0xF8 == ($ord_var_c & 0xFC)):
313
-                            // characters U-00200000 - U-03FFFFFF, mask 111110XX
314
-                            // see https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
315
-                            if ($c + 4 >= $strlen_var) {
316
-                                $c     += 4;
317
-                                $ascii .= '?';
318
-                                break;
319
-                            }
320
-                            $char  = pack('C*', $ord_var_c, ord($var[$c + 1]), ord($var[$c + 2]), ord($var[$c + 3]), ord($var[$c + 4]));
321
-                            $c     += 4;
322
-                            $utf16 = $this->utf82utf16($char);
323
-                            $ascii .= sprintf('\u%04s', bin2hex($utf16));
324
-                            break;
325
-                        case (0xFC == ($ord_var_c & 0xFE)):
326
-                            if ($c + 5 >= $strlen_var) {
327
-                                $c     += 5;
328
-                                $ascii .= '?';
329
-                                break;
330
-                            }
331
-                            // characters U-04000000 - U-7FFFFFFF, mask 1111110X
332
-                            // see https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
333
-                            $char  = pack('C*', $ord_var_c, ord($var[$c + 1]), ord($var[$c + 2]), ord($var[$c + 3]), ord($var[$c + 4]), ord($var[$c + 5]));
334
-                            $c     += 5;
335
-                            $utf16 = $this->utf82utf16($char);
336
-                            $ascii .= sprintf('\u%04s', bin2hex($utf16));
337
-                            break;
338
-                    }
339
-                }
340
-
341
-                return '"' . $ascii . '"';
342
-            case 'array':
343
-                /*
243
+				for ($c = 0; $c < $strlen_var; ++$c) {
244
+					$ord_var_c = ord($var[$c]);
245
+
246
+					switch (true) {
247
+						case 0x08 == $ord_var_c:
248
+							$ascii .= '\b';
249
+							break;
250
+						case 0x09 == $ord_var_c:
251
+							$ascii .= '\t';
252
+							break;
253
+						case 0x0A == $ord_var_c:
254
+							$ascii .= '\n';
255
+							break;
256
+						case 0x0C == $ord_var_c:
257
+							$ascii .= '\f';
258
+							break;
259
+						case 0x0D == $ord_var_c:
260
+							$ascii .= '\r';
261
+							break;
262
+						case 0x22 == $ord_var_c:
263
+						case 0x2F == $ord_var_c:
264
+						case 0x5C == $ord_var_c:
265
+							// double quote, slash, slosh
266
+							$ascii .= '\\' . $var[$c];
267
+							break;
268
+						case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
269
+							// characters U-00000000 - U-0000007F (same as ASCII)
270
+							$ascii .= $var[$c];
271
+							break;
272
+						case (0xC0 == ($ord_var_c & 0xE0)):
273
+							// characters U-00000080 - U-000007FF, mask 110SONGLIST
274
+							// see https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
275
+							if ($c + 1 >= $strlen_var) {
276
+								++$c;
277
+								$ascii .= '?';
278
+								break;
279
+							}
280
+
281
+							$char = pack('C*', $ord_var_c, ord($var[$c + 1]));
282
+							++$c;
283
+							$utf16 = $this->utf82utf16($char);
284
+							$ascii .= sprintf('\u%04s', bin2hex($utf16));
285
+							break;
286
+						case (0xE0 == ($ord_var_c & 0xF0)):
287
+							if ($c + 2 >= $strlen_var) {
288
+								$c     += 2;
289
+								$ascii .= '?';
290
+								break;
291
+							}
292
+							// characters U-00000800 - U-0000FFFF, mask 1110XXXX
293
+							// see https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
294
+							$char  = pack('C*', $ord_var_c, @ord($var[$c + 1]), @ord($var[$c + 2]));
295
+							$c     += 2;
296
+							$utf16 = $this->utf82utf16($char);
297
+							$ascii .= sprintf('\u%04s', bin2hex($utf16));
298
+							break;
299
+						case (0xF0 == ($ord_var_c & 0xF8)):
300
+							if ($c + 3 >= $strlen_var) {
301
+								$c     += 3;
302
+								$ascii .= '?';
303
+								break;
304
+							}
305
+							// characters U-00010000 - U-001FFFFF, mask 11110XXX
306
+							// see https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
307
+							$char  = pack('C*', $ord_var_c, ord($var[$c + 1]), ord($var[$c + 2]), ord($var[$c + 3]));
308
+							$c     += 3;
309
+							$utf16 = $this->utf82utf16($char);
310
+							$ascii .= sprintf('\u%04s', bin2hex($utf16));
311
+							break;
312
+						case (0xF8 == ($ord_var_c & 0xFC)):
313
+							// characters U-00200000 - U-03FFFFFF, mask 111110XX
314
+							// see https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
315
+							if ($c + 4 >= $strlen_var) {
316
+								$c     += 4;
317
+								$ascii .= '?';
318
+								break;
319
+							}
320
+							$char  = pack('C*', $ord_var_c, ord($var[$c + 1]), ord($var[$c + 2]), ord($var[$c + 3]), ord($var[$c + 4]));
321
+							$c     += 4;
322
+							$utf16 = $this->utf82utf16($char);
323
+							$ascii .= sprintf('\u%04s', bin2hex($utf16));
324
+							break;
325
+						case (0xFC == ($ord_var_c & 0xFE)):
326
+							if ($c + 5 >= $strlen_var) {
327
+								$c     += 5;
328
+								$ascii .= '?';
329
+								break;
330
+							}
331
+							// characters U-04000000 - U-7FFFFFFF, mask 1111110X
332
+							// see https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
333
+							$char  = pack('C*', $ord_var_c, ord($var[$c + 1]), ord($var[$c + 2]), ord($var[$c + 3]), ord($var[$c + 4]), ord($var[$c + 5]));
334
+							$c     += 5;
335
+							$utf16 = $this->utf82utf16($char);
336
+							$ascii .= sprintf('\u%04s', bin2hex($utf16));
337
+							break;
338
+					}
339
+				}
340
+
341
+				return '"' . $ascii . '"';
342
+			case 'array':
343
+				/*
344 344
                  * As per JSON spec if any array key is not an integer
345 345
                  * we must treat the the whole array as an object. We
346 346
                  * also try to catch a sparsely populated associative
@@ -358,422 +358,422 @@  discard block
 block discarded – undo
358 358
                  * bracket notation.
359 359
                  */
360 360
 
361
-                // treat as a JSON object
362
-                if (is_array($var) && count($var) && (array_keys($var) !== range(0, count($var) - 1))) {
363
-                    $properties = array_map([$this, 'name_value'], array_keys($var), array_values($var));
364
-
365
-                    foreach ($properties as $property) {
366
-                        if ($this->isError($property)) {
367
-                            return $property;
368
-                        }
369
-                    }
370
-
371
-                    return '{' . implode(',', $properties) . '}';
372
-                }
373
-
374
-                // treat it like a regular array
375
-                $elements = array_map([$this, '_encode'], $var);
376
-
377
-                foreach ($elements as $element) {
378
-                    if ($this->isError($element)) {
379
-                        return $element;
380
-                    }
381
-                }
382
-
383
-                return '[' . implode(',', $elements) . ']';
384
-            case 'object':
385
-                $vars = get_object_vars($var);
386
-
387
-                $properties = array_map([$this, 'name_value'], array_keys($vars), array_values($vars));
388
-
389
-                foreach ($properties as $property) {
390
-                    if ($this->isError($property)) {
391
-                        return $property;
392
-                    }
393
-                }
394
-
395
-                return '{' . implode(',', $properties) . '}';
396
-            default:
397
-                return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS) ? 'null' : new ServicesJSON_Error(gettype($var) . ' can not be encoded as JSON string');
398
-        }
399
-    }
400
-
401
-    /**
402
-     * array-walking function for use in generating JSON-formatted name-value pairs
403
-     *
404
-     * @param string $name  name of key to use
405
-     * @param mixed  $value reference to an array element to be encoded
406
-     *
407
-     * @return   string  JSON-formatted name-value pair, like '"name":value'
408
-     */
409
-    public function name_value($name, $value)
410
-    {
411
-        $encoded_value = $this->_encode($value);
412
-
413
-        if ($this->isError($encoded_value)) {
414
-            return $encoded_value;
415
-        }
416
-
417
-        return $this->_encode((string)$name) . ':' . $encoded_value;
418
-    }
419
-
420
-    /**
421
-     * reduce a string by removing leading and trailing comments and whitespace
422
-     *
423
-     * @param string $str string value to strip of comments and whitespace
424
-     *
425
-     * @return   string  string value stripped of comments and whitespace
426
-     */
427
-    public function reduce_string($str): string
428
-    {
429
-        $str = preg_replace(
430
-            [
431
-                // eliminate single line comments in '// ...' form
432
-                '#^\s*//(.+)$#m',
433
-
434
-                // eliminate multi-line comments in '/* ... */' form, at start of string
435
-                '#^\s*/\*(.+)\*/#Us',
436
-
437
-                // eliminate multi-line comments in '/* ... */' form, at end of string
438
-                '#/\*(.+)\*/\s*$#Us',
439
-            ],
440
-            '',
441
-            $str
442
-        );
443
-
444
-        // eliminate extraneous space
445
-        return trim($str);
446
-    }
447
-
448
-    /**
449
-     * decodes a JSON string into appropriate variable
450
-     *
451
-     * @param string $str JSON-formatted string
452
-     *
453
-     * @return   array|bool|float|int|\stdClass|string|void|null   number, boolean, string, array, or object
454
-     *                   corresponding to given JSON input string.
455
-     *                   See argument 1 to ServicesJSON() above for object-output behavior.
456
-     *                   Note that decode() always returns strings
457
-     *                   in ASCII or UTF-8 format!
458
-     */
459
-    public function decode($str)
460
-    {
461
-        $str = $this->reduce_string($str);
462
-
463
-        switch (mb_strtolower($str)) {
464
-            case 'true':
465
-                return true;
466
-            case 'false':
467
-                return false;
468
-            case 'null':
469
-                return null;
470
-            default:
471
-                $m = [];
472
-
473
-                if (is_numeric($str)) {
474
-                    // Lookie-loo, it's a number
475
-
476
-                    // This would work on its own, but I'm trying to be
477
-                    // good about returning integers where appropriate:
478
-                    // return (float)$str;
479
-
480
-                    // Return float or int, as appropriate
481
-                    return ((float)$str == (int)$str) ? (int)$str : (float)$str;
482
-                }
483
-
484
-                if (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
485
-                    // STRINGS RETURNED IN UTF-8 FORMAT
486
-                    $delim       = mb_substr($str, 0, 1);
487
-                    $chrs        = mb_substr($str, 1, -1);
488
-                    $utf8        = '';
489
-                    $strlen_chrs = mb_strlen($chrs);
490
-
491
-                    for ($c = 0; $c < $strlen_chrs; ++$c) {
492
-                        $substr_chrs_c_2 = mb_substr($chrs, $c, 2);
493
-                        $ord_chrs_c      = ord($chrs[$c]);
494
-
495
-                        switch (true) {
496
-                            case '\b' === $substr_chrs_c_2:
497
-                                $utf8 .= chr(0x08);
498
-                                ++$c;
499
-                                break;
500
-                            case '\t' === $substr_chrs_c_2:
501
-                                $utf8 .= chr(0x09);
502
-                                ++$c;
503
-                                break;
504
-                            case '\n' === $substr_chrs_c_2:
505
-                                $utf8 .= chr(0x0A);
506
-                                ++$c;
507
-                                break;
508
-                            case '\f' === $substr_chrs_c_2:
509
-                                $utf8 .= chr(0x0C);
510
-                                ++$c;
511
-                                break;
512
-                            case '\r' === $substr_chrs_c_2:
513
-                                $utf8 .= chr(0x0D);
514
-                                ++$c;
515
-                                break;
516
-                            case '\\"' === $substr_chrs_c_2:
517
-                            case '\\\'' === $substr_chrs_c_2:
518
-                            case '\\\\' === $substr_chrs_c_2:
519
-                            case '\\/' === $substr_chrs_c_2:
520
-                                if (('"' === $delim && '\\\'' !== $substr_chrs_c_2)
521
-                                    || ("'" === $delim && '\\"' !== $substr_chrs_c_2)) {
522
-                                    $utf8 .= $chrs[++$c];
523
-                                }
524
-                                break;
525
-                            case preg_match('/\\\u[0-9A-F]{4}/i', mb_substr($chrs, $c, 6)):
526
-                                // single, escaped unicode character
527
-                                $utf16 = chr(hexdec(mb_substr($chrs, $c + 2, 2))) . chr(hexdec(mb_substr($chrs, $c + 4, 2)));
528
-                                $utf8  .= $this->utf162utf8($utf16);
529
-                                $c     += 5;
530
-                                break;
531
-                            case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
532
-                                $utf8 .= $chrs[$c];
533
-                                break;
534
-                            case 0xC0 == ($ord_chrs_c & 0xE0):
535
-                                // characters U-00000080 - U-000007FF, mask 110SONGLIST
536
-                                //see https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
537
-                                $utf8 .= mb_substr($chrs, $c, 2);
538
-                                ++$c;
539
-                                break;
540
-                            case 0xE0 == ($ord_chrs_c & 0xF0):
541
-                                // characters U-00000800 - U-0000FFFF, mask 1110XXXX
542
-                                // see https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
543
-                                $utf8 .= mb_substr($chrs, $c, 3);
544
-                                $c    += 2;
545
-                                break;
546
-                            case 0xF0 == ($ord_chrs_c & 0xF8):
547
-                                // characters U-00010000 - U-001FFFFF, mask 11110XXX
548
-                                // see https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
549
-                                $utf8 .= mb_substr($chrs, $c, 4);
550
-                                $c    += 3;
551
-                                break;
552
-                            case 0xF8 == ($ord_chrs_c & 0xFC):
553
-                                // characters U-00200000 - U-03FFFFFF, mask 111110XX
554
-                                // see https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
555
-                                $utf8 .= mb_substr($chrs, $c, 5);
556
-                                $c    += 4;
557
-                                break;
558
-                            case 0xFC == ($ord_chrs_c & 0xFE):
559
-                                // characters U-04000000 - U-7FFFFFFF, mask 1111110X
560
-                                // see https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
561
-                                $utf8 .= mb_substr($chrs, $c, 6);
562
-                                $c    += 5;
563
-                                break;
564
-                        }
565
-                    }
566
-
567
-                    return $utf8;
568
-                }
569
-
570
-                if (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
571
-                    // array, or object notation
572
-
573
-                    if ('[' === $str[0]) {
574
-                        $stk = [SERVICES_JSON_IN_ARR];
575
-                        $arr = [];
576
-                    } elseif ($this->use & SERVICES_JSON_LOOSE_TYPE) {
577
-                            $stk = [SERVICES_JSON_IN_OBJ];
578
-                            $obj = [];
579
-                        } else {
580
-                            $stk = [SERVICES_JSON_IN_OBJ];
581
-                            $obj = new stdClass();
582
-                    }
583
-
584
-                    array_push(
585
-                        $stk,
586
-                        [
587
-                            'what'  => SERVICES_JSON_SLICE,
588
-                            'where' => 0,
589
-                            'delim' => false,
590
-                        ]
591
-                    );
592
-
593
-                    $chrs = mb_substr($str, 1, -1);
594
-                    $chrs = $this->reduce_string($chrs);
595
-
596
-                    if ('' == $chrs) {
597
-                        if (SERVICES_JSON_IN_ARR == reset($stk)) {
598
-                            return $arr;
599
-                        }
600
-
601
-                        return $obj;
602
-                    }
603
-
604
-                    //print("\nparsing {$chrs}\n");
605
-
606
-                    $strlen_chrs = mb_strlen($chrs);
607
-
608
-                    for ($c = 0; $c <= $strlen_chrs; ++$c) {
609
-                        $top             = end($stk);
610
-                        $substr_chrs_c_2 = mb_substr($chrs, $c, 2);
611
-
612
-                        if (($c == $strlen_chrs) || ((',' === $chrs[$c]) && (SERVICES_JSON_SLICE == $top['what']))) {
613
-                            // found a comma that is not inside a string, array, etc.,
614
-                            // OR we've reached the end of the character list
615
-                            $slice = mb_substr($chrs, $top['where'], $c - $top['where']);
616
-                            array_push($stk, ['what' => SERVICES_JSON_SLICE, 'where' => $c + 1, 'delim' => false]);
617
-                            //print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
618
-
619
-                            if (SERVICES_JSON_IN_ARR == reset($stk)) {
620
-                                // we are in an array, so just push an element onto the stack
621
-                                $arr[] = $this->decode($slice);
622
-                            } elseif (SERVICES_JSON_IN_OBJ == reset($stk)) {
623
-                                // we are in an object, so figure
624
-                                // out the property name and set an
625
-                                // element in an associative array,
626
-                                // for now
627
-                                $parts = [];
628
-
629
-                                if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
630
-                                    // "name":value pair
631
-                                    $key = $this->decode($parts[1]);
632
-                                    $val = $this->decode($parts[2]);
633
-
634
-                                    if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
635
-                                        $obj[$key] = $val;
636
-                                    } else {
637
-                                        $obj->$key = $val;
638
-                                    }
639
-                                } elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
640
-                                    // name:value pair, where name is unquoted
641
-                                    $key = $parts[1];
642
-                                    $val = $this->decode($parts[2]);
643
-
644
-                                    if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
645
-                                        $obj[$key] = $val;
646
-                                    } else {
647
-                                        $obj->$key = $val;
648
-                                    }
649
-                                }
650
-                            }
651
-                        } elseif ((('"' === $chrs[$c]) || ("'" === $chrs[$c])) && (SERVICES_JSON_IN_STR != $top['what'])) {
652
-                            // found a quote, and we are not inside a string
653
-                            array_push($stk, ['what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs[$c]]);
654
-                            //print("Found start of string at {$c}\n");
655
-                        } elseif (($chrs[$c] == $top['delim'])
656
-                                  && (SERVICES_JSON_IN_STR == $top['what'])
657
-                                  && (1 != (mb_strlen(mb_substr($chrs, 0, $c)) - mb_strlen(rtrim(mb_substr($chrs, 0, $c), '\\'))) % 2)) {
658
-                            // found a quote, we're in a string, and it's not escaped
659
-                            // we know that it's not escaped becase there is _not_ an
660
-                            // odd number of backslashes at the end of the string so far
661
-                            array_pop($stk);
662
-                            //print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
663
-                        } elseif (('[' === $chrs[$c])
664
-                                  && in_array($top['what'], [SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ], true)) {
665
-                            // found a left-bracket, and we are in an array, object, or slice
666
-                            array_push($stk, ['what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false]);
667
-                            //print("Found start of array at {$c}\n");
668
-                        } elseif ((']' === $chrs[$c]) && (SERVICES_JSON_IN_ARR == $top['what'])) {
669
-                            // found a right-bracket, and we're in an array
670
-                            array_pop($stk);
671
-                            //print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
672
-                        } elseif (('{' === $chrs[$c])
673
-                                  && in_array($top['what'], [SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ], true)) {
674
-                            // found a left-brace, and we are in an array, object, or slice
675
-                            array_push($stk, ['what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false]);
676
-                            //print("Found start of object at {$c}\n");
677
-                        } elseif (('}' === $chrs[$c]) && (SERVICES_JSON_IN_OBJ == $top['what'])) {
678
-                            // found a right-brace, and we're in an object
679
-                            array_pop($stk);
680
-                            //print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
681
-                        } elseif (('/*' === $substr_chrs_c_2)
682
-                                  && in_array($top['what'], [SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ], true)) {
683
-                            // found a comment start, and we are in an array, object, or slice
684
-                            array_push($stk, ['what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false]);
685
-                            ++$c;
686
-                            //print("Found start of comment at {$c}\n");
687
-                        } elseif (('*/' === $substr_chrs_c_2) && (SERVICES_JSON_IN_CMT == $top['what'])) {
688
-                            // found a comment end, and we're in one now
689
-                            array_pop($stk);
690
-                            ++$c;
691
-
692
-                            for ($i = $top['where']; $i <= $c; ++$i) {
693
-                                $chrs = substr_replace($chrs, ' ', $i, 1);
694
-                            }
695
-                            //print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
696
-                        }
697
-                    }
698
-
699
-                    if (SERVICES_JSON_IN_ARR == reset($stk)) {
700
-                        return $arr;
701
-                    }
702
-
703
-                    if (SERVICES_JSON_IN_OBJ == reset($stk)) {
704
-                        return $obj;
705
-                    }
706
-                }
707
-        }
708
-    }
709
-
710
-    /**
711
-     * @param      $data
712
-     * @param null $code
713
-     * @return bool
714
-     * @todo Ultimately, this should just call PEAR::isError()
715
-     */
716
-    public function isError($data, $code = null): bool
717
-    {
718
-        if (class_exists('pear')) {
719
-            return PEAR::isError($data, $code);
720
-        }
721
-
722
-        if (is_object($data)
723
-            && ($data instanceof \services_json_error
724
-                || $data instanceof \services_json_error)) {
725
-            return true;
726
-        }
727
-
728
-        return false;
729
-    }
361
+				// treat as a JSON object
362
+				if (is_array($var) && count($var) && (array_keys($var) !== range(0, count($var) - 1))) {
363
+					$properties = array_map([$this, 'name_value'], array_keys($var), array_values($var));
364
+
365
+					foreach ($properties as $property) {
366
+						if ($this->isError($property)) {
367
+							return $property;
368
+						}
369
+					}
370
+
371
+					return '{' . implode(',', $properties) . '}';
372
+				}
373
+
374
+				// treat it like a regular array
375
+				$elements = array_map([$this, '_encode'], $var);
376
+
377
+				foreach ($elements as $element) {
378
+					if ($this->isError($element)) {
379
+						return $element;
380
+					}
381
+				}
382
+
383
+				return '[' . implode(',', $elements) . ']';
384
+			case 'object':
385
+				$vars = get_object_vars($var);
386
+
387
+				$properties = array_map([$this, 'name_value'], array_keys($vars), array_values($vars));
388
+
389
+				foreach ($properties as $property) {
390
+					if ($this->isError($property)) {
391
+						return $property;
392
+					}
393
+				}
394
+
395
+				return '{' . implode(',', $properties) . '}';
396
+			default:
397
+				return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS) ? 'null' : new ServicesJSON_Error(gettype($var) . ' can not be encoded as JSON string');
398
+		}
399
+	}
400
+
401
+	/**
402
+	 * array-walking function for use in generating JSON-formatted name-value pairs
403
+	 *
404
+	 * @param string $name  name of key to use
405
+	 * @param mixed  $value reference to an array element to be encoded
406
+	 *
407
+	 * @return   string  JSON-formatted name-value pair, like '"name":value'
408
+	 */
409
+	public function name_value($name, $value)
410
+	{
411
+		$encoded_value = $this->_encode($value);
412
+
413
+		if ($this->isError($encoded_value)) {
414
+			return $encoded_value;
415
+		}
416
+
417
+		return $this->_encode((string)$name) . ':' . $encoded_value;
418
+	}
419
+
420
+	/**
421
+	 * reduce a string by removing leading and trailing comments and whitespace
422
+	 *
423
+	 * @param string $str string value to strip of comments and whitespace
424
+	 *
425
+	 * @return   string  string value stripped of comments and whitespace
426
+	 */
427
+	public function reduce_string($str): string
428
+	{
429
+		$str = preg_replace(
430
+			[
431
+				// eliminate single line comments in '// ...' form
432
+				'#^\s*//(.+)$#m',
433
+
434
+				// eliminate multi-line comments in '/* ... */' form, at start of string
435
+				'#^\s*/\*(.+)\*/#Us',
436
+
437
+				// eliminate multi-line comments in '/* ... */' form, at end of string
438
+				'#/\*(.+)\*/\s*$#Us',
439
+			],
440
+			'',
441
+			$str
442
+		);
443
+
444
+		// eliminate extraneous space
445
+		return trim($str);
446
+	}
447
+
448
+	/**
449
+	 * decodes a JSON string into appropriate variable
450
+	 *
451
+	 * @param string $str JSON-formatted string
452
+	 *
453
+	 * @return   array|bool|float|int|\stdClass|string|void|null   number, boolean, string, array, or object
454
+	 *                   corresponding to given JSON input string.
455
+	 *                   See argument 1 to ServicesJSON() above for object-output behavior.
456
+	 *                   Note that decode() always returns strings
457
+	 *                   in ASCII or UTF-8 format!
458
+	 */
459
+	public function decode($str)
460
+	{
461
+		$str = $this->reduce_string($str);
462
+
463
+		switch (mb_strtolower($str)) {
464
+			case 'true':
465
+				return true;
466
+			case 'false':
467
+				return false;
468
+			case 'null':
469
+				return null;
470
+			default:
471
+				$m = [];
472
+
473
+				if (is_numeric($str)) {
474
+					// Lookie-loo, it's a number
475
+
476
+					// This would work on its own, but I'm trying to be
477
+					// good about returning integers where appropriate:
478
+					// return (float)$str;
479
+
480
+					// Return float or int, as appropriate
481
+					return ((float)$str == (int)$str) ? (int)$str : (float)$str;
482
+				}
483
+
484
+				if (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
485
+					// STRINGS RETURNED IN UTF-8 FORMAT
486
+					$delim       = mb_substr($str, 0, 1);
487
+					$chrs        = mb_substr($str, 1, -1);
488
+					$utf8        = '';
489
+					$strlen_chrs = mb_strlen($chrs);
490
+
491
+					for ($c = 0; $c < $strlen_chrs; ++$c) {
492
+						$substr_chrs_c_2 = mb_substr($chrs, $c, 2);
493
+						$ord_chrs_c      = ord($chrs[$c]);
494
+
495
+						switch (true) {
496
+							case '\b' === $substr_chrs_c_2:
497
+								$utf8 .= chr(0x08);
498
+								++$c;
499
+								break;
500
+							case '\t' === $substr_chrs_c_2:
501
+								$utf8 .= chr(0x09);
502
+								++$c;
503
+								break;
504
+							case '\n' === $substr_chrs_c_2:
505
+								$utf8 .= chr(0x0A);
506
+								++$c;
507
+								break;
508
+							case '\f' === $substr_chrs_c_2:
509
+								$utf8 .= chr(0x0C);
510
+								++$c;
511
+								break;
512
+							case '\r' === $substr_chrs_c_2:
513
+								$utf8 .= chr(0x0D);
514
+								++$c;
515
+								break;
516
+							case '\\"' === $substr_chrs_c_2:
517
+							case '\\\'' === $substr_chrs_c_2:
518
+							case '\\\\' === $substr_chrs_c_2:
519
+							case '\\/' === $substr_chrs_c_2:
520
+								if (('"' === $delim && '\\\'' !== $substr_chrs_c_2)
521
+									|| ("'" === $delim && '\\"' !== $substr_chrs_c_2)) {
522
+									$utf8 .= $chrs[++$c];
523
+								}
524
+								break;
525
+							case preg_match('/\\\u[0-9A-F]{4}/i', mb_substr($chrs, $c, 6)):
526
+								// single, escaped unicode character
527
+								$utf16 = chr(hexdec(mb_substr($chrs, $c + 2, 2))) . chr(hexdec(mb_substr($chrs, $c + 4, 2)));
528
+								$utf8  .= $this->utf162utf8($utf16);
529
+								$c     += 5;
530
+								break;
531
+							case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
532
+								$utf8 .= $chrs[$c];
533
+								break;
534
+							case 0xC0 == ($ord_chrs_c & 0xE0):
535
+								// characters U-00000080 - U-000007FF, mask 110SONGLIST
536
+								//see https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
537
+								$utf8 .= mb_substr($chrs, $c, 2);
538
+								++$c;
539
+								break;
540
+							case 0xE0 == ($ord_chrs_c & 0xF0):
541
+								// characters U-00000800 - U-0000FFFF, mask 1110XXXX
542
+								// see https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
543
+								$utf8 .= mb_substr($chrs, $c, 3);
544
+								$c    += 2;
545
+								break;
546
+							case 0xF0 == ($ord_chrs_c & 0xF8):
547
+								// characters U-00010000 - U-001FFFFF, mask 11110XXX
548
+								// see https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
549
+								$utf8 .= mb_substr($chrs, $c, 4);
550
+								$c    += 3;
551
+								break;
552
+							case 0xF8 == ($ord_chrs_c & 0xFC):
553
+								// characters U-00200000 - U-03FFFFFF, mask 111110XX
554
+								// see https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
555
+								$utf8 .= mb_substr($chrs, $c, 5);
556
+								$c    += 4;
557
+								break;
558
+							case 0xFC == ($ord_chrs_c & 0xFE):
559
+								// characters U-04000000 - U-7FFFFFFF, mask 1111110X
560
+								// see https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
561
+								$utf8 .= mb_substr($chrs, $c, 6);
562
+								$c    += 5;
563
+								break;
564
+						}
565
+					}
566
+
567
+					return $utf8;
568
+				}
569
+
570
+				if (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
571
+					// array, or object notation
572
+
573
+					if ('[' === $str[0]) {
574
+						$stk = [SERVICES_JSON_IN_ARR];
575
+						$arr = [];
576
+					} elseif ($this->use & SERVICES_JSON_LOOSE_TYPE) {
577
+							$stk = [SERVICES_JSON_IN_OBJ];
578
+							$obj = [];
579
+						} else {
580
+							$stk = [SERVICES_JSON_IN_OBJ];
581
+							$obj = new stdClass();
582
+					}
583
+
584
+					array_push(
585
+						$stk,
586
+						[
587
+							'what'  => SERVICES_JSON_SLICE,
588
+							'where' => 0,
589
+							'delim' => false,
590
+						]
591
+					);
592
+
593
+					$chrs = mb_substr($str, 1, -1);
594
+					$chrs = $this->reduce_string($chrs);
595
+
596
+					if ('' == $chrs) {
597
+						if (SERVICES_JSON_IN_ARR == reset($stk)) {
598
+							return $arr;
599
+						}
600
+
601
+						return $obj;
602
+					}
603
+
604
+					//print("\nparsing {$chrs}\n");
605
+
606
+					$strlen_chrs = mb_strlen($chrs);
607
+
608
+					for ($c = 0; $c <= $strlen_chrs; ++$c) {
609
+						$top             = end($stk);
610
+						$substr_chrs_c_2 = mb_substr($chrs, $c, 2);
611
+
612
+						if (($c == $strlen_chrs) || ((',' === $chrs[$c]) && (SERVICES_JSON_SLICE == $top['what']))) {
613
+							// found a comma that is not inside a string, array, etc.,
614
+							// OR we've reached the end of the character list
615
+							$slice = mb_substr($chrs, $top['where'], $c - $top['where']);
616
+							array_push($stk, ['what' => SERVICES_JSON_SLICE, 'where' => $c + 1, 'delim' => false]);
617
+							//print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
618
+
619
+							if (SERVICES_JSON_IN_ARR == reset($stk)) {
620
+								// we are in an array, so just push an element onto the stack
621
+								$arr[] = $this->decode($slice);
622
+							} elseif (SERVICES_JSON_IN_OBJ == reset($stk)) {
623
+								// we are in an object, so figure
624
+								// out the property name and set an
625
+								// element in an associative array,
626
+								// for now
627
+								$parts = [];
628
+
629
+								if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
630
+									// "name":value pair
631
+									$key = $this->decode($parts[1]);
632
+									$val = $this->decode($parts[2]);
633
+
634
+									if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
635
+										$obj[$key] = $val;
636
+									} else {
637
+										$obj->$key = $val;
638
+									}
639
+								} elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
640
+									// name:value pair, where name is unquoted
641
+									$key = $parts[1];
642
+									$val = $this->decode($parts[2]);
643
+
644
+									if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
645
+										$obj[$key] = $val;
646
+									} else {
647
+										$obj->$key = $val;
648
+									}
649
+								}
650
+							}
651
+						} elseif ((('"' === $chrs[$c]) || ("'" === $chrs[$c])) && (SERVICES_JSON_IN_STR != $top['what'])) {
652
+							// found a quote, and we are not inside a string
653
+							array_push($stk, ['what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs[$c]]);
654
+							//print("Found start of string at {$c}\n");
655
+						} elseif (($chrs[$c] == $top['delim'])
656
+								  && (SERVICES_JSON_IN_STR == $top['what'])
657
+								  && (1 != (mb_strlen(mb_substr($chrs, 0, $c)) - mb_strlen(rtrim(mb_substr($chrs, 0, $c), '\\'))) % 2)) {
658
+							// found a quote, we're in a string, and it's not escaped
659
+							// we know that it's not escaped becase there is _not_ an
660
+							// odd number of backslashes at the end of the string so far
661
+							array_pop($stk);
662
+							//print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
663
+						} elseif (('[' === $chrs[$c])
664
+								  && in_array($top['what'], [SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ], true)) {
665
+							// found a left-bracket, and we are in an array, object, or slice
666
+							array_push($stk, ['what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false]);
667
+							//print("Found start of array at {$c}\n");
668
+						} elseif ((']' === $chrs[$c]) && (SERVICES_JSON_IN_ARR == $top['what'])) {
669
+							// found a right-bracket, and we're in an array
670
+							array_pop($stk);
671
+							//print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
672
+						} elseif (('{' === $chrs[$c])
673
+								  && in_array($top['what'], [SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ], true)) {
674
+							// found a left-brace, and we are in an array, object, or slice
675
+							array_push($stk, ['what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false]);
676
+							//print("Found start of object at {$c}\n");
677
+						} elseif (('}' === $chrs[$c]) && (SERVICES_JSON_IN_OBJ == $top['what'])) {
678
+							// found a right-brace, and we're in an object
679
+							array_pop($stk);
680
+							//print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
681
+						} elseif (('/*' === $substr_chrs_c_2)
682
+								  && in_array($top['what'], [SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ], true)) {
683
+							// found a comment start, and we are in an array, object, or slice
684
+							array_push($stk, ['what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false]);
685
+							++$c;
686
+							//print("Found start of comment at {$c}\n");
687
+						} elseif (('*/' === $substr_chrs_c_2) && (SERVICES_JSON_IN_CMT == $top['what'])) {
688
+							// found a comment end, and we're in one now
689
+							array_pop($stk);
690
+							++$c;
691
+
692
+							for ($i = $top['where']; $i <= $c; ++$i) {
693
+								$chrs = substr_replace($chrs, ' ', $i, 1);
694
+							}
695
+							//print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
696
+						}
697
+					}
698
+
699
+					if (SERVICES_JSON_IN_ARR == reset($stk)) {
700
+						return $arr;
701
+					}
702
+
703
+					if (SERVICES_JSON_IN_OBJ == reset($stk)) {
704
+						return $obj;
705
+					}
706
+				}
707
+		}
708
+	}
709
+
710
+	/**
711
+	 * @param      $data
712
+	 * @param null $code
713
+	 * @return bool
714
+	 * @todo Ultimately, this should just call PEAR::isError()
715
+	 */
716
+	public function isError($data, $code = null): bool
717
+	{
718
+		if (class_exists('pear')) {
719
+			return PEAR::isError($data, $code);
720
+		}
721
+
722
+		if (is_object($data)
723
+			&& ($data instanceof \services_json_error
724
+				|| $data instanceof \services_json_error)) {
725
+			return true;
726
+		}
727
+
728
+		return false;
729
+	}
730 730
 }
731 731
 
732 732
 if (class_exists('PEAR_Error')) {
733
-    /**
734
-     * Class ServicesJSON_Error
735
-     */
736
-    class ServicesJSON_Error extends PEAR_Error
737
-    {
738
-        /**
739
-         * ServicesJSON_Error constructor.
740
-         * @param string $message
741
-         * @param null   $code
742
-         * @param null   $mode
743
-         * @param null   $options
744
-         * @param null   $userinfo
745
-         */
746
-        public function __construct(
747
-            $message = 'unknown error',
748
-            $code = null,
749
-            $mode = null,
750
-            $options = null,
751
-            $userinfo = null
752
-        ) {
753
-            parent::__construct($message, $code, $mode, $options, $userinfo);
754
-        }
755
-    }
733
+	/**
734
+	 * Class ServicesJSON_Error
735
+	 */
736
+	class ServicesJSON_Error extends PEAR_Error
737
+	{
738
+		/**
739
+		 * ServicesJSON_Error constructor.
740
+		 * @param string $message
741
+		 * @param null   $code
742
+		 * @param null   $mode
743
+		 * @param null   $options
744
+		 * @param null   $userinfo
745
+		 */
746
+		public function __construct(
747
+			$message = 'unknown error',
748
+			$code = null,
749
+			$mode = null,
750
+			$options = null,
751
+			$userinfo = null
752
+		) {
753
+			parent::__construct($message, $code, $mode, $options, $userinfo);
754
+		}
755
+	}
756 756
 } else {
757
-    /**
758
-     * @todo Ultimately, this class shall be descended from PEAR_Error
759
-     */
760
-    class ServicesJSON_Error
761
-    {
762
-        /**
763
-         * ServicesJSON_Error constructor.
764
-         * @param string $message
765
-         * @param null   $code
766
-         * @param null   $mode
767
-         * @param null   $options
768
-         * @param null   $userinfo
769
-         */
770
-        public function __construct(
771
-            $message = 'unknown error',
772
-            $code = null,
773
-            $mode = null,
774
-            $options = null,
775
-            $userinfo = null
776
-        ) {
777
-        }
778
-    }
757
+	/**
758
+	 * @todo Ultimately, this class shall be descended from PEAR_Error
759
+	 */
760
+	class ServicesJSON_Error
761
+	{
762
+		/**
763
+		 * ServicesJSON_Error constructor.
764
+		 * @param string $message
765
+		 * @param null   $code
766
+		 * @param null   $mode
767
+		 * @param null   $options
768
+		 * @param null   $userinfo
769
+		 */
770
+		public function __construct(
771
+			$message = 'unknown error',
772
+			$code = null,
773
+			$mode = null,
774
+			$options = null,
775
+			$userinfo = null
776
+		) {
777
+		}
778
+	}
779 779
 }
Please login to merge, or discard this patch.
Spacing   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -117,18 +117,18 @@  discard block
 block discarded – undo
117 117
         $bytes = (ord($utf16[0]) << 8) | ord($utf16[1]);
118 118
 
119 119
         switch (true) {
120
-            case ((0x7F & $bytes) == $bytes):
120
+            case ((0x7F & $bytes)==$bytes):
121 121
                 // this case should never be reached, because we are in ASCII range
122 122
                 // see: https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
123 123
                 return chr(0x7F & $bytes);
124
-            case (0x07FF & $bytes) == $bytes:
124
+            case (0x07FF & $bytes)==$bytes:
125 125
                 // return a 2-byte UTF-8 character
126 126
                 // see: https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
127
-                return chr(0xC0 | (($bytes >> 6) & 0x1F)) . chr(0x80 | ($bytes & 0x3F));
128
-            case (0xFFFF & $bytes) == $bytes:
127
+                return chr(0xC0 | (($bytes >> 6) & 0x1F)).chr(0x80 | ($bytes & 0x3F));
128
+            case (0xFFFF & $bytes)==$bytes:
129 129
                 // return a 3-byte UTF-8 character
130 130
                 // see: https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
131
-                return chr(0xE0 | (($bytes >> 12) & 0x0F)) . chr(0x80 | (($bytes >> 6) & 0x3F)) . chr(0x80 | ($bytes & 0x3F));
131
+                return chr(0xE0 | (($bytes >> 12) & 0x0F)).chr(0x80 | (($bytes >> 6) & 0x3F)).chr(0x80 | ($bytes & 0x3F));
132 132
         }
133 133
 
134 134
         // ignoring UTF-32 for now, sorry
@@ -160,11 +160,11 @@  discard block
 block discarded – undo
160 160
             case 2:
161 161
                 // return a UTF-16 character from a 2-byte UTF-8 char
162 162
                 // see: https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
163
-                return chr(0x07 & (ord($utf8[0]) >> 2)) . chr((0xC0 & (ord($utf8[0]) << 6)) | (0x3F & ord($utf8[1])));
163
+                return chr(0x07 & (ord($utf8[0]) >> 2)).chr((0xC0 & (ord($utf8[0]) << 6)) | (0x3F & ord($utf8[1])));
164 164
             case 3:
165 165
                 // return a UTF-16 character from a 3-byte UTF-8 char
166 166
                 // see: https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
167
-                return chr((0xF0 & (ord($utf8[0]) << 4)) | (0x0F & (ord($utf8[1]) >> 2))) . chr((0xC0 & (ord($utf8[1]) << 6)) | (0x7F & ord($utf8[2])));
167
+                return chr((0xF0 & (ord($utf8[0]) << 4)) | (0x0F & (ord($utf8[1]) >> 2))).chr((0xC0 & (ord($utf8[1]) << 6)) | (0x7F & ord($utf8[2])));
168 168
         }
169 169
 
170 170
         // ignoring UTF-32 for now, sorry
@@ -227,10 +227,10 @@  discard block
 block discarded – undo
227 227
             case 'NULL':
228 228
                 return 'null';
229 229
             case 'integer':
230
-                return (int)$var;
230
+                return (int) $var;
231 231
             case 'double':
232 232
             case 'float':
233
-                return (float)$var;
233
+                return (float) $var;
234 234
             case 'string':
235 235
                 // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
236 236
                 $ascii      = '';
@@ -240,97 +240,97 @@  discard block
 block discarded – undo
240 240
                  * Iterate over every character in the string,
241 241
                  * escaping with a slash or encoding to UTF-8 where necessary
242 242
                  */
243
-                for ($c = 0; $c < $strlen_var; ++$c) {
243
+                for ($c = 0; $c<$strlen_var; ++$c) {
244 244
                     $ord_var_c = ord($var[$c]);
245 245
 
246 246
                     switch (true) {
247
-                        case 0x08 == $ord_var_c:
247
+                        case 0x08==$ord_var_c:
248 248
                             $ascii .= '\b';
249 249
                             break;
250
-                        case 0x09 == $ord_var_c:
250
+                        case 0x09==$ord_var_c:
251 251
                             $ascii .= '\t';
252 252
                             break;
253
-                        case 0x0A == $ord_var_c:
253
+                        case 0x0A==$ord_var_c:
254 254
                             $ascii .= '\n';
255 255
                             break;
256
-                        case 0x0C == $ord_var_c:
256
+                        case 0x0C==$ord_var_c:
257 257
                             $ascii .= '\f';
258 258
                             break;
259
-                        case 0x0D == $ord_var_c:
259
+                        case 0x0D==$ord_var_c:
260 260
                             $ascii .= '\r';
261 261
                             break;
262
-                        case 0x22 == $ord_var_c:
263
-                        case 0x2F == $ord_var_c:
264
-                        case 0x5C == $ord_var_c:
262
+                        case 0x22==$ord_var_c:
263
+                        case 0x2F==$ord_var_c:
264
+                        case 0x5C==$ord_var_c:
265 265
                             // double quote, slash, slosh
266
-                            $ascii .= '\\' . $var[$c];
266
+                            $ascii .= '\\'.$var[$c];
267 267
                             break;
268
-                        case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
268
+                        case (($ord_var_c>=0x20) && ($ord_var_c<=0x7F)):
269 269
                             // characters U-00000000 - U-0000007F (same as ASCII)
270 270
                             $ascii .= $var[$c];
271 271
                             break;
272
-                        case (0xC0 == ($ord_var_c & 0xE0)):
272
+                        case (0xC0==($ord_var_c & 0xE0)):
273 273
                             // characters U-00000080 - U-000007FF, mask 110SONGLIST
274 274
                             // see https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
275
-                            if ($c + 1 >= $strlen_var) {
275
+                            if ($c+1>=$strlen_var) {
276 276
                                 ++$c;
277 277
                                 $ascii .= '?';
278 278
                                 break;
279 279
                             }
280 280
 
281
-                            $char = pack('C*', $ord_var_c, ord($var[$c + 1]));
281
+                            $char = pack('C*', $ord_var_c, ord($var[$c+1]));
282 282
                             ++$c;
283 283
                             $utf16 = $this->utf82utf16($char);
284 284
                             $ascii .= sprintf('\u%04s', bin2hex($utf16));
285 285
                             break;
286
-                        case (0xE0 == ($ord_var_c & 0xF0)):
287
-                            if ($c + 2 >= $strlen_var) {
286
+                        case (0xE0==($ord_var_c & 0xF0)):
287
+                            if ($c+2>=$strlen_var) {
288 288
                                 $c     += 2;
289 289
                                 $ascii .= '?';
290 290
                                 break;
291 291
                             }
292 292
                             // characters U-00000800 - U-0000FFFF, mask 1110XXXX
293 293
                             // see https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
294
-                            $char  = pack('C*', $ord_var_c, @ord($var[$c + 1]), @ord($var[$c + 2]));
294
+                            $char  = pack('C*', $ord_var_c, @ord($var[$c+1]), @ord($var[$c+2]));
295 295
                             $c     += 2;
296 296
                             $utf16 = $this->utf82utf16($char);
297 297
                             $ascii .= sprintf('\u%04s', bin2hex($utf16));
298 298
                             break;
299
-                        case (0xF0 == ($ord_var_c & 0xF8)):
300
-                            if ($c + 3 >= $strlen_var) {
299
+                        case (0xF0==($ord_var_c & 0xF8)):
300
+                            if ($c+3>=$strlen_var) {
301 301
                                 $c     += 3;
302 302
                                 $ascii .= '?';
303 303
                                 break;
304 304
                             }
305 305
                             // characters U-00010000 - U-001FFFFF, mask 11110XXX
306 306
                             // see https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
307
-                            $char  = pack('C*', $ord_var_c, ord($var[$c + 1]), ord($var[$c + 2]), ord($var[$c + 3]));
307
+                            $char  = pack('C*', $ord_var_c, ord($var[$c+1]), ord($var[$c+2]), ord($var[$c+3]));
308 308
                             $c     += 3;
309 309
                             $utf16 = $this->utf82utf16($char);
310 310
                             $ascii .= sprintf('\u%04s', bin2hex($utf16));
311 311
                             break;
312
-                        case (0xF8 == ($ord_var_c & 0xFC)):
312
+                        case (0xF8==($ord_var_c & 0xFC)):
313 313
                             // characters U-00200000 - U-03FFFFFF, mask 111110XX
314 314
                             // see https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
315
-                            if ($c + 4 >= $strlen_var) {
315
+                            if ($c+4>=$strlen_var) {
316 316
                                 $c     += 4;
317 317
                                 $ascii .= '?';
318 318
                                 break;
319 319
                             }
320
-                            $char  = pack('C*', $ord_var_c, ord($var[$c + 1]), ord($var[$c + 2]), ord($var[$c + 3]), ord($var[$c + 4]));
320
+                            $char  = pack('C*', $ord_var_c, ord($var[$c+1]), ord($var[$c+2]), ord($var[$c+3]), ord($var[$c+4]));
321 321
                             $c     += 4;
322 322
                             $utf16 = $this->utf82utf16($char);
323 323
                             $ascii .= sprintf('\u%04s', bin2hex($utf16));
324 324
                             break;
325
-                        case (0xFC == ($ord_var_c & 0xFE)):
326
-                            if ($c + 5 >= $strlen_var) {
325
+                        case (0xFC==($ord_var_c & 0xFE)):
326
+                            if ($c+5>=$strlen_var) {
327 327
                                 $c     += 5;
328 328
                                 $ascii .= '?';
329 329
                                 break;
330 330
                             }
331 331
                             // characters U-04000000 - U-7FFFFFFF, mask 1111110X
332 332
                             // see https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
333
-                            $char  = pack('C*', $ord_var_c, ord($var[$c + 1]), ord($var[$c + 2]), ord($var[$c + 3]), ord($var[$c + 4]), ord($var[$c + 5]));
333
+                            $char  = pack('C*', $ord_var_c, ord($var[$c+1]), ord($var[$c+2]), ord($var[$c+3]), ord($var[$c+4]), ord($var[$c+5]));
334 334
                             $c     += 5;
335 335
                             $utf16 = $this->utf82utf16($char);
336 336
                             $ascii .= sprintf('\u%04s', bin2hex($utf16));
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
                     }
339 339
                 }
340 340
 
341
-                return '"' . $ascii . '"';
341
+                return '"'.$ascii.'"';
342 342
             case 'array':
343 343
                 /*
344 344
                  * As per JSON spec if any array key is not an integer
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
                  */
360 360
 
361 361
                 // treat as a JSON object
362
-                if (is_array($var) && count($var) && (array_keys($var) !== range(0, count($var) - 1))) {
362
+                if (is_array($var) && count($var) && (array_keys($var)!==range(0, count($var)-1))) {
363 363
                     $properties = array_map([$this, 'name_value'], array_keys($var), array_values($var));
364 364
 
365 365
                     foreach ($properties as $property) {
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
                         }
369 369
                     }
370 370
 
371
-                    return '{' . implode(',', $properties) . '}';
371
+                    return '{'.implode(',', $properties).'}';
372 372
                 }
373 373
 
374 374
                 // treat it like a regular array
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
                     }
381 381
                 }
382 382
 
383
-                return '[' . implode(',', $elements) . ']';
383
+                return '['.implode(',', $elements).']';
384 384
             case 'object':
385 385
                 $vars = get_object_vars($var);
386 386
 
@@ -392,9 +392,9 @@  discard block
 block discarded – undo
392 392
                     }
393 393
                 }
394 394
 
395
-                return '{' . implode(',', $properties) . '}';
395
+                return '{'.implode(',', $properties).'}';
396 396
             default:
397
-                return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS) ? 'null' : new ServicesJSON_Error(gettype($var) . ' can not be encoded as JSON string');
397
+                return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS) ? 'null' : new ServicesJSON_Error(gettype($var).' can not be encoded as JSON string');
398 398
         }
399 399
     }
400 400
 
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
             return $encoded_value;
415 415
         }
416 416
 
417
-        return $this->_encode((string)$name) . ':' . $encoded_value;
417
+        return $this->_encode((string) $name).':'.$encoded_value;
418 418
     }
419 419
 
420 420
     /**
@@ -478,84 +478,84 @@  discard block
 block discarded – undo
478 478
                     // return (float)$str;
479 479
 
480 480
                     // Return float or int, as appropriate
481
-                    return ((float)$str == (int)$str) ? (int)$str : (float)$str;
481
+                    return ((float) $str==(int) $str) ? (int) $str : (float) $str;
482 482
                 }
483 483
 
484
-                if (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
484
+                if (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1]==$m[2]) {
485 485
                     // STRINGS RETURNED IN UTF-8 FORMAT
486 486
                     $delim       = mb_substr($str, 0, 1);
487 487
                     $chrs        = mb_substr($str, 1, -1);
488 488
                     $utf8        = '';
489 489
                     $strlen_chrs = mb_strlen($chrs);
490 490
 
491
-                    for ($c = 0; $c < $strlen_chrs; ++$c) {
491
+                    for ($c = 0; $c<$strlen_chrs; ++$c) {
492 492
                         $substr_chrs_c_2 = mb_substr($chrs, $c, 2);
493 493
                         $ord_chrs_c      = ord($chrs[$c]);
494 494
 
495 495
                         switch (true) {
496
-                            case '\b' === $substr_chrs_c_2:
496
+                            case '\b'===$substr_chrs_c_2:
497 497
                                 $utf8 .= chr(0x08);
498 498
                                 ++$c;
499 499
                                 break;
500
-                            case '\t' === $substr_chrs_c_2:
500
+                            case '\t'===$substr_chrs_c_2:
501 501
                                 $utf8 .= chr(0x09);
502 502
                                 ++$c;
503 503
                                 break;
504
-                            case '\n' === $substr_chrs_c_2:
504
+                            case '\n'===$substr_chrs_c_2:
505 505
                                 $utf8 .= chr(0x0A);
506 506
                                 ++$c;
507 507
                                 break;
508
-                            case '\f' === $substr_chrs_c_2:
508
+                            case '\f'===$substr_chrs_c_2:
509 509
                                 $utf8 .= chr(0x0C);
510 510
                                 ++$c;
511 511
                                 break;
512
-                            case '\r' === $substr_chrs_c_2:
512
+                            case '\r'===$substr_chrs_c_2:
513 513
                                 $utf8 .= chr(0x0D);
514 514
                                 ++$c;
515 515
                                 break;
516
-                            case '\\"' === $substr_chrs_c_2:
517
-                            case '\\\'' === $substr_chrs_c_2:
518
-                            case '\\\\' === $substr_chrs_c_2:
519
-                            case '\\/' === $substr_chrs_c_2:
520
-                                if (('"' === $delim && '\\\'' !== $substr_chrs_c_2)
521
-                                    || ("'" === $delim && '\\"' !== $substr_chrs_c_2)) {
516
+                            case '\\"'===$substr_chrs_c_2:
517
+                            case '\\\''===$substr_chrs_c_2:
518
+                            case '\\\\'===$substr_chrs_c_2:
519
+                            case '\\/'===$substr_chrs_c_2:
520
+                                if (('"'===$delim && '\\\''!==$substr_chrs_c_2)
521
+                                    || ("'"===$delim && '\\"'!==$substr_chrs_c_2)) {
522 522
                                     $utf8 .= $chrs[++$c];
523 523
                                 }
524 524
                                 break;
525 525
                             case preg_match('/\\\u[0-9A-F]{4}/i', mb_substr($chrs, $c, 6)):
526 526
                                 // single, escaped unicode character
527
-                                $utf16 = chr(hexdec(mb_substr($chrs, $c + 2, 2))) . chr(hexdec(mb_substr($chrs, $c + 4, 2)));
527
+                                $utf16 = chr(hexdec(mb_substr($chrs, $c+2, 2))).chr(hexdec(mb_substr($chrs, $c+4, 2)));
528 528
                                 $utf8  .= $this->utf162utf8($utf16);
529 529
                                 $c     += 5;
530 530
                                 break;
531
-                            case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
531
+                            case ($ord_chrs_c>=0x20) && ($ord_chrs_c<=0x7F):
532 532
                                 $utf8 .= $chrs[$c];
533 533
                                 break;
534
-                            case 0xC0 == ($ord_chrs_c & 0xE0):
534
+                            case 0xC0==($ord_chrs_c & 0xE0):
535 535
                                 // characters U-00000080 - U-000007FF, mask 110SONGLIST
536 536
                                 //see https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
537 537
                                 $utf8 .= mb_substr($chrs, $c, 2);
538 538
                                 ++$c;
539 539
                                 break;
540
-                            case 0xE0 == ($ord_chrs_c & 0xF0):
540
+                            case 0xE0==($ord_chrs_c & 0xF0):
541 541
                                 // characters U-00000800 - U-0000FFFF, mask 1110XXXX
542 542
                                 // see https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
543 543
                                 $utf8 .= mb_substr($chrs, $c, 3);
544 544
                                 $c    += 2;
545 545
                                 break;
546
-                            case 0xF0 == ($ord_chrs_c & 0xF8):
546
+                            case 0xF0==($ord_chrs_c & 0xF8):
547 547
                                 // characters U-00010000 - U-001FFFFF, mask 11110XXX
548 548
                                 // see https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
549 549
                                 $utf8 .= mb_substr($chrs, $c, 4);
550 550
                                 $c    += 3;
551 551
                                 break;
552
-                            case 0xF8 == ($ord_chrs_c & 0xFC):
552
+                            case 0xF8==($ord_chrs_c & 0xFC):
553 553
                                 // characters U-00200000 - U-03FFFFFF, mask 111110XX
554 554
                                 // see https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
555 555
                                 $utf8 .= mb_substr($chrs, $c, 5);
556 556
                                 $c    += 4;
557 557
                                 break;
558
-                            case 0xFC == ($ord_chrs_c & 0xFE):
558
+                            case 0xFC==($ord_chrs_c & 0xFE):
559 559
                                 // characters U-04000000 - U-7FFFFFFF, mask 1111110X
560 560
                                 // see https://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
561 561
                                 $utf8 .= mb_substr($chrs, $c, 6);
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
                 if (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
571 571
                     // array, or object notation
572 572
 
573
-                    if ('[' === $str[0]) {
573
+                    if ('['===$str[0]) {
574 574
                         $stk = [SERVICES_JSON_IN_ARR];
575 575
                         $arr = [];
576 576
                     } elseif ($this->use & SERVICES_JSON_LOOSE_TYPE) {
@@ -593,8 +593,8 @@  discard block
 block discarded – undo
593 593
                     $chrs = mb_substr($str, 1, -1);
594 594
                     $chrs = $this->reduce_string($chrs);
595 595
 
596
-                    if ('' == $chrs) {
597
-                        if (SERVICES_JSON_IN_ARR == reset($stk)) {
596
+                    if (''==$chrs) {
597
+                        if (SERVICES_JSON_IN_ARR==reset($stk)) {
598 598
                             return $arr;
599 599
                         }
600 600
 
@@ -605,21 +605,21 @@  discard block
 block discarded – undo
605 605
 
606 606
                     $strlen_chrs = mb_strlen($chrs);
607 607
 
608
-                    for ($c = 0; $c <= $strlen_chrs; ++$c) {
608
+                    for ($c = 0; $c<=$strlen_chrs; ++$c) {
609 609
                         $top             = end($stk);
610 610
                         $substr_chrs_c_2 = mb_substr($chrs, $c, 2);
611 611
 
612
-                        if (($c == $strlen_chrs) || ((',' === $chrs[$c]) && (SERVICES_JSON_SLICE == $top['what']))) {
612
+                        if (($c==$strlen_chrs) || ((','===$chrs[$c]) && (SERVICES_JSON_SLICE==$top['what']))) {
613 613
                             // found a comma that is not inside a string, array, etc.,
614 614
                             // OR we've reached the end of the character list
615
-                            $slice = mb_substr($chrs, $top['where'], $c - $top['where']);
616
-                            array_push($stk, ['what' => SERVICES_JSON_SLICE, 'where' => $c + 1, 'delim' => false]);
615
+                            $slice = mb_substr($chrs, $top['where'], $c-$top['where']);
616
+                            array_push($stk, ['what' => SERVICES_JSON_SLICE, 'where' => $c+1, 'delim' => false]);
617 617
                             //print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
618 618
 
619
-                            if (SERVICES_JSON_IN_ARR == reset($stk)) {
619
+                            if (SERVICES_JSON_IN_ARR==reset($stk)) {
620 620
                                 // we are in an array, so just push an element onto the stack
621 621
                                 $arr[] = $this->decode($slice);
622
-                            } elseif (SERVICES_JSON_IN_OBJ == reset($stk)) {
622
+                            } elseif (SERVICES_JSON_IN_OBJ==reset($stk)) {
623 623
                                 // we are in an object, so figure
624 624
                                 // out the property name and set an
625 625
                                 // element in an associative array,
@@ -648,59 +648,59 @@  discard block
 block discarded – undo
648 648
                                     }
649 649
                                 }
650 650
                             }
651
-                        } elseif ((('"' === $chrs[$c]) || ("'" === $chrs[$c])) && (SERVICES_JSON_IN_STR != $top['what'])) {
651
+                        } elseif ((('"'===$chrs[$c]) || ("'"===$chrs[$c])) && (SERVICES_JSON_IN_STR!=$top['what'])) {
652 652
                             // found a quote, and we are not inside a string
653 653
                             array_push($stk, ['what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs[$c]]);
654 654
                             //print("Found start of string at {$c}\n");
655
-                        } elseif (($chrs[$c] == $top['delim'])
656
-                                  && (SERVICES_JSON_IN_STR == $top['what'])
657
-                                  && (1 != (mb_strlen(mb_substr($chrs, 0, $c)) - mb_strlen(rtrim(mb_substr($chrs, 0, $c), '\\'))) % 2)) {
655
+                        } elseif (($chrs[$c]==$top['delim'])
656
+                                  && (SERVICES_JSON_IN_STR==$top['what'])
657
+                                  && (1!=(mb_strlen(mb_substr($chrs, 0, $c))-mb_strlen(rtrim(mb_substr($chrs, 0, $c), '\\')))%2)) {
658 658
                             // found a quote, we're in a string, and it's not escaped
659 659
                             // we know that it's not escaped becase there is _not_ an
660 660
                             // odd number of backslashes at the end of the string so far
661 661
                             array_pop($stk);
662 662
                             //print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
663
-                        } elseif (('[' === $chrs[$c])
663
+                        } elseif (('['===$chrs[$c])
664 664
                                   && in_array($top['what'], [SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ], true)) {
665 665
                             // found a left-bracket, and we are in an array, object, or slice
666 666
                             array_push($stk, ['what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false]);
667 667
                             //print("Found start of array at {$c}\n");
668
-                        } elseif ((']' === $chrs[$c]) && (SERVICES_JSON_IN_ARR == $top['what'])) {
668
+                        } elseif ((']'===$chrs[$c]) && (SERVICES_JSON_IN_ARR==$top['what'])) {
669 669
                             // found a right-bracket, and we're in an array
670 670
                             array_pop($stk);
671 671
                             //print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
672
-                        } elseif (('{' === $chrs[$c])
672
+                        } elseif (('{'===$chrs[$c])
673 673
                                   && in_array($top['what'], [SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ], true)) {
674 674
                             // found a left-brace, and we are in an array, object, or slice
675 675
                             array_push($stk, ['what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false]);
676 676
                             //print("Found start of object at {$c}\n");
677
-                        } elseif (('}' === $chrs[$c]) && (SERVICES_JSON_IN_OBJ == $top['what'])) {
677
+                        } elseif (('}'===$chrs[$c]) && (SERVICES_JSON_IN_OBJ==$top['what'])) {
678 678
                             // found a right-brace, and we're in an object
679 679
                             array_pop($stk);
680 680
                             //print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
681
-                        } elseif (('/*' === $substr_chrs_c_2)
681
+                        } elseif (('/*'===$substr_chrs_c_2)
682 682
                                   && in_array($top['what'], [SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ], true)) {
683 683
                             // found a comment start, and we are in an array, object, or slice
684 684
                             array_push($stk, ['what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false]);
685 685
                             ++$c;
686 686
                             //print("Found start of comment at {$c}\n");
687
-                        } elseif (('*/' === $substr_chrs_c_2) && (SERVICES_JSON_IN_CMT == $top['what'])) {
687
+                        } elseif (('*/'===$substr_chrs_c_2) && (SERVICES_JSON_IN_CMT==$top['what'])) {
688 688
                             // found a comment end, and we're in one now
689 689
                             array_pop($stk);
690 690
                             ++$c;
691 691
 
692
-                            for ($i = $top['where']; $i <= $c; ++$i) {
692
+                            for ($i = $top['where']; $i<=$c; ++$i) {
693 693
                                 $chrs = substr_replace($chrs, ' ', $i, 1);
694 694
                             }
695 695
                             //print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
696 696
                         }
697 697
                     }
698 698
 
699
-                    if (SERVICES_JSON_IN_ARR == reset($stk)) {
699
+                    if (SERVICES_JSON_IN_ARR==reset($stk)) {
700 700
                         return $arr;
701 701
                     }
702 702
 
703
-                    if (SERVICES_JSON_IN_OBJ == reset($stk)) {
703
+                    if (SERVICES_JSON_IN_OBJ==reset($stk)) {
704 704
                         return $obj;
705 705
                     }
706 706
                 }
Please login to merge, or discard this patch.
include/onuninstall.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
  */
21 21
 function xoops_module_pre_uninstall_songlist(\XoopsModule $module): bool
22 22
 {
23
-    // Do some synchronization
24
-    return true;
23
+	// Do some synchronization
24
+	return true;
25 25
 }
26 26
 
27 27
 /**
@@ -32,26 +32,26 @@  discard block
 block discarded – undo
32 32
  */
33 33
 function xoops_module_uninstall_songlist(\XoopsModule $module): bool
34 34
 {
35
-    $moduleDirName      = \basename(\dirname(__DIR__));
36
-    $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
37
-    $helper             = Helper::getInstance();
35
+	$moduleDirName      = \basename(\dirname(__DIR__));
36
+	$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
37
+	$helper             = Helper::getInstance();
38 38
 
39
-    $success = true;
40
-    $helper->loadLanguage('admin');
39
+	$success = true;
40
+	$helper->loadLanguage('admin');
41 41
 
42
-    // Rename uploads folder to BAK and add date to name
43
-    $uploadDirectory = $GLOBALS['xoops']->path("uploads/$moduleDirName");
44
-    $dirInfo = new \SplFileInfo($uploadDirectory);
45
-    if ($dirInfo->isDir()) {
46
-        // The directory exists so rename it
47
-        $date = date('Y-m-d');
48
-        if (!rename($uploadDirectory, $uploadDirectory . "_bak_$date")) {
49
-            $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'ERROR_FOLDER_RENAME_FAILED'), $uploadDirectory));
50
-            $success = false;
51
-        }
52
-    }
53
-    unset($dirInfo);
54
-    /*
42
+	// Rename uploads folder to BAK and add date to name
43
+	$uploadDirectory = $GLOBALS['xoops']->path("uploads/$moduleDirName");
44
+	$dirInfo = new \SplFileInfo($uploadDirectory);
45
+	if ($dirInfo->isDir()) {
46
+		// The directory exists so rename it
47
+		$date = date('Y-m-d');
48
+		if (!rename($uploadDirectory, $uploadDirectory . "_bak_$date")) {
49
+			$module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'ERROR_FOLDER_RENAME_FAILED'), $uploadDirectory));
50
+			$success = false;
51
+		}
52
+	}
53
+	unset($dirInfo);
54
+	/*
55 55
     //------------ START ----------------
56 56
     //------------------------------------------------------------------
57 57
     // Remove xsitemap.xml from XOOPS root folder if it exists
@@ -65,6 +65,6 @@  discard block
 block discarded – undo
65 65
 //    return $success && $delOk; // use this if you're using this routine
66 66
 */
67 67
 
68
-    return $success;
69
-    //------------ END  ----------------
68
+	return $success;
69
+	//------------ END  ----------------
70 70
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -45,8 +45,8 @@
 block discarded – undo
45 45
     if ($dirInfo->isDir()) {
46 46
         // The directory exists so rename it
47 47
         $date = date('Y-m-d');
48
-        if (!rename($uploadDirectory, $uploadDirectory . "_bak_$date")) {
49
-            $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'ERROR_FOLDER_RENAME_FAILED'), $uploadDirectory));
48
+        if (!rename($uploadDirectory, $uploadDirectory."_bak_$date")) {
49
+            $module->setErrors(sprintf(constant('CO_'.$moduleDirNameUpper.'_'.'ERROR_FOLDER_RENAME_FAILED'), $uploadDirectory));
50 50
             $success = false;
51 51
         }
52 52
     }
Please login to merge, or discard this patch.
include/config.php 2 patches
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -21,63 +21,63 @@
 block discarded – undo
21 21
 $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
22 22
 
23 23
 return (object)[
24
-    'name'           => $moduleDirNameUpper . ' Module Configurator',
25
-    'paths'          => [
26
-        'dirname'    => $moduleDirName,
27
-        'admin'      => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin',
28
-        'modPath'    => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName,
29
-        'modUrl'     => XOOPS_URL . '/modules/' . $moduleDirName,
30
-        'uploadPath' => XOOPS_UPLOAD_PATH . '/' . $moduleDirName,
31
-        'uploadUrl'  => XOOPS_UPLOAD_URL . '/' . $moduleDirName,
32
-    ],
33
-    'uploadFolders'  => [
34
-        XOOPS_UPLOAD_PATH . '/' . $moduleDirName,
35
-        XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/category',
36
-        XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/screenshots',
37
-        //XOOPS_UPLOAD_PATH . '/flags'
38
-    ],
39
-    'copyBlankFiles' => [
40
-        XOOPS_UPLOAD_PATH . '/' . $moduleDirName,
41
-        XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/category',
42
-        XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/screenshots',
43
-        //XOOPS_UPLOAD_PATH . '/flags'
44
-    ],
24
+	'name'           => $moduleDirNameUpper . ' Module Configurator',
25
+	'paths'          => [
26
+		'dirname'    => $moduleDirName,
27
+		'admin'      => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin',
28
+		'modPath'    => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName,
29
+		'modUrl'     => XOOPS_URL . '/modules/' . $moduleDirName,
30
+		'uploadPath' => XOOPS_UPLOAD_PATH . '/' . $moduleDirName,
31
+		'uploadUrl'  => XOOPS_UPLOAD_URL . '/' . $moduleDirName,
32
+	],
33
+	'uploadFolders'  => [
34
+		XOOPS_UPLOAD_PATH . '/' . $moduleDirName,
35
+		XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/category',
36
+		XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/screenshots',
37
+		//XOOPS_UPLOAD_PATH . '/flags'
38
+	],
39
+	'copyBlankFiles' => [
40
+		XOOPS_UPLOAD_PATH . '/' . $moduleDirName,
41
+		XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/category',
42
+		XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/screenshots',
43
+		//XOOPS_UPLOAD_PATH . '/flags'
44
+	],
45 45
 
46
-    'copyTestFolders' => [
47
-        //[
48
-        //    constant($moduleDirNameUpper . '_PATH') . '/testdata/images',
49
-        //    XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images',
50
-        //]
51
-    ],
46
+	'copyTestFolders' => [
47
+		//[
48
+		//    constant($moduleDirNameUpper . '_PATH') . '/testdata/images',
49
+		//    XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images',
50
+		//]
51
+	],
52 52
 
53
-    'templateFolders' => [
54
-        '/templates/',
55
-        '/templates/blocks/',
56
-        '/templates/admin/',
57
-    ],
58
-    'oldFiles'        => [
59
-        '/class/request.php',
60
-        '/class/registry.php',
61
-        '/class/utilities.php',
62
-        '/class/util.php',
63
-        // '/include/constants.php',
64
-        // '/include/functions.php',
65
-        '/ajaxrating.txt',
66
-    ],
67
-    'oldFolders'      => [
68
-        '/images',
69
-        '/css',
70
-        '/js',
71
-        '/tcpdf',
72
-        '/images',
73
-    ],
74
-    'renameTables'    => [//         'XX_archive'     => 'ZZZZ_archive',
75
-    ],
76
-    'moduleStats'     => [
77
-        //            'totalcategories' => $helper->getHandler('Category')->getCategoriesCount(-1),
78
-        //            'totalitems'      => $helper->getHandler('Item')->getItemsCount(),
79
-        //            'totalsubmitted'  => $helper->getHandler('Item')->getItemsCount(-1, [Constants::PUBLISHER_STATUS_SUBMITTED]),
80
-    ],
81
-    'modCopyright'    => "<a href='https://xoops.org' title='XOOPS Project' target='_blank'>
53
+	'templateFolders' => [
54
+		'/templates/',
55
+		'/templates/blocks/',
56
+		'/templates/admin/',
57
+	],
58
+	'oldFiles'        => [
59
+		'/class/request.php',
60
+		'/class/registry.php',
61
+		'/class/utilities.php',
62
+		'/class/util.php',
63
+		// '/include/constants.php',
64
+		// '/include/functions.php',
65
+		'/ajaxrating.txt',
66
+	],
67
+	'oldFolders'      => [
68
+		'/images',
69
+		'/css',
70
+		'/js',
71
+		'/tcpdf',
72
+		'/images',
73
+	],
74
+	'renameTables'    => [//         'XX_archive'     => 'ZZZZ_archive',
75
+	],
76
+	'moduleStats'     => [
77
+		//            'totalcategories' => $helper->getHandler('Category')->getCategoriesCount(-1),
78
+		//            'totalitems'      => $helper->getHandler('Item')->getItemsCount(),
79
+		//            'totalsubmitted'  => $helper->getHandler('Item')->getItemsCount(-1, [Constants::PUBLISHER_STATUS_SUBMITTED]),
80
+	],
81
+	'modCopyright'    => "<a href='https://xoops.org' title='XOOPS Project' target='_blank'>
82 82
                      <img src='" . Admin::iconUrl('xoopsmicrobutton.gif') . "' alt='XOOPS Project'></a>",
83 83
 ];
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -20,26 +20,26 @@  discard block
 block discarded – undo
20 20
 $moduleDirName      = \basename(\dirname(__DIR__));
21 21
 $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
22 22
 
23
-return (object)[
24
-    'name'           => $moduleDirNameUpper . ' Module Configurator',
23
+return (object) [
24
+    'name'           => $moduleDirNameUpper.' Module Configurator',
25 25
     'paths'          => [
26 26
         'dirname'    => $moduleDirName,
27
-        'admin'      => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin',
28
-        'modPath'    => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName,
29
-        'modUrl'     => XOOPS_URL . '/modules/' . $moduleDirName,
30
-        'uploadPath' => XOOPS_UPLOAD_PATH . '/' . $moduleDirName,
31
-        'uploadUrl'  => XOOPS_UPLOAD_URL . '/' . $moduleDirName,
27
+        'admin'      => XOOPS_ROOT_PATH.'/modules/'.$moduleDirName.'/admin',
28
+        'modPath'    => XOOPS_ROOT_PATH.'/modules/'.$moduleDirName,
29
+        'modUrl'     => XOOPS_URL.'/modules/'.$moduleDirName,
30
+        'uploadPath' => XOOPS_UPLOAD_PATH.'/'.$moduleDirName,
31
+        'uploadUrl'  => XOOPS_UPLOAD_URL.'/'.$moduleDirName,
32 32
     ],
33 33
     'uploadFolders'  => [
34
-        XOOPS_UPLOAD_PATH . '/' . $moduleDirName,
35
-        XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/category',
36
-        XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/screenshots',
34
+        XOOPS_UPLOAD_PATH.'/'.$moduleDirName,
35
+        XOOPS_UPLOAD_PATH.'/'.$moduleDirName.'/category',
36
+        XOOPS_UPLOAD_PATH.'/'.$moduleDirName.'/screenshots',
37 37
         //XOOPS_UPLOAD_PATH . '/flags'
38 38
     ],
39 39
     'copyBlankFiles' => [
40
-        XOOPS_UPLOAD_PATH . '/' . $moduleDirName,
41
-        XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/category',
42
-        XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/screenshots',
40
+        XOOPS_UPLOAD_PATH.'/'.$moduleDirName,
41
+        XOOPS_UPLOAD_PATH.'/'.$moduleDirName.'/category',
42
+        XOOPS_UPLOAD_PATH.'/'.$moduleDirName.'/screenshots',
43 43
         //XOOPS_UPLOAD_PATH . '/flags'
44 44
     ],
45 45
 
@@ -79,5 +79,5 @@  discard block
 block discarded – undo
79 79
         //            'totalsubmitted'  => $helper->getHandler('Item')->getItemsCount(-1, [Constants::PUBLISHER_STATUS_SUBMITTED]),
80 80
     ],
81 81
     'modCopyright'    => "<a href='https://xoops.org' title='XOOPS Project' target='_blank'>
82
-                     <img src='" . Admin::iconUrl('xoopsmicrobutton.gif') . "' alt='XOOPS Project'></a>",
82
+                     <img src='" . Admin::iconUrl('xoopsmicrobutton.gif')."' alt='XOOPS Project'></a>",
83 83
 ];
Please login to merge, or discard this patch.
include/common.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -39,19 +39,19 @@  discard block
 block discarded – undo
39 39
 //$downloadHandler     = new Songlist\DownloadHandler($db);
40 40
 
41 41
 if (!defined($moduleDirNameUpper . '_CONSTANTS_DEFINED')) {
42
-    define($moduleDirNameUpper . '_DIRNAME', basename(dirname(__DIR__)));
43
-    define($moduleDirNameUpper . '_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/');
44
-    define($moduleDirNameUpper . '_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/');
45
-    define($moduleDirNameUpper . '_URL', XOOPS_URL . '/modules/' . $moduleDirName . '/');
46
-    define($moduleDirNameUpper . '_IMAGE_URL', constant($moduleDirNameUpper . '_URL') . '/assets/images/');
47
-    define($moduleDirNameUpper . '_IMAGE_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/assets/images');
48
-    define($moduleDirNameUpper . '_ADMIN_URL', constant($moduleDirNameUpper . '_URL') . '/admin/');
49
-    define($moduleDirNameUpper . '_ADMIN_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/admin/');
50
-    define($moduleDirNameUpper . '_ADMIN', constant($moduleDirNameUpper . '_URL') . '/admin/index.php');
51
-    define($moduleDirNameUpper . '_AUTHOR_LOGOIMG', constant($moduleDirNameUpper . '_URL') . '/assets/images/logoModule.png');
52
-    define($moduleDirNameUpper . '_UPLOAD_URL', XOOPS_UPLOAD_URL . '/' . $moduleDirName); // WITHOUT Trailing slash
53
-    define($moduleDirNameUpper . '_UPLOAD_PATH', XOOPS_UPLOAD_PATH . '/' . $moduleDirName); // WITHOUT Trailing slash
54
-    define($moduleDirNameUpper . '_CONSTANTS_DEFINED', 1);
42
+	define($moduleDirNameUpper . '_DIRNAME', basename(dirname(__DIR__)));
43
+	define($moduleDirNameUpper . '_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/');
44
+	define($moduleDirNameUpper . '_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/');
45
+	define($moduleDirNameUpper . '_URL', XOOPS_URL . '/modules/' . $moduleDirName . '/');
46
+	define($moduleDirNameUpper . '_IMAGE_URL', constant($moduleDirNameUpper . '_URL') . '/assets/images/');
47
+	define($moduleDirNameUpper . '_IMAGE_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/assets/images');
48
+	define($moduleDirNameUpper . '_ADMIN_URL', constant($moduleDirNameUpper . '_URL') . '/admin/');
49
+	define($moduleDirNameUpper . '_ADMIN_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/admin/');
50
+	define($moduleDirNameUpper . '_ADMIN', constant($moduleDirNameUpper . '_URL') . '/admin/index.php');
51
+	define($moduleDirNameUpper . '_AUTHOR_LOGOIMG', constant($moduleDirNameUpper . '_URL') . '/assets/images/logoModule.png');
52
+	define($moduleDirNameUpper . '_UPLOAD_URL', XOOPS_UPLOAD_URL . '/' . $moduleDirName); // WITHOUT Trailing slash
53
+	define($moduleDirNameUpper . '_UPLOAD_PATH', XOOPS_UPLOAD_PATH . '/' . $moduleDirName); // WITHOUT Trailing slash
54
+	define($moduleDirNameUpper . '_CONSTANTS_DEFINED', 1);
55 55
 }
56 56
 
57 57
 $pathIcon16 = Admin::iconUrl('', '16');
@@ -60,15 +60,15 @@  discard block
 block discarded – undo
60 60
 //$pathModIcon32 = \XoopsModules\Songlist\Helper::getInstance()->getModule()->getInfo('modicons32');
61 61
 
62 62
 $icons = [
63
-    'edit'    => "<img src='" . $pathIcon16 . "/edit.png'  alt=" . _EDIT . "' align='middle'>",
64
-    'delete'  => "<img src='" . $pathIcon16 . "/delete.png' alt='" . _DELETE . "' align='middle'>",
65
-    'clone'   => "<img src='" . $pathIcon16 . "/editcopy.png' alt='" . _CLONE . "' align='middle'>",
66
-    'preview' => "<img src='" . $pathIcon16 . "/view.png' alt='" . _PREVIEW . "' align='middle'>",
67
-    'print'   => "<img src='" . $pathIcon16 . "/printer.png' alt='" . _CLONE . "' align='middle'>",
68
-    'pdf'     => "<img src='" . $pathIcon16 . "/pdf.png' alt='" . _CLONE . "' align='middle'>",
69
-    'add'     => "<img src='" . $pathIcon16 . "/add.png' alt='" . _ADD . "' align='middle'>",
70
-    '0'       => "<img src='" . $pathIcon16 . "/0.png' alt='" . 0 . "' align='middle'>",
71
-    '1'       => "<img src='" . $pathIcon16 . "/1.png' alt='" . 1 . "' align='middle'>",
63
+	'edit'    => "<img src='" . $pathIcon16 . "/edit.png'  alt=" . _EDIT . "' align='middle'>",
64
+	'delete'  => "<img src='" . $pathIcon16 . "/delete.png' alt='" . _DELETE . "' align='middle'>",
65
+	'clone'   => "<img src='" . $pathIcon16 . "/editcopy.png' alt='" . _CLONE . "' align='middle'>",
66
+	'preview' => "<img src='" . $pathIcon16 . "/view.png' alt='" . _PREVIEW . "' align='middle'>",
67
+	'print'   => "<img src='" . $pathIcon16 . "/printer.png' alt='" . _CLONE . "' align='middle'>",
68
+	'pdf'     => "<img src='" . $pathIcon16 . "/pdf.png' alt='" . _CLONE . "' align='middle'>",
69
+	'add'     => "<img src='" . $pathIcon16 . "/add.png' alt='" . _ADD . "' align='middle'>",
70
+	'0'       => "<img src='" . $pathIcon16 . "/0.png' alt='" . 0 . "' align='middle'>",
71
+	'1'       => "<img src='" . $pathIcon16 . "/1.png' alt='" . 1 . "' align='middle'>",
72 72
 ];
73 73
 
74 74
 $debug = false;
@@ -77,23 +77,23 @@  discard block
 block discarded – undo
77 77
 $myts = \MyTextSanitizer::getInstance();
78 78
 
79 79
 if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof \XoopsTpl)) {
80
-    require_once $GLOBALS['xoops']->path('class/template.php');
81
-    $GLOBALS['xoopsTpl'] = new \XoopsTpl();
80
+	require_once $GLOBALS['xoops']->path('class/template.php');
81
+	$GLOBALS['xoopsTpl'] = new \XoopsTpl();
82 82
 }
83 83
 
84 84
 $GLOBALS['xoopsTpl']->assign('mod_url', $helper->url());
85 85
 // Local icons path
86 86
 if (is_object($helper->getModule())) {
87
-    $pathModIcon16 = $helper->getModule()->getInfo('modicons16');
88
-    $pathModIcon32 = $helper->getModule()->getInfo('modicons32');
87
+	$pathModIcon16 = $helper->getModule()->getInfo('modicons16');
88
+	$pathModIcon32 = $helper->getModule()->getInfo('modicons32');
89 89
 
90
-    $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon16);
91
-    $GLOBALS['xoopsTpl']->assign('pathModIcon32', $pathModIcon32);
90
+	$GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon16);
91
+	$GLOBALS['xoopsTpl']->assign('pathModIcon32', $pathModIcon32);
92 92
 }
93 93
 
94 94
 xoops_loadLanguage('main', $moduleDirName);
95 95
 if (class_exists('D3LanguageManager')) {
96
-    require_once XOOPS_TRUST_PATH . "/libs/altsys/class/D3LanguageManager.class.php";
97
-    $langman = D3LanguageManager::getInstance();
98
-    $langman->read('main.php', $moduleDirName);
96
+	require_once XOOPS_TRUST_PATH . "/libs/altsys/class/D3LanguageManager.class.php";
97
+	$langman = D3LanguageManager::getInstance();
98
+	$langman->read('main.php', $moduleDirName);
99 99
 }
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 use XoopsModules\Songlist;
20 20
 use XoopsModules\Songlist\Helper;
21 21
 
22
-require_once \dirname(__DIR__) . '/preloads/autoloader.php';
22
+require_once \dirname(__DIR__).'/preloads/autoloader.php';
23 23
 
24 24
 $moduleDirName      = \basename(\dirname(__DIR__));
25 25
 $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
@@ -38,20 +38,20 @@  discard block
 block discarded – undo
38 38
 //$categoryHandler     = new Songlist\CategoryHandler($db);
39 39
 //$downloadHandler     = new Songlist\DownloadHandler($db);
40 40
 
41
-if (!defined($moduleDirNameUpper . '_CONSTANTS_DEFINED')) {
42
-    define($moduleDirNameUpper . '_DIRNAME', basename(dirname(__DIR__)));
43
-    define($moduleDirNameUpper . '_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/');
44
-    define($moduleDirNameUpper . '_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/');
45
-    define($moduleDirNameUpper . '_URL', XOOPS_URL . '/modules/' . $moduleDirName . '/');
46
-    define($moduleDirNameUpper . '_IMAGE_URL', constant($moduleDirNameUpper . '_URL') . '/assets/images/');
47
-    define($moduleDirNameUpper . '_IMAGE_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/assets/images');
48
-    define($moduleDirNameUpper . '_ADMIN_URL', constant($moduleDirNameUpper . '_URL') . '/admin/');
49
-    define($moduleDirNameUpper . '_ADMIN_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/admin/');
50
-    define($moduleDirNameUpper . '_ADMIN', constant($moduleDirNameUpper . '_URL') . '/admin/index.php');
51
-    define($moduleDirNameUpper . '_AUTHOR_LOGOIMG', constant($moduleDirNameUpper . '_URL') . '/assets/images/logoModule.png');
52
-    define($moduleDirNameUpper . '_UPLOAD_URL', XOOPS_UPLOAD_URL . '/' . $moduleDirName); // WITHOUT Trailing slash
53
-    define($moduleDirNameUpper . '_UPLOAD_PATH', XOOPS_UPLOAD_PATH . '/' . $moduleDirName); // WITHOUT Trailing slash
54
-    define($moduleDirNameUpper . '_CONSTANTS_DEFINED', 1);
41
+if (!defined($moduleDirNameUpper.'_CONSTANTS_DEFINED')) {
42
+    define($moduleDirNameUpper.'_DIRNAME', basename(dirname(__DIR__)));
43
+    define($moduleDirNameUpper.'_ROOT_PATH', XOOPS_ROOT_PATH.'/modules/'.$moduleDirName.'/');
44
+    define($moduleDirNameUpper.'_PATH', XOOPS_ROOT_PATH.'/modules/'.$moduleDirName.'/');
45
+    define($moduleDirNameUpper.'_URL', XOOPS_URL.'/modules/'.$moduleDirName.'/');
46
+    define($moduleDirNameUpper.'_IMAGE_URL', constant($moduleDirNameUpper.'_URL').'/assets/images/');
47
+    define($moduleDirNameUpper.'_IMAGE_PATH', constant($moduleDirNameUpper.'_ROOT_PATH').'/assets/images');
48
+    define($moduleDirNameUpper.'_ADMIN_URL', constant($moduleDirNameUpper.'_URL').'/admin/');
49
+    define($moduleDirNameUpper.'_ADMIN_PATH', constant($moduleDirNameUpper.'_ROOT_PATH').'/admin/');
50
+    define($moduleDirNameUpper.'_ADMIN', constant($moduleDirNameUpper.'_URL').'/admin/index.php');
51
+    define($moduleDirNameUpper.'_AUTHOR_LOGOIMG', constant($moduleDirNameUpper.'_URL').'/assets/images/logoModule.png');
52
+    define($moduleDirNameUpper.'_UPLOAD_URL', XOOPS_UPLOAD_URL.'/'.$moduleDirName); // WITHOUT Trailing slash
53
+    define($moduleDirNameUpper.'_UPLOAD_PATH', XOOPS_UPLOAD_PATH.'/'.$moduleDirName); // WITHOUT Trailing slash
54
+    define($moduleDirNameUpper.'_CONSTANTS_DEFINED', 1);
55 55
 }
56 56
 
57 57
 $pathIcon16 = Admin::iconUrl('', '16');
@@ -60,15 +60,15 @@  discard block
 block discarded – undo
60 60
 //$pathModIcon32 = \XoopsModules\Songlist\Helper::getInstance()->getModule()->getInfo('modicons32');
61 61
 
62 62
 $icons = [
63
-    'edit'    => "<img src='" . $pathIcon16 . "/edit.png'  alt=" . _EDIT . "' align='middle'>",
64
-    'delete'  => "<img src='" . $pathIcon16 . "/delete.png' alt='" . _DELETE . "' align='middle'>",
65
-    'clone'   => "<img src='" . $pathIcon16 . "/editcopy.png' alt='" . _CLONE . "' align='middle'>",
66
-    'preview' => "<img src='" . $pathIcon16 . "/view.png' alt='" . _PREVIEW . "' align='middle'>",
67
-    'print'   => "<img src='" . $pathIcon16 . "/printer.png' alt='" . _CLONE . "' align='middle'>",
68
-    'pdf'     => "<img src='" . $pathIcon16 . "/pdf.png' alt='" . _CLONE . "' align='middle'>",
69
-    'add'     => "<img src='" . $pathIcon16 . "/add.png' alt='" . _ADD . "' align='middle'>",
70
-    '0'       => "<img src='" . $pathIcon16 . "/0.png' alt='" . 0 . "' align='middle'>",
71
-    '1'       => "<img src='" . $pathIcon16 . "/1.png' alt='" . 1 . "' align='middle'>",
63
+    'edit'    => "<img src='".$pathIcon16."/edit.png'  alt="._EDIT."' align='middle'>",
64
+    'delete'  => "<img src='".$pathIcon16."/delete.png' alt='"._DELETE."' align='middle'>",
65
+    'clone'   => "<img src='".$pathIcon16."/editcopy.png' alt='"._CLONE."' align='middle'>",
66
+    'preview' => "<img src='".$pathIcon16."/view.png' alt='"._PREVIEW."' align='middle'>",
67
+    'print'   => "<img src='".$pathIcon16."/printer.png' alt='"._CLONE."' align='middle'>",
68
+    'pdf'     => "<img src='".$pathIcon16."/pdf.png' alt='"._CLONE."' align='middle'>",
69
+    'add'     => "<img src='".$pathIcon16."/add.png' alt='"._ADD."' align='middle'>",
70
+    '0'       => "<img src='".$pathIcon16."/0.png' alt='".0."' align='middle'>",
71
+    '1'       => "<img src='".$pathIcon16."/1.png' alt='".1."' align='middle'>",
72 72
 ];
73 73
 
74 74
 $debug = false;
@@ -87,13 +87,13 @@  discard block
 block discarded – undo
87 87
     $pathModIcon16 = $helper->getModule()->getInfo('modicons16');
88 88
     $pathModIcon32 = $helper->getModule()->getInfo('modicons32');
89 89
 
90
-    $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon16);
90
+    $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL.'/modules/'.$moduleDirName.'/'.$pathModIcon16);
91 91
     $GLOBALS['xoopsTpl']->assign('pathModIcon32', $pathModIcon32);
92 92
 }
93 93
 
94 94
 xoops_loadLanguage('main', $moduleDirName);
95 95
 if (class_exists('D3LanguageManager')) {
96
-    require_once XOOPS_TRUST_PATH . "/libs/altsys/class/D3LanguageManager.class.php";
96
+    require_once XOOPS_TRUST_PATH."/libs/altsys/class/D3LanguageManager.class.php";
97 97
     $langman = D3LanguageManager::getInstance();
98 98
     $langman->read('main.php', $moduleDirName);
99 99
 }
Please login to merge, or discard this patch.
include/onupdate.php 2 patches
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -18,8 +18,8 @@  discard block
 block discarded – undo
18 18
 use XoopsModules\Songlist;
19 19
 
20 20
 if ((!defined('XOOPS_ROOT_PATH')) || !($GLOBALS['xoopsUser'] instanceof \XoopsUser)
21
-    || !$GLOBALS['xoopsUser']->isAdmin()) {
22
-    exit('Restricted access' . PHP_EOL);
21
+	|| !$GLOBALS['xoopsUser']->isAdmin()) {
22
+	exit('Restricted access' . PHP_EOL);
23 23
 }
24 24
 
25 25
 /**
@@ -30,16 +30,16 @@  discard block
 block discarded – undo
30 30
  */
31 31
 function xoops_module_pre_update_songlist(\XoopsModule $module): bool
32 32
 {
33
-    $moduleDirName = \basename(\dirname(__DIR__));
34
-    /** @var Songlist\Helper $helper */
35
-    /** @var Songlist\Utility $utility */
36
-    $helper  = Songlist\Helper::getInstance();
37
-    $utility = new Songlist\Utility();
33
+	$moduleDirName = \basename(\dirname(__DIR__));
34
+	/** @var Songlist\Helper $helper */
35
+	/** @var Songlist\Utility $utility */
36
+	$helper  = Songlist\Helper::getInstance();
37
+	$utility = new Songlist\Utility();
38 38
 
39
-    $xoopsSuccess = $utility::checkVerXoops($module);
40
-    $phpSuccess   = $utility::checkVerPhp($module);
39
+	$xoopsSuccess = $utility::checkVerXoops($module);
40
+	$phpSuccess   = $utility::checkVerPhp($module);
41 41
 
42
-    return $xoopsSuccess && $phpSuccess;
42
+	return $xoopsSuccess && $phpSuccess;
43 43
 }
44 44
 
45 45
 /**
@@ -51,18 +51,18 @@  discard block
 block discarded – undo
51 51
  */
52 52
 function xoops_module_update_songlist(\XoopsModule $module, $previousVersion = null): bool
53 53
 {
54
-    $moduleDirName      = \basename(\dirname(__DIR__));
55
-    $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
56
-
57
-    /** @var Songlist\Helper $helper */ /** @var Songlist\Utility $utility */
58
-    /** @var Songlist\Common\Configurator $configurator */
59
-    $helper       = Songlist\Helper::getInstance();
60
-    $utility      = new Songlist\Utility();
61
-    $configurator = new Songlist\Common\Configurator();
62
-
63
-    if ($previousVersion < 240) {
64
-        //delete old HTML templates
65
-        /*
54
+	$moduleDirName      = \basename(\dirname(__DIR__));
55
+	$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
56
+
57
+	/** @var Songlist\Helper $helper */ /** @var Songlist\Utility $utility */
58
+	/** @var Songlist\Common\Configurator $configurator */
59
+	$helper       = Songlist\Helper::getInstance();
60
+	$utility      = new Songlist\Utility();
61
+	$configurator = new Songlist\Common\Configurator();
62
+
63
+	if ($previousVersion < 240) {
64
+		//delete old HTML templates
65
+		/*
66 66
         if (count($configurator->templateFolders) > 0) {
67 67
             foreach ($configurator->templateFolders as $folder) {
68 68
                 $templateFolder = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $folder);
@@ -80,55 +80,55 @@  discard block
 block discarded – undo
80 80
             }
81 81
         }
82 82
 */
83
-        //  ---  DELETE OLD FILES ---------------
84
-        if (count($configurator->oldFiles) > 0) {
85
-            //    foreach (array_keys($GLOBALS['uploadFolders']) as $i) {
86
-            foreach (array_keys($configurator->oldFiles) as $i) {
87
-                $tempFile = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $configurator->oldFiles[$i]);
88
-                if (is_file($tempFile)) {
89
-                    unlink($tempFile);
90
-                }
91
-            }
92
-        }
93
-
94
-        //  ---  DELETE OLD FOLDERS ---------------
95
-        xoops_load('XoopsFile');
96
-        if (count($configurator->oldFolders) > 0) {
97
-            //    foreach (array_keys($GLOBALS['uploadFolders']) as $i) {
98
-            foreach (array_keys($configurator->oldFolders) as $i) {
99
-                $tempFolder = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $configurator->oldFolders[$i]);
100
-                /** @var XoopsObjectHandler $folderHandler */
101
-                $folderHandler = XoopsFile::getHandler('folder', $tempFolder);
102
-                $folderHandler->delete($tempFolder);
103
-            }
104
-        }
105
-
106
-        //  ---  CREATE FOLDERS ---------------
107
-        if (count($configurator->uploadFolders) > 0) {
108
-            //    foreach (array_keys($GLOBALS['uploadFolders']) as $i) {
109
-            foreach (array_keys($configurator->uploadFolders) as $i) {
110
-                $utility::createFolder($configurator->uploadFolders[$i]);
111
-            }
112
-        }
113
-
114
-        //  ---  COPY blank.png FILES ---------------
115
-        if (count($configurator->copyBlankFiles) > 0) {
116
-            $file = \dirname(__DIR__) . '/assets/images/blank.png';
117
-            foreach (array_keys($configurator->copyBlankFiles) as $i) {
118
-                $dest = $configurator->copyBlankFiles[$i] . '/blank.png';
119
-                $utility::copyFile($file, $dest);
120
-            }
121
-        }
122
-
123
-        //delete .html entries from the tpl table
124
-        $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $module->getVar('dirname', 'n') . '\' AND `tpl_file` LIKE \'%.tpl%\'';
125
-        $GLOBALS['xoopsDB']->queryF($sql);
126
-
127
-        /** @var \XoopsGroupPermHandler $grouppermHandler */
128
-        $grouppermHandler = xoops_getHandler('groupperm');
129
-
130
-        return $grouppermHandler->deleteByModule($module->getVar('mid'), 'item_read');
131
-    }
132
-
133
-    return true;
83
+		//  ---  DELETE OLD FILES ---------------
84
+		if (count($configurator->oldFiles) > 0) {
85
+			//    foreach (array_keys($GLOBALS['uploadFolders']) as $i) {
86
+			foreach (array_keys($configurator->oldFiles) as $i) {
87
+				$tempFile = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $configurator->oldFiles[$i]);
88
+				if (is_file($tempFile)) {
89
+					unlink($tempFile);
90
+				}
91
+			}
92
+		}
93
+
94
+		//  ---  DELETE OLD FOLDERS ---------------
95
+		xoops_load('XoopsFile');
96
+		if (count($configurator->oldFolders) > 0) {
97
+			//    foreach (array_keys($GLOBALS['uploadFolders']) as $i) {
98
+			foreach (array_keys($configurator->oldFolders) as $i) {
99
+				$tempFolder = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $configurator->oldFolders[$i]);
100
+				/** @var XoopsObjectHandler $folderHandler */
101
+				$folderHandler = XoopsFile::getHandler('folder', $tempFolder);
102
+				$folderHandler->delete($tempFolder);
103
+			}
104
+		}
105
+
106
+		//  ---  CREATE FOLDERS ---------------
107
+		if (count($configurator->uploadFolders) > 0) {
108
+			//    foreach (array_keys($GLOBALS['uploadFolders']) as $i) {
109
+			foreach (array_keys($configurator->uploadFolders) as $i) {
110
+				$utility::createFolder($configurator->uploadFolders[$i]);
111
+			}
112
+		}
113
+
114
+		//  ---  COPY blank.png FILES ---------------
115
+		if (count($configurator->copyBlankFiles) > 0) {
116
+			$file = \dirname(__DIR__) . '/assets/images/blank.png';
117
+			foreach (array_keys($configurator->copyBlankFiles) as $i) {
118
+				$dest = $configurator->copyBlankFiles[$i] . '/blank.png';
119
+				$utility::copyFile($file, $dest);
120
+			}
121
+		}
122
+
123
+		//delete .html entries from the tpl table
124
+		$sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $module->getVar('dirname', 'n') . '\' AND `tpl_file` LIKE \'%.tpl%\'';
125
+		$GLOBALS['xoopsDB']->queryF($sql);
126
+
127
+		/** @var \XoopsGroupPermHandler $grouppermHandler */
128
+		$grouppermHandler = xoops_getHandler('groupperm');
129
+
130
+		return $grouppermHandler->deleteByModule($module->getVar('mid'), 'item_read');
131
+	}
132
+
133
+	return true;
134 134
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 
20 20
 if ((!defined('XOOPS_ROOT_PATH')) || !($GLOBALS['xoopsUser'] instanceof \XoopsUser)
21 21
     || !$GLOBALS['xoopsUser']->isAdmin()) {
22
-    exit('Restricted access' . PHP_EOL);
22
+    exit('Restricted access'.PHP_EOL);
23 23
 }
24 24
 
25 25
 /**
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     $utility      = new Songlist\Utility();
61 61
     $configurator = new Songlist\Common\Configurator();
62 62
 
63
-    if ($previousVersion < 240) {
63
+    if ($previousVersion<240) {
64 64
         //delete old HTML templates
65 65
         /*
66 66
         if (count($configurator->templateFolders) > 0) {
@@ -81,10 +81,10 @@  discard block
 block discarded – undo
81 81
         }
82 82
 */
83 83
         //  ---  DELETE OLD FILES ---------------
84
-        if (count($configurator->oldFiles) > 0) {
84
+        if (count($configurator->oldFiles)>0) {
85 85
             //    foreach (array_keys($GLOBALS['uploadFolders']) as $i) {
86 86
             foreach (array_keys($configurator->oldFiles) as $i) {
87
-                $tempFile = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $configurator->oldFiles[$i]);
87
+                $tempFile = $GLOBALS['xoops']->path('modules/'.$moduleDirName.$configurator->oldFiles[$i]);
88 88
                 if (is_file($tempFile)) {
89 89
                     unlink($tempFile);
90 90
                 }
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
 
94 94
         //  ---  DELETE OLD FOLDERS ---------------
95 95
         xoops_load('XoopsFile');
96
-        if (count($configurator->oldFolders) > 0) {
96
+        if (count($configurator->oldFolders)>0) {
97 97
             //    foreach (array_keys($GLOBALS['uploadFolders']) as $i) {
98 98
             foreach (array_keys($configurator->oldFolders) as $i) {
99
-                $tempFolder = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $configurator->oldFolders[$i]);
99
+                $tempFolder = $GLOBALS['xoops']->path('modules/'.$moduleDirName.$configurator->oldFolders[$i]);
100 100
                 /** @var XoopsObjectHandler $folderHandler */
101 101
                 $folderHandler = XoopsFile::getHandler('folder', $tempFolder);
102 102
                 $folderHandler->delete($tempFolder);
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
         }
105 105
 
106 106
         //  ---  CREATE FOLDERS ---------------
107
-        if (count($configurator->uploadFolders) > 0) {
107
+        if (count($configurator->uploadFolders)>0) {
108 108
             //    foreach (array_keys($GLOBALS['uploadFolders']) as $i) {
109 109
             foreach (array_keys($configurator->uploadFolders) as $i) {
110 110
                 $utility::createFolder($configurator->uploadFolders[$i]);
@@ -112,16 +112,16 @@  discard block
 block discarded – undo
112 112
         }
113 113
 
114 114
         //  ---  COPY blank.png FILES ---------------
115
-        if (count($configurator->copyBlankFiles) > 0) {
116
-            $file = \dirname(__DIR__) . '/assets/images/blank.png';
115
+        if (count($configurator->copyBlankFiles)>0) {
116
+            $file = \dirname(__DIR__).'/assets/images/blank.png';
117 117
             foreach (array_keys($configurator->copyBlankFiles) as $i) {
118
-                $dest = $configurator->copyBlankFiles[$i] . '/blank.png';
118
+                $dest = $configurator->copyBlankFiles[$i].'/blank.png';
119 119
                 $utility::copyFile($file, $dest);
120 120
             }
121 121
         }
122 122
 
123 123
         //delete .html entries from the tpl table
124
-        $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $module->getVar('dirname', 'n') . '\' AND `tpl_file` LIKE \'%.tpl%\'';
124
+        $sql = 'DELETE FROM '.$GLOBALS['xoopsDB']->prefix('tplfile')." WHERE `tpl_module` = '".$module->getVar('dirname', 'n').'\' AND `tpl_file` LIKE \'%.tpl%\'';
125 125
         $GLOBALS['xoopsDB']->queryF($sql);
126 126
 
127 127
         /** @var \XoopsGroupPermHandler $grouppermHandler */
Please login to merge, or discard this patch.
request.php 2 patches
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -19,48 +19,48 @@
 block discarded – undo
19 19
 $requestsHandler = Helper::getInstance()->getHandler('Requests');
20 20
 
21 21
 switch ($op) {
22
-    default:
23
-    case 'request':
24
-        $url = $requestsHandler->getURL();
25
-        if (!mb_strpos($url, $_SERVER['REQUEST_URI']) && empty($_POST)) {
26
-            header('HTTP/1.1 301 Moved Permanently');
27
-            header('Location: ' . $url);
28
-            exit(0);
29
-        }
22
+	default:
23
+	case 'request':
24
+		$url = $requestsHandler->getURL();
25
+		if (!mb_strpos($url, $_SERVER['REQUEST_URI']) && empty($_POST)) {
26
+			header('HTTP/1.1 301 Moved Permanently');
27
+			header('Location: ' . $url);
28
+			exit(0);
29
+		}
30 30
 
31
-        switch ($fct) {
32
-            case 'save':
33
-                if (checkEmail($_POST[0]['email'], true) && !empty($_POST[0]['email'])) {
34
-                    $request = $requestsHandler->create();
35
-                    $request->setVars($_POST[0]);
36
-                    $rid = $requestsHandler->insert($request);
37
-                    if ($rid) {
38
-                        redirect_header($_SERVER['SCRIPT_NAME'] . "?op=item&fct=list&id=$id&value=$value&start=$start&limit=$limit", 10, _MD_SONGLIST_MSG_REQUESTSENT);
39
-                    } else {
40
-                        redirect_header($_SERVER['SCRIPT_NAME'] . "?op=item&fct=list&id=$id&value=$value&start=$start&limit=$limit", 10, _MD_SONGLIST_MSG_REQUESTNOTSENT);
41
-                    }
42
-                    exit;
43
-                    break;
44
-                }
45
-                $error = _MD_SONGLIST_MSG_EMAILNOTSET;
31
+		switch ($fct) {
32
+			case 'save':
33
+				if (checkEmail($_POST[0]['email'], true) && !empty($_POST[0]['email'])) {
34
+					$request = $requestsHandler->create();
35
+					$request->setVars($_POST[0]);
36
+					$rid = $requestsHandler->insert($request);
37
+					if ($rid) {
38
+						redirect_header($_SERVER['SCRIPT_NAME'] . "?op=item&fct=list&id=$id&value=$value&start=$start&limit=$limit", 10, _MD_SONGLIST_MSG_REQUESTSENT);
39
+					} else {
40
+						redirect_header($_SERVER['SCRIPT_NAME'] . "?op=item&fct=list&id=$id&value=$value&start=$start&limit=$limit", 10, _MD_SONGLIST_MSG_REQUESTNOTSENT);
41
+					}
42
+					exit;
43
+					break;
44
+				}
45
+				$error = _MD_SONGLIST_MSG_EMAILNOTSET;
46 46
 
47
-            // no break
48
-            default:
49
-            case 'list':
50
-                $GLOBALS['xoopsOption']['template_main'] = 'songlist_requests_index.tpl';
51
-                require_once $GLOBALS['xoops']->path('/header.php');
52
-                if ($GLOBALS['songlistModuleConfig']['force_jquery'] && !isset($GLOBALS['loaded_jquery'])) {
53
-                    $GLOBALS['xoTheme']->addScript(XOOPS_URL . _MI_SONGLIST_JQUERY, ['type' => 'text/javascript']);
54
-                    $GLOBALS['loaded_jquery'] = true;
55
-                }
56
-                $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . _MI_SONGLIST_STYLESHEET, ['type' => 'text/css']);
57
-                $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']);
58
-                $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']);
59
-                $GLOBALS['xoopsTpl']->assign('form', FormController::getFormRequests(false, false));
60
-                if (mb_strlen($error ?? '')) {
61
-                    xoops_error($error);
62
-                }
63
-                require_once $GLOBALS['xoops']->path('/footer.php');
64
-                break;
65
-        }
47
+			// no break
48
+			default:
49
+			case 'list':
50
+				$GLOBALS['xoopsOption']['template_main'] = 'songlist_requests_index.tpl';
51
+				require_once $GLOBALS['xoops']->path('/header.php');
52
+				if ($GLOBALS['songlistModuleConfig']['force_jquery'] && !isset($GLOBALS['loaded_jquery'])) {
53
+					$GLOBALS['xoTheme']->addScript(XOOPS_URL . _MI_SONGLIST_JQUERY, ['type' => 'text/javascript']);
54
+					$GLOBALS['loaded_jquery'] = true;
55
+				}
56
+				$GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . _MI_SONGLIST_STYLESHEET, ['type' => 'text/css']);
57
+				$GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']);
58
+				$GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']);
59
+				$GLOBALS['xoopsTpl']->assign('form', FormController::getFormRequests(false, false));
60
+				if (mb_strlen($error ?? '')) {
61
+					xoops_error($error);
62
+				}
63
+				require_once $GLOBALS['xoops']->path('/footer.php');
64
+				break;
65
+		}
66 66
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
 use XoopsModules\Songlist\RequestsHandler;
7 7
 use XoopsModules\Songlist\Form\FormController;
8 8
 
9
-require_once __DIR__ . '/header.php';
9
+require_once __DIR__.'/header.php';
10 10
 
11 11
 global $file, $op, $fct, $id, $value, $gid, $cid, $singer, $start, $limit;
12 12
 
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
         $url = $requestsHandler->getURL();
25 25
         if (!mb_strpos($url, $_SERVER['REQUEST_URI']) && empty($_POST)) {
26 26
             header('HTTP/1.1 301 Moved Permanently');
27
-            header('Location: ' . $url);
27
+            header('Location: '.$url);
28 28
             exit(0);
29 29
         }
30 30
 
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
                     $request->setVars($_POST[0]);
36 36
                     $rid = $requestsHandler->insert($request);
37 37
                     if ($rid) {
38
-                        redirect_header($_SERVER['SCRIPT_NAME'] . "?op=item&fct=list&id=$id&value=$value&start=$start&limit=$limit", 10, _MD_SONGLIST_MSG_REQUESTSENT);
38
+                        redirect_header($_SERVER['SCRIPT_NAME']."?op=item&fct=list&id=$id&value=$value&start=$start&limit=$limit", 10, _MD_SONGLIST_MSG_REQUESTSENT);
39 39
                     } else {
40
-                        redirect_header($_SERVER['SCRIPT_NAME'] . "?op=item&fct=list&id=$id&value=$value&start=$start&limit=$limit", 10, _MD_SONGLIST_MSG_REQUESTNOTSENT);
40
+                        redirect_header($_SERVER['SCRIPT_NAME']."?op=item&fct=list&id=$id&value=$value&start=$start&limit=$limit", 10, _MD_SONGLIST_MSG_REQUESTNOTSENT);
41 41
                     }
42 42
                     exit;
43 43
                     break;
@@ -50,10 +50,10 @@  discard block
 block discarded – undo
50 50
                 $GLOBALS['xoopsOption']['template_main'] = 'songlist_requests_index.tpl';
51 51
                 require_once $GLOBALS['xoops']->path('/header.php');
52 52
                 if ($GLOBALS['songlistModuleConfig']['force_jquery'] && !isset($GLOBALS['loaded_jquery'])) {
53
-                    $GLOBALS['xoTheme']->addScript(XOOPS_URL . _MI_SONGLIST_JQUERY, ['type' => 'text/javascript']);
53
+                    $GLOBALS['xoTheme']->addScript(XOOPS_URL._MI_SONGLIST_JQUERY, ['type' => 'text/javascript']);
54 54
                     $GLOBALS['loaded_jquery'] = true;
55 55
                 }
56
-                $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . _MI_SONGLIST_STYLESHEET, ['type' => 'text/css']);
56
+                $GLOBALS['xoTheme']->addStylesheet(XOOPS_URL._MI_SONGLIST_STYLESHEET, ['type' => 'text/css']);
57 57
                 $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']);
58 58
                 $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']);
59 59
                 $GLOBALS['xoopsTpl']->assign('form', FormController::getFormRequests(false, false));
Please login to merge, or discard this patch.
view.tag.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1 1
 <?php declare(strict_types=1);
2 2
 
3
-require_once __DIR__ . '/header.php';
4
-require_once XOOPS_ROOT_PATH . '/modules/tag/view.tag.php';
3
+require_once __DIR__.'/header.php';
4
+require_once XOOPS_ROOT_PATH.'/modules/tag/view.tag.php';
Please login to merge, or discard this patch.
preloads/autoloader.php 2 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -4,31 +4,31 @@
 block discarded – undo
4 4
  * @see https://www.php-fig.org/psr/psr-4/examples/
5 5
  */
6 6
 spl_autoload_register(
7
-    static function ($class): void {
8
-        // project-specific namespace prefix
9
-        $prefix = 'XoopsModules\\Songlist\\';
7
+	static function ($class): void {
8
+		// project-specific namespace prefix
9
+		$prefix = 'XoopsModules\\Songlist\\';
10 10
 
11
-        // base directory for the namespace prefix
12
-        $baseDir = \dirname(__DIR__) . '/class/';
11
+		// base directory for the namespace prefix
12
+		$baseDir = \dirname(__DIR__) . '/class/';
13 13
 
14
-        // does the class use the namespace prefix?
15
-        $len = mb_strlen($prefix);
14
+		// does the class use the namespace prefix?
15
+		$len = mb_strlen($prefix);
16 16
 
17
-        if (0 !== strncmp($prefix, $class, $len)) {
18
-            return;
19
-        }
17
+		if (0 !== strncmp($prefix, $class, $len)) {
18
+			return;
19
+		}
20 20
 
21
-        // get the relative class name
22
-        $relativeClass = mb_substr($class, $len);
21
+		// get the relative class name
22
+		$relativeClass = mb_substr($class, $len);
23 23
 
24
-        // replace the namespace prefix with the base directory, replace namespace
25
-        // separators with directory separators in the relative class name, append
26
-        // with .php
27
-        $file = $baseDir . str_replace('\\', '/', $relativeClass) . '.php';
24
+		// replace the namespace prefix with the base directory, replace namespace
25
+		// separators with directory separators in the relative class name, append
26
+		// with .php
27
+		$file = $baseDir . str_replace('\\', '/', $relativeClass) . '.php';
28 28
 
29
-        // if the file exists, require it
30
-        if (is_file($file)) {
31
-            require_once $file;
32
-        }
33
-    }
29
+		// if the file exists, require it
30
+		if (is_file($file)) {
31
+			require_once $file;
32
+		}
33
+	}
34 34
 );
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,17 +4,17 @@  discard block
 block discarded – undo
4 4
  * @see https://www.php-fig.org/psr/psr-4/examples/
5 5
  */
6 6
 spl_autoload_register(
7
-    static function ($class): void {
7
+    static function($class): void {
8 8
         // project-specific namespace prefix
9 9
         $prefix = 'XoopsModules\\Songlist\\';
10 10
 
11 11
         // base directory for the namespace prefix
12
-        $baseDir = \dirname(__DIR__) . '/class/';
12
+        $baseDir = \dirname(__DIR__).'/class/';
13 13
 
14 14
         // does the class use the namespace prefix?
15 15
         $len = mb_strlen($prefix);
16 16
 
17
-        if (0 !== strncmp($prefix, $class, $len)) {
17
+        if (0!==strncmp($prefix, $class, $len)) {
18 18
             return;
19 19
         }
20 20
 
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
         // replace the namespace prefix with the base directory, replace namespace
25 25
         // separators with directory separators in the relative class name, append
26 26
         // with .php
27
-        $file = $baseDir . str_replace('\\', '/', $relativeClass) . '.php';
27
+        $file = $baseDir.str_replace('\\', '/', $relativeClass).'.php';
28 28
 
29 29
         // if the file exists, require it
30 30
         if (is_file($file)) {
Please login to merge, or discard this patch.
preloads/core.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -20,12 +20,12 @@
 block discarded – undo
20 20
  */
21 21
 class SonglistCorePreload extends \XoopsPreloadItem
22 22
 {
23
-    // to add PSR-4 autoloader
24
-    /**
25
-     * @param $args
26
-     */
27
-    public static function eventCoreIncludeCommonEnd($args): void
28
-    {
29
-        require_once __DIR__ . '/autoloader.php';
30
-    }
23
+	// to add PSR-4 autoloader
24
+	/**
25
+	 * @param $args
26
+	 */
27
+	public static function eventCoreIncludeCommonEnd($args): void
28
+	{
29
+		require_once __DIR__ . '/autoloader.php';
30
+	}
31 31
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,6 +26,6 @@
 block discarded – undo
26 26
      */
27 27
     public static function eventCoreIncludeCommonEnd($args): void
28 28
     {
29
-        require_once __DIR__ . '/autoloader.php';
29
+        require_once __DIR__.'/autoloader.php';
30 30
     }
31 31
 }
Please login to merge, or discard this patch.