private static function _parseLine($line, $indent) { $ret = array(); if (($line[0] === '&' || $line[0] === '*') && preg_match('/^(&[A-z0-9_\\-]+|\\*[A-z0-9_\\-]+)/', $line, $match) || preg_match('/(&[A-z0-9_\\-]+|\\*[A-z0-9_\\-]+)$/', $line, $match) || preg_match('#^\\s*<<\\s*:\\s*(\\*[^\\s]+).*$#', $line, $match)) { // Add group if ($match[1][0] === '&') { self::$groupAnchor = substr($match[1], 1); } else { if ($match[1][0] === '*') { self::$groupAlias = substr($match[1], 1); } } // self::_addGroup($line, $groups); $line = trim(str_replace($match[1], '', $line)); } $last = substr($line, -1, 1); // Mapped sequence if ($line[0] === '-' && $last === ':') { if ($key = trim(substr($line, 1, -1))) { if ($key[0] === '\'') { $key = trim($key, '\''); } if ($key[0] === '"') { $key = trim($key, '"'); } } $ret[$key] = array(); self::$delayedPath = array(strpos($line, $key) + $indent => $key); return array($ret); } // Mapped value if ($last === ':') { if ($key = trim(substr($line, 0, -1))) { if ($key[0] === '\'') { $key = trim($key, '\''); } if ($key[0] === '"') { $key = trim($key, '"'); } } $ret[$key] = ''; return $ret; } // Array element if ($line && $line[0] === '-' && !(($tmpLen = strlen($line)) > 3 && substr($line, 0, 3) === '---')) { if ($tmpLen <= 1) { $ret = array(array()); } else { $ret[] = self::_toType(trim(substr($line, 1))); } return $ret; } // Plain array if ($line[0] === '[' && $last === ']') { return self::_toType($line); } // getKeyValuePair inline if (strpos($line, ':')) { if (($line[0] === '"' || $line[0] === '\'') && preg_match('#^(["\'](.*)["\'](\\s)*:)#', $line, $match)) { $val = trim(str_replace($match[1], '', $line)); $key = $match[2]; } else { $point = strpos($line, ':'); $key = trim(substr($line, 0, $point)); $val = trim(substr($line, ++$point)); } if ($key === '0') { $key = '__SPICYZERO__'; } $ret[$key] = self::_toType($val); } else { $ret = array($line); } return $ret; }