public function getDataFormSpecifications() { $parser = new Parser(); $path = __DIR__ . '/Fixtures'; $tests = array(); $files = $parser->parse(file_get_contents($path . '/index.yml')); foreach ($files as $file) { $yamls = file_get_contents($path . '/' . $file . '.yml'); // split YAMLs documents foreach (preg_split('/^---( %YAML\\:1\\.0)?/m', $yamls) as $yaml) { if (!$yaml) { continue; } $test = $parser->parse($yaml); if (isset($test['todo']) && $test['todo']) { // TODO } else { eval('$expected = ' . trim($test['php']) . ';'); $tests[] = array($file, var_export($expected, true), $test['yaml'], $test['test']); } } } return $tests; }
/** * Parses YAML into a PHP array. * * The parse method, when supplied with a YAML stream (string or file), * will do its best to convert YAML in a file into a PHP array. * * Usage: * <code> * $array = Yaml::parse(file_get_contents('config.yml')); * print_r($array); * </code> * * @param string $input A string containing YAML * @param bool $exceptionOnInvalidType True if an exception must be thrown on invalid types false otherwise * @param bool $objectSupport True if object support is enabled, false otherwise * @param bool $objectForMap True if maps should return a stdClass instead of array() * * @return array The YAML converted to a PHP array * * @throws ParseException If the YAML is not valid */ public static function parse($input, $exceptionOnInvalidType = false, $objectSupport = false, $objectForMap = false) { $yaml = new Parser(); return $yaml->parse($input, $exceptionOnInvalidType, $objectSupport, $objectForMap); }