Skip to content

Commit 886ec87

Browse files
committed
CS
1 parent 31295a7 commit 886ec87

27 files changed

Lines changed: 56 additions & 141 deletions

Mbstring.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,13 @@
3939
abstract class Mbstring
4040
{
4141
const CASE_SENSITIVE = true;
42+
4243
const CASE_INSENSITIVE = false;
4344

4445
const ENCODING_DEFAULT_ISO = 'ISO-8859-1';
46+
4547
const ENCODING_UTF8 = 'UTF-8';
48+
4649
const ENCODING_US_ASCII = 'US-ASCII';
4750

4851
/**

Str.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@
1616
class Str
1717
{
1818
const CASE_SENSITIVE = true;
19+
1920
const CASE_INSENSITIVE = false;
2021

2122
const ENCODING_DEFAULT_ISO = 'ISO-8859-1';
23+
2224
const ENCODING_UTF8 = 'UTF-8';
25+
2326
const ENCODING_US_ASCII = 'US-ASCII';
2427

2528
/**

StringHelper.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
abstract class StringHelper
1919
{
2020
const INCREMENT_STYLE_DASH = 'dash';
21+
2122
const INCREMENT_STYLE_DEFAULT = 'default';
2223

2324
/**

StringInflector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,9 @@ public function addSingulariseRule($data)
306306
public static function getInstance($new = false)
307307
{
308308
if ($new) {
309-
return new static;
309+
return new static();
310310
} elseif (!is_object(static::$instance)) {
311-
static::$instance = new static;
311+
static::$instance = new static();
312312
}
313313

314314
return static::$instance;

StringObject.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ class StringObject implements \Countable, \ArrayAccess, \IteratorAggregate, Stri
6060
* @see http://php.net/manual/en/xml.encoding.php
6161
*/
6262
const ENCODING_DEFAULT_ISO = 'ISO-8859-1';
63+
6364
const ENCODING_UTF8 = 'UTF-8';
65+
6466
const ENCODING_US_ASCII = 'US-ASCII';
6567

6668
/**

Test/InflectorTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public function testAddRule()
157157
*/
158158
public function testAddRuleException()
159159
{
160-
TestHelper::invoke($this->StringInflector, 'addRule', new \stdClass, 'singular');
160+
TestHelper::invoke($this->StringInflector, 'addRule', new \stdClass(), 'singular');
161161
}
162162

163163
/**
@@ -412,11 +412,11 @@ public function testGetInstance()
412412
);
413413

414414
// Inject an instance an test.
415-
TestHelper::setValue($this->StringInflector, 'instance', new \stdClass);
415+
TestHelper::setValue($this->StringInflector, 'instance', new \stdClass());
416416

417417
$this->assertThat(
418418
StringInflector::getInstance(),
419-
$this->equalTo(new \stdClass),
419+
$this->equalTo(new \stdClass()),
420420
'Checks singleton instance is returned.'
421421
);
422422

phputf8/mbstring/core.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ function utf8_strlen($str)
3030
return mb_strlen($str);
3131
}
3232

33-
3433
//--------------------------------------------------------------------
3534
/**
3635
* Assumes mbstring internal encoding is set to UTF-8
@@ -73,10 +72,12 @@ function utf8_strrpos($str, $search, $offset = false)
7372
if (empty($str)) {
7473
return false;
7574
}
75+
7676
return mb_strrpos($str, $search);
7777
} else {
7878
if (!is_int($offset)) {
7979
trigger_error('utf8_strrpos expects parameter 3 to be long', E_USER_WARNING);
80+
8081
return false;
8182
}
8283

phputf8/native/core.php

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ function utf8_strlen($str)
3737
return strlen(utf8_decode($str));
3838
}
3939

40-
4140
//--------------------------------------------------------------------
4241
/**
4342
* UTF-8 aware alternative to strpos
@@ -57,19 +56,17 @@ function utf8_strlen($str)
5756
*/
5857
function utf8_strpos($str, $needle, $offset = null)
5958
{
60-
6159
if (is_null($offset)) {
62-
6360
$ar = explode($needle, $str, 2);
6461
if (count($ar) > 1) {
6562
return utf8_strlen($ar[0]);
6663
}
67-
return false;
6864

65+
return false;
6966
} else {
70-
7167
if (!is_int($offset)) {
7268
trigger_error('utf8_strpos: Offset must be an integer', E_USER_ERROR);
69+
7370
return false;
7471
}
7572

@@ -81,7 +78,6 @@ function utf8_strpos($str, $needle, $offset = null)
8178

8279
return false;
8380
}
84-
8581
}
8682

8783
//--------------------------------------------------------------------
@@ -103,23 +99,22 @@ function utf8_strpos($str, $needle, $offset = null)
10399
*/
104100
function utf8_strrpos($str, $needle, $offset = null)
105101
{
106-
107102
if (is_null($offset)) {
108-
109103
$ar = explode($needle, $str);
110104

111105
if (count($ar) > 1) {
112106
// Pop off the end of the string where the last match was made
113107
array_pop($ar);
114108
$str = join($needle, $ar);
109+
115110
return utf8_strlen($str);
116111
}
117-
return false;
118112

113+
return false;
119114
} else {
120-
121115
if (!is_int($offset)) {
122116
trigger_error('utf8_strrpos expects parameter 3 to be long', E_USER_WARNING);
117+
123118
return false;
124119
}
125120

@@ -131,7 +126,6 @@ function utf8_strrpos($str, $needle, $offset = null)
131126

132127
return false;
133128
}
134-
135129
}
136130

137131
//--------------------------------------------------------------------
@@ -167,7 +161,6 @@ function utf8_strrpos($str, $needle, $offset = null)
167161
*/
168162
function utf8_substr($str, $offset, $length = null)
169163
{
170-
171164
// generates E_NOTICE
172165
// for PHP4 objects, but not PHP5 objects
173166
$str = (string) $str;
@@ -187,14 +180,12 @@ function utf8_substr($str, $offset, $length = null)
187180
// normalise negative offsets (we could use a tail
188181
// anchored pattern, but they are horribly slow!)
189182
if ($offset < 0) {
190-
191183
// see notes
192184
$strlen = strlen(utf8_decode($str));
193185
$offset = $strlen + $offset;
194186
if ($offset < 0) {
195187
$offset = 0;
196188
}
197-
198189
}
199190

200191
$Op = '';
@@ -203,7 +194,6 @@ function utf8_substr($str, $offset, $length = null)
203194
// establish a pattern for offset, a
204195
// non-captured group equal in length to offset
205196
if ($offset > 0) {
206-
207197
$Ox = (int) ($offset / 65535);
208198
$Oy = $offset % 65535;
209199

@@ -212,22 +202,16 @@ function utf8_substr($str, $offset, $length = null)
212202
}
213203

214204
$Op = '^(?:' . $Op . '.{' . $Oy . '})';
215-
216205
} else {
217-
218206
// offset == 0; just anchor the pattern
219207
$Op = '^';
220-
221208
}
222209

223210
// establish a pattern for length
224211
if (is_null($length)) {
225-
226212
// the rest of the string
227213
$Lp = '(.*)$';
228-
229214
} else {
230-
231215
if (!isset($strlen)) {
232216
// see notes
233217
$strlen = strlen(utf8_decode($str));
@@ -239,7 +223,6 @@ function utf8_substr($str, $offset, $length = null)
239223
}
240224

241225
if ($length > 0) {
242-
243226
// reduce any length that would
244227
// go passed the end of the string
245228
$length = min($strlen - $offset, $length);
@@ -253,10 +236,8 @@ function utf8_substr($str, $offset, $length = null)
253236
$Lp = '(?:.{65535}){' . $Lx . '}';
254237
}
255238
$Lp = '(' . $Lp . '.{' . $Ly . '})';
256-
257239
} else {
258240
if ($length < 0) {
259-
260241
if ($length < ($offset - $strlen)) {
261242
return '';
262243
}
@@ -271,18 +252,15 @@ function utf8_substr($str, $offset, $length = null)
271252
$Lp = '(?:.{65535}){' . $Lx . '}';
272253
}
273254
$Lp = '(.*)(?:' . $Lp . '.{' . $Ly . '})$';
274-
275255
}
276256
}
277-
278257
}
279258

280259
if (!preg_match('#' . $Op . $Lp . '#us', $str, $match)) {
281260
return '';
282261
}
283262

284263
return $match[1];
285-
286264
}
287265

288266
//---------------------------------------------------------------
@@ -308,7 +286,6 @@ function utf8_substr($str, $offset, $length = null)
308286
*/
309287
function utf8_strtolower($string)
310288
{
311-
312289
static $UTF8_UPPER_TO_LOWER = null;
313290

314291
if (is_null($UTF8_UPPER_TO_LOWER)) {
@@ -568,7 +545,6 @@ function utf8_strtolower($string)
568545
*/
569546
function utf8_strtoupper($string)
570547
{
571-
572548
static $UTF8_LOWER_TO_UPPER = null;
573549

574550
if (is_null($UTF8_LOWER_TO_UPPER)) {

phputf8/ord.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
*/
2020
function utf8_ord($chr)
2121
{
22-
2322
$ord0 = ord($chr);
2423

2524
if ($ord0 >= 0 && $ord0 <= 127) {
@@ -28,6 +27,7 @@ function utf8_ord($chr)
2827

2928
if (!isset($chr{1})) {
3029
trigger_error('Short sequence - at least 2 bytes expected, only 1 seen');
30+
3131
return false;
3232
}
3333

@@ -39,6 +39,7 @@ function utf8_ord($chr)
3939

4040
if (!isset($chr{2})) {
4141
trigger_error('Short sequence - at least 3 bytes expected, only 2 seen');
42+
4243
return false;
4344
}
4445
$ord2 = ord($chr{2});
@@ -50,6 +51,7 @@ function utf8_ord($chr)
5051

5152
if (!isset($chr{3})) {
5253
trigger_error('Short sequence - at least 4 bytes expected, only 3 seen');
54+
5355
return false;
5456
}
5557
$ord3 = ord($chr{3});
@@ -58,11 +60,11 @@ function utf8_ord($chr)
5860
+ ($ord1 - 128) * 4096
5961
+ ($ord2 - 128) * 64
6062
+ ($ord3 - 128);
61-
6263
}
6364

6465
if (!isset($chr{4})) {
6566
trigger_error('Short sequence - at least 5 bytes expected, only 4 seen');
67+
6668
return false;
6769
}
6870
$ord4 = ord($chr{4});
@@ -76,6 +78,7 @@ function utf8_ord($chr)
7678

7779
if (!isset($chr{5})) {
7880
trigger_error('Short sequence - at least 6 bytes expected, only 5 seen');
81+
7982
return false;
8083
}
8184
if ($ord0 >= 252 && $ord0 <= 253) {
@@ -89,8 +92,8 @@ function utf8_ord($chr)
8992

9093
if ($ord0 >= 254 && $ord0 <= 255) {
9194
trigger_error('Invalid UTF-8 with surrogate ordinal ' . $ord0);
95+
9296
return false;
9397
}
94-
9598
}
9699

phputf8/str_ireplace.php

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@
2525
*/
2626
function utf8_ireplace($search, $replace, $str, $count = null)
2727
{
28-
2928
if (!is_array($search)) {
30-
3129
$slen = strlen($search);
3230
if ($slen == 0) {
3331
return $str;
@@ -50,34 +48,23 @@ function utf8_ireplace($search, $replace, $str, $count = null)
5048
$matched += $mlen + $lendif;
5149
$i++;
5250
}
53-
return $str;
5451

52+
return $str;
5553
} else {
56-
5754
foreach (array_keys($search) as $k) {
58-
5955
if (is_array($replace)) {
60-
6156
if (array_key_exists($k, $replace)) {
62-
6357
$str = utf8_ireplace($search[$k], $replace[$k], $str, $count);
64-
6558
} else {
66-
6759
$str = utf8_ireplace($search[$k], '', $str, $count);
68-
6960
}
70-
7161
} else {
72-
7362
$str = utf8_ireplace($search[$k], $replace, $str, $count);
74-
7563
}
7664
}
77-
return $str;
7865

66+
return $str;
7967
}
80-
8168
}
8269

8370

0 commit comments

Comments
 (0)