Current File : /home/mmdealscpanel/yummmdeals.com/alt-php84-pecl-yaml_2.2.3-1.el8.tar
tests/yaml_parse_spec_bool.phpt000064400000000523150414240740012765 0ustar00--TEST--
Yaml 1.1 Spec - bool
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('
canonical: y
answer: NO
logical: True
option: on
'));
?>
--EXPECT--
array(4) {
  ["canonical"]=>
  bool(true)
  ["answer"]=>
  bool(false)
  ["logical"]=>
  bool(true)
  ["option"]=>
  bool(true)
}
tests/yaml_parse_wiki_YtsBasicTests_006.phpt000064400000000742150414240740015177 0ustar00--TEST--
Yaml YtsBasicTests - Sequence in a Mapping
--DESCRIPTION--
A value in a mapping can be a sequence.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('foo: whatever
bar:
 - uno
 - dos
'));
?>
--EXPECT--
array(2) {
  ["foo"]=>
  string(8) "whatever"
  ["bar"]=>
  array(2) {
    [0]=>
    string(3) "uno"
    [1]=>
    string(3) "dos"
  }
}
tests/bug_75029.phpt000064400000000632150414240740010130 0ustar00--TEST--
Test PECL bug #75029
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse(''));
var_dump(yaml_parse('# Empty', -1));
$doc = <<<EOD
doc
---
---
doc
EOD;
var_dump(yaml_parse($doc, -1));
var_dump(yaml_parse($doc, 1));
?>
--EXPECT--
NULL
array(1) {
  [0]=>
  NULL
}
array(3) {
  [0]=>
  string(3) "doc"
  [1]=>
  NULL
  [2]=>
  string(3) "doc"
}
NULL
tests/bug_69465.phpt000064400000001442150414240740010137 0ustar00--TEST--
Test PECL bug #69465
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--INI--
yaml.decode_timestamp=1
date.timezone=UTC
--FILE--
<?php
$yaml_code = <<<YAML
date1: 2015-05-15
date2: "2015-05-15"
date3: ! 2015-05-15
bool1: true
bool2: "true"
bool3: ! true
int1: 1
int2: "1"
int3: ! 1
float1: 1.5
float2: "1.5"
float3: ! 1.5
YAML;

var_dump(yaml_parse($yaml_code));
?>
--EXPECT--
array(12) {
  ["date1"]=>
  int(1431648000)
  ["date2"]=>
  string(10) "2015-05-15"
  ["date3"]=>
  string(10) "2015-05-15"
  ["bool1"]=>
  bool(true)
  ["bool2"]=>
  string(4) "true"
  ["bool3"]=>
  string(4) "true"
  ["int1"]=>
  int(1)
  ["int2"]=>
  string(1) "1"
  ["int3"]=>
  string(1) "1"
  ["float1"]=>
  float(1.5)
  ["float2"]=>
  string(3) "1.5"
  ["float3"]=>
  string(3) "1.5"
}
tests/yaml_parse_wiki_YtsBasicTests_007.phpt000064400000001067150414240750015202 0ustar00--TEST--
Yaml YtsBasicTests - Nested Mappings
--DESCRIPTION--
A value in a mapping can be another mapping.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('foo: whatever
bar:
 fruit: apple
 name: steve
 sport: baseball
'));
?>
--EXPECT--
array(2) {
  ["foo"]=>
  string(8) "whatever"
  ["bar"]=>
  array(3) {
    ["fruit"]=>
    string(5) "apple"
    ["name"]=>
    string(5) "steve"
    ["sport"]=>
    string(8) "baseball"
  }
}
tests/yaml_parse_wiki_YtsStrangeKeys_001.phpt000064400000000602150414240750015361 0ustar00--TEST--
Yaml YtsStrangeKeys - Quoted line noise key
--DESCRIPTION--
Check that quoted line noise parses as key.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('---
"!@#%" : bar baz
'));
?>
--EXPECT--
array(1) {
  ["!@#%"]=>
  string(7) "bar baz"
}
tests/yaml_parse_spec_seq.phpt000064400000002526150414240750012630 0ustar00--TEST--
Yaml 1.1 Spec - seq
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('
# Ordered sequence of nodes
Block style: !!seq
- Mercury   # Rotates - no light/dark sides.
- Venus     # Deadliest. Aptly named.
- Earth     # Mostly dirt.
- Mars      # Seems empty.
- Jupiter   # The king.
- Saturn    # Pretty.
- Uranus    # Where the sun hardly shines.
- Neptune   # Boring. No rings.
- Pluto     # You call this a planet?
Flow style: !!seq [ Mercury, Venus, Earth, Mars,      # Rocks
                    Jupiter, Saturn, Uranus, Neptune, # Gas
                    Pluto ]                           # Overrated
'));
?>
--EXPECT--
array(2) {
  ["Block style"]=>
  array(9) {
    [0]=>
    string(7) "Mercury"
    [1]=>
    string(5) "Venus"
    [2]=>
    string(5) "Earth"
    [3]=>
    string(4) "Mars"
    [4]=>
    string(7) "Jupiter"
    [5]=>
    string(6) "Saturn"
    [6]=>
    string(6) "Uranus"
    [7]=>
    string(7) "Neptune"
    [8]=>
    string(5) "Pluto"
  }
  ["Flow style"]=>
  array(9) {
    [0]=>
    string(7) "Mercury"
    [1]=>
    string(5) "Venus"
    [2]=>
    string(5) "Earth"
    [3]=>
    string(4) "Mars"
    [4]=>
    string(7) "Jupiter"
    [5]=>
    string(6) "Saturn"
    [6]=>
    string(6) "Uranus"
    [7]=>
    string(7) "Neptune"
    [8]=>
    string(5) "Pluto"
  }
}
tests/yaml_emit_004.phpt000064400000000520150414240750011145 0ustar00--TEST--
yaml_emit - datetime
--SKIPIF--
<?php
if(!extension_loaded('yaml')) die('skip yaml n/a');
if(!class_exists('DateTime')) die('skip DateTime n/a');
?>
--INI--
date.timezone=GMT
--FILE--
<?php
$d = new DateTime('2008-08-03T14:52:10Z');
var_dump(yaml_emit($d));
?>
--EXPECT--
string(41) "--- 2008-08-03T14:52:10.000000+00:00
...
"
tests/yaml_parse_wiki_YtsBasicTests_004.phpt000064400000001023150414240750015167 0ustar00--TEST--
Yaml YtsBasicTests - Deeply Nested Sequences
--DESCRIPTION--
Sequences can be nested even deeper, with each
level of indentation representing a level of
depth.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('-
 -
  - uno
  - dos
'));
?>
--EXPECT--
array(1) {
  [0]=>
  array(1) {
    [0]=>
    array(2) {
      [0]=>
      string(3) "uno"
      [1]=>
      string(3) "dos"
    }
  }
}
tests/yaml_parse_spec_float.phpt000064400000001032150414240750013134 0ustar00--TEST--
Yaml 1.1 Spec - float
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('
canonical: 6.8523015e+5
exponentioal: 685.230_15e+03
fixed: 685_230.15
sexagesimal: 190:20:30.15
negative infinity: -.inf
not a number: .NaN
'));
?>
--EXPECT--
array(6) {
  ["canonical"]=>
  float(685230.15)
  ["exponentioal"]=>
  float(685230.15)
  ["fixed"]=>
  float(685230.15)
  ["sexagesimal"]=>
  float(685230.15)
  ["negative infinity"]=>
  float(-INF)
  ["not a number"]=>
  float(NAN)
}
tests/yaml_parse_wiki_YtsBasicTests_009.phpt000064400000001055150414240750015201 0ustar00--TEST--
Yaml YtsBasicTests - Sequence-Mapping Shortcut
--DESCRIPTION--
If you are adding a mapping to a sequence, you
can place the mapping on the same line as the
dash as a shortcut.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('- work on YAML.py:
   - work on Store
'));
?>
--EXPECT--
array(1) {
  [0]=>
  array(1) {
    ["work on YAML.py"]=>
    array(1) {
      [0]=>
      string(13) "work on Store"
    }
  }
}
tests/yaml_parse_wiki_YtsBlockMapping_003.phpt000064400000001022150414240750015467 0ustar00--TEST--
Yaml YtsBlockMapping - Values aligned
--DESCRIPTION--
Often times human editors of documents will align the values even
though YAML emitters generally don't.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('---
red:   baron
white: walls
blue:  berries
'));
?>
--EXPECT--
array(3) {
  ["red"]=>
  string(5) "baron"
  ["white"]=>
  string(5) "walls"
  ["blue"]=>
  string(7) "berries"
}
tests/yaml_parse_wiki_YtsMapInSeq_002.phpt000064400000000651150414240760014605 0ustar00--TEST--
Yaml YtsMapInSeq - Multiple keys
--DESCRIPTION--
Test a map with multiple keys.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('---
- foo: bar
  baz: bug
'));
?>
--EXPECT--
array(1) {
  [0]=>
  array(2) {
    ["foo"]=>
    string(3) "bar"
    ["baz"]=>
    string(3) "bug"
  }
}
tests/bug_60628.phpt000064400000002751150414240760010135 0ustar00--TEST--
Test PECL bug #260628
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
$data = <<<YAML
#yaml
---
data: !mytag
  - look upper
...
YAML;

function tag_callback ($value, $tag, $flags) {
  echo "-- callback value --\n";
  var_dump($value);
  var_dump($tag);
  var_dump($flags);
  echo "-- end callback value --\n";
  return array(
      'data' => $value,
      'another' => 'test',
    );
}

/* baseline. do like operation in native php. */
$native = array(
  "data" => array("look upper"),
);
$native["data"] = tag_callback($native["data"], "!mytag", 0);

echo "-- native value --\n";
var_dump($native);
echo "-- end native value --\n";

$cnt = null;
$array = yaml_parse($data, 0, $cnt, array(
    '!mytag' => 'tag_callback',
  ));

echo "-- parsed value --\n";
var_dump($array);
echo "-- end parsed value --\n";
?>
--EXPECT--
-- callback value --
array(1) {
  [0]=>
  string(10) "look upper"
}
string(6) "!mytag"
int(0)
-- end callback value --
-- native value --
array(1) {
  ["data"]=>
  array(2) {
    ["data"]=>
    array(1) {
      [0]=>
      string(10) "look upper"
    }
    ["another"]=>
    string(4) "test"
  }
}
-- end native value --
-- callback value --
array(1) {
  [0]=>
  string(10) "look upper"
}
string(6) "!mytag"
int(0)
-- end callback value --
-- parsed value --
array(1) {
  ["data"]=>
  array(2) {
    ["data"]=>
    array(1) {
      [0]=>
      string(10) "look upper"
    }
    ["another"]=>
    string(4) "test"
  }
}
-- end parsed value --
tests/yaml_parse_spec_omap.phpt000064400000002013150414240760012764 0ustar00--TEST--
Yaml 1.1 Spec - omap
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('
# Explicitly typed ordered map (dictionary).
Bestiary: !!omap
  - aardvark: African pig-like ant eater. Ugly.
  - anteater: South-American ant eater. Two species.
  - anaconda: South-American constrictor snake. Scaly.
  # Etc.
# Flow style
Numbers: !!omap [ one: 1, two: 2, three : 3 ]
'));
?>
--EXPECT--
array(2) {
  ["Bestiary"]=>
  array(3) {
    [0]=>
    array(1) {
      ["aardvark"]=>
      string(33) "African pig-like ant eater. Ugly."
    }
    [1]=>
    array(1) {
      ["anteater"]=>
      string(38) "South-American ant eater. Two species."
    }
    [2]=>
    array(1) {
      ["anaconda"]=>
      string(40) "South-American constrictor snake. Scaly."
    }
  }
  ["Numbers"]=>
  array(3) {
    [0]=>
    array(1) {
      ["one"]=>
      int(1)
    }
    [1]=>
    array(1) {
      ["two"]=>
      int(2)
    }
    [2]=>
    array(1) {
      ["three"]=>
      int(3)
    }
  }
}
tests/yaml_parse_005.phpt000064400000003701150414240760011327 0ustar00--TEST--
yaml_parse - syck bug #12656
--CREDITS--
From syck bug #12656
http://pecl.php.net/bugs/bug.php?id=12656
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('
models : [ /usr/home/enovodk/data/core/easyworks/current/models/ ]
behaviors : [
/usr/home/enovodk/data/core/easyworks/current/models/behaviors/ ]
controllers : [
/usr/home/enovodk/data/core/easyworks/current/controllers/ ]
components : [
/usr/home/enovodk/data/core/easyworks/current/controllers/components/ ]
apis : [ /usr/home/enovodk/data/core/easyworks/current/controllers/api/
]
views : [ /usr/home/enovodk/data/core/easyworks/current/views/ ]
helpers : [ /usr/home/enovodk/data/core/easyworks/current/views/helpers/
]
libs : [ /usr/home/enovodk/data/core/easyworks/current/libs/ ]
plugins : [ /usr/home/enovodk/data/core/easyworks/current/plugins/ ]

'));
?>
--EXPECT--
array(9) {
  ["models"]=>
  array(1) {
    [0]=>
    string(53) "/usr/home/enovodk/data/core/easyworks/current/models/"
  }
  ["behaviors"]=>
  array(1) {
    [0]=>
    string(63) "/usr/home/enovodk/data/core/easyworks/current/models/behaviors/"
  }
  ["controllers"]=>
  array(1) {
    [0]=>
    string(58) "/usr/home/enovodk/data/core/easyworks/current/controllers/"
  }
  ["components"]=>
  array(1) {
    [0]=>
    string(69) "/usr/home/enovodk/data/core/easyworks/current/controllers/components/"
  }
  ["apis"]=>
  array(1) {
    [0]=>
    string(62) "/usr/home/enovodk/data/core/easyworks/current/controllers/api/"
  }
  ["views"]=>
  array(1) {
    [0]=>
    string(52) "/usr/home/enovodk/data/core/easyworks/current/views/"
  }
  ["helpers"]=>
  array(1) {
    [0]=>
    string(60) "/usr/home/enovodk/data/core/easyworks/current/views/helpers/"
  }
  ["libs"]=>
  array(1) {
    [0]=>
    string(51) "/usr/home/enovodk/data/core/easyworks/current/libs/"
  }
  ["plugins"]=>
  array(1) {
    [0]=>
    string(54) "/usr/home/enovodk/data/core/easyworks/current/plugins/"
  }
}
tests/yaml_parse_002.phpt000064400000001205150414240760011321 0ustar00--TEST--
yaml_parse - multiple documents
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('
---
time: !!str 20:03:20
player: Sammy Sosa
action: strike (miss)
...

%YAML 1.1
---
time: "20:03:47"
player: Sammy Sosa
action: grand slam
...
', -1));
?>
--EXPECT--
array(2) {
  [0]=>
  array(3) {
    ["time"]=>
    string(8) "20:03:20"
    ["player"]=>
    string(10) "Sammy Sosa"
    ["action"]=>
    string(13) "strike (miss)"
  }
  [1]=>
  array(3) {
    ["time"]=>
    string(8) "20:03:47"
    ["player"]=>
    string(10) "Sammy Sosa"
    ["action"]=>
    string(10) "grand slam"
  }
}
tests/yaml_parse_spec_binary.phpt000064400000001775150414240760013332 0ustar00--TEST--
Yaml 1.1 Spec - binary
--SKIPIF--
<?php
  if(!extension_loaded('yaml')) die('skip yaml n/a');
  if(!function_exists('md5')) die('skip md5 unavailable');
?>
--INI--
yaml.decode_binary=1
--FILE--
<?php
  $y = yaml_parse('
canonical: !!binary "\
 R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5\
 OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+\
 +f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC\
 AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs="
generic: !!binary |
 R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5
 OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+
 +f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC
 AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=
description:
 The binary value above is a tiny arrow encoded as a gif image.
');
  var_dump($y['canonical'] === $y['generic']);
  var_dump(md5($y['canonical']));
?>
--EXPECT--
bool(true)
string(32) "a8363b3d0e4e39d9e77e244e216c7840"
tests/yaml_emit_005.phpt000064400000000531150414240760011151 0ustar00--TEST--
yaml_emit - serializable
--SKIPIF--
<?php
if(!extension_loaded('yaml')) die('skip yaml n/a');
?>
--FILE--
<?php
class A {
  public $one = 1;

  public function show_one() {
    echo $this->one;
  }
}
$a = new A;

var_dump(yaml_emit(array('a' => $a)));
?>
--EXPECT--
string(56) "---
a: !php/object "O:1:\"A\":1:{s:3:\"one\";i:1;}"
...
"
tests/bug_64019.phpt000064400000001254150414240760010130 0ustar00--TEST--
Test PECL bug #64019
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
$yaml_code = <<<YAML
configAnchors:
  - &wrongAnchor:   # This last colon (:) makes the script die
    configKey: configValue

config:
  <<: *wrongAnchor
YAML;

var_dump(yaml_parse($yaml_code));

$yaml_code = <<<YAML
config:
  <<:
YAML;

var_dump(yaml_parse($yaml_code));
?>
--EXPECT--
array(2) {
  ["configAnchors"]=>
  array(1) {
    [0]=>
    array(2) {
      [""]=>
      NULL
      ["configKey"]=>
      string(11) "configValue"
    }
  }
  ["config"]=>
  array(1) {
    ["<<"]=>
    NULL
  }
}
array(1) {
  ["config"]=>
  array(1) {
    ["<<"]=>
    NULL
  }
}
tests/yaml_parse_wiki_YtsMapInSeq_001.phpt000064400000000675150414240760014612 0ustar00--TEST--
Yaml YtsMapInSeq - Single key
--DESCRIPTION--
Test maps with just one key.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('---
- foo: bar
- baz: bug
'));
?>
--EXPECT--
array(2) {
  [0]=>
  array(1) {
    ["foo"]=>
    string(3) "bar"
  }
  [1]=>
  array(1) {
    ["baz"]=>
    string(3) "bug"
  }
}
tests/bug_72204.phpt000064400000000620150414240760010117 0ustar00--TEST--
Test PECL bug #72204
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
$yaml_code = <<<YAML
foo: &ref
    bar: true
baz: &ref2
    <<: *ref
    bar: false
YAML;
$yaml = yaml_parse($yaml_code);
var_dump($yaml);
?>
--EXPECT--
array(2) {
  ["foo"]=>
  array(1) {
    ["bar"]=>
    bool(true)
  }
  ["baz"]=>
  array(1) {
    ["bar"]=>
    bool(false)
  }
}
tests/yaml_parse_spec_set.phpt000064400000000572150414240760012633 0ustar00--TEST--
Yaml 1.1 Spec - set
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('baseball players: !!set
  ? Mark McGwire
  ? Sammy Sosa
  ? Ken Griffey
'));
?>
--EXPECT--
array(1) {
  ["baseball players"]=>
  array(3) {
    ["Mark McGwire"]=>
    NULL
    ["Sammy Sosa"]=>
    NULL
    ["Ken Griffey"]=>
    NULL
  }
}
tests/yaml_emit_006.phpt000064400000007250150414240760011157 0ustar00--TEST--
yaml_emit - ini settings
--SKIPIF--
<?php
if(!extension_loaded('yaml')) die('skip yaml n/a');
?>
--INI--
yaml.output_canonical=0
yaml.output_indent=2
yaml.output_width=80
serialize_precision=-1
--FILE--
<?php
$addr = array(
    "given" => "Chris",
    "family"=> "Dumars",
    "address"=> array(
        "lines"=> "458 Walkman Dr.
        Suite #292",
        "city"=> "Royal Oak",
        "state"=> "MI",
        "postal"=> 48046,
      ),
  );
$invoice = array (
    "invoice"=> 34843,
    "date"=> 980208000,
    "bill-to"=> $addr,
    "ship-to"=> $addr,
    "product"=> array(
        array(
            "sku"=> "BL394D",
            "quantity"=> 4,
            "description"=> "Basketball",
            "price"=> 450,
          ),
        array(
            "sku"=> "BL4438H",
            "quantity"=> 1,
            "description"=> "Super Hoop",
            "price"=> 2392,
          ),
      ),
    "tax"=> 251.42,
    "total"=> 4443.52,
    "comments"=> "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.",
  );
var_dump(yaml_emit($invoice));

ini_set("yaml.output_canonical", "1");
ini_set("yaml.output_indent", "4");
ini_set("yaml.output_width", "40");
echo "== CANONICAL ==\n";
var_dump(yaml_emit($invoice));

?>
--EXPECT--
string(620) "---
invoice: 34843
date: 980208000
bill-to:
  given: Chris
  family: Dumars
  address:
    lines: |-
      458 Walkman Dr.
              Suite #292
    city: Royal Oak
    state: MI
    postal: 48046
ship-to:
  given: Chris
  family: Dumars
  address:
    lines: |-
      458 Walkman Dr.
              Suite #292
    city: Royal Oak
    state: MI
    postal: 48046
product:
- sku: BL394D
  quantity: 4
  description: Basketball
  price: 450
- sku: BL4438H
  quantity: 1
  description: Super Hoop
  price: 2392
tax: 251.42
total: 4443.52
comments: Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.
...
"
== CANONICAL ==
string(1822) "---
!!map {
    ? !!str "invoice"
    : !!int "34843",
    ? !!str "date"
    : !!int "980208000",
    ? !!str "bill-to"
    : !!map {
        ? !!str "given"
        : !!str "Chris",
        ? !!str "family"
        : !!str "Dumars",
        ? !!str "address"
        : !!map {
            ? !!str "lines"
            : !!str "458 Walkman Dr.\n        Suite
                #292",
            ? !!str "city"
            : !!str "Royal Oak",
            ? !!str "state"
            : !!str "MI",
            ? !!str "postal"
            : !!int "48046",
        },
    },
    ? !!str "ship-to"
    : !!map {
        ? !!str "given"
        : !!str "Chris",
        ? !!str "family"
        : !!str "Dumars",
        ? !!str "address"
        : !!map {
            ? !!str "lines"
            : !!str "458 Walkman Dr.\n        Suite
                #292",
            ? !!str "city"
            : !!str "Royal Oak",
            ? !!str "state"
            : !!str "MI",
            ? !!str "postal"
            : !!int "48046",
        },
    },
    ? !!str "product"
    : !!seq [
        !!map {
            ? !!str "sku"
            : !!str "BL394D",
            ? !!str "quantity"
            : !!int "4",
            ? !!str "description"
            : !!str "Basketball",
            ? !!str "price"
            : !!int "450",
        },
        !!map {
            ? !!str "sku"
            : !!str "BL4438H",
            ? !!str "quantity"
            : !!int "1",
            ? !!str "description"
            : !!str "Super Hoop",
            ? !!str "price"
            : !!int "2392",
        },
    ],
    ? !!str "tax"
    : !!float "251.42",
    ? !!str "total"
    : !!float "4443.52",
    ? !!str "comments"
    : !!str "Late afternoon is best. Backup
        contact is Nancy Billsmer @ 338-4338.",
}
...
"
tests/yaml_parse_spec_pairs.phpt000064400000001636150414240770013161 0ustar00--TEST--
Yaml 1.1 Spec - pairs
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('
# Explicitly typed pairs.
Block tasks: !!pairs
  - meeting: with team.
  - meeting: with boss.
  - break: lunch.
  - meeting: with client.
Flow tasks: !!pairs [ meeting: with team, meeting: with boss ]
'));
?>
--EXPECT--
array(2) {
  ["Block tasks"]=>
  array(4) {
    [0]=>
    array(1) {
      ["meeting"]=>
      string(10) "with team."
    }
    [1]=>
    array(1) {
      ["meeting"]=>
      string(10) "with boss."
    }
    [2]=>
    array(1) {
      ["break"]=>
      string(6) "lunch."
    }
    [3]=>
    array(1) {
      ["meeting"]=>
      string(12) "with client."
    }
  }
  ["Flow tasks"]=>
  array(2) {
    [0]=>
    array(1) {
      ["meeting"]=>
      string(9) "with team"
    }
    [1]=>
    array(1) {
      ["meeting"]=>
      string(9) "with boss"
    }
  }
}
tests/yaml_001.phpt000064400000002121150414240770010125 0ustar00--TEST--
yaml - emit -> parse roundtrip
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
$addr = array(
    "given" => "Chris",
    "family"=> "Dumars",
    "address"=> array(
        "lines"=> "458 Walkman Dr.
        Suite #292",
        "city"=> "Royal Oak",
        "state"=> "MI",
        "postal"=> 48046,
      ),
  );
$invoice = array (
    "invoice"=> 34843,
    "date"=> 980208000,
    "bill-to"=> $addr,
    "ship-to"=> $addr,
    "product"=> array(
        array(
            "sku"=> "BL394D",
            "quantity"=> 4,
            "description"=> "Basketball",
            "price"=> 450,
          ),
        array(
            "sku"=> "BL4438H",
            "quantity"=> 1,
            "description"=> "Super Hoop",
            "price"=> 2392,
          ),
      ),
    "tax"=> 251.42,
    "total"=> 4443.52,
    "comments"=> "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.",
    "tags" => array("a","b","c"),
  );
$yaml = yaml_emit($invoice);
$parsed = yaml_parse($yaml);
var_dump($parsed == $invoice);
?>
--EXPECT--
bool(true)
tests/yaml_parse_spec_map.phpt000064400000001225150414240770012612 0ustar00--TEST--
Yaml 1.1 Spec - map
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('
# Unordered set of key: value pairs.
Block style: !!map
  Clark : Evans
  Brian : Ingerson
  Oren  : Ben-Kiki
Flow style: !!map { Clark: Evans, Brian: Ingerson, Oren: Ben-Kiki }
'));
?>
--EXPECT--
array(2) {
  ["Block style"]=>
  array(3) {
    ["Clark"]=>
    string(5) "Evans"
    ["Brian"]=>
    string(8) "Ingerson"
    ["Oren"]=>
    string(8) "Ben-Kiki"
  }
  ["Flow style"]=>
  array(3) {
    ["Clark"]=>
    string(5) "Evans"
    ["Brian"]=>
    string(8) "Ingerson"
    ["Oren"]=>
    string(8) "Ben-Kiki"
  }
}
tests/bug_79494.phpt000064400000001141150414240770010141 0ustar00--TEST--
Test PECL bug #74949
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--INI--
serialize_precision=-1
--FILE--
<?php
$data = array (
    'audio' =>
    array (
        'audioEnabled' =>
        array (
          0 => 132317787432502136,
          1 => 0,
    ),
    'eveampGain' =>
    array (
          0 => 132316833510704299,
          1 => 0.25,
        ),
    ),
);

print yaml_emit($data);
?>
--EXPECTF--
---
audio:
  audioEnabled:
  - %r(132317787432502136|1\.3231778743250214E\+17)%r
  - 0
  eveampGain:
  - %r(132316833510704299|1\.323168335107043E\+17)%r
  - 0.25
...
tests/bug_79567.phpt000064400000000513150414240770010144 0ustar00--TEST--
Test PECL bug #79567
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
$data = [
    'audioEnabled' => [
        0 => 132317787432502136,
        1 => 0,
    ],
];
$yaml = yaml_emit($data);
$result = yaml_parse($yaml);
print $result == $data ? "Yes!\n" : "No...\n";
?>
--EXPECT--
Yes!
tests/bug_59860.phpt000064400000003164150414240770010143 0ustar00--TEST--
Test PECL bug #59860
--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) {
  var_dump(func_get_args());
  return $tag;
}

$yaml = <<<YAML
implicit_map:
  a: b
explicit_map: !!map
  c: d
implicit_seq: [e, f]
explicit_seq: !!seq [g, h]
YAML;

yaml_parse($yaml, 0, $ndocs, array(
    YAML_MAP_TAG => 'tag_callback',
    YAML_SEQ_TAG => 'tag_callback',
  ));
?>
--EXPECT--
array(3) {
  [0]=>
  array(1) {
    ["a"]=>
    string(1) "b"
  }
  [1]=>
  string(21) "tag:yaml.org,2002:map"
  [2]=>
  int(0)
}
array(3) {
  [0]=>
  array(1) {
    ["c"]=>
    string(1) "d"
  }
  [1]=>
  string(21) "tag:yaml.org,2002:map"
  [2]=>
  int(0)
}
array(3) {
  [0]=>
  array(2) {
    [0]=>
    string(1) "e"
    [1]=>
    string(1) "f"
  }
  [1]=>
  string(21) "tag:yaml.org,2002:seq"
  [2]=>
  int(0)
}
array(3) {
  [0]=>
  array(2) {
    [0]=>
    string(1) "g"
    [1]=>
    string(1) "h"
  }
  [1]=>
  string(21) "tag:yaml.org,2002:seq"
  [2]=>
  int(0)
}
array(3) {
  [0]=>
  array(4) {
    ["implicit_map"]=>
    string(21) "tag:yaml.org,2002:map"
    ["explicit_map"]=>
    string(21) "tag:yaml.org,2002:map"
    ["implicit_seq"]=>
    string(21) "tag:yaml.org,2002:seq"
    ["explicit_seq"]=>
    string(21) "tag:yaml.org,2002:seq"
  }
  [1]=>
  string(21) "tag:yaml.org,2002:map"
  [2]=>
  int(0)
}
tests/bug_61770.phpt000064400000000403150414240770010125 0ustar00--TEST--
Test PECL bug #61770
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_emit("\xc2"));
?>
--EXPECTF--
Warning: yaml_emit(): Invalid UTF-8 sequence in argument in %sbug_61770.php on line 2
bool(false)
tests/yaml_parse_url_001.phpt000064400000003067150414240770012213 0ustar00--TEST--
yaml_parse_url - general
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--INI--
yaml.decode_timestamp=1
date.timezone=GMT
--FILE--
<?php
var_dump(yaml_parse_url('file://' . __DIR__ . '/yaml_parse_file_001.yaml'));
?>
--EXPECT--
array(8) {
  ["invoice"]=>
  int(34843)
  ["date"]=>
  int(980208000)
  ["bill-to"]=>
  &array(3) {
    ["given"]=>
    string(5) "Chris"
    ["family"]=>
    string(6) "Dumars"
    ["address"]=>
    array(4) {
      ["lines"]=>
      string(27) "458 Walkman Dr.
Suite #292
"
      ["city"]=>
      string(9) "Royal Oak"
      ["state"]=>
      string(2) "MI"
      ["postal"]=>
      int(48046)
    }
  }
  ["ship-to"]=>
  &array(3) {
    ["given"]=>
    string(5) "Chris"
    ["family"]=>
    string(6) "Dumars"
    ["address"]=>
    array(4) {
      ["lines"]=>
      string(27) "458 Walkman Dr.
Suite #292
"
      ["city"]=>
      string(9) "Royal Oak"
      ["state"]=>
      string(2) "MI"
      ["postal"]=>
      int(48046)
    }
  }
  ["product"]=>
  array(2) {
    [0]=>
    array(4) {
      ["sku"]=>
      string(6) "BL394D"
      ["quantity"]=>
      int(4)
      ["description"]=>
      string(10) "Basketball"
      ["price"]=>
      float(450)
    }
    [1]=>
    array(4) {
      ["sku"]=>
      string(7) "BL4438H"
      ["quantity"]=>
      int(1)
      ["description"]=>
      string(10) "Super Hoop"
      ["price"]=>
      float(2392)
    }
  }
  ["tax"]=>
  float(251.42)
  ["total"]=>
  float(4443.52)
  ["comments"]=>
  string(68) "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338."
}
tests/bug_80324.phpt000064400000000673150414240770010132 0ustar00--TEST--
Bug #80324 (Segfault in YAML with anonymous functions)
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
$yaml = <<<YAML
- !env ENV
- !path PATH
YAML;

$result = yaml_parse($yaml, 0, $ndocs, array(
    '!env' => function ($str) {return $str;},
    '!path' => function ($str) {return $str;},
  ));

var_dump($result);
?>
--EXPECT--
array(2) {
  [0]=>
  string(3) "ENV"
  [1]=>
  string(4) "PATH"
}
tests/bug_61923.phpt000064400000002234150414240770010131 0ustar00--TEST--
Test PECL bug #61923
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--INI--
serialize_precision=-1
--FILE--
<?php
$yaml_code = <<<YAML
---
strings:
  - '1:0'
  - '0:1'
  - '1:0:0'
  - '+1:0:0'
  - '-1:0:0'
  - ':01'
  - ':1'
  - '18:53:17.00037'
numbers:
  - 1:0
  - 0:1
  - 1:0:0
  - +1:0:0
  - -1:0:0
  - :01
  - :1
  - 18:53:17.00037
YAML;

$parsed = yaml_parse($yaml_code);
var_dump($parsed);
var_dump(yaml_emit($parsed));
?>
--EXPECT--
array(2) {
  ["strings"]=>
  array(8) {
    [0]=>
    string(3) "1:0"
    [1]=>
    string(3) "0:1"
    [2]=>
    string(5) "1:0:0"
    [3]=>
    string(6) "+1:0:0"
    [4]=>
    string(6) "-1:0:0"
    [5]=>
    string(3) ":01"
    [6]=>
    string(2) ":1"
    [7]=>
    string(14) "18:53:17.00037"
  }
  ["numbers"]=>
  array(8) {
    [0]=>
    int(60)
    [1]=>
    int(1)
    [2]=>
    int(3600)
    [3]=>
    int(3600)
    [4]=>
    int(-3600)
    [5]=>
    int(1)
    [6]=>
    int(1)
    [7]=>
    float(67997.00037)
  }
}
string(161) "---
strings:
- "1:0"
- "0:1"
- "1:0:0"
- "+1:0:0"
- "-1:0:0"
- ":01"
- ":1"
- "18:53:17.00037"
numbers:
- 60
- 1
- 3600
- 3600
- -3600
- 1
- 1
- 67997.00037
...
"
tests/bug_64694.phpt000064400000000643150414240770010143 0ustar00--TEST--
Test PECL bug #64694
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
$yaml_code = <<<YAML
"[a]": 1
YAML;

var_dump(yaml_parse($yaml_code));

$yaml_code = <<<YAML
[a]: 1
YAML;

var_dump(yaml_parse($yaml_code));
?>
--EXPECTF--
array(1) {
  ["[a]"]=>
  int(1)
}

Warning: yaml_parse(): Illegal offset type array (line 1, column 7) in %sbug_64694.php on line 12
array(0) {
}
tests/bug_69617.phpt000064400000000472150414240770010143 0ustar00--TEST--
Test PECL bug #69617
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
$yaml_code = <<<YAML
---
a: !php/object "O:1:\"A\":1:{s:3:\"one\";i:1;}"
...
YAML;

var_dump(yaml_parse($yaml_code));
?>
--EXPECT--
array(1) {
  ["a"]=>
  string(26) "O:1:"A":1:{s:3:"one";i:1;}"
}
tests/yaml_parse_spec_timestamp.phpt000064400000001331150414240770014036 0ustar00--TEST--
Yaml 1.1 Spec - timestamp
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--INI--
yaml.decode_timestamp=1
date.timezone=GMT
--FILE--
<?php
  var_dump(yaml_parse('
canonical:         2001-12-15T02:59:43.1Z
valid iso8601:     2001-12-14t21:59:43.10-05:00
alternate iso8601: 2001-12-14T21:59:43.10-0500
space separated:   2001-12-14 21:59:43.10 -5
no time zone (Z):  2001-12-15 2:59:43.10
date (00:00:00Z):  2002-12-14
'));
?>
--EXPECT--
array(6) {
  ["canonical"]=>
  int(1008385183)
  ["valid iso8601"]=>
  int(1008385183)
  ["alternate iso8601"]=>
  int(1008385183)
  ["space separated"]=>
  int(1008385183)
  ["no time zone (Z)"]=>
  int(1008385183)
  ["date (00:00:00Z)"]=>
  int(1039824000)
}
tests/bug_21995.phpt000064400000000611150414240770010133 0ustar00--TEST--
Test PECL bug #21995
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
function yaml_cbk ($a) {
  var_dump($a);
  return $a;
}

$yaml_code = <<<YAML
boo: doo
a: [1,2,3,4]
d: []
YAML;

$yaml = yaml_parse($yaml_code, 0, $ndocs, array(
    YAML_STR_TAG => "yaml_cbk",
    ));
?>
--EXPECT--
string(3) "boo"
string(3) "doo"
string(1) "a"
string(1) "d"
tests/yaml_parse_file_001.phpt000064400000003052150414240770012322 0ustar00--TEST--
yaml_parse_file - general
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--INI--
yaml.decode_timestamp=1
date.timezone=GMT
--FILE--
<?php
var_dump(yaml_parse_file(__DIR__ . '/yaml_parse_file_001.yaml'));
--EXPECT--
array(8) {
  ["invoice"]=>
  int(34843)
  ["date"]=>
  int(980208000)
  ["bill-to"]=>
  &array(3) {
    ["given"]=>
    string(5) "Chris"
    ["family"]=>
    string(6) "Dumars"
    ["address"]=>
    array(4) {
      ["lines"]=>
      string(27) "458 Walkman Dr.
Suite #292
"
      ["city"]=>
      string(9) "Royal Oak"
      ["state"]=>
      string(2) "MI"
      ["postal"]=>
      int(48046)
    }
  }
  ["ship-to"]=>
  &array(3) {
    ["given"]=>
    string(5) "Chris"
    ["family"]=>
    string(6) "Dumars"
    ["address"]=>
    array(4) {
      ["lines"]=>
      string(27) "458 Walkman Dr.
Suite #292
"
      ["city"]=>
      string(9) "Royal Oak"
      ["state"]=>
      string(2) "MI"
      ["postal"]=>
      int(48046)
    }
  }
  ["product"]=>
  array(2) {
    [0]=>
    array(4) {
      ["sku"]=>
      string(6) "BL394D"
      ["quantity"]=>
      int(4)
      ["description"]=>
      string(10) "Basketball"
      ["price"]=>
      float(450)
    }
    [1]=>
    array(4) {
      ["sku"]=>
      string(7) "BL4438H"
      ["quantity"]=>
      int(1)
      ["description"]=>
      string(10) "Super Hoop"
      ["price"]=>
      float(2392)
    }
  }
  ["tax"]=>
  float(251.42)
  ["total"]=>
  float(4443.52)
  ["comments"]=>
  string(68) "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338."
}
tests/yaml_parse_001.phpt000064400000006706150414240770011334 0ustar00--TEST--
yaml_parse - general
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--INI--
yaml.decode_timestamp=1
date.timezone=GMT
--FILE--
<?php
  var_dump(yaml_parse('
--- !<tag:clarkevans.com,2002:invoice>
invoice: 34843
date   : 2001-01-23
bill-to: &id001
    given  : Chris
    family : Dumars
    address:
        lines: |
            458 Walkman Dr.
            Suite #292
        city    : Royal Oak
        state   : MI
        postal  : 48046
ship-to: *id001
product:
    - sku         : BL394D
      quantity    : 4
      description : Basketball
      price       : 450.00
    - sku         : BL4438H
      quantity    : 1
      description : Super Hoop
      price       : 2392.00
tax  : 251.42
total: 4443.52
comments:
    Late afternoon is best.
    Backup contact is Nancy
    Billsmer @ 338-4338.
'));
  var_dump(yaml_parse('
---
Time: 2001-11-23 15:01:42 -5
User: ed
Warning:
  This is an error message
  for the log file
---
Time: 2001-11-23 15:02:31 -5
User: ed
Warning:
  A slightly different error
  message.
---
Date: 2001-11-23 15:03:17 -5
User: ed
Fatal:
  Unknown variable "bar"
Stack:
  - file: TopClass.py
    line: 23
    code: |
      x = MoreObject("345\n")
  - file: MoreClass.py
    line: 58
    code: |-
      foo = bar
', -1));
?>
--EXPECT--
array(8) {
  ["invoice"]=>
  int(34843)
  ["date"]=>
  int(980208000)
  ["bill-to"]=>
  &array(3) {
    ["given"]=>
    string(5) "Chris"
    ["family"]=>
    string(6) "Dumars"
    ["address"]=>
    array(4) {
      ["lines"]=>
      string(27) "458 Walkman Dr.
Suite #292
"
      ["city"]=>
      string(9) "Royal Oak"
      ["state"]=>
      string(2) "MI"
      ["postal"]=>
      int(48046)
    }
  }
  ["ship-to"]=>
  &array(3) {
    ["given"]=>
    string(5) "Chris"
    ["family"]=>
    string(6) "Dumars"
    ["address"]=>
    array(4) {
      ["lines"]=>
      string(27) "458 Walkman Dr.
Suite #292
"
      ["city"]=>
      string(9) "Royal Oak"
      ["state"]=>
      string(2) "MI"
      ["postal"]=>
      int(48046)
    }
  }
  ["product"]=>
  array(2) {
    [0]=>
    array(4) {
      ["sku"]=>
      string(6) "BL394D"
      ["quantity"]=>
      int(4)
      ["description"]=>
      string(10) "Basketball"
      ["price"]=>
      float(450)
    }
    [1]=>
    array(4) {
      ["sku"]=>
      string(7) "BL4438H"
      ["quantity"]=>
      int(1)
      ["description"]=>
      string(10) "Super Hoop"
      ["price"]=>
      float(2392)
    }
  }
  ["tax"]=>
  float(251.42)
  ["total"]=>
  float(4443.52)
  ["comments"]=>
  string(68) "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338."
}
array(3) {
  [0]=>
  array(3) {
    ["Time"]=>
    int(1006545702)
    ["User"]=>
    string(2) "ed"
    ["Warning"]=>
    string(41) "This is an error message for the log file"
  }
  [1]=>
  array(3) {
    ["Time"]=>
    int(1006545751)
    ["User"]=>
    string(2) "ed"
    ["Warning"]=>
    string(35) "A slightly different error message."
  }
  [2]=>
  array(4) {
    ["Date"]=>
    int(1006545797)
    ["User"]=>
    string(2) "ed"
    ["Fatal"]=>
    string(22) "Unknown variable "bar""
    ["Stack"]=>
    array(2) {
      [0]=>
      array(3) {
        ["file"]=>
        string(11) "TopClass.py"
        ["line"]=>
        int(23)
        ["code"]=>
        string(24) "x = MoreObject("345\n")
"
      }
      [1]=>
      array(3) {
        ["file"]=>
        string(12) "MoreClass.py"
        ["line"]=>
        int(58)
        ["code"]=>
        string(9) "foo = bar"
      }
    }
  }
}
tests/bug_74799.yaml000064400000000025150414240770010133 0ustar00---
key:
  !value
...tests/yaml_parse_file_002.phpt000064400000002456150414240770012332 0ustar00--TEST--
yaml_parse_file - error cases
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--INI--
yaml.decode_timestamp=1
date.timezone=GMT
; E_ALL - E_DEPRECATED to hide Deprecated: yaml_parse_file(): Passing null to parameter #1...
error_reporting=24575
--FILE--
<?php
try {
  // PHP7 emits a Warning here
  yaml_parse_file(NULL);
} catch (ValueError $e) {
  // PHP8 raises this exception
  echo "\nWarning: yaml_parse_file(): {$e->getMessage()} in " . __FILE__ . " on line 4\n";
}
try {
  // PHP7 emits a Warning here
  yaml_parse_file('');
} catch (ValueError $e) {
  // PHP8 raises this exception
  echo "\nWarning: yaml_parse_file(): {$e->getMessage()} in " . __FILE__ . " on line 11\n";
}
yaml_parse_file('invalid');
try {
  // PHP7 emits a Warning here
  yaml_parse_file();
} catch (ArgumentCountError $e) {
  // PHP8 raises this exception
  echo "\nWarning: {$e->getMessage()} in " . __FILE__ . " on line 19\n";
}
--EXPECTF--
Warning: yaml_parse_file(): %r(Filename|Path)%r cannot be empty in %s on line %d

Warning: yaml_parse_file(): %r(Filename|Path)%r cannot be empty in %s on line %d

Warning: yaml_parse_file(invalid): %r[Ff]%railed to open stream: No such file or directory in %s on line %d

Warning: yaml_parse_file() expects at least 1 %r(argument|parameter)%r, 0 given in %s on line %d
tests/yaml_parse_wiki_YtsBasicTests_001.phpt000064400000001017150414240770015171 0ustar00--TEST--
Yaml YtsBasicTests - Simple Sequence
--DESCRIPTION--
You can specify a list in YAML by placing each
member of the list on a new line with an opening
dash. These lists are called sequences.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('- apple
- banana
- carrot
'));
?>
--EXPECT--
array(3) {
  [0]=>
  string(5) "apple"
  [1]=>
  string(6) "banana"
  [2]=>
  string(6) "carrot"
}
tests/yaml_parse_007.phpt000064400000000630150414241000011313 0ustar00--TEST--
yaml_parse - serializable
--SKIPIF--
<?php
if(!extension_loaded('yaml')) die('skip yaml n/a');
?>
--INI--
yaml.decode_php=1
--FILE--
<?php
class A {
  public $one = 1;

  public function show_one() {
    echo $this->one;
  }
}

var_dump(yaml_parse('
---
a: !php/object "O:1:\"A\":1:{s:3:\"one\";i:1;}"
...
'));
?>
--EXPECTF--
array(1) {
  ["a"]=>
  object(A)#%d (1) {
    ["one"]=>
    int(1)
  }
}
tests/yaml_emit_file_basic.phpt000064400000003574150414241000012723 0ustar00--TEST--
Test Github pull request #1
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--INI--
serialize_precision=-1
--FILE--
<?php
$addr = array(
    "given" => "Chris",
    "family"=> "Dumars",
    "address"=> array(
        "lines"=> "458 Walkman Dr.
        Suite #292",
        "city"=> "Royal Oak",
        "state"=> "MI",
        "postal"=> 48046,
      ),
  );
$invoice = array (
    "invoice"=> 34843,
    "date"=> 980208000,
    "bill-to"=> $addr,
    "ship-to"=> $addr,
    "product"=> array(
        array(
            "sku"=> "BL394D",
            "quantity"=> 4,
            "description"=> "Basketball",
            "price"=> 450,
          ),
        array(
            "sku"=> "BL4438H",
            "quantity"=> 1,
            "description"=> "Super Hoop",
            "price"=> 2392,
          ),
      ),
    "tax"=> 251.42,
    "total"=> 4443.52,
    "comments"=> "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.",
  );

$temp_filename = dirname(__FILE__) . 'yaml_emit_file_basic.tmp';
var_dump(yaml_emit_file($temp_filename, $invoice));
var_dump(file_get_contents($temp_filename));
?>
--CLEAN--
<?php
$temp_filename = dirname(__FILE__) . 'yaml_emit_file_basic.tmp';
unlink($temp_filename);
?>
--EXPECT--
bool(true)
string(620) "---
invoice: 34843
date: 980208000
bill-to:
  given: Chris
  family: Dumars
  address:
    lines: |-
      458 Walkman Dr.
              Suite #292
    city: Royal Oak
    state: MI
    postal: 48046
ship-to:
  given: Chris
  family: Dumars
  address:
    lines: |-
      458 Walkman Dr.
              Suite #292
    city: Royal Oak
    state: MI
    postal: 48046
product:
- sku: BL394D
  quantity: 4
  description: Basketball
  price: 450
- sku: BL4438H
  quantity: 1
  description: Super Hoop
  price: 2392
tax: 251.42
total: 4443.52
comments: Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.
...
"
tests/yaml_parse_wiki_YtsBlockMapping_001.phpt000064400000000552150414241000015461 0ustar00--TEST--
Yaml YtsBlockMapping - One Element Mapping
--DESCRIPTION--
A mapping with one key/value pair
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('---
foo: bar
'));
?>
--EXPECT--
array(1) {
  ["foo"]=>
  string(3) "bar"
}
tests/yaml_emit_009.phpt000064400000002300150414241010011136 0ustar00--TEST--
yaml_emit - custom tags with closures
--SKIPIF--
<?php
if(!extension_loaded('yaml')) die('skip yaml n/a');
if (version_compare(PHP_VERSION, '5.3.0', '<')) die('skip Closure unsupported');
?>
--FILE--
<?php
$emit_callbacks = array(
  'Emit009Example' => function ($o) {
    return array(
      'tag' => '!emit009',
      'data' => $o->data,
    );
  },
);

class Emit009Example {
  public $data;    // data may be in any pecl/yaml suitable type
}

$t = new Emit009Example();
$t->data = array ('a','b','c');
$yaml = yaml_emit(
  array(
    'callback' => $t,
  ),
  YAML_ANY_ENCODING,
  YAML_ANY_BREAK,
  $emit_callbacks
);
var_dump($yaml);

/* make sure you can undo the custome serialization */
function parse_009 ($value, $tag, $flags) {
  $ret = new Emit009Example();
  $ret->data = $value;
  return $ret;
}
$parse_callbacks = array(
  '!emit009' => 'parse_009',
);
$array = yaml_parse($yaml, 0, $cnt, $parse_callbacks);
var_dump($array['callback'] == $t);

/* roundtrip with raw object */
var_dump($t == yaml_parse(
  yaml_emit($t, YAML_ANY_ENCODING, YAML_ANY_BREAK, $emit_callbacks),
  0, $cnt, $parse_callbacks));
?>
--EXPECT--
string(39) "---
callback: !emit009
- a
- b
- c
...
"
bool(true)
bool(true)
tests/bug_79866.phpt000064400000001653150414241010010140 0ustar00--TEST--
Test PECL bug #79866
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--INI--
precision=14
serialize_precision=-1
--FILE--
<?php
$floats = [
  "0"            => 0,
  "1"            => 1,
  "-1"           => -1,
  "2."           => 2.,
  "2.0"          => 2.0,
  "2.00"         => 2.00,
  "2.000"        => 2.000,
  "0.123456789"  => 0.123456789,
  "-0.123456789" => -0.123456789,
  "2.3e6"        => 2.3e6,
  "-2.3e6"       => -2.3e6,
  "2.3e-6"       => 2.3e-6,
  "-2.3e-6"      => -2.3e-6,
  "INF"          => INF,
  "NAN"          => NAN,
  "0.000021"     => 0.000021,
];

foreach( $floats as $idx => $float ) {
  $float = floatval($float);
  ob_start();
  echo $float;
  $native = ob_get_clean();

  $expect = "--- {$native}\n...\n";
  $got = yaml_emit($float);
  if ( $got !== $expect ) {
    echo "== FAIL! {$idx} ==\n";
    echo "expected:\n{$expect}\n";
    echo "got:{$got}\n";
  }
}
?>
--EXPECT--
tests/yaml_parse_wiki_YtsBasicTests_002.phpt000064400000001031150414241020015153 0ustar00--TEST--
Yaml YtsBasicTests - Nested Sequences
--DESCRIPTION--
You can include a sequence within another
sequence by giving the sequence an empty
dash, followed by an indented list.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('-
 - foo
 - bar
 - baz
'));
?>
--EXPECT--
array(1) {
  [0]=>
  array(3) {
    [0]=>
    string(3) "foo"
    [1]=>
    string(3) "bar"
    [2]=>
    string(3) "baz"
  }
}
tests/yaml_parse_wiki_YtsBasicTests_008.phpt000064400000001602150414241020015165 0ustar00--TEST--
Yaml YtsBasicTests - Mixed Mapping
--DESCRIPTION--
A mapping can contain any assortment
of mappings and sequences as values.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('foo: whatever
bar:
 -
  fruit: apple
  name: steve
  sport: baseball
 - more
 -
  python: rocks
  perl: papers
  ruby: scissorses
'));
?>
--EXPECT--
array(2) {
  ["foo"]=>
  string(8) "whatever"
  ["bar"]=>
  array(3) {
    [0]=>
    array(3) {
      ["fruit"]=>
      string(5) "apple"
      ["name"]=>
      string(5) "steve"
      ["sport"]=>
      string(8) "baseball"
    }
    [1]=>
    string(4) "more"
    [2]=>
    array(3) {
      ["python"]=>
      string(5) "rocks"
      ["perl"]=>
      string(6) "papers"
      ["ruby"]=>
      string(10) "scissorses"
    }
  }
}
tests/yaml_parse_wiki_YtsMapInSeq_003.phpt000064400000000666150414241030014603 0ustar00--TEST--
Yaml YtsMapInSeq - Strange keys
--DESCRIPTION--
Test a map with "line noise" keys.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('---
- "!@#$" : foo
  -+!@ :   bar
'));
?>
--EXPECT--
array(1) {
  [0]=>
  array(2) {
    ["!@#$"]=>
    string(3) "foo"
    ["-+!@"]=>
    string(3) "bar"
  }
}
tests/yaml_emit_007.phpt000064400000000625150414241030011146 0ustar00--TEST--
yaml_emit - recursive structures
--SKIPIF--
<?php
if(!extension_loaded('yaml')) die('skip yaml n/a');
?>
--FILE--
<?php
$recursive = array(
  "a" => "a",
  "b" => "b",
  "c" => &$recursive,
);
var_dump(yaml_emit($recursive));

// clean up a little or we may see false memory leak reports
unset($recursive['c']);
?>
--EXPECT--
string(56) "---
a: a
b: b
c: &refid1
  a: a
  b: b
  c: *refid1
...
"
tests/yaml_parse_006.phpt000064400000003172150414241040011322 0ustar00--TEST--
yaml_parse - syck bug #14384
--CREDITS--
From syck bug #14384
http://pecl.php.net/bugs/bug.php?id=14384
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('---
	"leading tab"
...
'));
  var_dump(yaml_parse('---
  	"space and tab"
...
'));
var_dump(yaml_parse('---
  "key":	"tab before value"
...
'));
var_dump(yaml_parse('---
  "key":  	"space and tab before value"
...
'));
var_dump(yaml_parse('---
-	"tab before value"
...
'));
var_dump(yaml_parse('---
-  	"space and tab before value"
...
'));
?>
--EXPECTF--
Warning: yaml_parse(): scanning error encountered during parsing: found character that cannot start any token (line 2, column 1), context while scanning for the next token (line 2, column 1) in %syaml_parse_006.php on line %d
bool(false)

Warning: yaml_parse(): scanning error encountered during parsing: found character that cannot start any token (line 2, column 3), context while scanning for the next token (line 2, column 3) in %syaml_parse_006.php on line %d
bool(false)
array(1) {
  ["key"]=>
  string(16) "tab before value"
}
array(1) {
  ["key"]=>
  string(26) "space and tab before value"
}

Warning: yaml_parse(): scanning error encountered during parsing: found character that cannot start any token (line 2, column 2), context while scanning for the next token (line 2, column 2) in %syaml_parse_006.php on line %d
bool(false)

Warning: yaml_parse(): scanning error encountered during parsing: found character that cannot start any token (line 2, column 4), context while scanning for the next token (line 2, column 4) in %syaml_parse_006.php on line %d
bool(false)
tests/bug_72540.phpt000064400000000402150414241040010110 0ustar00--TEST--
Test PECL bug #72540
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
$tmpfname = tempnam(sys_get_temp_dir(), 'bug_72540.yaml');
var_dump(yaml_parse_url($tmpfname));
unlink($tmpfname);
?>
--EXPECT--
bool(false)
tests/yaml_parse_003.phpt000064400000001323150414241040011313 0ustar00--TEST--
yaml_parse - parse errors
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('---
commercial-at: @text
'));
  var_dump(yaml_parse('---
grave-accent: `text
'));
?>
--EXPECTF--
Warning: yaml_parse(): scanning error encountered during parsing: found character that cannot start any token (line 2, column 16), context while scanning for the next token (line 2, column 16) in %syaml_parse_003.php on line %d
bool(false)

Warning: yaml_parse(): scanning error encountered during parsing: found character that cannot start any token (line 2, column 15), context while scanning for the next token (line 2, column 15) in %syaml_parse_003.php on line %d
bool(false)
tests/yaml_parse_spec_null.phpt000064400000001423150414241050012777 0ustar00--TEST--
Yaml 1.1 Spec - null
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('
# A document may be null.
---
---
# This mapping has four keys,
# one has a value.
empty:
canonical: ~
english: null
~: null key
---
# This sequence has five
# entries, two have values.
sparse:
  - ~
  - 2nd entry
  -
  - 4th entry
  - Null
', -1));
?>
--EXPECT--
array(3) {
  [0]=>
  NULL
  [1]=>
  array(4) {
    ["empty"]=>
    NULL
    ["canonical"]=>
    NULL
    ["english"]=>
    NULL
    [""]=>
    string(8) "null key"
  }
  [2]=>
  array(1) {
    ["sparse"]=>
    array(5) {
      [0]=>
      NULL
      [1]=>
      string(9) "2nd entry"
      [2]=>
      NULL
      [3]=>
      string(9) "4th entry"
      [4]=>
      NULL
    }
  }
}
tests/bug_parsing_alias.phpt000064400000001254150414241060012253 0ustar00--TEST--
Test PECL strange alias bug
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php

$yaml_code = <<<YAML
basic:
  - &external {value: 22 }
keylevel0:
  keylevel1:
    value: 1
  keylevel1.1:
    keylevel2: &strange
      value: 2
      <<: *external
YAML;
var_dump(yaml_parse($yaml_code));
?>
--EXPECT--
array(2) {
  ["basic"]=>
  array(1) {
    [0]=>
    array(1) {
      ["value"]=>
      int(22)
    }
  }
  ["keylevel0"]=>
  array(2) {
    ["keylevel1"]=>
    array(1) {
      ["value"]=>
      int(1)
    }
    ["keylevel1.1"]=>
    array(1) {
      ["keylevel2"]=>
      array(1) {
        ["value"]=>
        int(2)
      }
    }
  }
}
tests/yaml_parse_spec_str.phpt000064400000000333150414241060012635 0ustar00--TEST--
Yaml 1.1 Spec - str
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('
string: abcd
'));
?>
--EXPECT--
array(1) {
  ["string"]=>
  string(4) "abcd"
}
tests/yaml_parse_spec_merge.phpt000064400000002522150414241060013126 0ustar00--TEST--
Yaml 1.1 Spec - merge
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('
---
- &CENTER { x: 1, "y": 2 }
- &LEFT { x: 0, "y": 2 }
- &BIG { r: 10 }
- &SMALL { r: 1 }

# All the following maps are equal:

- # Explicit keys
  x: 1
  "y": 2
  r: 10
  label: center/big

- # Merge one map
  << : *CENTER
  r: 10
  label: center/big

- # Merge multiple maps
  << : [ *CENTER, *BIG ]
  label: center/big

- # Override
  << : [ *BIG, *LEFT, *SMALL ]
  x: 1
  label: center/big
'));
?>
--EXPECT--
array(8) {
  [0]=>
  array(2) {
    ["x"]=>
    int(1)
    ["y"]=>
    int(2)
  }
  [1]=>
  array(2) {
    ["x"]=>
    int(0)
    ["y"]=>
    int(2)
  }
  [2]=>
  array(1) {
    ["r"]=>
    int(10)
  }
  [3]=>
  array(1) {
    ["r"]=>
    int(1)
  }
  [4]=>
  array(4) {
    ["x"]=>
    int(1)
    ["y"]=>
    int(2)
    ["r"]=>
    int(10)
    ["label"]=>
    string(10) "center/big"
  }
  [5]=>
  array(4) {
    ["x"]=>
    int(1)
    ["y"]=>
    int(2)
    ["r"]=>
    int(10)
    ["label"]=>
    string(10) "center/big"
  }
  [6]=>
  array(4) {
    ["x"]=>
    int(1)
    ["y"]=>
    int(2)
    ["r"]=>
    int(10)
    ["label"]=>
    string(10) "center/big"
  }
  [7]=>
  array(4) {
    ["r"]=>
    int(10)
    ["x"]=>
    int(1)
    ["y"]=>
    int(2)
    ["label"]=>
    string(10) "center/big"
  }
}
tests/yaml_parse_file_001.yaml000064400000001204150414241060012277 0ustar00--- !<tag:clarkevans.com,2002:invoice>
invoice: 34843
date   : 2001-01-23
bill-to: &id001
    given  : Chris
    family : Dumars
    address:
        lines: |
            458 Walkman Dr.
            Suite #292
        city    : Royal Oak
        state   : MI
        postal  : 48046
ship-to: *id001
product:
    - sku         : BL394D
      quantity    : 4
      description : Basketball
      price       : 450.00
    - sku         : BL4438H
      quantity    : 1
      description : Super Hoop
      price       : 2392.00
tax  : 251.42
total: 4443.52
comments:
    Late afternoon is best.
    Backup contact is Nancy
    Billsmer @ 338-4338.
tests/bug_77720.phpt000064400000030513150414241070010126 0ustar00--TEST--
Test PECL bug #77720
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
$key_laughs = <<<YAML
- &a ["lol","lol","lol","lol","lol","lol","lol","lol","lol"]
- ? &b [{*a:1},{*a:1},{*a:1},{*a:1},{*a:1},{*a:1},{*a:1},{*a:1},{*a:}] : "foo"
- ? &c [{*b:1},{*b:1},{*b:1},{*b:1},{*b:1},{*b:1},{*b:1},{*b:1},{*b:}] : "foo"
- ? &d [{*c:1},{*c:1},{*c:1},{*c:1},{*c:1},{*c:1},{*c:1},{*c:1},{*c:}] : "foo"
- ? &e [{*d:1},{*d:1},{*d:1},{*d:1},{*d:1},{*d:1},{*d:1},{*d:1},{*d:}] : "foo"
- ? &f [{*e:1},{*e:1},{*e:1},{*e:1},{*e:1},{*e:1},{*e:1},{*e:1},{*e:}] : "foo"
- ? &g [{*f:1},{*f:1},{*f:1},{*f:1},{*f:1},{*f:1},{*f:1},{*f:1},{*f:}] : "foo"
- ? &h [{*g:1},{*g:1},{*g:1},{*g:1},{*g:1},{*g:1},{*g:1},{*g:1},{*g:}] : "foo"
- ? &i [{*h:1},{*h:1},{*h:1},{*h:1},{*h:1},{*h:1},{*h:1},{*h:1},{*h:}] : "foo"
- ? &j [{*i:1},{*i:1},{*i:1},{*i:1},{*i:1},{*i:1},{*i:1},{*i:1},{*i:}] : "foo"
- ? &k [{*j:1},{*j:1},{*j:1},{*j:1},{*j:1},{*j:1},{*j:1},{*j:1},{*j:}] : "foo"
YAML;
var_dump(yaml_parse($key_laughs));
?>
--EXPECTF--

Warning: yaml_parse(): Illegal offset type array (line 2, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 2, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 2, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 2, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 2, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 2, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 2, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 2, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 2, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 2, column 79) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 3, column 2) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 3, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 3, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 3, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 3, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 3, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 3, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 3, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 3, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 3, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 3, column 79) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 4, column 2) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 4, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 4, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 4, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 4, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 4, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 4, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 4, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 4, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 4, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 4, column 79) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 5, column 2) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 5, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 5, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 5, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 5, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 5, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 5, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 5, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 5, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 5, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 5, column 79) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 6, column 2) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 6, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 6, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 6, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 6, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 6, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 6, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 6, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 6, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 6, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 6, column 79) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 7, column 2) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 7, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 7, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 7, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 7, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 7, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 7, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 7, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 7, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 7, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 7, column 79) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 8, column 2) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 8, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 8, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 8, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 8, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 8, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 8, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 8, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 8, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 8, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 8, column 79) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 9, column 2) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 9, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 9, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 9, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 9, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 9, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 9, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 9, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 9, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 9, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 9, column 79) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 10, column 2) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 10, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 10, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 10, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 10, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 10, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 10, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 10, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 10, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 10, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 10, column 79) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 11, column 2) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 11, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 11, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 11, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 11, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 11, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 11, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 11, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 11, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 11, column 73) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 11, column 79) in %sbug_77720.php on line 15

Warning: yaml_parse(): Illegal offset type array (line 12, column 1) in %sbug_77720.php on line 15
array(11) {
  [0]=>
  array(9) {
    [0]=>
    string(3) "lol"
    [1]=>
    string(3) "lol"
    [2]=>
    string(3) "lol"
    [3]=>
    string(3) "lol"
    [4]=>
    string(3) "lol"
    [5]=>
    string(3) "lol"
    [6]=>
    string(3) "lol"
    [7]=>
    string(3) "lol"
    [8]=>
    string(3) "lol"
  }
  [1]=>
  array(0) {
  }
  [2]=>
  array(0) {
  }
  [3]=>
  array(0) {
  }
  [4]=>
  array(0) {
  }
  [5]=>
  array(0) {
  }
  [6]=>
  array(0) {
  }
  [7]=>
  array(0) {
  }
  [8]=>
  array(0) {
  }
  [9]=>
  array(0) {
  }
  [10]=>
  array(0) {
  }
}
tests/bug_76309.phpt000064400000000516150414241070010130 0ustar00--TEST--
Test PECL bug #76309
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--INI--
serialize_precision=-1
--FILE--
<?php
echo yaml_emit([
  'a' => '1.0',
  'b' => '2.',
  'c' => '3',
  'd' => '.',
  'e' => 1.0,
  'f' => 2.,
  'g' => 3,
] );
?>
--EXPECT--
---
a: "1.0"
b: "2."
c: "3"
d: .
e: 1
f: 2
g: 3
...
tests/bug_69616.phpt000064400000000642150414241070010133 0ustar00--TEST--
Test PECL bug #69616
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--INI--
yaml.decode_php=1
--FILE--
<?php
$yaml_code = <<<YAML
a: !php/object O:0:1
b: !php/object



YAML;

$yaml = yaml_parse($yaml_code);
?>
--EXPECTF--
Notice: yaml_parse(): Failed to unserialize class in %sbug_69616.php on line 10

Notice: yaml_parse(): Failed to unserialize class in %sbug_69616.php on line 10
tests/yaml_parse_008.phpt000064400000004453150414241070011332 0ustar00--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)
tests/yaml_002.phpt000064400000002107150414241070010124 0ustar00--TEST--
yaml - emit -> parse roundtrip with datetime
--SKIPIF--
<?php
if(!extension_loaded('yaml')) die('skip yaml n/a');
if(!class_exists('DateTime')) die('skip DateTime n/a');
?>
--INI--
date.timezone=GMT
yaml.decode_timestamp=2
--FILE--
<?php
$original = array(
  "canonical" => new DateTime("2001-12-15T02:59:43.1Z"),
  "valid iso8601" => new DateTime("2001-12-14t21:59:43.10-05:00"),
  "alternate iso8601" => new DateTime("2001-12-14T21:59:43.10-0500"),
  "space separated" => new DateTime("2001-12-14 21:59:43.10 -5"),
  "no time zone (Z)" => new DateTime("2001-12-15 2:59:43.10"),
  "date (0000:00Z)" => new DateTime("2002-12-14"),
);

$yaml = yaml_emit($original);
var_dump($yaml);
$parsed = yaml_parse($yaml);
var_dump($parsed == $original);
?>
--EXPECT--
string(303) "---
canonical: 2001-12-15T02:59:43.100000+00:00
valid iso8601: 2001-12-14T21:59:43.100000-05:00
alternate iso8601: 2001-12-14T21:59:43.100000-05:00
space separated: 2001-12-14T21:59:43.100000-05:00
no time zone (Z): 2001-12-15T02:59:43.100000+00:00
date (0000:00Z): 2002-12-14T00:00:00.000000+00:00
...
"
bool(true)
tests/bug_74799.phpt000064400000001501150414241100010130 0ustar00--TEST--
Memory leak check
--CREDITS--
Gleb Svitelskiy <gleb.svitelskiy@gmail.com>
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
function tag_callback($value, $tag, $flags) {
    return 'callback value';
}

$base_memory = memory_get_usage();

$yamlString ="---\nkey: !value\n...\n";
$ndocs = null;
yaml_parse($yamlString, 0, $ndocs, ['!value' => 'tag_callback']);
unset($yamlString, $ndocs);

$ndocs = null;
yaml_parse_file(__DIR__.'/bug_74799.yaml', 0, $ndocs, ['!value' => 'tag_callback']);
unset($ndocs);

$array = ['key' => 'value'];
yaml_emit($array);
unset($array);

$array = ['key' => 'value'];
yaml_emit_file(__DIR__.'/bug_74799.tmp', $array);
unset($array);

var_dump($base_memory == memory_get_usage());
?>
--CLEAN--
<?php
unlink(__DIR__.'/bug_74799.tmp');
?>
--EXPECT--
bool(true)
tests/yaml_parse_wiki_YtsBlockMapping_002.phpt000064400000000713150414241100015462 0ustar00--TEST--
Yaml YtsBlockMapping - Multi Element Mapping
--DESCRIPTION--
More than one key/value pair
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('---
red: baron
white: walls
blue: berries
'));
?>
--EXPECT--
array(3) {
  ["red"]=>
  string(5) "baron"
  ["white"]=>
  string(5) "walls"
  ["blue"]=>
  string(7) "berries"
}
tests/yaml_parse_wiki_YtsStrangeKeys_002.phpt000064400000000726150414241110015360 0ustar00--TEST--
Yaml YtsStrangeKeys - Unquoted line noise key
--DESCRIPTION--
Check that unquoted line noise parses as key.
This requires the line noise be tame enough
to pass as an implicit plain key.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('---
-+!@#% : bar baz
'));
?>
--EXPECT--
array(1) {
  ["-+!@#%"]=>
  string(7) "bar baz"
}
tests/yaml_parse_wiki_YtsBlockMapping_004.phpt000064400000000742150414241110015467 0ustar00--TEST--
Yaml YtsBlockMapping - Colons aligned
--DESCRIPTION--
Spaces can come before the ': ' key/value separator.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('---
red   : baron
white : walls
blue  : berries
'));
?>
--EXPECT--
array(3) {
  ["red"]=>
  string(5) "baron"
  ["white"]=>
  string(5) "walls"
  ["blue"]=>
  string(7) "berries"
}
tests/yaml_parse_spec_int.phpt000064400000000756150414241120012625 0ustar00--TEST--
Yaml 1.1 Spec - int
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('
canonical: 685230
decimal: +685_230
octal: 02472256
hexadecimal: 0x_0A_74_AE
binary: 0b1010_0111_0100_1010_1110
sexagesimal: 190:20:30
'));
?>
--EXPECT--
array(6) {
  ["canonical"]=>
  int(685230)
  ["decimal"]=>
  int(685230)
  ["octal"]=>
  int(685230)
  ["hexadecimal"]=>
  int(685230)
  ["binary"]=>
  int(685230)
  ["sexagesimal"]=>
  int(685230)
}
tests/yaml_emit_008.phpt000064400000002720150414241120011145 0ustar00--TEST--
yaml_emit - custom tags
--SKIPIF--
<?php
if(!extension_loaded('yaml')) die('skip yaml n/a');
?>
--FILE--
<?php
class Emit008Example {
  public $data;    // data may be in any pecl/yaml suitable type

  /**
   * Yaml emit callback function, referred on yaml_emit call by class name.
   *
   * Expected to return an array with 2 values:
   *   - 'tag': custom tag for this serialization
   *   - 'data': value to convert to yaml (array, string, bool, number)
   *
   * @return array
   */
  public static function yamlEmit (Emit008Example $obj) {
    return array(
      'tag' => '!emit008',
      'data' => $obj->data,
    );
  }
}

$emit_callbacks = array(
  'Emit008Example' => array('Emit008Example', 'yamlEmit')
);

$t = new Emit008Example();
$t->data = array ('a','b','c');
$yaml = yaml_emit(
  array(
    'callback' => $t,
  ),
  YAML_ANY_ENCODING,
  YAML_ANY_BREAK,
  $emit_callbacks
);
var_dump($yaml);

/* make sure you can undo the custome serialization */
function parse_008 ($value, $tag, $flags) {
  $ret = new Emit008Example();
  $ret->data = $value;
  return $ret;
}
$parse_callbacks = array(
  '!emit008' => 'parse_008',
);
$array = yaml_parse($yaml, 0, $cnt, $parse_callbacks);
var_dump($array['callback'] == $t);

/* roundtrip with raw object */
var_dump($t == yaml_parse(
  yaml_emit($t, YAML_ANY_ENCODING, YAML_ANY_BREAK, $emit_callbacks),
  0, $cnt, $parse_callbacks));
?>
--EXPECT--
string(39) "---
callback: !emit008
- a
- b
- c
...
"
bool(true)
bool(true)
tests/yaml_emit_003.phpt000064400000003172150414241130011143 0ustar00--TEST--
yaml_emit - mappings
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--INI--
serialize_precision=-1
--FILE--
<?php
$addr = array(
    "given" => "Chris",
    "family"=> "Dumars",
    "address"=> array(
        "lines"=> "458 Walkman Dr.
        Suite #292",
        "city"=> "Royal Oak",
        "state"=> "MI",
        "postal"=> 48046,
      ),
  );
$invoice = array (
    "invoice"=> 34843,
    "date"=> 980208000,
    "bill-to"=> $addr,
    "ship-to"=> $addr,
    "product"=> array(
        array(
            "sku"=> "BL394D",
            "quantity"=> 4,
            "description"=> "Basketball",
            "price"=> 450,
          ),
        array(
            "sku"=> "BL4438H",
            "quantity"=> 1,
            "description"=> "Super Hoop",
            "price"=> 2392,
          ),
      ),
    "tax"=> 251.42,
    "total"=> 4443.52,
    "comments"=> "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.",
  );
var_dump(yaml_emit($invoice));
?>
--EXPECT--
string(620) "---
invoice: 34843
date: 980208000
bill-to:
  given: Chris
  family: Dumars
  address:
    lines: |-
      458 Walkman Dr.
              Suite #292
    city: Royal Oak
    state: MI
    postal: 48046
ship-to:
  given: Chris
  family: Dumars
  address:
    lines: |-
      458 Walkman Dr.
              Suite #292
    city: Royal Oak
    state: MI
    postal: 48046
product:
- sku: BL394D
  quantity: 4
  description: Basketball
  price: 450
- sku: BL4438H
  quantity: 1
  description: Super Hoop
  price: 2392
tax: 251.42
total: 4443.52
comments: Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.
...
"
tests/yaml_emit_001.phpt000064400000004341150414241130011140 0ustar00--TEST--
yaml_emit - scalars
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--INI--
serialize_precision=-1
--FILE--
<?php
var_dump(yaml_emit(null));
var_dump(yaml_emit(true));
var_dump(yaml_emit(false));
var_dump(yaml_emit(10));
var_dump(yaml_emit(-10));
var_dump(yaml_emit(123.456));
var_dump(yaml_emit(-123.456));
var_dump(yaml_emit("yes"));
var_dump(yaml_emit("no"));
var_dump(yaml_emit("~"));
var_dump(yaml_emit("-"));
var_dump(yaml_emit("'"));
var_dump(yaml_emit('"'));
var_dump(yaml_emit("I\\xF1t\\xEBrn\\xE2ti\\xF4n\\xE0liz\\xE6ti\\xF8n"));
var_dump(yaml_emit("# looks like a comment"));
var_dump(yaml_emit("@looks_like_a_ref"));
var_dump(yaml_emit("&looks_like_a_alias"));
var_dump(yaml_emit("!!str"));
var_dump(yaml_emit("%TAG ! tag:looks.like.one,999:"));
var_dump(yaml_emit("!something"));
var_dump(yaml_emit("Hello world!"));
var_dump(yaml_emit("This is a string with\nan embedded newline."));
$str = <<<EOD
This string was made with a here doc.

It contains embedded newlines.
  		It also has some embedded tabs.

Here are some symbols:
`~!@#$%^&*()_-+={}[]|\:";'<>,.?/

These are extended characters: Iñtërnâtiônàlizætiøn


EOD;
var_dump(yaml_emit($str));
?>
--EXPECT--
string(10) "--- ~
...
"
string(13) "--- true
...
"
string(14) "--- false
...
"
string(11) "--- 10
...
"
string(12) "--- -10
...
"
string(16) "--- 123.456
...
"
string(17) "--- -123.456
...
"
string(14) "--- "yes"
...
"
string(13) "--- "no"
...
"
string(12) "--- "~"
...
"
string(12) "--- '-'
...
"
string(13) "--- ''''
...
"
string(12) "--- '"'
...
"
string(50) "--- I\xF1t\xEBrn\xE2ti\xF4n\xE0liz\xE6ti\xF8n
...
"
string(33) "--- '# looks like a comment'
...
"
string(28) "--- '@looks_like_a_ref'
...
"
string(30) "--- '&looks_like_a_alias'
...
"
string(16) "--- '!!str'
...
"
string(41) "--- '%TAG ! tag:looks.like.one,999:'
...
"
string(21) "--- '!something'
...
"
string(21) "--- Hello world!
...
"
string(58) "--- |-
  This is a string with
  an embedded newline.
...
"
string(267) "--- "This string was made with a here doc.\n\nIt contains embedded newlines.\n  \t\tIt
  also has some embedded tabs.\n\nHere are some symbols:\n`~!@#$%^&*()_-+={}[]|\\:\";'<>,.?/\n\nThese
  are extended characters: I\xF1t\xEBrn\xE2ti\xF4n\xE0liz\xE6ti\xF8n\n\n"
...
"
tests/yaml_parse_wiki_YtsBasicTests_005.phpt000064400000001124150414241140015164 0ustar00--TEST--
Yaml YtsBasicTests - Simple Mapping
--DESCRIPTION--
You can add a keyed list "also known as a dictionary or
hash" to your document by placing each member of the
list on a new line, with a colon seperating the key
from its value.  In YAML, this type of list is called
a mapping.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('foo: whatever
bar: stuff
'));
?>
--EXPECT--
array(2) {
  ["foo"]=>
  string(8) "whatever"
  ["bar"]=>
  string(5) "stuff"
}
tests/yaml_parse_004.phpt000064400000000727150414241140011324 0ustar00--TEST--
yaml_parse - syck bug #11585
--CREDITS--
From syck bug #11585
http://pecl.php.net/bugs/bug.php?id=11585
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('---
define: &pointer_to_define
   - 1
   - 2
   - 3
reference: *broken_pointer_to_define
'));
?>
--EXPECTF--
Warning: yaml_parse(): alias broken_pointer_to_define is not registered (line 6, column 37) in %syaml_parse_004.php on line %d
bool(false)
tests/yaml_parse_wiki_YtsBasicTests_003.phpt000064400000001137150414241150015167 0ustar00--TEST--
Yaml YtsBasicTests - Mixed Sequences
--DESCRIPTION--
Sequences can contain any YAML data,
including strings and other sequences.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
  var_dump(yaml_parse('- apple
-
 - foo
 - bar
 - x123
- banana
- carrot
'));
?>
--EXPECT--
array(4) {
  [0]=>
  string(5) "apple"
  [1]=>
  array(3) {
    [0]=>
    string(3) "foo"
    [1]=>
    string(3) "bar"
    [2]=>
    string(4) "x123"
  }
  [2]=>
  string(6) "banana"
  [3]=>
  string(6) "carrot"
}
tests/yaml_emit_002.phpt000064400000003644150414241150011150 0ustar00--TEST--
yaml_emit - sequences
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--INI--
serialize_precision=-1
--FILE--
<?php
$str = <<<EOD
This string was made with a here doc.

It contains embedded newlines.
  		It also has some embedded tabs.

Here are some symbols:
`~!@#$%^&*()_-+={}[]|\:";'<>,.?/

These are extended characters: Iñtërnâtiônàlizætiøn


EOD;
$doc = array(
    null,
    true,
    false,
    10,
    -10,
    123.456,
    -123.456,
    "yes",
    "no",
    "~",
    "-",
    "'",
    '"',
    "I\\xF1t\\xEBrn\\xE2ti\\xF4n\\xE0liz\\xE6ti\\xF8n",
    "# looks like a comment",
    "@looks_like_a_ref",
    "&looks_like_a_alias",
    "!!str",
    "%TAG ! tag:looks.like.one,999:",
    "!something",
    "Hello world!",
    "This is a string with\nan embedded newline.",
    $str,
  );
echo  "=== Array of scalars ===\n";
var_dump(yaml_emit($doc));

echo  "=== Nested ===\n";
var_dump(yaml_emit(array(
    "top level",
    array(
        "in array",
      ),
    array(
        "in array",
        array(
            "in array",
          ),
      ),
)));

echo  "=== Degenerate ===\n";
var_dump(yaml_emit(array()));

?>
--EXPECT--
=== Array of scalars ===
string(604) "---
- ~
- true
- false
- 10
- -10
- 123.456
- -123.456
- "yes"
- "no"
- "~"
- '-'
- ''''
- '"'
- I\xF1t\xEBrn\xE2ti\xF4n\xE0liz\xE6ti\xF8n
- '# looks like a comment'
- '@looks_like_a_ref'
- '&looks_like_a_alias'
- '!!str'
- '%TAG ! tag:looks.like.one,999:'
- '!something'
- Hello world!
- |-
  This is a string with
  an embedded newline.
- "This string was made with a here doc.\n\nIt contains embedded newlines.\n  \t\tIt
  also has some embedded tabs.\n\nHere are some symbols:\n`~!@#$%^&*()_-+={}[]|\\:\";'<>,.?/\n\nThese
  are extended characters: I\xF1t\xEBrn\xE2ti\xF4n\xE0liz\xE6ti\xF8n\n\n"
...
"
=== Nested ===
string(61) "---
- top level
- - in array
- - in array
  - - in array
...
"
=== Degenerate ===
string(11) "--- []
...
"