Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2fe4442

Browse files
minor #41431 [Yaml] Leverage array_is_list() (nicolas-grekas)
This PR was merged into the 5.4 branch. Discussion ---------- [Yaml] Leverage array_is_list() | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Commits ------- f4da7e4 [Yaml] Leverage array_is_list()
2 parents dbeebd1 + f4da7e4 commit 2fe4442

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

src/Symfony/Component/Yaml/Inline.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -207,19 +207,7 @@ public static function dump($value, int $flags = 0): string
207207
*/
208208
public static function isHash($value): bool
209209
{
210-
if ($value instanceof \stdClass || $value instanceof \ArrayObject) {
211-
return true;
212-
}
213-
214-
$expectedKey = 0;
215-
216-
foreach ($value as $key => $val) {
217-
if ($key !== $expectedKey++) {
218-
return true;
219-
}
220-
}
221-
222-
return false;
210+
return !\is_array($value) || !array_is_list($value);
223211
}
224212

225213
/**

src/Symfony/Component/Yaml/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"require": {
1919
"php": ">=7.2.5",
2020
"symfony/deprecation-contracts": "^2.1",
21-
"symfony/polyfill-ctype": "~1.8"
21+
"symfony/polyfill-ctype": "^1.8",
22+
"symfony/polyfill-php81": "^1.22"
2223
},
2324
"require-dev": {
2425
"symfony/console": "^4.4|^5.0|^6.0"

0 commit comments

Comments
 (0)