Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a5383c7

Browse filesBrowse files
minor symfony#41973 Leverage str_ends_with (Tobion)
This PR was merged into the 4.4 branch. Discussion ---------- Leverage str_ends_with | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | | License | MIT | Doc PR | added the php80 polyfill to requirements when necessary. some components already had the requirement anyway. Related to symfony#41576 Commits ------- 9d80729 Leverage str_ends_with
2 parents 0243383 + ffc26d5 commit a5383c7
Copy full SHA for a5383c7

File tree

Expand file treeCollapse file tree

3 files changed

+5
-4
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+5
-4
lines changed

‎Normalizer/ArrayDenormalizer.php

Copy file name to clipboardExpand all lines: Normalizer/ArrayDenormalizer.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function denormalize($data, $type, $format = null, array $context = [])
4646
if (!\is_array($data)) {
4747
throw new InvalidArgumentException('Data expected to be an array, '.\gettype($data).' given.');
4848
}
49-
if ('[]' !== substr($type, -2)) {
49+
if (!str_ends_with($type, '[]')) {
5050
throw new InvalidArgumentException('Unsupported class: '.$type);
5151
}
5252

@@ -74,7 +74,7 @@ public function supportsDenormalization($data, $type, $format = null, array $con
7474
throw new BadMethodCallException(sprintf('The serializer needs to be set to allow "%s()" to be used.', __METHOD__));
7575
}
7676

77-
return '[]' === substr($type, -2)
77+
return str_ends_with($type, '[]')
7878
&& $this->serializer->supportsDenormalization($data, substr($type, 0, -2), $format, $context);
7979
}
8080

‎Tests/Normalizer/AbstractObjectNormalizerTest.php

Copy file name to clipboardExpand all lines: Tests/Normalizer/AbstractObjectNormalizerTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ public function denormalize($data, $type, $format = null, array $context = [])
484484
*/
485485
public function supportsDenormalization($data, $type, $format = null, array $context = []): bool
486486
{
487-
return '[]' === substr($type, -2)
487+
return str_ends_with($type, '[]')
488488
&& $this->serializer->supportsDenormalization($data, substr($type, 0, -2), $format, $context);
489489
}
490490

‎composer.json

Copy file name to clipboardExpand all lines: composer.json
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
],
1818
"require": {
1919
"php": ">=7.1.3",
20-
"symfony/polyfill-ctype": "~1.8"
20+
"symfony/polyfill-ctype": "~1.8",
21+
"symfony/polyfill-php80": "^1.16"
2122
},
2223
"require-dev": {
2324
"doctrine/annotations": "^1.10.4",

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.