mirror of
				https://github.com/hauke68/Magallanes.git
				synced 2025-11-04 00:50:18 +01:00 
			
		
		
		
	Update SPYC Library.
This commit is contained in:
		
							parent
							
								
									5cc9c02c3e
								
							
						
					
					
						commit
						fc3b7d87a5
					
				@ -1,7 +1,7 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
   * Spyc -- A Simple PHP YAML Class
 | 
			
		||||
   * @version 0.5
 | 
			
		||||
   * @version 0.5.1
 | 
			
		||||
   * @author Vlad Andersen <vlad.andersen@gmail.com>
 | 
			
		||||
   * @author Chris Wanstrath <chris@ozmm.org>
 | 
			
		||||
   * @link http://code.google.com/p/spyc/
 | 
			
		||||
@ -63,7 +63,7 @@ class Spyc {
 | 
			
		||||
  /**
 | 
			
		||||
   * Setting this to true will force YAMLDump to enclose any string value in
 | 
			
		||||
   * quotes.  False by default.
 | 
			
		||||
   * 
 | 
			
		||||
   *
 | 
			
		||||
   * @var bool
 | 
			
		||||
   */
 | 
			
		||||
  public $setting_dump_force_quotes = false;
 | 
			
		||||
@ -143,7 +143,7 @@ class Spyc {
 | 
			
		||||
  /**
 | 
			
		||||
     * Load a string of YAML into a PHP array statically
 | 
			
		||||
     *
 | 
			
		||||
     * The load method, when supplied with a YAML string, will do its best 
 | 
			
		||||
     * The load method, when supplied with a YAML string, will do its best
 | 
			
		||||
     * to convert YAML in a string into a PHP array.  Pretty simple.
 | 
			
		||||
     *
 | 
			
		||||
     * Note: use this function if you don't want files from the file system
 | 
			
		||||
@ -232,7 +232,7 @@ class Spyc {
 | 
			
		||||
 | 
			
		||||
    // Start at the base of the array and move through it.
 | 
			
		||||
    if ($array) {
 | 
			
		||||
      $array = (array)$array; 
 | 
			
		||||
      $array = (array)$array;
 | 
			
		||||
      $previous_key = -1;
 | 
			
		||||
      foreach ($array as $key => $value) {
 | 
			
		||||
        if (!isset($first_key)) $first_key = $key;
 | 
			
		||||
@ -321,7 +321,7 @@ class Spyc {
 | 
			
		||||
    if (is_bool($value)) {
 | 
			
		||||
       $value = ($value) ? "true" : "false";
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    if ($value === null) $value = 'null';
 | 
			
		||||
    if ($value === "'" . self::REMPTY . "'") $value = null;
 | 
			
		||||
 | 
			
		||||
@ -413,7 +413,7 @@ class Spyc {
 | 
			
		||||
    $cnt = count($Source);
 | 
			
		||||
    for ($i = 0; $i < $cnt; $i++) {
 | 
			
		||||
      $line = $Source[$i];
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      $this->indent = strlen($line) - strlen(ltrim($line));
 | 
			
		||||
      $tempPath = $this->getParentPathByIndent($this->indent);
 | 
			
		||||
      $line = self::stripIndent($line, $this->indent);
 | 
			
		||||
@ -433,18 +433,16 @@ class Spyc {
 | 
			
		||||
        $i--;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      // Strip out comments
 | 
			
		||||
      if (strpos ($line, '#')) {
 | 
			
		||||
          $line = preg_replace('/\s*#([^"\']+)$/','',$line);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      while (++$i < $cnt && self::greedilyNeedNextLine($line)) {
 | 
			
		||||
        $line = rtrim ($line, " \n\t\r") . ' ' . ltrim ($Source[$i], " \t");
 | 
			
		||||
      }
 | 
			
		||||
      $i--;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
      if (strpos ($line, '#')) {
 | 
			
		||||
        if (strpos ($line, '"') === false && strpos ($line, "'") === false)
 | 
			
		||||
          $line = preg_replace('/\s+#(.+)$/','',$line);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      $lineArray = $this->_parseLine($line);
 | 
			
		||||
 | 
			
		||||
      if ($literalBlockStyle)
 | 
			
		||||
@ -505,9 +503,9 @@ class Spyc {
 | 
			
		||||
     return $this->returnArrayElement($line);
 | 
			
		||||
 | 
			
		||||
    if ($this->isPlainArray($line))
 | 
			
		||||
     return $this->returnPlainArray($line); 
 | 
			
		||||
     
 | 
			
		||||
     
 | 
			
		||||
     return $this->returnPlainArray($line);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    return $this->returnKeyValuePair($line);
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
@ -533,7 +531,7 @@ class Spyc {
 | 
			
		||||
 | 
			
		||||
    if ($is_quoted)
 | 
			
		||||
      return strtr(substr ($value, 1, -1), array ('\\"' => '"', '\'\'' => '\'', '\\\'' => '\''));
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    if (strpos($value, ' #') !== false && !$is_quoted)
 | 
			
		||||
      $value = preg_replace('/\s+#(.+)$/','',$value);
 | 
			
		||||
 | 
			
		||||
@ -560,7 +558,7 @@ class Spyc {
 | 
			
		||||
      $value = $this->_toType($value);
 | 
			
		||||
      return array($key => $value);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    if ($first_character == '{' && $last_character == '}') {
 | 
			
		||||
      $innerValue = trim(substr ($value, 1, -1));
 | 
			
		||||
      if ($innerValue === '') return array();
 | 
			
		||||
@ -607,7 +605,7 @@ class Spyc {
 | 
			
		||||
        $value = (float)$value;
 | 
			
		||||
      return $value;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    return $value;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -653,7 +651,8 @@ class Spyc {
 | 
			
		||||
 | 
			
		||||
    } while (strpos ($inline, '[') !== false || strpos ($inline, '{') !== false);
 | 
			
		||||
 | 
			
		||||
    $explode = explode(', ',$inline);
 | 
			
		||||
    $explode = explode(',',$inline);
 | 
			
		||||
    $explode = array_map('trim', $explode);
 | 
			
		||||
    $stringi = 0; $i = 0;
 | 
			
		||||
 | 
			
		||||
    while (1) {
 | 
			
		||||
@ -710,7 +709,7 @@ class Spyc {
 | 
			
		||||
    if ($finished) break;
 | 
			
		||||
 | 
			
		||||
    $i++;
 | 
			
		||||
    if ($i > 10) 
 | 
			
		||||
    if ($i > 10)
 | 
			
		||||
      break; // Prevent infinite loops.
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -738,7 +737,7 @@ class Spyc {
 | 
			
		||||
  private function addArrayInline ($array, $indent) {
 | 
			
		||||
      $CommonGroupPath = $this->path;
 | 
			
		||||
      if (empty ($array)) return false;
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      foreach ($array as $k => $_) {
 | 
			
		||||
        $this->addArray(array($k => $_), $indent);
 | 
			
		||||
        $this->path = $CommonGroupPath;
 | 
			
		||||
@ -752,7 +751,7 @@ class Spyc {
 | 
			
		||||
 | 
			
		||||
    if (count ($incoming_data) > 1)
 | 
			
		||||
      return $this->addArrayInline ($incoming_data, $incoming_indent);
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    $key = key ($incoming_data);
 | 
			
		||||
    $value = isset($incoming_data[$key]) ? $incoming_data[$key] : null;
 | 
			
		||||
    if ($key === '__!YAMLZero') $key = '0';
 | 
			
		||||
@ -768,7 +767,7 @@ class Spyc {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    $history = array();
 | 
			
		||||
    // Unfolding inner array tree.
 | 
			
		||||
    $history[] = $_arr = $this->result;
 | 
			
		||||
@ -915,7 +914,7 @@ class Spyc {
 | 
			
		||||
    if ($line[0] != '-') return false;
 | 
			
		||||
    if (strlen ($line) > 3)
 | 
			
		||||
      if (substr($line,0,3) == '---') return false;
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    return true;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -960,14 +959,14 @@ class Spyc {
 | 
			
		||||
  private function startsMappedValue ($line) {
 | 
			
		||||
    return (substr ($line, -1, 1) == ':');
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  private function isPlainArray ($line) {
 | 
			
		||||
    return ($line[0] == '[' && substr ($line, -1, 1) == ']');
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  private function returnPlainArray ($line) {
 | 
			
		||||
    return $this->_toType($line); 
 | 
			
		||||
  }  
 | 
			
		||||
    return $this->_toType($line);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private function returnKeyValuePair ($line) {
 | 
			
		||||
    $array = array();
 | 
			
		||||
@ -1007,7 +1006,7 @@ class Spyc {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  private function nodeContainsGroup ($line) {    
 | 
			
		||||
  private function nodeContainsGroup ($line) {
 | 
			
		||||
    $symbolsForReference = 'A-z0-9_\-';
 | 
			
		||||
    if (strpos($line, '&') === false && strpos($line, '*') === false) return false; // Please die fast ;-)
 | 
			
		||||
    if ($line[0] == '&' && preg_match('/^(&['.$symbolsForReference.']+)/', $line, $matches)) return $matches[1];
 | 
			
		||||
@ -1032,15 +1031,15 @@ class Spyc {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Enable use of Spyc from command line
 | 
			
		||||
// The syntax is the following: php spyc.php spyc.yaml
 | 
			
		||||
// The syntax is the following: php Spyc.php spyc.yaml
 | 
			
		||||
 | 
			
		||||
define ('SPYC_FROM_COMMAND_LINE', false);
 | 
			
		||||
 | 
			
		||||
do {
 | 
			
		||||
  if (!SPYC_FROM_COMMAND_LINE) break;
 | 
			
		||||
  if (empty ($_SERVER['argc']) || $_SERVER['argc'] < 2) break;
 | 
			
		||||
  if (empty ($_SERVER['PHP_SELF']) || $_SERVER['PHP_SELF'] != 'spyc.php') break;
 | 
			
		||||
  if (empty ($_SERVER['PHP_SELF']) || $_SERVER['PHP_SELF'] != 'Spyc.php') break;
 | 
			
		||||
  $file = $argv[1];
 | 
			
		||||
  printf ("Spyc loading file: %s\n", $file);
 | 
			
		||||
  print_r (spyc_load_file ($file));
 | 
			
		||||
} while (0);
 | 
			
		||||
} while (0);
 | 
			
		||||
							
								
								
									
										2
									
								
								bin/mage
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								bin/mage
									
									
									
									
									
								
							@ -17,7 +17,7 @@ define('MAGALLANES_VERSION', '1.0.0');
 | 
			
		||||
define('MAGALLANES_DIRECTORY', $baseDir);
 | 
			
		||||
 | 
			
		||||
// Preload
 | 
			
		||||
require_once $baseDir . '/Mage/spyc.php';
 | 
			
		||||
require_once $baseDir . '/Mage/Spyc.php';
 | 
			
		||||
require_once $baseDir . '/Mage/Autoload.php';
 | 
			
		||||
spl_autoload_register(array('Mage\\Autoload', 'autoload'));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user