ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
Symfony\Component\Yaml\Yaml Class Reference

Yaml offers convenience methods to load and dump YAML. More...

+ Collaboration diagram for Symfony\Component\Yaml\Yaml:

Static Public Member Functions

static parse ($input, $flags=0)
 Parses YAML into a PHP value. More...
 
static dump ($input, $inline=2, $indent=4, $flags=0)
 Dumps a PHP value to a YAML string. More...
 

Data Fields

const DUMP_OBJECT = 1
 
const PARSE_EXCEPTION_ON_INVALID_TYPE = 2
 
const PARSE_OBJECT = 4
 
const PARSE_OBJECT_FOR_MAP = 8
 
const DUMP_EXCEPTION_ON_INVALID_TYPE = 16
 
const PARSE_DATETIME = 32
 
const DUMP_OBJECT_AS_MAP = 64
 
const DUMP_MULTI_LINE_LITERAL_BLOCK = 128
 

Detailed Description

Yaml offers convenience methods to load and dump YAML.

Author
Fabien Potencier fabie.nosp@m.n@sy.nosp@m.mfony.nosp@m..com

Definition at line 21 of file Yaml.php.

Member Function Documentation

◆ dump()

static Symfony\Component\Yaml\Yaml::dump (   $input,
  $inline = 2,
  $indent = 4,
  $flags = 0 
)
static

Dumps a PHP value to a YAML string.

The dump method, when supplied with an array, will do its best to convert the array into friendly YAML.

Parameters
mixed$inputThe PHP value
int$inlineThe level where you switch to inline YAML
int$indentThe amount of spaces to use for indentation of nested nodes
int$flagsA bit field of DUMP_* constants to customize the dumped YAML string
Returns
string A YAML string representing the original PHP value

Definition at line 94 of file Yaml.php.

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) {
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 }
const DUMP_EXCEPTION_ON_INVALID_TYPE
Definition: Yaml.php:27

References Symfony\Component\Yaml\Yaml\DUMP_EXCEPTION_ON_INVALID_TYPE, and Symfony\Component\Yaml\Yaml\DUMP_OBJECT.

Referenced by Symfony\Component\Yaml\Tests\YamlTest\testNegativeIndentationThrowsException(), Symfony\Component\Yaml\Tests\YamlTest\testParseAndDump(), and Symfony\Component\Yaml\Tests\YamlTest\testZeroIndentationThrowsException().

+ Here is the caller graph for this function:

◆ parse()

static Symfony\Component\Yaml\Yaml::parse (   $input,
  $flags = 0 
)
static

Parses YAML into a PHP value.

Usage: $array = Yaml::parse(file_get_contents('config.yml')); print_r($array);

Parameters
string$inputA string containing YAML
int$flagsA bit field of PARSE_* constants to customize the YAML parser behavior
Returns
mixed The YAML converted to a PHP value
Exceptions
ParseExceptionIf the YAML is not valid

Definition at line 48 of file Yaml.php.

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) {
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)) {
73 }
74 }
75
76 $yaml = new Parser();
77
78 return $yaml->parse($input, $flags);
79 }
const PARSE_EXCEPTION_ON_INVALID_TYPE
Definition: Yaml.php:24

References Symfony\Component\Yaml\Yaml\PARSE_EXCEPTION_ON_INVALID_TYPE, Symfony\Component\Yaml\Yaml\PARSE_OBJECT, and Symfony\Component\Yaml\Yaml\PARSE_OBJECT_FOR_MAP.

Referenced by Symfony\Component\Yaml\Tests\DumperTest\testDumpObjectAsMap(), and Symfony\Component\Yaml\Tests\YamlTest\testParseAndDump().

+ Here is the caller graph for this function:

Field Documentation

◆ DUMP_EXCEPTION_ON_INVALID_TYPE

◆ DUMP_MULTI_LINE_LITERAL_BLOCK

const Symfony\Component\Yaml\Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK = 128

◆ DUMP_OBJECT

◆ DUMP_OBJECT_AS_MAP

const Symfony\Component\Yaml\Yaml::DUMP_OBJECT_AS_MAP = 64

◆ PARSE_DATETIME

◆ PARSE_EXCEPTION_ON_INVALID_TYPE

const Symfony\Component\Yaml\Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE = 2

◆ PARSE_OBJECT

◆ PARSE_OBJECT_FOR_MAP


The documentation for this class was generated from the following file: