Ticket #2622: spyc.patch
| File spyc.patch, 4.8 kB (added by b166er, 1 year ago) |
|---|
-
Spyc.class.php
old new 1 1 <?php 2 /** 2 /** 3 3 * Spyc -- A Simple PHP YAML Class 4 4 * @version 0.2.3 -- 2006-02-04 5 5 * @author Chris Wanstrath <chris@ozmm.org> … … 9 9 * @package Spyc 10 10 */ 11 11 12 /** 12 /** 13 13 * A node, used by Spyc for parsing YAML. 14 14 * @package Spyc 15 15 */ … … 53 53 /** 54 54 * Load YAML into a PHP array statically 55 55 * 56 * The load method, when supplied with a YAML stream (string or file), 57 * will do its best to convert YAML in a file into a PHP array. Pretty 56 * The load method, when supplied with a YAML stream (string or file), 57 * will do its best to convert YAML in a file into a PHP array. Pretty 58 58 * simple. 59 * Usage: 59 * Usage: 60 60 * <code> 61 61 * $array = Spyc::YAMLLoad('lucky.yml'); 62 62 * print_r($array); … … 80 80 * save the returned string as nothing.yml and pass it around. 81 81 * 82 82 * Oh, and you can decide how big the indent is and what the wordwrap 83 * for folding is. Pretty cool -- just pass in 'false' for either if 83 * for folding is. Pretty cool -- just pass in 'false' for either if 84 84 * you want to use the default. 85 85 * 86 86 * Indent's default is 2 spaces, wordwrap's default is 40 characters. And … … 88 88 * 89 89 * @return string 90 90 * @param array $array PHP array 91 * @param int $indent Pass in false to use the default, which is 2 91 * @param int $indent Pass in false to use the default, which is 2 92 92 * @param int $wordwrap Pass in 0 for no wordwrap, false for default (40) 93 93 */ 94 94 public static function YAMLDump($array, $indent = false, $wordwrap = false) … … 101 101 /** 102 102 * Load YAML into a PHP array from an instantiated object 103 103 * 104 * The load method, when supplied with a YAML stream (string or file path), 104 * The load method, when supplied with a YAML stream (string or file path), 105 105 * will do its best to convert the YAML into a PHP array. Pretty simple. 106 * Usage: 106 * Usage: 107 107 * <code> 108 108 * $parser = new Spyc; 109 109 * $array = $parser->load('lucky.yml'); … … 196 196 // we drop our indent. 197 197 $parent =& $this->_allNodes[$node->parent]; 198 198 $this->_allNodes[$node->parent]->children = true; 199 if (is_array($parent->data) )199 if (is_array($parent->data) && isset($parent->data[key($parent->data)])===true) 200 200 { 201 201 $chk = $parent->data[key($parent->data)]; 202 202 if ($chk === '>') … … 258 258 $this->_indentSort[$node->indent][] =& $this->_allNodes[$node->id]; 259 259 // Add a reference to the node in a References array if this node 260 260 // has a YAML reference in it. 261 if ( 261 if ( 262 262 ((is_array($node->data)) && 263 263 isset($node->data[key($node->data)]) && 264 264 (!is_array($node->data[key($node->data)]))) 265 265 && 266 266 ((preg_match('/^&([^ ]+)/', $node->data[key($node->data)])) 267 || 267 || 268 268 (preg_match('/^\*([^ ]+)/', $node->data[key($node->data)]))) 269 269 ) 270 270 { … … 307 307 * save the returned string as tasteful.yml and pass it around. 308 308 * 309 309 * Oh, and you can decide how big the indent is and what the wordwrap 310 * for folding is. Pretty cool -- just pass in 'false' for either if 310 * for folding is. Pretty cool -- just pass in 'false' for either if 311 311 * you want to use the default. 312 312 * 313 313 * Indent's default is 2 spaces, wordwrap's default is 40 characters. And … … 315 315 * 316 316 * @return string 317 317 * @param array $array PHP array 318 * @param int $indent Pass in false to use the default, which is 2 318 * @param int $indent Pass in false to use the default, which is 2 319 319 * @param int $wordwrap Pass in 0 for no wordwrap, false for default (40) 320 320 */ 321 321 public function dump($array, $indent = false, $wordwrap = false) … … 470 470 * Creates a literal block for dumping 471 471 * 472 472 * @return string 473 * @param $value 473 * @param $value 474 474 * @param $indent int The value of the indent 475 */ 475 */ 476 476 protected function _doLiteralBlock($value, $indent) 477 477 { 478 478 $exploded = explode("\n", $value); … … 831 831 $this->_linkRef($node, $key); 832 832 } 833 833 } 834 } 834 } 835 835 } 836 836 837 837 return true; … … 918 918 $key = key($node->data); 919 919 $key = empty($key) ? 0 : $key; 920 920 // If it's an array, add to it of course 921 if (is _array($node->data[$key]))921 if (isset($node->data[$key])===true && is_array($node->data[$key])) 922 922 { 923 923 $node->data[$key] = $this->_array_kmerge($node->data[$key], $childs); 924 924 }