comparison vendor/symfony/yaml/Inline.php @ 12:7a779792577d

Update Drupal core to v8.4.5 (via Composer)
author Chris Cannam
date Fri, 23 Feb 2018 15:52:07 +0000
parents 4c8ae668cc8c
children 1fec387a4317
comparison
equal deleted inserted replaced
11:bfffd8d7479a 12:7a779792577d
162 if (Yaml::DUMP_OBJECT & $flags) { 162 if (Yaml::DUMP_OBJECT & $flags) {
163 return '!php/object:'.serialize($value); 163 return '!php/object:'.serialize($value);
164 } 164 }
165 165
166 if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($value instanceof \stdClass || $value instanceof \ArrayObject)) { 166 if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($value instanceof \stdClass || $value instanceof \ArrayObject)) {
167 return self::dumpArray((array) $value, $flags); 167 return self::dumpArray($value, $flags);
168 } 168 }
169 169
170 if (Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE & $flags) { 170 if (Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE & $flags) {
171 throw new DumpException('Object support when dumping a YAML file has been disabled.'); 171 throw new DumpException('Object support when dumping a YAML file has been disabled.');
172 } 172 }
222 /** 222 /**
223 * Check if given array is hash or just normal indexed array. 223 * Check if given array is hash or just normal indexed array.
224 * 224 *
225 * @internal 225 * @internal
226 * 226 *
227 * @param array $value The PHP array to check 227 * @param array|\ArrayObject|\stdClass $value The PHP array or array-like object to check
228 * 228 *
229 * @return bool true if value is hash array, false otherwise 229 * @return bool true if value is hash array, false otherwise
230 */ 230 */
231 public static function isHash(array $value) 231 public static function isHash($value)
232 { 232 {
233 if ($value instanceof \stdClass || $value instanceof \ArrayObject) {
234 return true;
235 }
236
233 $expectedKey = 0; 237 $expectedKey = 0;
234 238
235 foreach ($value as $key => $val) { 239 foreach ($value as $key => $val) {
236 if ($key !== $expectedKey++) { 240 if ($key !== $expectedKey++) {
237 return true; 241 return true;
455 459
456 return $output; 460 return $output;
457 } 461 }
458 462
459 // key 463 // key
464 $isKeyQuoted = in_array($mapping[$i], array('"', "'"), true);
460 $key = self::parseScalar($mapping, $flags, array(':', ' '), array('"', "'"), $i, false); 465 $key = self::parseScalar($mapping, $flags, array(':', ' '), array('"', "'"), $i, false);
461 466
462 if (':' !== $key && false === $i = strpos($mapping, ':', $i)) { 467 if (':' !== $key && false === $i = strpos($mapping, ':', $i)) {
463 break; 468 break;
464 } 469 }
465 470
466 if (':' !== $key && (!isset($mapping[$i + 1]) || !in_array($mapping[$i + 1], array(' ', ',', '[', ']', '{', '}'), true))) { 471 if (':' !== $key && !$isKeyQuoted && (!isset($mapping[$i + 1]) || !in_array($mapping[$i + 1], array(' ', ',', '[', ']', '{', '}'), true))) {
467 @trigger_error('Using a colon that is not followed by an indication character (i.e. " ", ",", "[", "]", "{", "}" is deprecated since version 3.2 and will throw a ParseException in 4.0.', E_USER_DEPRECATED); 472 @trigger_error('Using a colon after an unquoted mapping key that is not followed by an indication character (i.e. " ", ",", "[", "]", "{", "}") is deprecated since version 3.2 and will throw a ParseException in 4.0.', E_USER_DEPRECATED);
468 } 473 }
469 474
470 // value 475 // value
471 $done = false; 476 $done = false;
472 477