/**
  * Load YAML from a PHP stream resource.
  *
  * @param  resource  $stream     PHP stream resource
  * @return array                 PHP array representation of YAML content
  */
 public static function loadStream($stream)
 {
     if (!is_resource($stream) || get_resource_type($stream) != 'stream') {
         throw new InvalidArgumentException('Stream must be a stream resource');
     }
     if (is_callable(self::$loadfunc)) {
         return call_user_func(self::$loadfunc, stream_get_contents($stream));
     }
     $loader = new Horde_Yaml_Loader();
     while (!feof($stream)) {
         $loader->parse(stream_get_line($stream, 100000, "\n"));
     }
     return $loader->toArray();
 }
Exemple #2
0
 /**
  * Load YAML from a PHP stream resource.
  *
  * @param  resource  $stream     PHP stream resource
  * @return array                 PHP array representation of YAML content
  */
 function loadStream($stream)
 {
     //if (is_callable($this->$loadfunc)) {
     //    $array = call_user_func($this->$loadfunc, file_get_contents($stream));
     //    return is_array($array) ? $array : array();
     //}
     $loader = new Horde_Yaml_Loader();
     $handle = @fopen($stream, "r");
     if ($handle) {
         while (!feof($handle)) {
             $loader->parse(fgets($handle, 4096));
         }
         fclose($handle);
     }
     return $loader->toArray();
 }