Skip to content

Commit c38c303

Browse files
feature #435 [PHP 8.3] Polyfill mb_str_pad() (IonBazan)
This PR was squashed before being merged into the 1.28-dev branch. Discussion ---------- [PHP 8.3] Polyfill mb_str_pad() Polyfills the `mb_str_pad()` function added in PHP 8.3: https://wiki.php.net/rfc/mb_str_pad Test cases were taken from the RFC implementation and adapted to PHPUnit. Commits ------- 7ccd416 [PHP 8.3] Polyfill mb_str_pad()
2 parents 99e610e + 7ccd416 commit c38c303

File tree

9 files changed

+302
-3
lines changed

9 files changed

+302
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ Polyfills are provided for:
7171
- the `Random\Engine\Secure` class introduced in PHP 8.2 (check [arokettu/random-polyfill](https://packagist.org/packages/arokettu/random-polyfill) for more engines);
7272
- the `json_validate` function introduced in PHP 8.3;
7373
- the `Override` attribute introduced in PHP 8.3;
74+
- the `mb_str_pad` function introduced in PHP 8.3;
7475

7576
It is strongly recommended to upgrade your PHP version and/or install the missing
7677
extensions whenever possible. This polyfill should be used only when there is no

src/Mbstring/Mbstring.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,50 @@ public static function mb_ord($s, $encoding = null)
827827
return $code;
828828
}
829829

830+
public static function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = \STR_PAD_RIGHT, string $encoding = null): string
831+
{
832+
if (!\in_array($pad_type, [\STR_PAD_RIGHT, \STR_PAD_LEFT, \STR_PAD_BOTH], true)) {
833+
throw new \ValueError('mb_str_pad(): Argument #4 ($pad_type) must be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH');
834+
}
835+
836+
if (null === $encoding) {
837+
$encoding = self::mb_internal_encoding();
838+
}
839+
840+
try {
841+
$validEncoding = @self::mb_check_encoding('', $encoding);
842+
} catch (\ValueError $e) {
843+
throw new \ValueError(sprintf('mb_str_pad(): Argument #5 ($encoding) must be a valid encoding, "%s" given', $encoding));
844+
}
845+
846+
// BC for PHP 7.3 and lower
847+
if (!$validEncoding) {
848+
throw new \ValueError(sprintf('mb_str_pad(): Argument #5 ($encoding) must be a valid encoding, "%s" given', $encoding));
849+
}
850+
851+
if (self::mb_strlen($pad_string, $encoding) <= 0) {
852+
throw new \ValueError('mb_str_pad(): Argument #3 ($pad_string) must be a non-empty string');
853+
}
854+
855+
$paddingRequired = $length - self::mb_strlen($string, $encoding);
856+
857+
if ($paddingRequired < 1) {
858+
return $string;
859+
}
860+
861+
switch ($pad_type) {
862+
case \STR_PAD_LEFT:
863+
return self::mb_substr(str_repeat($pad_string, $paddingRequired), 0, $paddingRequired, $encoding).$string;
864+
case \STR_PAD_RIGHT:
865+
return $string.self::mb_substr(str_repeat($pad_string, $paddingRequired), 0, $paddingRequired, $encoding);
866+
default:
867+
$leftPaddingLength = floor($paddingRequired / 2);
868+
$rightPaddingLength = $paddingRequired - $leftPaddingLength;
869+
870+
return self::mb_substr(str_repeat($pad_string, $leftPaddingLength), 0, $leftPaddingLength, $encoding).$string.self::mb_substr(str_repeat($pad_string, $rightPaddingLength), 0, $rightPaddingLength, $encoding);
871+
}
872+
}
873+
830874
private static function getSubpart($pos, $part, $haystack, $encoding)
831875
{
832876
if (false === $pos) {

src/Mbstring/bootstrap.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ function mb_scrub($string, $encoding = null) { $encoding = null === $encoding ?
132132
function mb_str_split($string, $length = 1, $encoding = null) { return p\Mbstring::mb_str_split($string, $length, $encoding); }
133133
}
134134

135+
if (!function_exists('mb_str_pad')) {
136+
function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = STR_PAD_RIGHT, ?string $encoding = null): string { return p\Mbstring::mb_str_pad($string, $length, $pad_string, $pad_type, $encoding); }
137+
}
138+
135139
if (extension_loaded('mbstring')) {
136140
return;
137141
}

src/Mbstring/bootstrap80.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ function mb_scrub(?string $string, ?string $encoding = null): string { $encoding
128128
function mb_str_split(?string $string, ?int $length = 1, ?string $encoding = null): array { return p\Mbstring::mb_str_split((string) $string, (int) $length, $encoding); }
129129
}
130130

131+
if (!function_exists('mb_str_pad')) {
132+
function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = STR_PAD_RIGHT, ?string $encoding = null): string { return p\Mbstring::mb_str_pad($string, $length, $pad_string, $pad_type, $encoding); }
133+
}
134+
131135
if (extension_loaded('mbstring')) {
132136
return;
133137
}

src/Php83/Php83.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,48 @@ public static function json_validate(string $json, int $depth = 512, int $flags
3838

3939
return \JSON_ERROR_NONE === json_last_error();
4040
}
41+
42+
public static function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = \STR_PAD_RIGHT, string $encoding = null): string
43+
{
44+
if (!\in_array($pad_type, [\STR_PAD_RIGHT, \STR_PAD_LEFT, \STR_PAD_BOTH], true)) {
45+
throw new \ValueError('mb_str_pad(): Argument #4 ($pad_type) must be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH');
46+
}
47+
48+
if (null === $encoding) {
49+
$encoding = mb_internal_encoding();
50+
}
51+
52+
try {
53+
$validEncoding = @mb_check_encoding('', $encoding);
54+
} catch (\ValueError $e) {
55+
throw new \ValueError(sprintf('mb_str_pad(): Argument #5 ($encoding) must be a valid encoding, "%s" given', $encoding));
56+
}
57+
58+
// BC for PHP 7.3 and lower
59+
if (!$validEncoding) {
60+
throw new \ValueError(sprintf('mb_str_pad(): Argument #5 ($encoding) must be a valid encoding, "%s" given', $encoding));
61+
}
62+
63+
if (mb_strlen($pad_string, $encoding) <= 0) {
64+
throw new \ValueError('mb_str_pad(): Argument #3 ($pad_string) must be a non-empty string');
65+
}
66+
67+
$paddingRequired = $length - mb_strlen($string, $encoding);
68+
69+
if ($paddingRequired < 1) {
70+
return $string;
71+
}
72+
73+
switch ($pad_type) {
74+
case \STR_PAD_LEFT:
75+
return mb_substr(str_repeat($pad_string, $paddingRequired), 0, $paddingRequired, $encoding).$string;
76+
case \STR_PAD_RIGHT:
77+
return $string.mb_substr(str_repeat($pad_string, $paddingRequired), 0, $paddingRequired, $encoding);
78+
default:
79+
$leftPaddingLength = floor($paddingRequired / 2);
80+
$rightPaddingLength = $paddingRequired - $leftPaddingLength;
81+
82+
return mb_substr(str_repeat($pad_string, $leftPaddingLength), 0, $leftPaddingLength, $encoding).$string.mb_substr(str_repeat($pad_string, $rightPaddingLength), 0, $rightPaddingLength, $encoding);
83+
}
84+
}
4185
}

src/Php83/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This component provides features added to PHP 8.3 core:
55

66
- [`json_validate`](https://wiki.php.net/rfc/json_validate)
77
- [`Override`](https://wiki.php.net/rfc/marking_overriden_methods)
8+
- [`mb_str_pad`](https://wiki.php.net/rfc/mb_str_pad)
89

910
More information can be found in the
1011
[main Polyfill README](https://github.com/symfony/polyfill/blob/main/README.md).

src/Php83/bootstrap.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@
1818
if (!function_exists('json_validate')) {
1919
function json_validate(string $json, int $depth = 512, int $flags = 0): bool { return p\Php83::json_validate($json, $depth, $flags); }
2020
}
21+
22+
if (!function_exists('mb_str_pad') && function_exists('mb_substr')) {
23+
function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = STR_PAD_RIGHT, ?string $encoding = null): string { return p\Php83::mb_str_pad($string, $length, $pad_string, $pad_type, $encoding); }
24+
}

tests/Mbstring/MbstringTest.php

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,4 +627,104 @@ public function testDecodeMimeheader()
627627
$this->assertSame(sprintf('Test: %s', base64_decode('7/Du4uXw6uA=')), mb_decode_mimeheader('Test: =?windows-1251?B?7/Du4uXw6uA=?='));
628628
$this->assertTrue(mb_internal_encoding('utf8'));
629629
}
630+
631+
/**
632+
* @covers \Symfony\Polyfill\Mbstring\Mbstring::mb_str_pad
633+
*
634+
* @dataProvider paddingStringProvider
635+
* @dataProvider paddingEmojiProvider
636+
* @dataProvider paddingEncodingProvider
637+
*/
638+
public function testMbStrPad(string $expectedResult, string $string, int $length, string $padString, int $padType, string $encoding = null): void
639+
{
640+
if ('UTF-32' === $encoding && \PHP_VERSION_ID < 73000) {
641+
$this->markTestSkipped('PHP < 7.3 doesn\'t handle UTF-32 encoding properly');
642+
}
643+
644+
$this->assertSame($expectedResult, mb_convert_encoding(mb_str_pad($string, $length, $padString, $padType, $encoding), 'UTF-8', $encoding ?? mb_internal_encoding()));
645+
}
646+
647+
/**
648+
* @covers \Symfony\Polyfill\Mbstring\Mbstring::mb_str_pad
649+
*
650+
* @dataProvider mbStrPadInvalidArgumentsProvider
651+
*/
652+
public function testMbStrPadInvalidArguments(string $expectedError, string $string, int $length, string $padString, int $padType, string $encoding = null): void
653+
{
654+
$this->expectException(\ValueError::class);
655+
$this->expectErrorMessage($expectedError);
656+
657+
mb_str_pad($string, $length, $padString, $padType, $encoding);
658+
}
659+
660+
public static function paddingStringProvider(): iterable
661+
{
662+
// Simple ASCII strings
663+
yield ['+Hello+', 'Hello', 7, '+-', \STR_PAD_BOTH];
664+
yield ['+-World+-+', 'World', 10, '+-', \STR_PAD_BOTH];
665+
yield ['+-Hello', 'Hello', 7, '+-', \STR_PAD_LEFT];
666+
yield ['+-+-+World', 'World', 10, '+-', \STR_PAD_LEFT];
667+
yield ['Hello+-', 'Hello', 7, '+-', \STR_PAD_RIGHT];
668+
yield ['World+-+-+', 'World', 10, '+-', \STR_PAD_RIGHT];
669+
// Edge cases pad length
670+
yield ['▶▶', '▶▶', 2, ' ', \STR_PAD_BOTH];
671+
yield ['▶▶', '▶▶', 1, ' ', \STR_PAD_BOTH];
672+
yield ['▶▶', '▶▶', 0, ' ', \STR_PAD_BOTH];
673+
yield ['▶▶', '▶▶', -1, ' ', \STR_PAD_BOTH];
674+
// Empty input string
675+
yield [' ', '', 2, ' ', \STR_PAD_BOTH];
676+
yield [' ', '', 1, ' ', \STR_PAD_BOTH];
677+
yield ['', '', 0, ' ', \STR_PAD_BOTH];
678+
yield ['', '', -1, ' ', \STR_PAD_BOTH];
679+
// Default argument
680+
yield ['▶▶ ', '▶▶', 6, ' ', \STR_PAD_RIGHT];
681+
yield [' ▶▶', '▶▶', 6, ' ', \STR_PAD_LEFT];
682+
yield [' ▶▶ ', '▶▶', 6, ' ', \STR_PAD_BOTH];
683+
}
684+
685+
public static function paddingEmojiProvider(): iterable
686+
{
687+
// UTF-8 Emojis
688+
yield ['▶▶❤❓❇❤', '▶▶', 6, '❤❓❇', \STR_PAD_RIGHT];
689+
yield ['❤❓❇❤▶▶', '▶▶', 6, '❤❓❇', \STR_PAD_LEFT];
690+
yield ['❤❓▶▶❤❓', '▶▶', 6, '❤❓❇', \STR_PAD_BOTH];
691+
yield ['▶▶❤❓❇', '▶▶', 5, '❤❓❇', \STR_PAD_RIGHT];
692+
yield ['❤❓❇▶▶', '▶▶', 5, '❤❓❇', \STR_PAD_LEFT];
693+
yield ['❤▶▶❤❓', '▶▶', 5, '❤❓❇', \STR_PAD_BOTH];
694+
yield ['▶▶❤❓', '▶▶', 4, '❤❓❇', \STR_PAD_RIGHT];
695+
yield ['❤❓▶▶', '▶▶', 4, '❤❓❇', \STR_PAD_LEFT];
696+
yield ['❤▶▶❤', '▶▶', 4, '❤❓❇', \STR_PAD_BOTH];
697+
yield ['▶▶❤', '▶▶', 3, '❤❓❇', \STR_PAD_RIGHT];
698+
yield ['❤▶▶', '▶▶', 3, '❤❓❇', \STR_PAD_LEFT];
699+
yield ['▶▶❤', '▶▶', 3, '❤❓❇', \STR_PAD_BOTH];
700+
701+
for ($i = 2; $i >= 0; --$i) {
702+
yield ['▶▶', '▶▶', $i, '❤❓❇', \STR_PAD_RIGHT];
703+
yield ['▶▶', '▶▶', $i, '❤❓❇', \STR_PAD_LEFT];
704+
yield ['▶▶', '▶▶', $i, '❤❓❇', \STR_PAD_BOTH];
705+
}
706+
}
707+
708+
public static function paddingEncodingProvider(): iterable
709+
{
710+
$string = 'Σὲ γνωρίζω ἀπὸ τὴν κόψη Зарегистрируйтесь';
711+
712+
foreach (['UTF-8', 'UTF-32', 'UTF-7'] as $encoding) {
713+
$input = mb_convert_encoding($string, $encoding, 'UTF-8');
714+
$padStr = mb_convert_encoding('▶▶', $encoding, 'UTF-8');
715+
716+
yield ['Σὲ γνωρίζω ἀπὸ τὴν κόψη Зарегистрируйтесь▶▶▶', $input, 44, $padStr, \STR_PAD_RIGHT, $encoding];
717+
yield ['▶▶▶Σὲ γνωρίζω ἀπὸ τὴν κόψη Зарегистрируйтесь', $input, 44, $padStr, \STR_PAD_LEFT, $encoding];
718+
yield ['▶Σὲ γνωρίζω ἀπὸ τὴν κόψη Зарегистрируйтесь▶▶', $input, 44, $padStr, \STR_PAD_BOTH, $encoding];
719+
}
720+
}
721+
722+
public static function mbStrPadInvalidArgumentsProvider(): iterable
723+
{
724+
yield ['mb_str_pad(): Argument #3 ($pad_string) must be a non-empty string', '▶▶', 6, '', \STR_PAD_RIGHT];
725+
yield ['mb_str_pad(): Argument #3 ($pad_string) must be a non-empty string', '▶▶', 6, '', \STR_PAD_LEFT];
726+
yield ['mb_str_pad(): Argument #3 ($pad_string) must be a non-empty string', '▶▶', 6, '', \STR_PAD_BOTH];
727+
yield ['mb_str_pad(): Argument #4 ($pad_type) must be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH', '▶▶', 6, ' ', 123456];
728+
yield ['mb_str_pad(): Argument #5 ($encoding) must be a valid encoding, "unexisting" given', '▶▶', 6, ' ', \STR_PAD_BOTH, 'unexisting'];
729+
}
630730
}

tests/Php83/Php83Test.php

Lines changed: 100 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class Php83Test extends TestCase
1717
{
1818
/**
1919
* @covers \Symfony\Polyfill\Php83\Php83::json_validate
20+
*
2021
* @dataProvider jsonDataProvider
2122
*/
2223
public function testJsonValidate(bool $valid, string $json, string $errorMessage = 'No error', int $depth = 512, int $options = 0)
@@ -25,6 +26,102 @@ public function testJsonValidate(bool $valid, string $json, string $errorMessage
2526
$this->assertSame($errorMessage, json_last_error_msg());
2627
}
2728

29+
/**
30+
* @covers \Symfony\Polyfill\Php83\Php83::mb_str_pad
31+
*
32+
* @dataProvider paddingStringProvider
33+
* @dataProvider paddingEmojiProvider
34+
* @dataProvider paddingEncodingProvider
35+
*/
36+
public function testMbStrPad(string $expectedResult, string $string, int $length, string $padString, int $padType, string $encoding = null): void
37+
{
38+
$this->assertSame($expectedResult, mb_convert_encoding(mb_str_pad($string, $length, $padString, $padType, $encoding), 'UTF-8', $encoding ?? mb_internal_encoding()));
39+
}
40+
41+
/**
42+
* @covers \Symfony\Polyfill\Php83\Php83::mb_str_pad
43+
*
44+
* @dataProvider mbStrPadInvalidArgumentsProvider
45+
*/
46+
public function testMbStrPadInvalidArguments(string $expectedError, string $string, int $length, string $padString, int $padType, string $encoding = null): void
47+
{
48+
$this->expectException(\ValueError::class);
49+
$this->expectErrorMessage($expectedError);
50+
51+
mb_str_pad($string, $length, $padString, $padType, $encoding);
52+
}
53+
54+
public static function paddingStringProvider(): iterable
55+
{
56+
// Simple ASCII strings
57+
yield ['+Hello+', 'Hello', 7, '+-', \STR_PAD_BOTH];
58+
yield ['+-World+-+', 'World', 10, '+-', \STR_PAD_BOTH];
59+
yield ['+-Hello', 'Hello', 7, '+-', \STR_PAD_LEFT];
60+
yield ['+-+-+World', 'World', 10, '+-', \STR_PAD_LEFT];
61+
yield ['Hello+-', 'Hello', 7, '+-', \STR_PAD_RIGHT];
62+
yield ['World+-+-+', 'World', 10, '+-', \STR_PAD_RIGHT];
63+
// Edge cases pad length
64+
yield ['▶▶', '▶▶', 2, ' ', \STR_PAD_BOTH];
65+
yield ['▶▶', '▶▶', 1, ' ', \STR_PAD_BOTH];
66+
yield ['▶▶', '▶▶', 0, ' ', \STR_PAD_BOTH];
67+
yield ['▶▶', '▶▶', -1, ' ', \STR_PAD_BOTH];
68+
// Empty input string
69+
yield [' ', '', 2, ' ', \STR_PAD_BOTH];
70+
yield [' ', '', 1, ' ', \STR_PAD_BOTH];
71+
yield ['', '', 0, ' ', \STR_PAD_BOTH];
72+
yield ['', '', -1, ' ', \STR_PAD_BOTH];
73+
// Default argument
74+
yield ['▶▶ ', '▶▶', 6, ' ', \STR_PAD_RIGHT];
75+
yield [' ▶▶', '▶▶', 6, ' ', \STR_PAD_LEFT];
76+
yield [' ▶▶ ', '▶▶', 6, ' ', \STR_PAD_BOTH];
77+
}
78+
79+
public static function paddingEmojiProvider(): iterable
80+
{
81+
// UTF-8 Emojis
82+
yield ['▶▶❤❓❇❤', '▶▶', 6, '❤❓❇', \STR_PAD_RIGHT];
83+
yield ['❤❓❇❤▶▶', '▶▶', 6, '❤❓❇', \STR_PAD_LEFT];
84+
yield ['❤❓▶▶❤❓', '▶▶', 6, '❤❓❇', \STR_PAD_BOTH];
85+
yield ['▶▶❤❓❇', '▶▶', 5, '❤❓❇', \STR_PAD_RIGHT];
86+
yield ['❤❓❇▶▶', '▶▶', 5, '❤❓❇', \STR_PAD_LEFT];
87+
yield ['❤▶▶❤❓', '▶▶', 5, '❤❓❇', \STR_PAD_BOTH];
88+
yield ['▶▶❤❓', '▶▶', 4, '❤❓❇', \STR_PAD_RIGHT];
89+
yield ['❤❓▶▶', '▶▶', 4, '❤❓❇', \STR_PAD_LEFT];
90+
yield ['❤▶▶❤', '▶▶', 4, '❤❓❇', \STR_PAD_BOTH];
91+
yield ['▶▶❤', '▶▶', 3, '❤❓❇', \STR_PAD_RIGHT];
92+
yield ['❤▶▶', '▶▶', 3, '❤❓❇', \STR_PAD_LEFT];
93+
yield ['▶▶❤', '▶▶', 3, '❤❓❇', \STR_PAD_BOTH];
94+
95+
for ($i = 2; $i >= 0; --$i) {
96+
yield ['▶▶', '▶▶', $i, '❤❓❇', \STR_PAD_RIGHT];
97+
yield ['▶▶', '▶▶', $i, '❤❓❇', \STR_PAD_LEFT];
98+
yield ['▶▶', '▶▶', $i, '❤❓❇', \STR_PAD_BOTH];
99+
}
100+
}
101+
102+
public static function paddingEncodingProvider(): iterable
103+
{
104+
$string = 'Σὲ γνωρίζω ἀπὸ τὴν κόψη Зарегистрируйтесь';
105+
106+
foreach (['UTF-8', 'UTF-32', 'UTF-7'] as $encoding) {
107+
$input = mb_convert_encoding($string, $encoding, 'UTF-8');
108+
$padStr = mb_convert_encoding('▶▶', $encoding, 'UTF-8');
109+
110+
yield ['Σὲ γνωρίζω ἀπὸ τὴν κόψη Зарегистрируйтесь▶▶▶', $input, 44, $padStr, \STR_PAD_RIGHT, $encoding];
111+
yield ['▶▶▶Σὲ γνωρίζω ἀπὸ τὴν κόψη Зарегистрируйтесь', $input, 44, $padStr, \STR_PAD_LEFT, $encoding];
112+
yield ['▶Σὲ γνωρίζω ἀπὸ τὴν κόψη Зарегистрируйтесь▶▶', $input, 44, $padStr, \STR_PAD_BOTH, $encoding];
113+
}
114+
}
115+
116+
public static function mbStrPadInvalidArgumentsProvider(): iterable
117+
{
118+
yield ['mb_str_pad(): Argument #3 ($pad_string) must be a non-empty string', '▶▶', 6, '', \STR_PAD_RIGHT];
119+
yield ['mb_str_pad(): Argument #3 ($pad_string) must be a non-empty string', '▶▶', 6, '', \STR_PAD_LEFT];
120+
yield ['mb_str_pad(): Argument #3 ($pad_string) must be a non-empty string', '▶▶', 6, '', \STR_PAD_BOTH];
121+
yield ['mb_str_pad(): Argument #4 ($pad_type) must be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH', '▶▶', 6, ' ', 123456];
122+
yield ['mb_str_pad(): Argument #5 ($encoding) must be a valid encoding, "unexisting" given', '▶▶', 6, ' ', \STR_PAD_BOTH, 'unexisting'];
123+
}
124+
28125
/**
29126
* @return iterable<array{0: bool, 1: string, 2?: string, 3?: int, 4?: int}>
30127
*/
@@ -59,9 +156,9 @@ public static function jsonDataProvider(): iterable
59156
/**
60157
* @covers \Symfony\Polyfill\Php83\Php83::json_validate
61158
*
62-
* @dataProvider invalidOptionsProvider
159+
* @dataProvider jsonInvalidOptionsProvider
63160
*/
64-
public function testInvalidOptionsProvided(int $depth, int $flags, string $expectedError)
161+
public function testJsonValidateInvalidOptionsProvided(int $depth, int $flags, string $expectedError)
65162
{
66163
$this->expectException(\ValueError::class);
67164
$this->expectErrorMessage($expectedError);
@@ -71,7 +168,7 @@ public function testInvalidOptionsProvided(int $depth, int $flags, string $expec
71168
/**
72169
* @return iterable<array{0: int, 1: int, 2: string}>
73170
*/
74-
public static function invalidOptionsProvider(): iterable
171+
public static function jsonInvalidOptionsProvider(): iterable
75172
{
76173
yield [0, 0, 'json_validate(): Argument #2 ($depth) must be greater than 0'];
77174
if (\PHP_INT_MAX > 2147483647) {

0 commit comments

Comments
 (0)