Issues (13)

examples/references.php (2 issues)

Labels
Severity
1
<?php
2
require_once __DIR__.'/../vendor/autoload.php';
3
4
use Dallgoot\Yaml\Yaml;
5
6
$yamlContent = <<<EOF
7
anchor_definition: &anchor_name OK
8
9
anchor_call: *anchor_name
10
EOF;
11
12
$obj = Yaml::parse($yamlContent);
13
14
echo "values on parsing\n";
15
print_r($obj->anchor_definition);
0 ignored issues
show
The property anchor_definition does not seem to exist on Dallgoot\Yaml\Types\YamlObject.
Loading history...
16
print_r($obj->anchor_call);
0 ignored issues
show
The property anchor_call does not seem to exist on Dallgoot\Yaml\Types\YamlObject.
Loading history...
17
18
echo "\nchange anchor/reference value to 123\n";
19
$obj->addReference('anchor_name', 123);
20
21
print_r($obj->anchor_definition);
22
print_r($obj->anchor_call);
23
24
echo "\nchange one anchor to new value 'abc'\n";
25
$obj->anchor_definition = 'abc';
26
27
print_r($obj->anchor_definition);
28
print_r($obj->anchor_call);
29
30
echo "\nunset anchor_call and re-set value\n";
31
unset($obj->anchor_call);
32
$obj->anchor_call = 'xyz';
33
34
print_r($obj->anchor_definition);
35
print_r($obj->anchor_call);
36
37
echo "\nchange anchor/reference value to 789\n";
38
$obj->addReference('anchor_name', 789);
39
40
print_r($obj->anchor_definition);
41
print_r($obj->anchor_call);
42
43
print_r($obj);