PATH:
opt
/
alt
/
tests
/
alt-php82-pecl-yaml_2.2.3-1.el8
/
tests
--TEST-- yaml_parse - callbacks --SKIPIF-- <?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?> --FILE-- <?php /** * Parsing callback for yaml tag. * @param mixed $value Data from yaml file * @param string $tag Tag that triggered callback * @param int $flags Scalar entity style (see YAML_*_SCALAR_STYLE) * @return mixed Value that YAML parser should emit for the given value */ function tag_callback ($value, $tag, $flags) { if (is_array($value)) { $new_value = ''; foreach ($value as $k => $v) { $new_value .= "'{$k}' => '{$v}', "; } $value = trim($new_value, ', '); } return "<value=[{$value}], tag=[{$tag}], flags=[{$flags}]>"; } // yaml with some custom tags $yaml_str = <<<YAML %TAG ! test- %TAG !! test2- --- key_a : !tag_a value_a key_b : !!tag_b 'value_b' key_c : !<tag:example.com,2011:test/tag_c> "value_c" key_d : !tag_d | some text key_e : !tag_e > some text key_f : !tag_f [ one, two ] key_g : !tag_g { sky: blue, sea: green } key_h : !tag_h - one - two key_i : !tag_i sky: blue sea: green ... YAML; $yaml = yaml_parse($yaml_str, 0, $ndocs, array( "test-tag_a" => "tag_callback", "test2-tag_b" => "tag_callback", "tag:example.com,2011:test/tag_c" => "tag_callback", "test-tag_d" => "tag_callback", "test-tag_e" => "tag_callback", "test-tag_f" => "tag_callback", "test-tag_g" => "tag_callback", "test-tag_h" => "tag_callback", "test-tag_i" => "tag_callback", )); var_dump($yaml); var_dump($ndocs); ?> --EXPECT-- array(9) { ["key_a"]=> string(46) "<value=[value_a], tag=[test-tag_a], flags=[1]>" ["key_b"]=> string(47) "<value=[value_b], tag=[test2-tag_b], flags=[2]>" ["key_c"]=> string(67) "<value=[value_c], tag=[tag:example.com,2011:test/tag_c], flags=[3]>" ["key_d"]=> string(49) "<value=[some text ], tag=[test-tag_d], flags=[4]>" ["key_e"]=> string(49) "<value=[some text ], tag=[test-tag_e], flags=[5]>" ["key_f"]=> string(65) "<value=['0' => 'one', '1' => 'two'], tag=[test-tag_f], flags=[0]>" ["key_g"]=> string(72) "<value=['sky' => 'blue', 'sea' => 'green'], tag=[test-tag_g], flags=[0]>" ["key_h"]=> string(65) "<value=['0' => 'one', '1' => 'two'], tag=[test-tag_h], flags=[0]>" ["key_i"]=> string(72) "<value=['sky' => 'blue', 'sea' => 'green'], tag=[test-tag_i], flags=[0]>" } int(1)
[-] yaml_parse_wiki_YtsStrangeKeys_002.phpt
[edit]
[-] yaml_parse_006.phpt
[edit]
[-] yaml_parse_007.phpt
[edit]
[-] yaml_parse_wiki_YtsMapInSeq_002.phpt
[edit]
[-] bug_69617.phpt
[edit]
[-] yaml_parse_wiki_YtsBasicTests_009.phpt
[edit]
[-] bug_77720.phpt
[edit]
[-] yaml_parse_spec_set.phpt
[edit]
[-] bug_75029.phpt
[edit]
[-] yaml_parse_wiki_YtsBasicTests_004.phpt
[edit]
[-] yaml_emit_002.phpt
[edit]
[-] bug_64694.phpt
[edit]
[-] yaml_parse_wiki_YtsBasicTests_006.phpt
[edit]
[-] yaml_001.phpt
[edit]
[-] bug_64019.phpt
[edit]
[-] yaml_parse_wiki_YtsMapInSeq_001.phpt
[edit]
[-] yaml_emit_009.phpt
[edit]
[-] yaml_emit_004.phpt
[edit]
[-] yaml_parse_wiki_YtsBasicTests_001.phpt
[edit]
[-] yaml_parse_wiki_YtsBlockMapping_003.phpt
[edit]
[-] yaml_emit_003.phpt
[edit]
[-] bug_74799.phpt
[edit]
[-] yaml_emit_file_basic.phpt
[edit]
[-] yaml_parse_004.phpt
[edit]
[-] bug_80324.phpt
[edit]
[-] yaml_parse_wiki_YtsMapInSeq_003.phpt
[edit]
[-] bug_79866.phpt
[edit]
[-] bug_76309.phpt
[edit]
[-] bug_21995.phpt
[edit]
[-] yaml_parse_url_001.phpt
[edit]
[-] yaml_parse_wiki_YtsBlockMapping_004.phpt
[edit]
[-] yaml_parse_spec_merge.phpt
[edit]
[-] yaml_parse_wiki_YtsBasicTests_002.phpt
[edit]
[-] bug_61770.phpt
[edit]
[-] yaml_parse_008.phpt
[edit]
[-] bug_60628.phpt
[edit]
[-] yaml_parse_file_001.phpt
[edit]
[-] yaml_parse_spec_timestamp.phpt
[edit]
[-] yaml_parse_wiki_YtsBlockMapping_001.phpt
[edit]
[-] yaml_002.phpt
[edit]
[-] yaml_parse_spec_seq.phpt
[edit]
[+]
..
[-] yaml_parse_spec_map.phpt
[edit]
[-] yaml_parse_wiki_YtsBasicTests_007.phpt
[edit]
[-] yaml_parse_002.phpt
[edit]
[-] bug_72204.phpt
[edit]
[-] bug_69465.phpt
[edit]
[-] yaml_emit_008.phpt
[edit]
[-] bug_59860.phpt
[edit]
[-] yaml_parse_wiki_YtsBasicTests_008.phpt
[edit]
[-] yaml_parse_spec_pairs.phpt
[edit]
[-] bug_parsing_alias.phpt
[edit]
[-] yaml_parse_file_001.yaml
[edit]
[-] yaml_parse_spec_int.phpt
[edit]
[-] yaml_emit_006.phpt
[edit]
[-] yaml_parse_wiki_YtsStrangeKeys_001.phpt
[edit]
[-] yaml_parse_005.phpt
[edit]
[-] yaml_parse_wiki_YtsBlockMapping_002.phpt
[edit]
[-] bug_79567.phpt
[edit]
[-] bug_79494.phpt
[edit]
[-] yaml_parse_spec_omap.phpt
[edit]
[-] bug_72540.phpt
[edit]
[-] bug_61923.phpt
[edit]
[-] yaml_parse_spec_float.phpt
[edit]
[-] yaml_parse_wiki_YtsBasicTests_005.phpt
[edit]
[-] yaml_parse_file_002.phpt
[edit]
[-] bug_74799.yaml
[edit]
[-] yaml_emit_001.phpt
[edit]
[-] yaml_parse_001.phpt
[edit]
[-] yaml_emit_007.phpt
[edit]
[-] yaml_parse_wiki_YtsBasicTests_003.phpt
[edit]
[-] yaml_parse_003.phpt
[edit]
[-] yaml_parse_spec_bool.phpt
[edit]
[-] yaml_parse_spec_binary.phpt
[edit]
[-] yaml_parse_spec_str.phpt
[edit]
[-] yaml_emit_005.phpt
[edit]
[-] yaml_parse_spec_null.phpt
[edit]
[-] bug_69616.phpt
[edit]