ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
Yaml.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
12 namespace Symfony\Component\Yaml;
13 
15 
21 class Yaml
22 {
23  const DUMP_OBJECT = 1;
25  const PARSE_OBJECT = 4;
28  const PARSE_DATETIME = 32;
29  const DUMP_OBJECT_AS_MAP = 64;
31 
48  public static function parse($input, $flags = 0)
49  {
50  if (is_bool($flags)) {
51  @trigger_error('Passing a boolean flag to toggle exception handling is deprecated since version 3.1 and will be removed in 4.0. Use the PARSE_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED);
52 
53  if ($flags) {
54  $flags = self::PARSE_EXCEPTION_ON_INVALID_TYPE;
55  } else {
56  $flags = 0;
57  }
58  }
59 
60  if (func_num_args() >= 3) {
61  @trigger_error('Passing a boolean flag to toggle object support is deprecated since version 3.1 and will be removed in 4.0. Use the PARSE_OBJECT flag instead.', E_USER_DEPRECATED);
62 
63  if (func_get_arg(2)) {
64  $flags |= self::PARSE_OBJECT;
65  }
66  }
67 
68  if (func_num_args() >= 4) {
69  @trigger_error('Passing a boolean flag to toggle object for map support is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT_FOR_MAP flag instead.', E_USER_DEPRECATED);
70 
71  if (func_get_arg(3)) {
72  $flags |= self::PARSE_OBJECT_FOR_MAP;
73  }
74  }
75 
76  $yaml = new Parser();
77 
78  return $yaml->parse($input, $flags);
79  }
80 
94  public static function dump($input, $inline = 2, $indent = 4, $flags = 0)
95  {
96  if (is_bool($flags)) {
97  @trigger_error('Passing a boolean flag to toggle exception handling is deprecated since version 3.1 and will be removed in 4.0. Use the DUMP_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED);
98 
99  if ($flags) {
100  $flags = self::DUMP_EXCEPTION_ON_INVALID_TYPE;
101  } else {
102  $flags = 0;
103  }
104  }
105 
106  if (func_num_args() >= 5) {
107  @trigger_error('Passing a boolean flag to toggle object support is deprecated since version 3.1 and will be removed in 4.0. Use the DUMP_OBJECT flag instead.', E_USER_DEPRECATED);
108 
109  if (func_get_arg(4)) {
110  $flags |= self::DUMP_OBJECT;
111  }
112  }
113 
114  $yaml = new Dumper($indent);
115 
116  return $yaml->dump($input, $inline, 0, $flags);
117  }
118 }
static dump($input, $inline=2, $indent=4, $flags=0)
Dumps a PHP value to a YAML string.
Definition: Yaml.php:94
const PARSE_EXCEPTION_ON_INVALID_TYPE
Definition: Yaml.php:24
const DUMP_MULTI_LINE_LITERAL_BLOCK
Definition: Yaml.php:30
Yaml offers convenience methods to load and dump YAML.
Definition: Yaml.php:21
static parse($input, $flags=0)
Parses YAML into a PHP value.
Definition: Yaml.php:48
Parser parses YAML strings to convert them to PHP arrays.
Definition: Parser.php:21
Dumper dumps PHP variables to YAML strings.
Definition: Dumper.php:19
const DUMP_EXCEPTION_ON_INVALID_TYPE
Definition: Yaml.php:27