Development

#2622: spyc.patch

You must first sign up to be able to contribute.

Ticket #2622: spyc.patch

File spyc.patch, 4.8 kB (added by b166er, 1 year ago)

patch with isset check

  • Spyc.class.php

    old new  
    11<?php 
    2   /**  
     2  /** 
    33   * Spyc -- A Simple PHP YAML Class 
    44   * @version 0.2.3 -- 2006-02-04 
    55   * @author Chris Wanstrath <chris@ozmm.org> 
     
    99   * @package Spyc 
    1010   */ 
    1111 
    12 /**  
     12/** 
    1313 * A node, used by Spyc for parsing YAML. 
    1414 * @package Spyc 
    1515 */ 
     
    5353  /** 
    5454   * Load YAML into a PHP array statically 
    5555   * 
    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 
    5858   * simple. 
    59    *  Usage:  
     59   *  Usage: 
    6060   *  <code> 
    6161   *   $array = Spyc::YAMLLoad('lucky.yml'); 
    6262   *   print_r($array); 
     
    8080   * save the returned string as nothing.yml and pass it around. 
    8181   * 
    8282   * 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 
    8484   * you want to use the default. 
    8585   * 
    8686   * Indent's default is 2 spaces, wordwrap's default is 40 characters.  And 
     
    8888   * 
    8989   * @return string 
    9090   * @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 
    9292   * @param int $wordwrap Pass in 0 for no wordwrap, false for default (40) 
    9393   */ 
    9494  public static function YAMLDump($array, $indent = false, $wordwrap = false) 
     
    101101  /** 
    102102   * Load YAML into a PHP array from an instantiated object 
    103103   * 
    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), 
    105105   * will do its best to convert the YAML into a PHP array.  Pretty simple. 
    106    *  Usage:  
     106   *  Usage: 
    107107   *  <code> 
    108108   *   $parser = new Spyc; 
    109109   *   $array  = $parser->load('lucky.yml'); 
     
    196196            // we drop our indent. 
    197197            $parent =& $this->_allNodes[$node->parent]; 
    198198            $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
    200200            { 
    201201              $chk = $parent->data[key($parent->data)]; 
    202202              if ($chk === '>') 
     
    258258          $this->_indentSort[$node->indent][] =& $this->_allNodes[$node->id]; 
    259259          // Add a reference to the node in a References array if this node 
    260260          // has a YAML reference in it. 
    261           if (  
     261          if ( 
    262262             ((is_array($node->data)) && 
    263263              isset($node->data[key($node->data)]) && 
    264264              (!is_array($node->data[key($node->data)]))) 
    265265            && 
    266266             ((preg_match('/^&([^ ]+)/', $node->data[key($node->data)])) 
    267               ||  
     267              || 
    268268              (preg_match('/^\*([^ ]+)/', $node->data[key($node->data)]))) 
    269269          ) 
    270270          { 
     
    307307   * save the returned string as tasteful.yml and pass it around. 
    308308   * 
    309309   * 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 
    311311   * you want to use the default. 
    312312   * 
    313313   * Indent's default is 2 spaces, wordwrap's default is 40 characters.  And 
     
    315315   * 
    316316   * @return string 
    317317   * @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 
    319319   * @param int $wordwrap Pass in 0 for no wordwrap, false for default (40) 
    320320   */ 
    321321   public function dump($array, $indent = false, $wordwrap = false) 
     
    470470   * Creates a literal block for dumping 
    471471   * 
    472472   * @return string 
    473    * @param $value  
     473   * @param $value 
    474474   * @param $indent int The value of the indent 
    475    */  
     475   */ 
    476476   protected function _doLiteralBlock($value, $indent) 
    477477   { 
    478478    $exploded = explode("\n", $value); 
     
    831831            $this->_linkRef($node, $key); 
    832832          } 
    833833        } 
    834       }  
     834      } 
    835835    } 
    836836 
    837837    return true; 
     
    918918      $key = key($node->data); 
    919919      $key = empty($key) ? 0 : $key; 
    920920      // 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])) 
    922922      { 
    923923        $node->data[$key] = $this->_array_kmerge($node->data[$key], $childs); 
    924924      }