Skip to content

Commit 088eb6f

Browse files
Add return types - batch 1/n
1 parent 1057386 commit 088eb6f

File tree

6 files changed

+83
-83
lines changed

6 files changed

+83
-83
lines changed

AbstractString.php

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public static function wrap(array $values): array
9595
*
9696
* @return static
9797
*/
98-
public function after(string|iterable $needle, bool $includeNeedle = false, int $offset = 0): self
98+
public function after(string|iterable $needle, bool $includeNeedle = false, int $offset = 0): static
9999
{
100100
$str = clone $this;
101101
$i = \PHP_INT_MAX;
@@ -130,7 +130,7 @@ public function after(string|iterable $needle, bool $includeNeedle = false, int
130130
*
131131
* @return static
132132
*/
133-
public function afterLast(string|iterable $needle, bool $includeNeedle = false, int $offset = 0): self
133+
public function afterLast(string|iterable $needle, bool $includeNeedle = false, int $offset = 0): static
134134
{
135135
$str = clone $this;
136136
$i = null;
@@ -163,14 +163,14 @@ public function afterLast(string|iterable $needle, bool $includeNeedle = false,
163163
/**
164164
* @return static
165165
*/
166-
abstract public function append(string ...$suffix): self;
166+
abstract public function append(string ...$suffix): static;
167167

168168
/**
169169
* @param string|string[] $needle
170170
*
171171
* @return static
172172
*/
173-
public function before(string|iterable $needle, bool $includeNeedle = false, int $offset = 0): self
173+
public function before(string|iterable $needle, bool $includeNeedle = false, int $offset = 0): static
174174
{
175175
$str = clone $this;
176176
$i = \PHP_INT_MAX;
@@ -205,7 +205,7 @@ public function before(string|iterable $needle, bool $includeNeedle = false, int
205205
*
206206
* @return static
207207
*/
208-
public function beforeLast(string|iterable $needle, bool $includeNeedle = false, int $offset = 0): self
208+
public function beforeLast(string|iterable $needle, bool $includeNeedle = false, int $offset = 0): static
209209
{
210210
$str = clone $this;
211211
$i = null;
@@ -248,7 +248,7 @@ public function bytesAt(int $offset): array
248248
/**
249249
* @return static
250250
*/
251-
abstract public function camel(): self;
251+
abstract public function camel(): static;
252252

253253
/**
254254
* @return static[]
@@ -258,7 +258,7 @@ abstract public function chunk(int $length = 1): array;
258258
/**
259259
* @return static
260260
*/
261-
public function collapseWhitespace(): self
261+
public function collapseWhitespace(): static
262262
{
263263
$str = clone $this;
264264
$str->string = trim(preg_replace('/(?:\s{2,}+|[^\S ])/', ' ', $str->string));
@@ -295,7 +295,7 @@ public function endsWith(string|iterable $suffix): bool
295295
/**
296296
* @return static
297297
*/
298-
public function ensureEnd(string $suffix): self
298+
public function ensureEnd(string $suffix): static
299299
{
300300
if (!$this->endsWith($suffix)) {
301301
return $this->append($suffix);
@@ -310,7 +310,7 @@ public function ensureEnd(string $suffix): self
310310
/**
311311
* @return static
312312
*/
313-
public function ensureStart(string $prefix): self
313+
public function ensureStart(string $prefix): static
314314
{
315315
$prefix = new static($prefix);
316316

@@ -350,12 +350,12 @@ public function equalsTo(string|iterable $string): bool
350350
/**
351351
* @return static
352352
*/
353-
abstract public function folded(): self;
353+
abstract public function folded(): static;
354354

355355
/**
356356
* @return static
357357
*/
358-
public function ignoreCase(): self
358+
public function ignoreCase(): static
359359
{
360360
$str = clone $this;
361361
$str->ignoreCase = true;
@@ -415,7 +415,7 @@ public function isEmpty(): bool
415415
/**
416416
* @return static
417417
*/
418-
abstract public function join(array $strings, string $lastGlue = null): self;
418+
abstract public function join(array $strings, string $lastGlue = null): static;
419419

420420
public function jsonSerialize(): string
421421
{
@@ -427,7 +427,7 @@ abstract public function length(): int;
427427
/**
428428
* @return static
429429
*/
430-
abstract public function lower(): self;
430+
abstract public function lower(): static;
431431

432432
/**
433433
* Matches the string using a regular expression.
@@ -441,27 +441,27 @@ abstract public function match(string $regexp, int $flags = 0, int $offset = 0):
441441
/**
442442
* @return static
443443
*/
444-
abstract public function padBoth(int $length, string $padStr = ' '): self;
444+
abstract public function padBoth(int $length, string $padStr = ' '): static;
445445

446446
/**
447447
* @return static
448448
*/
449-
abstract public function padEnd(int $length, string $padStr = ' '): self;
449+
abstract public function padEnd(int $length, string $padStr = ' '): static;
450450

451451
/**
452452
* @return static
453453
*/
454-
abstract public function padStart(int $length, string $padStr = ' '): self;
454+
abstract public function padStart(int $length, string $padStr = ' '): static;
455455

456456
/**
457457
* @return static
458458
*/
459-
abstract public function prepend(string ...$prefix): self;
459+
abstract public function prepend(string ...$prefix): static;
460460

461461
/**
462462
* @return static
463463
*/
464-
public function repeat(int $multiplier): self
464+
public function repeat(int $multiplier): static
465465
{
466466
if (0 > $multiplier) {
467467
throw new InvalidArgumentException(sprintf('Multiplier must be positive, %d given.', $multiplier));
@@ -476,34 +476,34 @@ public function repeat(int $multiplier): self
476476
/**
477477
* @return static
478478
*/
479-
abstract public function replace(string $from, string $to): self;
479+
abstract public function replace(string $from, string $to): static;
480480

481481
/**
482482
* @param string|callable $to
483483
*
484484
* @return static
485485
*/
486-
abstract public function replaceMatches(string $fromRegexp, string|callable $to): self;
486+
abstract public function replaceMatches(string $fromRegexp, string|callable $to): static;
487487

488488
/**
489489
* @return static
490490
*/
491-
abstract public function reverse(): self;
491+
abstract public function reverse(): static;
492492

493493
/**
494494
* @return static
495495
*/
496-
abstract public function slice(int $start = 0, int $length = null): self;
496+
abstract public function slice(int $start = 0, int $length = null): static;
497497

498498
/**
499499
* @return static
500500
*/
501-
abstract public function snake(): self;
501+
abstract public function snake(): static;
502502

503503
/**
504504
* @return static
505505
*/
506-
abstract public function splice(string $replacement, int $start = 0, int $length = null): self;
506+
abstract public function splice(string $replacement, int $start = 0, int $length = null): static;
507507

508508
/**
509509
* @return static[]
@@ -574,7 +574,7 @@ public function startsWith(string|iterable $prefix): bool
574574
/**
575575
* @return static
576576
*/
577-
abstract public function title(bool $allWords = false): self;
577+
abstract public function title(bool $allWords = false): static;
578578

579579
public function toByteString(string $toEncoding = null): ByteString
580580
{
@@ -625,22 +625,22 @@ public function toUnicodeString(): UnicodeString
625625
/**
626626
* @return static
627627
*/
628-
abstract public function trim(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): self;
628+
abstract public function trim(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): static;
629629

630630
/**
631631
* @return static
632632
*/
633-
abstract public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): self;
633+
abstract public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): static;
634634

635635
/**
636636
* @return static
637637
*/
638-
abstract public function trimStart(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): self;
638+
abstract public function trimStart(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): static;
639639

640640
/**
641641
* @return static
642642
*/
643-
public function truncate(int $length, string $ellipsis = '', bool $cut = true): self
643+
public function truncate(int $length, string $ellipsis = '', bool $cut = true): static
644644
{
645645
$stringLength = $this->length();
646646

@@ -670,7 +670,7 @@ public function truncate(int $length, string $ellipsis = '', bool $cut = true):
670670
/**
671671
* @return static
672672
*/
673-
abstract public function upper(): self;
673+
abstract public function upper(): static;
674674

675675
/**
676676
* Returns the printable length on a terminal.
@@ -680,7 +680,7 @@ abstract public function width(bool $ignoreAnsiDecoration = true): int;
680680
/**
681681
* @return static
682682
*/
683-
public function wordwrap(int $width = 75, string $break = "\n", bool $cut = false): self
683+
public function wordwrap(int $width = 75, string $break = "\n", bool $cut = false): static
684684
{
685685
$lines = '' !== $break ? $this->split($break) : [clone $this];
686686
$chars = [];

AbstractUnicodeString.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ abstract class AbstractUnicodeString extends AbstractString
5353
/**
5454
* @return static
5555
*/
56-
public static function fromCodePoints(int ...$codes): self
56+
public static function fromCodePoints(int ...$codes): static
5757
{
5858
$string = '';
5959

@@ -157,7 +157,7 @@ public function ascii(array $rules = []): self
157157
return $str;
158158
}
159159

160-
public function camel(): parent
160+
public function camel(): static
161161
{
162162
$str = clone $this;
163163
$str->string = str_replace(' ', '', preg_replace_callback('/\b./u', static function ($m) use (&$i) {
@@ -187,7 +187,7 @@ public function codePointsAt(int $offset): array
187187
return $codePoints;
188188
}
189189

190-
public function folded(bool $compat = true): parent
190+
public function folded(bool $compat = true): static
191191
{
192192
$str = clone $this;
193193

@@ -201,7 +201,7 @@ public function folded(bool $compat = true): parent
201201
return $str;
202202
}
203203

204-
public function join(array $strings, string $lastGlue = null): parent
204+
public function join(array $strings, string $lastGlue = null): static
205205
{
206206
$str = clone $this;
207207

@@ -215,7 +215,7 @@ public function join(array $strings, string $lastGlue = null): parent
215215
return $str;
216216
}
217217

218-
public function lower(): parent
218+
public function lower(): static
219219
{
220220
$str = clone $this;
221221
$str->string = mb_strtolower(str_replace('İ', '', $str->string), 'UTF-8');
@@ -255,7 +255,7 @@ public function match(string $regexp, int $flags = 0, int $offset = 0): array
255255
/**
256256
* @return static
257257
*/
258-
public function normalize(int $form = self::NFC): self
258+
public function normalize(int $form = self::NFC): static
259259
{
260260
if (!\in_array($form, [self::NFC, self::NFD, self::NFKC, self::NFKD])) {
261261
throw new InvalidArgumentException('Unsupported normalization form.');
@@ -267,7 +267,7 @@ public function normalize(int $form = self::NFC): self
267267
return $str;
268268
}
269269

270-
public function padBoth(int $length, string $padStr = ' '): parent
270+
public function padBoth(int $length, string $padStr = ' '): static
271271
{
272272
if ('' === $padStr || !preg_match('//u', $padStr)) {
273273
throw new InvalidArgumentException('Invalid UTF-8 string.');
@@ -279,7 +279,7 @@ public function padBoth(int $length, string $padStr = ' '): parent
279279
return $this->pad($length, $pad, \STR_PAD_BOTH);
280280
}
281281

282-
public function padEnd(int $length, string $padStr = ' '): parent
282+
public function padEnd(int $length, string $padStr = ' '): static
283283
{
284284
if ('' === $padStr || !preg_match('//u', $padStr)) {
285285
throw new InvalidArgumentException('Invalid UTF-8 string.');
@@ -291,7 +291,7 @@ public function padEnd(int $length, string $padStr = ' '): parent
291291
return $this->pad($length, $pad, \STR_PAD_RIGHT);
292292
}
293293

294-
public function padStart(int $length, string $padStr = ' '): parent
294+
public function padStart(int $length, string $padStr = ' '): static
295295
{
296296
if ('' === $padStr || !preg_match('//u', $padStr)) {
297297
throw new InvalidArgumentException('Invalid UTF-8 string.');
@@ -303,7 +303,7 @@ public function padStart(int $length, string $padStr = ' '): parent
303303
return $this->pad($length, $pad, \STR_PAD_LEFT);
304304
}
305305

306-
public function replaceMatches(string $fromRegexp, string|callable $to): parent
306+
public function replaceMatches(string $fromRegexp, string|callable $to): static
307307
{
308308
if ($this->ignoreCase) {
309309
$fromRegexp .= 'i';
@@ -354,23 +354,23 @@ public function replaceMatches(string $fromRegexp, string|callable $to): parent
354354
return $str;
355355
}
356356

357-
public function reverse(): parent
357+
public function reverse(): static
358358
{
359359
$str = clone $this;
360360
$str->string = implode('', array_reverse(preg_split('/(\X)/u', $str->string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY)));
361361

362362
return $str;
363363
}
364364

365-
public function snake(): parent
365+
public function snake(): static
366366
{
367367
$str = $this->camel()->title();
368368
$str->string = mb_strtolower(preg_replace(['/(\p{Lu}+)(\p{Lu}\p{Ll})/u', '/([\p{Ll}0-9])(\p{Lu})/u'], '\1_\2', $str->string), 'UTF-8');
369369

370370
return $str;
371371
}
372372

373-
public function title(bool $allWords = false): parent
373+
public function title(bool $allWords = false): static
374374
{
375375
$str = clone $this;
376376

@@ -383,7 +383,7 @@ public function title(bool $allWords = false): parent
383383
return $str;
384384
}
385385

386-
public function trim(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): parent
386+
public function trim(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): static
387387
{
388388
if (" \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}" !== $chars && !preg_match('//u', $chars)) {
389389
throw new InvalidArgumentException('Invalid UTF-8 chars.');
@@ -396,7 +396,7 @@ public function trim(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): parent
396396
return $str;
397397
}
398398

399-
public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): parent
399+
public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): static
400400
{
401401
if (" \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}" !== $chars && !preg_match('//u', $chars)) {
402402
throw new InvalidArgumentException('Invalid UTF-8 chars.');
@@ -409,7 +409,7 @@ public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): pare
409409
return $str;
410410
}
411411

412-
public function trimStart(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): parent
412+
public function trimStart(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): static
413413
{
414414
if (" \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}" !== $chars && !preg_match('//u', $chars)) {
415415
throw new InvalidArgumentException('Invalid UTF-8 chars.');
@@ -422,7 +422,7 @@ public function trimStart(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): pa
422422
return $str;
423423
}
424424

425-
public function upper(): parent
425+
public function upper(): static
426426
{
427427
$str = clone $this;
428428
$str->string = mb_strtoupper($str->string, 'UTF-8');

0 commit comments

Comments
 (0)