Skip to content

Commit 9eab999

Browse files
Merge branch '5.3' into 5.4
* 5.3: [GHA] fix running "Patch return types" step [Serializer] Don't pass null to preg_match() Use identity operator to prevent type juggling [Form] Don't trim unassigned unicode characters anymore
2 parents a12d4e8 + be3e201 commit 9eab999

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

Tests/Util/StringUtilTest.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,20 @@
1616

1717
class StringUtilTest extends TestCase
1818
{
19-
public function testTrim()
19+
public function trimProvider()
2020
{
21-
$data = ' Foo! ';
21+
return [
22+
[' Foo! ', 'Foo!'],
23+
["\u{1F92E}", "\u{1F92E}"], // unassigned character in PCRE versions of <PHP 7.3
24+
];
25+
}
2226

23-
$this->assertEquals('Foo!', StringUtil::trim($data));
27+
/**
28+
* @dataProvider trimProvider
29+
*/
30+
public function testTrim($data, $expectedData)
31+
{
32+
$this->assertSame($expectedData, StringUtil::trim($data));
2433
}
2534

2635
/**

Util/StringUtil.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ private function __construct()
3131
*/
3232
public static function trim(string $string)
3333
{
34-
if (null !== $result = @preg_replace('/^[\pZ\pC]+|[\pZ\pC]+$/u', '', $string)) {
34+
if (null !== $result = @preg_replace('/^[\pZ\p{Cc}\p{Cf}]+|[\pZ\p{Cc}\p{Cf}]+$/u', '', $string)) {
3535
return $result;
3636
}
3737

0 commit comments

Comments
 (0)