update v1.0.7.9 R.C.
This is a Release Candidate. We are still testing.
This commit is contained in:
30
vendor/symfony/yaml/Inline.php
vendored
30
vendor/symfony/yaml/Inline.php
vendored
@@ -214,6 +214,28 @@ class Inline
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if given array is hash or just normal indexed array.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @param array $value The PHP array to check
|
||||
*
|
||||
* @return bool true if value is hash array, false otherwise
|
||||
*/
|
||||
public static function isHash(array $value)
|
||||
{
|
||||
$expectedKey = 0;
|
||||
|
||||
foreach ($value as $key => $val) {
|
||||
if ($key !== $expectedKey++) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dumps a PHP array to a YAML string.
|
||||
*
|
||||
@@ -225,11 +247,7 @@ class Inline
|
||||
private static function dumpArray($value, $flags)
|
||||
{
|
||||
// array
|
||||
$keys = array_keys($value);
|
||||
$keysCount = count($keys);
|
||||
if ((1 === $keysCount && '0' == $keys[0])
|
||||
|| ($keysCount > 1 && array_reduce($keys, function ($v, $w) { return (int) $v + $w; }, 0) === $keysCount * ($keysCount - 1) / 2)
|
||||
) {
|
||||
if ($value && !self::isHash($value)) {
|
||||
$output = array();
|
||||
foreach ($value as $val) {
|
||||
$output[] = self::dump($val, $flags);
|
||||
@@ -238,7 +256,7 @@ class Inline
|
||||
return sprintf('[%s]', implode(', ', $output));
|
||||
}
|
||||
|
||||
// mapping
|
||||
// hash
|
||||
$output = array();
|
||||
foreach ($value as $key => $val) {
|
||||
$output[] = sprintf('%s: %s', self::dump($key, $flags), self::dump($val, $flags));
|
||||
|
Reference in New Issue
Block a user