Skip to content

Commit 7523a9c

Browse files
Merge branch '4.4' into 5.1
* 4.4: Enable "native_constant_invocation" CS rule Make AbstractPhpFileCacheWarmer public
1 parent 0de4cc1 commit 7523a9c

File tree

9 files changed

+52
-52
lines changed

9 files changed

+52
-52
lines changed

AbstractString.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@
2929
*/
3030
abstract class AbstractString implements \Stringable, \JsonSerializable
3131
{
32-
public const PREG_PATTERN_ORDER = PREG_PATTERN_ORDER;
33-
public const PREG_SET_ORDER = PREG_SET_ORDER;
34-
public const PREG_OFFSET_CAPTURE = PREG_OFFSET_CAPTURE;
35-
public const PREG_UNMATCHED_AS_NULL = PREG_UNMATCHED_AS_NULL;
32+
public const PREG_PATTERN_ORDER = \PREG_PATTERN_ORDER;
33+
public const PREG_SET_ORDER = \PREG_SET_ORDER;
34+
public const PREG_OFFSET_CAPTURE = \PREG_OFFSET_CAPTURE;
35+
public const PREG_UNMATCHED_AS_NULL = \PREG_UNMATCHED_AS_NULL;
3636

3737
public const PREG_SPLIT = 0;
38-
public const PREG_SPLIT_NO_EMPTY = PREG_SPLIT_NO_EMPTY;
39-
public const PREG_SPLIT_DELIM_CAPTURE = PREG_SPLIT_DELIM_CAPTURE;
40-
public const PREG_SPLIT_OFFSET_CAPTURE = PREG_SPLIT_OFFSET_CAPTURE;
38+
public const PREG_SPLIT_NO_EMPTY = \PREG_SPLIT_NO_EMPTY;
39+
public const PREG_SPLIT_DELIM_CAPTURE = \PREG_SPLIT_DELIM_CAPTURE;
40+
public const PREG_SPLIT_OFFSET_CAPTURE = \PREG_SPLIT_OFFSET_CAPTURE;
4141

4242
protected $string = '';
4343
protected $ignoreCase = false;
@@ -99,7 +99,7 @@ public function after($needle, bool $includeNeedle = false, int $offset = 0): se
9999
{
100100
$str = clone $this;
101101
$str->string = '';
102-
$i = PHP_INT_MAX;
102+
$i = \PHP_INT_MAX;
103103

104104
foreach ((array) $needle as $n) {
105105
$n = (string) $n;
@@ -111,7 +111,7 @@ public function after($needle, bool $includeNeedle = false, int $offset = 0): se
111111
}
112112
}
113113

114-
if (PHP_INT_MAX === $i) {
114+
if (\PHP_INT_MAX === $i) {
115115
return $str;
116116
}
117117

@@ -168,7 +168,7 @@ public function before($needle, bool $includeNeedle = false, int $offset = 0): s
168168
{
169169
$str = clone $this;
170170
$str->string = '';
171-
$i = PHP_INT_MAX;
171+
$i = \PHP_INT_MAX;
172172

173173
foreach ((array) $needle as $n) {
174174
$n = (string) $n;
@@ -180,7 +180,7 @@ public function before($needle, bool $includeNeedle = false, int $offset = 0): s
180180
}
181181
}
182182

183-
if (PHP_INT_MAX === $i) {
183+
if (\PHP_INT_MAX === $i) {
184184
return $str;
185185
}
186186

@@ -360,7 +360,7 @@ public function indexOf($needle, int $offset = 0): ?int
360360
throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
361361
}
362362

363-
$i = PHP_INT_MAX;
363+
$i = \PHP_INT_MAX;
364364

365365
foreach ($needle as $n) {
366366
$j = $this->indexOf((string) $n, $offset);
@@ -370,7 +370,7 @@ public function indexOf($needle, int $offset = 0): ?int
370370
}
371371
}
372372

373-
return PHP_INT_MAX === $i ? null : $i;
373+
return \PHP_INT_MAX === $i ? null : $i;
374374
}
375375

376376
/**

AbstractUnicodeString.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public function ascii(array $rules = []): self
137137
}
138138
} elseif (!\function_exists('iconv')) {
139139
$s = preg_replace('/[^\x00-\x7F]/u', '?', $s);
140-
} elseif (ICONV_IMPL === 'glibc') {
140+
} elseif (\ICONV_IMPL === 'glibc') {
141141
$s = iconv('UTF-8', 'ASCII//TRANSLIT', $s);
142142
} else {
143143
$s = @preg_replace_callback('/[^\x00-\x7F]/u', static function ($c) {
@@ -159,7 +159,7 @@ public function camel(): parent
159159
{
160160
$str = clone $this;
161161
$str->string = str_replace(' ', '', preg_replace_callback('/\b./u', static function ($m) use (&$i) {
162-
return 1 === ++$i ? ('İ' === $m[0] ? '' : mb_strtolower($m[0], 'UTF-8')) : mb_convert_case($m[0], MB_CASE_TITLE, 'UTF-8');
162+
return 1 === ++$i ? ('İ' === $m[0] ? '' : mb_strtolower($m[0], 'UTF-8')) : mb_convert_case($m[0], \MB_CASE_TITLE, 'UTF-8');
163163
}, preg_replace('/[^\pL0-9]++/u', ' ', $this->string)));
164164

165165
return $str;
@@ -178,7 +178,7 @@ public function codePointsAt(int $offset): array
178178

179179
$codePoints = [];
180180

181-
foreach (preg_split('//u', $str->string, -1, PREG_SPLIT_NO_EMPTY) as $c) {
181+
foreach (preg_split('//u', $str->string, -1, \PREG_SPLIT_NO_EMPTY) as $c) {
182182
$codePoints[] = mb_ord($c, 'UTF-8');
183183
}
184184

@@ -223,7 +223,7 @@ public function lower(): parent
223223

224224
public function match(string $regexp, int $flags = 0, int $offset = 0): array
225225
{
226-
$match = ((PREG_PATTERN_ORDER | PREG_SET_ORDER) & $flags) ? 'preg_match_all' : 'preg_match';
226+
$match = ((\PREG_PATTERN_ORDER | \PREG_SET_ORDER) & $flags) ? 'preg_match_all' : 'preg_match';
227227

228228
if ($this->ignoreCase) {
229229
$regexp .= 'i';
@@ -232,7 +232,7 @@ public function match(string $regexp, int $flags = 0, int $offset = 0): array
232232
set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
233233

234234
try {
235-
if (false === $match($regexp.'u', $this->string, $matches, $flags | PREG_UNMATCHED_AS_NULL, $offset)) {
235+
if (false === $match($regexp.'u', $this->string, $matches, $flags | \PREG_UNMATCHED_AS_NULL, $offset)) {
236236
$lastError = preg_last_error();
237237

238238
foreach (get_defined_constants(true)['pcre'] as $k => $v) {
@@ -274,7 +274,7 @@ public function padBoth(int $length, string $padStr = ' '): parent
274274
$pad = clone $this;
275275
$pad->string = $padStr;
276276

277-
return $this->pad($length, $pad, STR_PAD_BOTH);
277+
return $this->pad($length, $pad, \STR_PAD_BOTH);
278278
}
279279

280280
public function padEnd(int $length, string $padStr = ' '): parent
@@ -286,7 +286,7 @@ public function padEnd(int $length, string $padStr = ' '): parent
286286
$pad = clone $this;
287287
$pad->string = $padStr;
288288

289-
return $this->pad($length, $pad, STR_PAD_RIGHT);
289+
return $this->pad($length, $pad, \STR_PAD_RIGHT);
290290
}
291291

292292
public function padStart(int $length, string $padStr = ' '): parent
@@ -298,7 +298,7 @@ public function padStart(int $length, string $padStr = ' '): parent
298298
$pad = clone $this;
299299
$pad->string = $padStr;
300300

301-
return $this->pad($length, $pad, STR_PAD_LEFT);
301+
return $this->pad($length, $pad, \STR_PAD_LEFT);
302302
}
303303

304304
public function replaceMatches(string $fromRegexp, $to): parent
@@ -355,7 +355,7 @@ public function replaceMatches(string $fromRegexp, $to): parent
355355
public function reverse(): parent
356356
{
357357
$str = clone $this;
358-
$str->string = implode('', array_reverse(preg_split('/(\X)/u', $str->string, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY)));
358+
$str->string = implode('', array_reverse(preg_split('/(\X)/u', $str->string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY)));
359359

360360
return $str;
361361
}
@@ -375,7 +375,7 @@ public function title(bool $allWords = false): parent
375375
$limit = $allWords ? -1 : 1;
376376

377377
$str->string = preg_replace_callback('/\b./u', static function (array $m): string {
378-
return mb_convert_case($m[0], MB_CASE_TITLE, 'UTF-8');
378+
return mb_convert_case($m[0], \MB_CASE_TITLE, 'UTF-8');
379379
}, $str->string, $limit);
380380

381381
return $str;
@@ -477,13 +477,13 @@ private function pad(int $len, self $pad, int $type): parent
477477
$len = $freeLen % $padLen;
478478

479479
switch ($type) {
480-
case STR_PAD_RIGHT:
480+
case \STR_PAD_RIGHT:
481481
return $this->append(str_repeat($pad->string, $freeLen / $padLen).($len ? $pad->slice(0, $len) : ''));
482482

483-
case STR_PAD_LEFT:
483+
case \STR_PAD_LEFT:
484484
return $this->prepend(str_repeat($pad->string, $freeLen / $padLen).($len ? $pad->slice(0, $len) : ''));
485485

486-
case STR_PAD_BOTH:
486+
case \STR_PAD_BOTH:
487487
$freeLen /= 2;
488488

489489
$rightLen = ceil($freeLen);
@@ -507,7 +507,7 @@ private function wcswidth(string $string): int
507507
{
508508
$width = 0;
509509

510-
foreach (preg_split('//u', $string, -1, PREG_SPLIT_NO_EMPTY) as $c) {
510+
foreach (preg_split('//u', $string, -1, \PREG_SPLIT_NO_EMPTY) as $c) {
511511
$codePoint = mb_ord($c, 'UTF-8');
512512

513513
if (0 === $codePoint // NULL

ByteString.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public function lower(): parent
235235

236236
public function match(string $regexp, int $flags = 0, int $offset = 0): array
237237
{
238-
$match = ((PREG_PATTERN_ORDER | PREG_SET_ORDER) & $flags) ? 'preg_match_all' : 'preg_match';
238+
$match = ((\PREG_PATTERN_ORDER | \PREG_SET_ORDER) & $flags) ? 'preg_match_all' : 'preg_match';
239239

240240
if ($this->ignoreCase) {
241241
$regexp .= 'i';
@@ -244,7 +244,7 @@ public function match(string $regexp, int $flags = 0, int $offset = 0): array
244244
set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
245245

246246
try {
247-
if (false === $match($regexp, $this->string, $matches, $flags | PREG_UNMATCHED_AS_NULL, $offset)) {
247+
if (false === $match($regexp, $this->string, $matches, $flags | \PREG_UNMATCHED_AS_NULL, $offset)) {
248248
$lastError = preg_last_error();
249249

250250
foreach (get_defined_constants(true)['pcre'] as $k => $v) {
@@ -265,23 +265,23 @@ public function match(string $regexp, int $flags = 0, int $offset = 0): array
265265
public function padBoth(int $length, string $padStr = ' '): parent
266266
{
267267
$str = clone $this;
268-
$str->string = str_pad($this->string, $length, $padStr, STR_PAD_BOTH);
268+
$str->string = str_pad($this->string, $length, $padStr, \STR_PAD_BOTH);
269269

270270
return $str;
271271
}
272272

273273
public function padEnd(int $length, string $padStr = ' '): parent
274274
{
275275
$str = clone $this;
276-
$str->string = str_pad($this->string, $length, $padStr, STR_PAD_RIGHT);
276+
$str->string = str_pad($this->string, $length, $padStr, \STR_PAD_RIGHT);
277277

278278
return $str;
279279
}
280280

281281
public function padStart(int $length, string $padStr = ' '): parent
282282
{
283283
$str = clone $this;
284-
$str->string = str_pad($this->string, $length, $padStr, STR_PAD_LEFT);
284+
$str->string = str_pad($this->string, $length, $padStr, \STR_PAD_LEFT);
285285

286286
return $str;
287287
}
@@ -356,7 +356,7 @@ public function reverse(): parent
356356
public function slice(int $start = 0, int $length = null): parent
357357
{
358358
$str = clone $this;
359-
$str->string = (string) substr($this->string, $start, $length ?? PHP_INT_MAX);
359+
$str->string = (string) substr($this->string, $start, $length ?? \PHP_INT_MAX);
360360

361361
return $str;
362362
}
@@ -372,14 +372,14 @@ public function snake(): parent
372372
public function splice(string $replacement, int $start = 0, int $length = null): parent
373373
{
374374
$str = clone $this;
375-
$str->string = substr_replace($this->string, $replacement, $start, $length ?? PHP_INT_MAX);
375+
$str->string = substr_replace($this->string, $replacement, $start, $length ?? \PHP_INT_MAX);
376376

377377
return $str;
378378
}
379379

380380
public function split(string $delimiter, int $limit = null, int $flags = null): array
381381
{
382-
if (1 > $limit = $limit ?? PHP_INT_MAX) {
382+
if (1 > $limit = $limit ?? \PHP_INT_MAX) {
383383
throw new InvalidArgumentException('Split limit must be a positive integer.');
384384
}
385385

CodePointString.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function chunk(int $length = 1): array
6565
$str = clone $this;
6666
$chunks = [];
6767

68-
foreach (preg_split($rx, $this->string, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY) as $chunk) {
68+
foreach (preg_split($rx, $this->string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY) as $chunk) {
6969
$str->string = $chunk;
7070
$chunks[] = clone $str;
7171
}
@@ -211,14 +211,14 @@ public function splice(string $replacement, int $start = 0, int $length = null):
211211
$str = clone $this;
212212
$start = $start ? \strlen(mb_substr($this->string, 0, $start, 'UTF-8')) : 0;
213213
$length = $length ? \strlen(mb_substr($this->string, $start, $length, 'UTF-8')) : $length;
214-
$str->string = substr_replace($this->string, $replacement, $start, $length ?? PHP_INT_MAX);
214+
$str->string = substr_replace($this->string, $replacement, $start, $length ?? \PHP_INT_MAX);
215215

216216
return $str;
217217
}
218218

219219
public function split(string $delimiter, int $limit = null, int $flags = null): array
220220
{
221-
if (1 > $limit = $limit ?? PHP_INT_MAX) {
221+
if (1 > $limit = $limit ?? \PHP_INT_MAX) {
222222
throw new InvalidArgumentException('Split limit must be a positive integer.');
223223
}
224224

LazyString.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function __toString()
113113

114114
if (\PHP_VERSION_ID < 70400) {
115115
// leverage the ErrorHandler component with graceful fallback when it's not available
116-
return trigger_error($e, E_USER_ERROR);
116+
return trigger_error($e, \E_USER_ERROR);
117117
}
118118

119119
throw $e;

Resources/WcswidthDataGenerator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ private function writeWideWidthData(): void
4646

4747
$version = $matches[1];
4848

49-
if (!preg_match_all('/^([A-H\d]{4,})(?:\.\.([A-H\d]{4,}))?;[W|F]/m', $content, $matches, PREG_SET_ORDER)) {
49+
if (!preg_match_all('/^([A-H\d]{4,})(?:\.\.([A-H\d]{4,}))?;[W|F]/m', $content, $matches, \PREG_SET_ORDER)) {
5050
throw new RuntimeException('The wide width pattern did not match anything.');
5151
}
5252

@@ -61,7 +61,7 @@ private function writeZeroWidthData(): void
6161

6262
$version = $matches[1];
6363

64-
if (!preg_match_all('/^([A-H\d]{4,})(?:\.\.([A-H\d]{4,}))? *; (?:Me|Mn)/m', $content, $matches, PREG_SET_ORDER)) {
64+
if (!preg_match_all('/^([A-H\d]{4,})(?:\.\.([A-H\d]{4,}))? *; (?:Me|Mn)/m', $content, $matches, \PREG_SET_ORDER)) {
6565
throw new RuntimeException('The zero width pattern did not match anything.');
6666
}
6767

Resources/bin/update-data.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
use Symfony\Component\String\Resources\WcswidthDataGenerator;
1313

14-
error_reporting(E_ALL);
14+
error_reporting(\E_ALL);
1515

1616
set_error_handler(static function (int $type, string $msg, string $file, int $line): void {
1717
throw new \ErrorException($msg, 0, $type, $file, $line);

Tests/LazyStringTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function testIsNotStringable()
105105
{
106106
$this->assertFalse(LazyString::isStringable(null));
107107
$this->assertFalse(LazyString::isStringable([]));
108-
$this->assertFalse(LazyString::isStringable(STDIN));
108+
$this->assertFalse(LazyString::isStringable(\STDIN));
109109
$this->assertFalse(LazyString::isStringable(new \StdClass()));
110110
}
111111
}

UnicodeString.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function chunk(int $length = 1): array
7474
$str = clone $this;
7575
$chunks = [];
7676

77-
foreach (preg_split($rx, $this->string, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY) as $chunk) {
77+
foreach (preg_split($rx, $this->string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY) as $chunk) {
7878
$str->string = $chunk;
7979
$chunks[] = clone $str;
8080
}
@@ -100,10 +100,10 @@ public function endsWith($suffix): bool
100100
}
101101

102102
if ($this->ignoreCase) {
103-
return 0 === mb_stripos(grapheme_extract($this->string, \strlen($suffix), GRAPHEME_EXTR_MAXBYTES, \strlen($this->string) - \strlen($suffix)), $suffix, 0, 'UTF-8');
103+
return 0 === mb_stripos(grapheme_extract($this->string, \strlen($suffix), \GRAPHEME_EXTR_MAXBYTES, \strlen($this->string) - \strlen($suffix)), $suffix, 0, 'UTF-8');
104104
}
105105

106-
return $suffix === grapheme_extract($this->string, \strlen($suffix), GRAPHEME_EXTR_MAXBYTES, \strlen($this->string) - \strlen($suffix));
106+
return $suffix === grapheme_extract($this->string, \strlen($suffix), \GRAPHEME_EXTR_MAXBYTES, \strlen($this->string) - \strlen($suffix));
107107
}
108108

109109
public function equalsTo($string): bool
@@ -263,7 +263,7 @@ public function replaceMatches(string $fromRegexp, $to): AbstractString
263263
public function slice(int $start = 0, int $length = null): AbstractString
264264
{
265265
$str = clone $this;
266-
$str->string = (string) grapheme_substr($this->string, $start, $length ?? PHP_INT_MAX);
266+
$str->string = (string) grapheme_substr($this->string, $start, $length ?? \PHP_INT_MAX);
267267

268268
return $str;
269269
}
@@ -272,8 +272,8 @@ public function splice(string $replacement, int $start = 0, int $length = null):
272272
{
273273
$str = clone $this;
274274
$start = $start ? \strlen(grapheme_substr($this->string, 0, $start)) : 0;
275-
$length = $length ? \strlen(grapheme_substr($this->string, $start, $length ?? PHP_INT_MAX)) : $length;
276-
$str->string = substr_replace($this->string, $replacement, $start, $length ?? PHP_INT_MAX);
275+
$length = $length ? \strlen(grapheme_substr($this->string, $start, $length ?? \PHP_INT_MAX)) : $length;
276+
$str->string = substr_replace($this->string, $replacement, $start, $length ?? \PHP_INT_MAX);
277277
normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string);
278278

279279
if (false === $str->string) {
@@ -285,7 +285,7 @@ public function splice(string $replacement, int $start = 0, int $length = null):
285285

286286
public function split(string $delimiter, int $limit = null, int $flags = null): array
287287
{
288-
if (1 > $limit = $limit ?? PHP_INT_MAX) {
288+
if (1 > $limit = $limit ?? \PHP_INT_MAX) {
289289
throw new InvalidArgumentException('Split limit must be a positive integer.');
290290
}
291291

@@ -339,10 +339,10 @@ public function startsWith($prefix): bool
339339
}
340340

341341
if ($this->ignoreCase) {
342-
return 0 === mb_stripos(grapheme_extract($this->string, \strlen($prefix), GRAPHEME_EXTR_MAXBYTES), $prefix, 0, 'UTF-8');
342+
return 0 === mb_stripos(grapheme_extract($this->string, \strlen($prefix), \GRAPHEME_EXTR_MAXBYTES), $prefix, 0, 'UTF-8');
343343
}
344344

345-
return $prefix === grapheme_extract($this->string, \strlen($prefix), GRAPHEME_EXTR_MAXBYTES);
345+
return $prefix === grapheme_extract($this->string, \strlen($prefix), \GRAPHEME_EXTR_MAXBYTES);
346346
}
347347

348348
public function __wakeup()

0 commit comments

Comments
 (0)