diff --git a/module/VuFind/src/VuFind/Config/SearchSpecsReader.php b/module/VuFind/src/VuFind/Config/SearchSpecsReader.php index b388d6a8c6372ba72df46358bf3d78bb08f57cce..16a52dd48828e4a39b6de6bf4a5616ef30d815af 100644 --- a/module/VuFind/src/VuFind/Config/SearchSpecsReader.php +++ b/module/VuFind/src/VuFind/Config/SearchSpecsReader.php @@ -26,7 +26,7 @@ * @link http://vufind.org Main Site */ namespace VuFind\Config; -use Horde_Yaml as Yaml, Zend\ServiceManager\ServiceLocatorAwareInterface, +use Symfony\Component\Yaml\Yaml, Zend\ServiceManager\ServiceLocatorAwareInterface, Zend\ServiceManager\ServiceLocatorInterface; /** @@ -83,9 +83,9 @@ class SearchSpecsReader implements ServiceLocatorAwareInterface // Generate data if not found in cache: if (!$cache || !($results = $cache->getItem($key))) { - $results = Yaml::load(file_get_contents($fullpath)); + $results = Yaml::parse($fullpath); if (!empty($local)) { - $localResults = Yaml::load(file_get_contents($local)); + $localResults = Yaml::parse($local); foreach ($localResults as $key => $value) { $results[$key] = $value; } diff --git a/vendor/Horde/Exception.php b/vendor/Horde/Exception.php deleted file mode 100644 index c0271ad4c1b8fe8e434871890f8d91a30ec7ad90..0000000000000000000000000000000000000000 --- a/vendor/Horde/Exception.php +++ /dev/null @@ -1,89 +0,0 @@ -<?php -if (version_compare(PHP_VERSION, '5.3.0', '<')) { - /** - * Horde base exception class that supports prior exception for PHP < 5.3.0 - * - * Originates from - * http://framework.zend.com/wiki/display/ZFPROP/previous+Exception+on+Zend_Exception+-+Marc+Bennewitz - * - * Copyright 2008-2011 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Horde - * @package Exception - */ - class Horde_Exception extends Exception - { - private $_previous = null; - - /** - * Error details that should not be part of the main exception message, - * e.g. any additional debugging information. - * - * @var string - */ - public $details; - - /** - * Construct the exception - * - * @param string $msg - * @param int $code - * @param Exception $previous - */ - public function __construct($msg = '', $code = 0, Exception $previous = null) - { - parent::__construct($msg, $code); - $this->_previous = $previous; - } - - /** - * Returns previous Exception - * - * @return Exception|null - */ - final public function getPrevious() - { - return $this->_previous; - } - - /** - * String representation of the exception - * - * @return string - */ - public function __toString() - { - if ($this->getPrevious()) { - return $this->getPrevious()->__toString() . "\n\nNext " . parent::__toString(); - } else { - return parent::__toString(); - } - } - - } -} else { - /** - * Horde base exception class. - * - * Copyright 2008-2011 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Horde - * @package Exception - */ - class Horde_Exception extends Exception - { - /** - * Error details that should not be part of the main exception message, - * e.g. any additional debugging information. - * - * @var string - */ - public $details; - } -} diff --git a/vendor/Horde/Exception/LastError.php b/vendor/Horde/Exception/LastError.php deleted file mode 100644 index 39b1546ffa9b9cae7a359fcb9426b5bd4187894a..0000000000000000000000000000000000000000 --- a/vendor/Horde/Exception/LastError.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php -/** - * Horde exception class that accepts output of error_get_last() as $code and - * mask itself as that error. - * - * Copyright 2008-2011 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Horde - * @package Exception - */ -class Horde_Exception_LastError extends Horde_Exception -{ - /** - * Exception constructor - * - * If $lasterror is passed the return value of error_get_last() (or a - * matching format), the exception will be rewritten to have its file and - * line parameters match that of the array, and any message in the array - * will be appended to $message. - * - * @param mixed $message The exception message, a PEAR_Error - * object, or an Exception object. - * @param mixed $code_or_lasterror Either a numeric error code, or - * an array from error_get_last(). - */ - public function __construct($message = null, $code_or_lasterror = null) - { - if (is_array($code_or_lasterror)) { - if ($message) { - $message .= $code_or_lasterror['message']; - } else { - $message = $code_or_lasterror['message']; - } - parent::__construct($message, $code_or_lasterror['type']); - $this->file = $code_or_lasterror['file']; - $this->line = $code_or_lasterror['line']; - } else { - parent::__construct($message, $code_or_lasterror); - } - } - -} diff --git a/vendor/Horde/Exception/NotFound.php b/vendor/Horde/Exception/NotFound.php deleted file mode 100644 index ff6b00588af843cbb7012f8c8cefde739637b6a7..0000000000000000000000000000000000000000 --- a/vendor/Horde/Exception/NotFound.php +++ /dev/null @@ -1,31 +0,0 @@ -<?php -/** - * Exception thrown if an object wasn't found. - * - * Copyright 2010-2011 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Horde - * @package Exception - */ -class Horde_Exception_NotFound extends Horde_Exception -{ - /** - * Constructor. - * - * @see Horde_Exception::__construct() - * - * @param mixed $message The exception message, a PEAR_Error - * object, or an Exception object. - * @param integer $code A numeric error code. - */ - public function __construct($message = null, $code = null) - { - if (is_null($message)) { - $message = Horde_Exception_Translation::t("Not Found"); - } - parent::__construct($message, $code); - } -} \ No newline at end of file diff --git a/vendor/Horde/Exception/Pear.php b/vendor/Horde/Exception/Pear.php deleted file mode 100644 index 0c6c121d8af08294bd4b75064925c476daeaa25a..0000000000000000000000000000000000000000 --- a/vendor/Horde/Exception/Pear.php +++ /dev/null @@ -1,87 +0,0 @@ -<?php -/** - * Horde exception class that converts PEAR errors to exceptions. - * - * Copyright 2008-2011 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Horde - * @package Exception - */ -class Horde_Exception_Pear extends Horde_Exception -{ - /** - * The class name for generated exceptions. - * - * @var string - */ - static protected $_class = __CLASS__; - - /** - * The original PEAR error. - * - * @var PEAR_Error - */ - private $_error; - - /** - * Exception constructor. - * - * @param PEAR_Error $error The PEAR error. - */ - public function __construct(PEAR_Error $error) - { - parent::__construct( - $error->getMessage() . $this->_getPearTrace($error), - $error->getCode() - ); - if ($details = $error->getUserInfo()) { - $this->details = $details; - } - } - - /** - * Return a trace for the PEAR error. - * - * @param PEAR_Error $error The PEAR error. - * - * @return string The backtrace as a string. - */ - private function _getPearTrace(PEAR_Error $error) - { - $backtrace = $error->getBacktrace(); - if (!empty($backtrace)) { - $pear_error = "\n\n" . 'PEAR Error:' . "\n"; - foreach ($backtrace as $frame) { - $pear_error .= ' ' - . (isset($frame['class']) ? $frame['class'] : '') - . (isset($frame['type']) ? $frame['type'] : '') - . (isset($frame['function']) ? $frame['function'] : 'unkown') . ' ' - . (isset($frame['file']) ? $frame['file'] : 'unkown') . ':' - . (isset($frame['line']) ? $frame['line'] : 'unkown') . "\n"; - } - $pear_error .= "\n"; - return $pear_error; - } - return ''; - } - - /** - * Exception handling. - * - * @param mixed $result The result to be checked for a PEAR_Error. - * - * @return mixed Returns the original result if it was no PEAR_Error. - * - * @throws Horde_Exception_Pear In case the result was a PEAR_Error. - */ - static public function catchError($result) - { - if ($result instanceOf PEAR_Error) { - throw new self::$_class($result); - } - return $result; - } -} diff --git a/vendor/Horde/Exception/PermissionDenied.php b/vendor/Horde/Exception/PermissionDenied.php deleted file mode 100644 index 943c7cc3f5bec6f5713b815920c09f2b77e85be8..0000000000000000000000000000000000000000 --- a/vendor/Horde/Exception/PermissionDenied.php +++ /dev/null @@ -1,31 +0,0 @@ -<?php -/** - * Exception thrown if any access without sufficient permissions occured. - * - * Copyright 2010-2011 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Horde - * @package Exception - */ -class Horde_Exception_PermissionDenied extends Horde_Exception -{ - /** - * Constructor. - * - * @see Horde_Exception::__construct() - * - * @param mixed $message The exception message, a PEAR_Error - * object, or an Exception object. - * @param integer $code A numeric error code. - */ - public function __construct($message = null, $code = null) - { - if (is_null($message)) { - $message = Horde_Exception_Translation::t("Permission Denied"); - } - parent::__construct($message, $code); - } -} \ No newline at end of file diff --git a/vendor/Horde/Exception/Translation.php b/vendor/Horde/Exception/Translation.php deleted file mode 100644 index ca98f3a24ea35a57eb27813c60cda43a4308486c..0000000000000000000000000000000000000000 --- a/vendor/Horde/Exception/Translation.php +++ /dev/null @@ -1,50 +0,0 @@ -<?php -/** - * @package Exception - * - * Copyright 2010-2011 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - */ - -/** - * Horde_Exception_Translation is the translation wrapper class for Horde_Exception. - * - * @author Jan Schneider <jan@horde.org> - * @package Exception - */ -class Horde_Exception_Translation extends Horde_Translation -{ - /** - * Returns the translation of a message. - * - * @var string $message The string to translate. - * - * @return string The string translation, or the original string if no - * translation exists. - */ - static public function t($message) - { - self::$_domain = 'Horde_Exception'; - self::$_directory = '/usr/share/php/data' == '@'.'data_dir'.'@' ? dirname(__FILE__) . '/../../../locale' : '/usr/share/php/data/Horde_Exception/locale'; - return parent::t($message); - } - - /** - * Returns the plural translation of a message. - * - * @param string $singular The singular version to translate. - * @param string $plural The plural version to translate. - * @param integer $number The number that determines singular vs. plural. - * - * @return string The string translation, or the original string if no - * translation exists. - */ - static public function ngettext($singular, $plural, $number) - { - self::$_domain = 'Horde_Exception'; - self::$_directory = '/usr/share/php/data' == '@'.'data_dir'.'@' ? dirname(__FILE__) . '/../../../locale' : '/usr/share/php/data/Horde_Exception/locale'; - return parent::ngettext($singular, $plural, $number); - } -} diff --git a/vendor/Horde/Exception/Wrapped.php b/vendor/Horde/Exception/Wrapped.php deleted file mode 100644 index 173498d714148d57a32d68b667e68d8e0be59c0d..0000000000000000000000000000000000000000 --- a/vendor/Horde/Exception/Wrapped.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php -/** - * Horde exception class that can wrap and set its details from PEAR_Error, - * Exception, and other objects with similar interfaces. - * - * Copyright 2008-2011 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Horde - * @package Exception - */ -class Horde_Exception_Wrapped extends Horde_Exception -{ - /** - * Exception constructor. - * - * @param mixed $message The exception message, a PEAR_Error - * object, or an Exception object. - * @param int $code A numeric error code. - */ - public function __construct($message = null, $code = 0) - { - $previous = null; - if (is_object($message) && - method_exists($message, 'getMessage')) { - if (empty($code) && - method_exists($message, 'getCode')) { - $code = $message->getCode(); - } - if ($message instanceof Exception) { - $previous = $message; - } - if (method_exists($message, 'getUserinfo') && - $details = $message->getUserinfo()) { - $this->details = $details; - } - $message = $message->getMessage(); - } - - parent::__construct($message, $code, $previous); - } -} diff --git a/vendor/Horde/Translation.php b/vendor/Horde/Translation.php deleted file mode 100644 index 9eda63472b53b2bf4cb134258c040b5a79910326..0000000000000000000000000000000000000000 --- a/vendor/Horde/Translation.php +++ /dev/null @@ -1,111 +0,0 @@ -<?php -/** - * @package Translation - * - * Copyright 2010-2011 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - */ - -/** - * Horde_Translation is the base class for any translation wrapper classes in - * libraries that want to utilize the Horde_Translation library for - * translations. - * - * @author Jan Schneider <jan@horde.org> - * @package Translation - */ -abstract class Horde_Translation -{ - /** - * The translation domain, e.g. the library name, for the default gettext - * handler. - * - * @var string - */ - static protected $_domain; - - /** - * The relative path to the translations for the default gettext handler. - * - * This path is relative to the - * - * @var string - */ - static protected $_directory; - - /** - * The handlers providing the actual translations. - * - * @var array - */ - static protected $_handlers = array(); - - /** - * Loads a translation handler class pointing to the library's translations - * and assigns it to $_handler. - * - * @param string $handlerClass The name of a class implementing the - * Horde_Translation_Handler interface. - */ - static public function loadHandler($handlerClass) - { - if (!self::$_domain || !self::$_directory) { - throw new Horde_Translation_Exception('The domain and directory properties must be set by the class that extends Horde_Translation.'); - } - self::setHandler(self::$_domain, new $handlerClass(self::$_domain, self::$_directory)); - } - - /** - * Assigns a translation handler object to $_handlers. - * - * Type hinting isn't used on purpose. You should extend a custom - * translation handler passed here from the Horde_Translation interface, - * but technically it's sufficient if you provide the API of that - * interface. - * - * @param string $domain The translation domain. - * @param Horde_Translation_Handler $handler An object implementing the - * Horde_Translation_Handler - * interface. - */ - static public function setHandler($domain, $handler) - { - self::$_handlers[$domain] = $handler; - } - - /** - * Returns the translation of a message. - * - * @var string $message The string to translate. - * - * @return string The string translation, or the original string if no - * translation exists. - */ - static public function t($message) - { - if (!isset(self::$_handlers[self::$_domain])) { - self::loadHandler('Horde_Translation_Handler_Gettext'); - } - return self::$_handlers[self::$_domain]->t($message); - } - - /** - * Returns the plural translation of a message. - * - * @param string $singular The singular version to translate. - * @param string $plural The plural version to translate. - * @param integer $number The number that determines singular vs. plural. - * - * @return string The string translation, or the original string if no - * translation exists. - */ - static public function ngettext($singular, $plural, $number) - { - if (!isset(self::$_handlers[self::$_domain])) { - self::loadHandler('Horde_Translation_Handler_Gettext'); - } - return self::$_handlers[self::$_domain]->ngettext($singular, $plural, $number); - } -} diff --git a/vendor/Horde/Translation/Exception.php b/vendor/Horde/Translation/Exception.php deleted file mode 100644 index 1e89cfaaf6a38511d8a6093e47794f760888fe98..0000000000000000000000000000000000000000 --- a/vendor/Horde/Translation/Exception.php +++ /dev/null @@ -1,15 +0,0 @@ -<?php -/** - * Exception class for Horde_Translation. - * - * Copyright 2010-2011 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @author Jan Schneider <jan@horde.org> - * @package Translation - */ -class Horde_Translation_Exception extends Horde_Exception_Wrapped -{ -} diff --git a/vendor/Horde/Translation/Handler.php b/vendor/Horde/Translation/Handler.php deleted file mode 100644 index 3f87df6497acf9e83bb3235e2fc910622a47734a..0000000000000000000000000000000000000000 --- a/vendor/Horde/Translation/Handler.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php -/** - * @package Translation - * - * Copyright 2010-2011 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - */ - -/** - * The Horde_Translation_Handler interface defines the interface for any - * classes providing translations. - * - * @author Jan Schneider <jan@horde.org> - * @package Translation - */ -interface Horde_Translation_Handler -{ - /** - * Returns the translation of a message. - * - * @var string $message The string to translate. - * - * @return string The string translation, or the original string if no - * translation exists. - */ - public function t($message); - - /** - * Returns the plural translation of a message. - * - * @param string $singular The singular version to translate. - * @param string $plural The plural version to translate. - * @param integer $number The number that determines singular vs. plural. - * - * @return string The string translation, or the original string if no - * translation exists. - */ - public function ngettext($singular, $plural, $number); -} diff --git a/vendor/Horde/Translation/Handler/Gettext.php b/vendor/Horde/Translation/Handler/Gettext.php deleted file mode 100644 index 73dc181698921d0584ce5eb6b3bfafb838df523d..0000000000000000000000000000000000000000 --- a/vendor/Horde/Translation/Handler/Gettext.php +++ /dev/null @@ -1,82 +0,0 @@ -<?php -/** - * @package Translation - * - * Copyright 2010-2011 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - */ - -/** - * The Horde_Translation_Handler_Gettext provides translations through the - * gettext extension, but fails gracefully if gettext is not installed. - * - * @author Jan Schneider <jan@horde.org> - * @package Translation - */ -class Horde_Translation_Handler_Gettext implements Horde_Translation_Handler -{ - /** - * The translation domain, e.g. package name. - * - * @var string - */ - protected $_domain; - - /** - * Whether the gettext extension is installed. - * - * @var boolean - */ - protected $_gettext; - - /** - * Constructor. - * - * @param string $domain The translation domain, e.g. package name. - * @param string $path The path to the gettext catalog. - */ - public function __construct($domain, $path) - { - if (!is_dir($path)) { - throw new InvalidArgumentException("$path is not a directory"); - } - $this->_gettext = function_exists('_'); - if (!$this->_gettext) { - return; - } - $this->_domain = $domain; - bindtextdomain($this->_domain, $path); - } - - /** - * Returns the translation of a message. - * - * @param string $message The string to translate. - * - * @return string The string translation, or the original string if no - * translation exists. - */ - public function t($message) - { - return $this->_gettext ? dgettext($this->_domain, $message) : $message; - } - - /** - * Returns the plural translation of a message. - * - * @param string $singular The singular version to translate. - * @param string $plural The plural version to translate. - * @param integer $number The number that determines singular vs. plural. - * - * @return string The string translation, or the original string if no - * translation exists. - */ - public function ngettext($singular, $plural, $number) - { - return $this->_gettext - ? dngettext($this->_domain, $singular, $plural, $number) - : ($number > 1 ? $plural : $singular); - } -} diff --git a/vendor/Horde/Yaml.php b/vendor/Horde/Yaml.php deleted file mode 100644 index 7a740221c915f00b1c514f215c779049ea040ccd..0000000000000000000000000000000000000000 --- a/vendor/Horde/Yaml.php +++ /dev/null @@ -1,158 +0,0 @@ -<?php -/** - * Horde YAML package - * - * This package is heavily inspired by the Spyc PHP YAML - * implementation (http://spyc.sourceforge.net/), and portions are - * copyright 2005-2006 Chris Wanstrath. - * - * @author Chris Wanstrath <chris@ozmm.org> - * @author Chuck Hagenbuch <chuck@horde.org> - * @author Mike Naberezny <mike@maintainable.com> - * @license http://opensource.org/licenses/bsd-license.php BSD - * @category Horde - * @package Yaml - */ - -/** - * Horde YAML parser. - * - * This class can be used to read a YAML file and convert its contents - * into a PHP array. The native PHP parser supports a limited - * subsection of the YAML spec, but if the syck extension is present, - * that will be used for parsing. - * - * @category Horde - * @package Yaml - */ -class Horde_Yaml -{ - /** - * Callback used for alternate YAML loader, typically exported - * by a faster PHP extension. This function's first argument - * must accept a string with YAML content. - * - * @var callback - */ - public static $loadfunc = 'syck_load'; - - /** - * Callback used for alternate YAML dumper, typically exported - * by a faster PHP extension. This function's first argument - * must accept a mixed variable to be dumped. - * - * @var callback - */ - public static $dumpfunc = 'syck_dump'; - - /** - * Whitelist of classes that can be instantiated automatically - * when loading YAML docs that include serialized PHP objects. - * - * @var array - */ - public static $allowedClasses = array('ArrayObject'); - - /** - * Load a string containing YAML and parse it into a PHP array. - * Returns an empty array on failure. - * - * @param string $yaml String containing YAML - * @return array PHP array representation of YAML content - */ - public static function load($yaml) - { - if (!is_string($yaml) || !strlen($yaml)) { - $msg = 'YAML to parse must be a string and cannot be empty.'; - throw new InvalidArgumentException($msg); - } - - if (is_callable(self::$loadfunc)) { - return call_user_func(self::$loadfunc, $yaml); - return is_array($array) ? $array : array(); - } - - if (strpos($yaml, "\r") !== false) { - $yaml = str_replace(array("\r\n", "\r"), array("\n", "\n"), $yaml); - } - $lines = explode("\n", $yaml); - $loader = new Horde_Yaml_Loader; - - while (list(,$line) = each($lines)) { - $loader->parse($line); - } - - return $loader->toArray(); - } - - /** - * Load a file containing YAML and parse it into a PHP array. - * - * If the file cannot be opened, an exception is thrown. If the - * file is read but parsing fails, an empty array is returned. - * - * @param string $filename Filename to load - * @return array PHP array representation of YAML content - * @throws IllegalArgumentException If $filename is invalid - * @throws Horde_Yaml_Exception If the file cannot be opened. - */ - public static function loadFile($filename) - { - if (!is_string($filename) || !strlen($filename)) { - $msg = 'Filename must be a string and cannot be empty'; - throw new InvalidArgumentException($msg); - } - - $stream = @fopen($filename, 'rb'); - if (!$stream) { - throw new Horde_Yaml_Exception('Failed to open file: ', error_get_last()); - } - - return self::loadStream($stream); - } - - /** - * 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(); - } - - /** - * Dump a PHP array to YAML. - * - * The dump method, when supplied with an array, will do its best - * to convert the array into friendly YAML. - * - * @param array|Traversable $array PHP array or traversable object - * @param integer $options Options to pass to dumper - * @return string YAML representation of $value - */ - public static function dump($value, $options = array()) - { - if (is_callable(self::$dumpfunc)) { - return call_user_func(self::$dumpfunc, $value); - } - - $dumper = new Horde_Yaml_Dumper(); - return $dumper->dump($value, $options); - } - -} diff --git a/vendor/Horde/Yaml/Dumper.php b/vendor/Horde/Yaml/Dumper.php deleted file mode 100644 index 2e9ea4efa97d0205e153d6241887054ac8cd5800..0000000000000000000000000000000000000000 --- a/vendor/Horde/Yaml/Dumper.php +++ /dev/null @@ -1,216 +0,0 @@ -<?php -/** - * Horde YAML package - * - * This package is heavily inspired by the Spyc PHP YAML - * implementation (http://spyc.sourceforge.net/), and portions are - * copyright 2005-2006 Chris Wanstrath. - * - * @author Chris Wanstrath <chris@ozmm.org> - * @author Chuck Hagenbuch <chuck@horde.org> - * @author Mike Naberezny <mike@maintainable.com> - * @license http://opensource.org/licenses/bsd-license.php BSD - * @category Horde - * @package Yaml - */ - -/** - * Dump PHP data structures to YAML. - * - * @category Horde - * @package Yaml - */ -class Horde_Yaml_Dumper -{ - protected $_options = array(); - - /** - * Dump PHP array to YAML - * - * The dump method, when supplied with an array, will do its best - * to convert the array into valid YAML. - * - * Options: - * `indent`: - * number of spaces to indent children (default 2) - * `wordwrap`: - * wordwrap column number (default 40) - * - * @param array|Traversable $array PHP array or traversable object - * @param integer $options Options for dumping - * @return string YAML representation of $value - */ - public function dump($value, $options = array()) - { - // validate & merge default options - if (!is_array($options)) { - throw new InvalidArgumentException('Options must be an array'); - } - - $defaults = array('indent' => 2, - 'wordwrap' => 40); - $this->_options = array_merge($defaults, $options); - - if (! is_int($this->_options['indent'])) { - throw new InvalidArgumentException('Indent must be an integer'); - } - - if (! is_int($this->_options['wordwrap'])) { - throw new InvalidArgumentException('Wordwrap column must be an integer'); - } - - // new YAML document - $dump = "---\n"; - - // iterate through array and yamlize it - foreach ($value as $key => $value) { - $dump .= $this->_yamlize($key, $value, 0); - } - return $dump; - } - - /** - * Attempts to convert a key / value array item to YAML - * - * @param string $key The name of the key - * @param string|array $value The value of the item - * @param integer $indent The indent of the current node - * @return string - */ - protected function _yamlize($key, $value, $indent) - { - if ($value instanceof Serializable) { - // Dump serializable objects as !php/object::classname serialize_data - $data = '!php/object::' . get_class($value) . ' ' . $value->serialize(); - $string = $this->_dumpNode($key, $data, $indent); - } elseif (is_array($value) || $value instanceof Traversable) { - // It has children. Make it the right kind of item. - $string = $this->_dumpNode($key, null, $indent); - - // Add the indent. - $indent += $this->_options['indent']; - - // Yamlize the array. - $string .= $this->_yamlizeArray($value, $indent); - } elseif (!is_array($value)) { - // No children. - $string = $this->_dumpNode($key, $value, $indent); - } - - return $string; - } - - /** - * Attempts to convert an array to YAML - * - * @param array $array The array you want to convert - * @param integer $indent The indent of the current level - * @return string - */ - protected function _yamlizeArray($array, $indent) - { - if (!is_array($array)) { - return false; - } - - $string = ''; - foreach ($array as $key => $value) { - $string .= $this->_yamlize($key, $value, $indent); - } - return $string; - } - - /** - * Returns YAML from a key and a value - * - * @param string $key The name of the key - * @param string $value The value of the item - * @param integer $indent The indent of the current node - * @return string - */ - protected function _dumpNode($key, $value, $indent) - { - $literal = false; - // Do some folding here, for blocks. - if (strpos($value, "\n") !== false - || strpos($value, ': ') !== false - || strpos($value, '- ') !== false) { - $value = $this->_doLiteralBlock($value, $indent); - $literal = true; - } else { - $value = $this->_fold($value, $indent); - } - - if (is_bool($value)) { - $value = ($value) ? 'true' : 'false'; - } elseif (is_float($value)) { - if (is_nan($value)) { - $value = '.NAN'; - } elseif ($value === INF) { - $value = '.INF'; - } elseif ($value === -INF) { - $value = '-.INF'; - } - } - - $spaces = str_repeat(' ', $indent); - - // Quote strings if necessary, and not folded - if (!$literal && strpos($value, "\n") === false && strchr($value, '#')) { - $value = "'{$value}'"; - } - - if (is_int($key)) { - // It's a sequence. - $string = $spaces . '- ' . $value . "\n"; - } else { - // It's mapped. - $string = $spaces . $key . ': ' . $value . "\n"; - } - - return $string; - } - - /** - * Creates a literal block for dumping - * - * @param string $value - * @param integer $indent The value of the indent. - * @return string - */ - protected function _doLiteralBlock($value, $indent) - { - $exploded = explode("\n", $value); - $newValue = '|'; - $indent += $this->_options['indent']; - $spaces = str_repeat(' ', $indent); - foreach ($exploded as $line) { - $newValue .= "\n" . $spaces . trim($line); - } - return $newValue; - } - - /** - * Folds a string of text, if necessary - * - * @param $value The string you wish to fold - * @return string - */ - protected function _fold($value, $indent) - { - // Don't do anything if wordwrap is set to 0 - if (! $this->_options['wordwrap']) { - return $value; - } - - if (strlen($value) > $this->_options['wordwrap']) { - $indent += $this->_options['indent']; - $indent = str_repeat(' ', $indent); - $wrapped = wordwrap($value, $this->_options['wordwrap'], "\n$indent"); - $value = ">\n" . $indent . $wrapped; - } - - return $value; - } - -} diff --git a/vendor/Horde/Yaml/Exception.php b/vendor/Horde/Yaml/Exception.php deleted file mode 100644 index 40ba711fce9241acfd85c3273e479c81e9cecf82..0000000000000000000000000000000000000000 --- a/vendor/Horde/Yaml/Exception.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php -/** - * Horde YAML package - * - * This package is heavily inspired by the Spyc PHP YAML - * implementation (http://spyc.sourceforge.net/), and portions are - * copyright 2005-2006 Chris Wanstrath. - * - * @author Chris Wanstrath <chris@ozmm.org> - * @author Chuck Hagenbuch <chuck@horde.org> - * @author Mike Naberezny <mike@maintainable.com> - * @license http://opensource.org/licenses/bsd-license.php BSD - * @category Horde - * @package Yaml - */ - -/** - * Exception class for exceptions thrown by Horde_Yaml - * - * @category Horde - * @package Yaml - */ -class Horde_Yaml_Exception extends Horde_Exception_LastError -{ -} diff --git a/vendor/Horde/Yaml/Loader.php b/vendor/Horde/Yaml/Loader.php deleted file mode 100644 index 08160f64789c84db41adc13f5e13fa28a41a345e..0000000000000000000000000000000000000000 --- a/vendor/Horde/Yaml/Loader.php +++ /dev/null @@ -1,751 +0,0 @@ -<?php -/** - * Horde YAML package - * - * This package is heavily inspired by the Spyc PHP YAML - * implementation (http://spyc.sourceforge.net/), and portions are - * copyright 2005-2006 Chris Wanstrath. - * - * @author Chris Wanstrath <chris@ozmm.org> - * @author Chuck Hagenbuch <chuck@horde.org> - * @author Mike Naberezny <mike@maintainable.com> - * @license http://opensource.org/licenses/bsd-license.php BSD - * @category Horde - * @package Yaml - */ - -/** - * Parse YAML strings into PHP data structures - * - * @category Horde - * @package Yaml - */ -class Horde_Yaml_Loader -{ - /** - * List of nodes with references - * @var array - */ - protected $_haveRefs = array(); - - /** - * All nodes - * @var array - */ - protected $_allNodes = array(); - - /** - * Array of node parents - * @var array - */ - protected $_allParent = array(); - - /** - * Last indent level - * @var integer - */ - protected $_lastIndent = 0; - - /** - * Last node id - * @var integer - */ - protected $_lastNode = null; - - /** - * Is the parser inside a block? - * @var boolean - */ - protected $_inBlock = false; - - /** - * @var boolean - */ - protected $_isInline = false; - - /** - * Next node id to use - * @var integer - */ - protected $_nodeId = 1; - - /** - * Last line number parsed. - * @var integer - */ - protected $_lineNumber = 0; - - /** - * Create a new YAML parser. - */ - public function __construct() - { - $base = new Horde_Yaml_Node($this->_nodeId++); - $base->indent = 0; - $this->_lastNode = $base->id; - } - - /** - * Return the PHP built from all YAML parsed so far. - * - * @return array PHP version of parsed YAML - */ - public function toArray() - { - // Here we travel through node-space and pick out references - // (& and *). - $this->_linkReferences(); - - // Build the PHP array out of node-space. - return $this->_buildArray(); - } - - /** - * Parse a line of a YAML file. - * - * @param string $line The line of YAML to parse. - * @return Horde_Yaml_Node YAML Node - */ - public function parse($line) - { - // Keep track of how many lines we've parsed for friendlier - // error messages. - ++$this->_lineNumber; - - $trimmed = trim($line); - - // If the line starts with a tab (instead of a space), throw a fit. - if (preg_match('/^ *(\t) *[^\t ]/', $line)) { - $msg = "Line {$this->_lineNumber} indent contains a tab. " - . 'YAML only allows spaces for indentation.'; - throw new Horde_Yaml_Exception($msg); - } - - if (!$this->_inBlock && empty($trimmed)) { - return; - } elseif ($this->_inBlock && empty($trimmed)) { - $last =& $this->_allNodes[$this->_lastNode]; - $last->data[key($last->data)] .= "\n"; - } elseif ($trimmed[0] != '#' && substr($trimmed, 0, 3) != '---') { - // Create a new node and get its indent - $node = new Horde_Yaml_Node($this->_nodeId++); - $node->indent = $this->_getIndent($line); - - // Check where the node lies in the hierarchy - if ($this->_lastIndent == $node->indent) { - // If we're in a block, add the text to the parent's data - if ($this->_inBlock) { - $parent =& $this->_allNodes[$this->_lastNode]; - $parent->data[key($parent->data)] .= trim($line) . $this->_blockEnd; - } else { - // The current node's parent is the same as the previous node's - if (isset($this->_allNodes[$this->_lastNode])) { - $node->parent = $this->_allNodes[$this->_lastNode]->parent; - } - } - } elseif ($this->_lastIndent < $node->indent) { - if ($this->_inBlock) { - $parent =& $this->_allNodes[$this->_lastNode]; - $parent->data[key($parent->data)] .= trim($line) . $this->_blockEnd; - } elseif (!$this->_inBlock) { - // The current node's parent is the previous node - $node->parent = $this->_lastNode; - - // If the value of the last node's data was > or | - // we need to start blocking i.e. taking in all - // lines as a text value until we drop our indent. - $parent =& $this->_allNodes[$node->parent]; - $this->_allNodes[$node->parent]->children = true; - if (is_array($parent->data)) { - if (isset($parent->data[key($parent->data)])) { - $chk = $parent->data[key($parent->data)]; - if ($chk === '>') { - $this->_inBlock = true; - $this->_blockEnd = ''; - $parent->data[key($parent->data)] = - str_replace('>', '', $parent->data[key($parent->data)]); - $parent->data[key($parent->data)] .= trim($line) . ' '; - $this->_allNodes[$node->parent]->children = false; - $this->_lastIndent = $node->indent; - } elseif ($chk === '|') { - $this->_inBlock = true; - $this->_blockEnd = "\n"; - $parent->data[key($parent->data)] = - str_replace('|', '', $parent->data[key($parent->data)]); - $parent->data[key($parent->data)] .= trim($line) . "\n"; - $this->_allNodes[$node->parent]->children = false; - $this->_lastIndent = $node->indent; - } - } - } - } - } elseif ($this->_lastIndent > $node->indent) { - // Any block we had going is dead now - if ($this->_inBlock) { - $this->_inBlock = false; - if ($this->_blockEnd == "\n") { - $last =& $this->_allNodes[$this->_lastNode]; - $last->data[key($last->data)] = - trim($last->data[key($last->data)]); - } - } - - // We don't know the parent of the node so we have to - // find it - foreach ($this->_indentSort[$node->indent] as $n) { - if ($n->indent == $node->indent) { - $node->parent = $n->parent; - } - } - } - - if (!$this->_inBlock) { - // Set these properties with information from our - // current node - $this->_lastIndent = $node->indent; - - // Set the last node - $this->_lastNode = $node->id; - - // Parse the YAML line and return its data - $node->data = $this->_parseLine($line); - - // Add the node to the master list - $this->_allNodes[$node->id] = $node; - - // Add a reference to the parent list - $this->_allParent[intval($node->parent)][] = $node->id; - - // Add a reference to the node in an indent array - $this->_indentSort[$node->indent][] =& $this->_allNodes[$node->id]; - - // Add a reference to the node in a References array - // if this node has a YAML reference in it. - $is_array = is_array($node->data); - $key = key($node->data); - $isset = isset($node->data[$key]); - if ($isset) { - $nodeval = $node->data[$key]; - } - if (($is_array && $isset && !is_array($nodeval) && !is_object($nodeval)) - && (strlen($nodeval) && ($nodeval[0] == '&' || $nodeval[0] == '*') && $nodeval[1] != ' ')) { - $this->_haveRefs[] =& $this->_allNodes[$node->id]; - } elseif ($is_array && $isset && is_array($nodeval)) { - // Incomplete reference making code. Needs to be - // cleaned up. - foreach ($node->data[$key] as $d) { - if (!is_array($d) && strlen($d) && (($d[0] == '&' || $d[0] == '*') && $d[1] != ' ')) { - $this->_haveRefs[] =& $this->_allNodes[$node->id]; - } - } - } - } - } - } - - /** - * Finds and returns the indentation of a YAML line - * - * @param string $line A line from the YAML file - * @return int Indentation level - */ - protected function _getIndent($line) - { - if (preg_match('/^\s+/', $line, $match)) { - return strlen($match[0]); - } else { - return 0; - } - } - - /** - * Parses YAML code and returns an array for a node - * - * @param string $line A line from the YAML file - * @return array - */ - protected function _parseLine($line) - { - $array = array(); - - $line = trim($line); - if (preg_match('/^-(.*):$/', $line)) { - // It's a mapped sequence - $key = trim(substr(substr($line, 1), 0, -1)); - $array[$key] = ''; - } elseif ($line[0] == '-' && substr($line, 0, 3) != '---') { - // It's a list item but not a new stream - if (strlen($line) > 1) { - // Set the type of the value. Int, string, etc - $array[] = $this->_toType(trim(substr($line, 1))); - } else { - $array[] = array(); - } - } elseif (preg_match('/^(.+):/', $line, $key)) { - // It's a key/value pair most likely - // If the key is in double quotes pull it out - if (preg_match('/^(["\'](.*)["\'](\s)*:)/', $line, $matches)) { - $value = trim(str_replace($matches[1], '', $line)); - $key = $matches[2]; - } else { - // Do some guesswork as to the key and the value - $explode = explode(':', $line); - $key = trim(array_shift($explode)); - $value = trim(implode(':', $explode)); - } - - // Set the type of the value. Int, string, etc - $value = $this->_toType($value); - if (empty($key)) { - $array[] = $value; - } else { - $array[$key] = $value; - } - } - - return $array; - } - - /** - * Finds the type of the passed value, returns the value as the new type. - * - * @param string $value - * @return mixed - */ - protected function _toType($value) - { - // Check for PHP specials - self::_unserialize($value); - if (!is_scalar($value)) { - return $value; - } - - // Used in a lot of cases. - $lower_value = strtolower($value); - - if (preg_match('/^("(.*)"|\'(.*)\')/', $value, $matches)) { - $value = (string)str_replace(array('\'\'', '\\\''), "'", end($matches)); - $value = str_replace('\\"', '"', $value); - } elseif (preg_match('/^\\[(\s*)\\]$/', $value)) { - // empty inline mapping - $value = array(); - } elseif (preg_match('/^\\[(.+)\\]$/', $value, $matches)) { - // Inline Sequence - - // Take out strings sequences and mappings - $explode = $this->_inlineEscape($matches[1]); - - // Propogate value array - $value = array(); - foreach ($explode as $v) { - $value[] = $this->_toType($v); - } - } elseif (preg_match('/^\\{(\s*)\\}$/', $value)) { - // empty inline mapping - $value = array(); - } elseif (strpos($value, ': ') !== false && !preg_match('/^{(.+)/', $value)) { - // inline mapping - $array = explode(': ', $value); - $key = trim($array[0]); - array_shift($array); - $value = trim(implode(': ', $array)); - $value = $this->_toType($value); - $value = array($key => $value); - } elseif (preg_match("/{(.+)}$/", $value, $matches)) { - // Inline Mapping - - // Take out strings sequences and mappings - $explode = $this->_inlineEscape($matches[1]); - - // Propogate value array - $array = array(); - foreach ($explode as $v) { - $array = $array + $this->_toType($v); - } - $value = $array; - } elseif ($lower_value == 'null' || $value == '' || $value == '~') { - $value = null; - } elseif ($lower_value == '.nan') { - $value = NAN; - } elseif ($lower_value == '.inf') { - $value = INF; - } elseif ($lower_value == '-.inf') { - $value = -INF; - } elseif (ctype_digit($value)) { - $value = (int)$value; - } elseif (in_array($lower_value, - array('true', 'on', '+', 'yes', 'y'))) { - $value = true; - } elseif (in_array($lower_value, - array('false', 'off', '-', 'no', 'n'))) { - $value = false; - } elseif (is_numeric($value)) { - $value = (float)$value; - } else { - // Just a normal string, right? - if (($pos = strpos($value, '#')) !== false) { - $value = substr($value, 0, $pos); - } - $value = trim($value); - } - - return $value; - } - - /** - * Handle PHP serialized data. - * - * @param string &$data Data to check for serialized PHP types. - */ - protected function _unserialize(&$data) - { - if (substr($data, 0, 5) != '!php/') { - return; - } - - $first_space = strpos($data, ' '); - $type = substr($data, 5, $first_space - 5); - $class = null; - if (strpos($type, '::') !== false) { - list($type, $class) = explode('::', $type); - - if (!in_array($class, Horde_Yaml::$allowedClasses)) { - throw new Horde_Yaml_Exception("$class is not in the list of allowed classes"); - } - } - - switch ($type) { - case 'object': - if (!class_exists($class)) { - throw new Horde_Yaml_Exception("$class is not defined"); - } - - $reflector = new ReflectionClass($class); - if (!$reflector->implementsInterface('Serializable')) { - throw new Horde_Yaml_Exception("$class does not implement Serializable"); - } - - $class_data = substr($data, $first_space + 1); - $serialized = 'C:' . strlen($class) . ':"' . $class . '":' . strlen($class_data) . ':{' . $class_data . '}'; - $data = unserialize($serialized); - break; - - case 'array': - case 'hash': - $array_data = substr($data, $first_space + 1); - $array_data = Horde_Yaml::load('a: ' . $array_data); - - if (is_null($class)) { - $data = $array_data['a']; - } else { - if (!class_exists($class)) { - throw new Horde_Yaml_Exception("$class is not defined"); - } - - $array = new $class; - if (!$array instanceof ArrayAccess) { - throw new Horde_Yaml_Exception("$class does not implement ArrayAccess"); - } - - foreach ($array_data['a'] as $key => $val) { - $array[$key] = $val; - } - - $data = $array; - } - break; - } - } - - /** - * Used in inlines to check for more inlines or quoted strings - * - * @todo There should be a cleaner way to do this. While - * pure sequences seem to be nesting just fine, - * pure mappings and mappings with sequences inside - * can't go very deep. This needs to be fixed. - * - * @param string $inline Inline data - * @return array - */ - protected function _inlineEscape($inline) - { - $saved_strings = array(); - - // Check for strings - $regex = '/(?:(")|(?:\'))((?(1)[^"]+|[^\']+))(?(1)"|\')/'; - if (preg_match_all($regex, $inline, $strings)) { - $saved_strings = $strings[0]; - $inline = preg_replace($regex, 'YAMLString', $inline); - } - - // Check for sequences - if (preg_match_all('/\[(.+)\]/U', $inline, $seqs)) { - $inline = preg_replace('/\[(.+)\]/U', 'YAMLSeq', $inline); - $seqs = $seqs[0]; - } - - // Check for mappings - if (preg_match_all('/{(.+)}/U', $inline, $maps)) { - $inline = preg_replace('/{(.+)}/U', 'YAMLMap', $inline); - $maps = $maps[0]; - } - - $explode = explode(', ', $inline); - - // Re-add the sequences - if (!empty($seqs)) { - $i = 0; - foreach ($explode as $key => $value) { - if (strpos($value, 'YAMLSeq') !== false) { - $explode[$key] = str_replace('YAMLSeq', $seqs[$i], $value); - ++$i; - } - } - } - - // Re-add the mappings - if (!empty($maps)) { - $i = 0; - foreach ($explode as $key => $value) { - if (strpos($value, 'YAMLMap') !== false) { - $explode[$key] = str_replace('YAMLMap', $maps[$i], $value); - ++$i; - } - } - } - - // Re-add the strings - if (!empty($saved_strings)) { - $i = 0; - foreach ($explode as $key => $value) { - while (strpos($value, 'YAMLString') !== false) { - $explode[$key] = preg_replace('/YAMLString/', $saved_strings[$i], $value, 1); - ++$i; - $value = $explode[$key]; - } - } - } - - return $explode; - } - - /** - * Builds the PHP array from all the YAML nodes we've gathered - * - * @return array - */ - protected function _buildArray() - { - $trunk = array(); - if (!isset($this->_indentSort[0])) { - return $trunk; - } - - foreach ($this->_indentSort[0] as $n) { - if (empty($n->parent)) { - $this->_nodeArrayizeData($n); - - // Check for references and copy the needed data to complete them. - $this->_makeReferences($n); - - // Merge our data with the big array we're building - $trunk = $this->_array_kmerge($trunk, $n->data); - } - } - - return $trunk; - } - - /** - * Traverses node-space and sets references (& and *) accordingly - * - * @return bool - */ - protected function _linkReferences() - { - if (is_array($this->_haveRefs)) { - foreach ($this->_haveRefs as $node) { - if (!empty($node->data)) { - $key = key($node->data); - // If it's an array, don't check. - if (is_array($node->data[$key])) { - foreach ($node->data[$key] as $k => $v) { - $this->_linkRef($node, $key, $k, $v); - } - } else { - $this->_linkRef($node, $key); - } - } - } - } - - return true; - } - - /** - * Helper for _linkReferences() - * - * @param Horde_Yaml_Node $n Node - * @param string $k Key - * @param mixed $v Value - * @return void - */ - function _linkRef(&$n, $key, $k = null, $v = null) - { - if (empty($k) && empty($v)) { - // Look for &refs - if (preg_match('/^&([^ ]+)/', $n->data[$key], $matches)) { - // Flag the node so we know it's a reference - $this->_allNodes[$n->id]->ref = substr($matches[0], 1); - $this->_allNodes[$n->id]->data[$key] = - substr($n->data[$key], strlen($matches[0]) + 1); - // Look for *refs - } elseif (preg_match('/^\*([^ ]+)/', $n->data[$key], $matches)) { - $ref = substr($matches[0], 1); - // Flag the node as having a reference - $this->_allNodes[$n->id]->refKey = $ref; - } - } elseif (!empty($k) && !empty($v)) { - if (preg_match('/^&([^ ]+)/', $v, $matches)) { - // Flag the node so we know it's a reference - $this->_allNodes[$n->id]->ref = substr($matches[0], 1); - $this->_allNodes[$n->id]->data[$key][$k] = - substr($v, strlen($matches[0]) + 1); - // Look for *refs - } elseif (preg_match('/^\*([^ ]+)/', $v, $matches)) { - $ref = substr($matches[0], 1); - // Flag the node as having a reference - $this->_allNodes[$n->id]->refKey = $ref; - } - } - } - - /** - * Finds the children of a node and aids in the building of the PHP array - * - * @param int $nid The id of the node whose children we're gathering - * @return array - */ - protected function _gatherChildren($nid) - { - $return = array(); - $node =& $this->_allNodes[$nid]; - if (is_array ($this->_allParent[$node->id])) { - foreach ($this->_allParent[$node->id] as $nodeZ) { - $z =& $this->_allNodes[$nodeZ]; - // We found a child - $this->_nodeArrayizeData($z); - - // Check for references - $this->_makeReferences($z); - - // Merge with the big array we're returning, the big - // array being all the data of the children of our - // parent node - $return = $this->_array_kmerge($return, $z->data); - } - } - return $return; - } - - /** - * Turns a node's data and its children's data into a PHP array - * - * @param array $node The node which you want to arrayize - * @return boolean - */ - protected function _nodeArrayizeData(&$node) - { - if ($node->children == true) { - if (is_array($node->data)) { - // This node has children, so we need to find them - $children = $this->_gatherChildren($node->id); - - // We've gathered all our children's data and are ready to use it - $key = key($node->data); - $key = empty($key) ? 0 : $key; - // If it's an array, add to it of course - if (isset($node->data[$key])) { - if (is_array($node->data[$key])) { - $node->data[$key] = $this->_array_kmerge($node->data[$key], $children); - } else { - $node->data[$key] = $children; - } - } else { - $node->data[$key] = $children; - } - } else { - // Same as above, find the children of this node - $children = $this->_gatherChildren($node->id); - $node->data = array(); - $node->data[] = $children; - } - } else { - // The node is a single string. See if we need to unserialize it. - if (is_array($node->data)) { - $key = key($node->data); - $key = empty($key) ? 0 : $key; - - if (!isset($node->data[$key]) || is_array($node->data[$key]) || is_object($node->data[$key])) { - return true; - } - - self::_unserialize($node->data[$key]); - } elseif (is_string($node->data)) { - self::_unserialize($node->data); - } - } - - // We edited $node by reference, so just return true - return true; - } - - /** - * Traverses node-space and copies references to / from this object. - * - * @param Horde_Yaml_Node $z A node whose references we wish to make real - * @return bool - */ - protected function _makeReferences(&$z) - { - // It is a reference - if (isset($z->ref)) { - $key = key($z->data); - // Copy the data to this object for easy retrieval later - $this->ref[$z->ref] =& $z->data[$key]; - // It has a reference - } elseif (isset($z->refKey)) { - if (isset($this->ref[$z->refKey])) { - $key = key($z->data); - // Copy the data from this object to make the node a real reference - $z->data[$key] =& $this->ref[$z->refKey]; - } - } - - return true; - } - - /** - * Merges two arrays, maintaining numeric keys. If two numeric - * keys clash, the second one will be appended to the resulting - * array. If string keys clash, the last one wins. - * - * @param array $arr1 - * @param array $arr2 - * @return array - */ - protected function _array_kmerge($arr1, $arr2) - { - while (list($key, $val) = each($arr2)) { - if (isset($arr1[$key]) && is_int($key)) { - $arr1[] = $val; - } else { - $arr1[$key] = $val; - } - } - - return $arr1; - } - -} diff --git a/vendor/Horde/Yaml/Node.php b/vendor/Horde/Yaml/Node.php deleted file mode 100644 index bc66839307b535781bdb659e2a57584f4b67c444..0000000000000000000000000000000000000000 --- a/vendor/Horde/Yaml/Node.php +++ /dev/null @@ -1,58 +0,0 @@ -<?php -/** - * Horde YAML package - * - * This package is heavily inspired by the Spyc PHP YAML - * implementation (http://spyc.sourceforge.net/), and portions are - * copyright 2005-2006 Chris Wanstrath. - * - * @author Chris Wanstrath <chris@ozmm.org> - * @author Chuck Hagenbuch <chuck@horde.org> - * @author Mike Naberezny <mike@maintainable.com> - * @license http://opensource.org/licenses/bsd-license.php BSD - * @category Horde - * @package Yaml - */ - -/** - * A node, used for parsing YAML. - * - * @category Horde - * @package Yaml - */ -class Horde_Yaml_Node -{ - /** - * @var string - */ - public $parent; - - /** - */ - public $id; - - /** - * @var mixed - */ - public $data; - - /** - * @var integer - */ - public $indent; - - /** - * @var bool - */ - public $children = false; - - /** - * The constructor assigns the node a unique ID. - * @return void - */ - public function __construct($nodeId) - { - $this->id = $nodeId; - } - -} diff --git a/vendor/Symfony/Component/Yaml/.gitattributes b/vendor/Symfony/Component/Yaml/.gitattributes new file mode 100644 index 0000000000000000000000000000000000000000..80481513cff2c5c6cde0c1bff5655bcde5f34976 --- /dev/null +++ b/vendor/Symfony/Component/Yaml/.gitattributes @@ -0,0 +1,2 @@ +/Tests export-ignore +phpunit.xml.dist export-ignore diff --git a/vendor/Symfony/Component/Yaml/CHANGELOG.md b/vendor/Symfony/Component/Yaml/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..096cf654d8058a56bb2bab3e3c1df1224ae25b77 --- /dev/null +++ b/vendor/Symfony/Component/Yaml/CHANGELOG.md @@ -0,0 +1,8 @@ +CHANGELOG +========= + +2.1.0 +----- + + * Yaml::parse() does not evaluate loaded files as PHP files by default + anymore (call Yaml::enablePhpParsing() to get back the old behavior) diff --git a/vendor/Symfony/Component/Yaml/Dumper.php b/vendor/Symfony/Component/Yaml/Dumper.php new file mode 100644 index 0000000000000000000000000000000000000000..220cb39742569d67fcaf8d30165c8c59c4acf9dc --- /dev/null +++ b/vendor/Symfony/Component/Yaml/Dumper.php @@ -0,0 +1,71 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Yaml; + +/** + * Dumper dumps PHP variables to YAML strings. + * + * @author Fabien Potencier <fabien@symfony.com> + */ +class Dumper +{ + /** + * The amount of spaces to use for indentation of nested nodes. + * + * @var integer + */ + protected $indentation = 4; + + /** + * Sets the indentation. + * + * @param integer $num The amount of spaces to use for intendation of nested nodes. + */ + public function setIndentation($num) + { + $this->indentation = (int) $num; + } + + /** + * Dumps a PHP value to YAML. + * + * @param mixed $input The PHP value + * @param integer $inline The level where you switch to inline YAML + * @param integer $indent The level of indentation (used internally) + * + * @return string The YAML representation of the PHP value + */ + public function dump($input, $inline = 0, $indent = 0) + { + $output = ''; + $prefix = $indent ? str_repeat(' ', $indent) : ''; + + if ($inline <= 0 || !is_array($input) || empty($input)) { + $output .= $prefix.Inline::dump($input); + } else { + $isAHash = array_keys($input) !== range(0, count($input) - 1); + + foreach ($input as $key => $value) { + $willBeInlined = $inline - 1 <= 0 || !is_array($value) || empty($value); + + $output .= sprintf('%s%s%s%s', + $prefix, + $isAHash ? Inline::dump($key).':' : '-', + $willBeInlined ? ' ' : "\n", + $this->dump($value, $inline - 1, $willBeInlined ? 0 : $indent + $this->indentation) + ).($willBeInlined ? "\n" : ''); + } + } + + return $output; + } +} diff --git a/vendor/Symfony/Component/Yaml/Escaper.php b/vendor/Symfony/Component/Yaml/Escaper.php new file mode 100644 index 0000000000000000000000000000000000000000..f77545db9563264c9c3a9d01336ef991eb7ab9d3 --- /dev/null +++ b/vendor/Symfony/Component/Yaml/Escaper.php @@ -0,0 +1,88 @@ +<?php + +/* + * This file is part of the Symfony package. + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Yaml; + +/** + * Escaper encapsulates escaping rules for single and double-quoted + * YAML strings. + * + * @author Matthew Lewinski <matthew@lewinski.org> + */ +class Escaper +{ + // Characters that would cause a dumped string to require double quoting. + const REGEX_CHARACTER_TO_ESCAPE = "[\\x00-\\x1f]|\xc2\x85|\xc2\xa0|\xe2\x80\xa8|\xe2\x80\xa9"; + + // Mapping arrays for escaping a double quoted string. The backslash is + // first to ensure proper escaping because str_replace operates iteratively + // on the input arrays. This ordering of the characters avoids the use of strtr, + // which performs more slowly. + private static $escapees = array('\\\\', '\\"', '"', + "\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", + "\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f", + "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", + "\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f", + "\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9"); + private static $escaped = array('\\"', '\\\\', '\\"', + "\\0", "\\x01", "\\x02", "\\x03", "\\x04", "\\x05", "\\x06", "\\a", + "\\b", "\\t", "\\n", "\\v", "\\f", "\\r", "\\x0e", "\\x0f", + "\\x10", "\\x11", "\\x12", "\\x13", "\\x14", "\\x15", "\\x16", "\\x17", + "\\x18", "\\x19", "\\x1a", "\\e", "\\x1c", "\\x1d", "\\x1e", "\\x1f", + "\\N", "\\_", "\\L", "\\P"); + + /** + * Determines if a PHP value would require double quoting in YAML. + * + * @param string $value A PHP value + * + * @return Boolean True if the value would require double quotes. + */ + public static function requiresDoubleQuoting($value) + { + return preg_match('/'.self::REGEX_CHARACTER_TO_ESCAPE.'/u', $value); + } + + /** + * Escapes and surrounds a PHP value with double quotes. + * + * @param string $value A PHP value + * + * @return string The quoted, escaped string + */ + public static function escapeWithDoubleQuotes($value) + { + return sprintf('"%s"', str_replace(self::$escapees, self::$escaped, $value)); + } + + /** + * Determines if a PHP value would require single quoting in YAML. + * + * @param string $value A PHP value + * + * @return Boolean True if the value would require single quotes. + */ + public static function requiresSingleQuoting($value) + { + return preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ - ? | < > = ! % @ ` ]/x', $value); + } + + /** + * Escapes and surrounds a PHP value with single quotes. + * + * @param string $value A PHP value + * + * @return string The quoted, escaped string + */ + public static function escapeWithSingleQuotes($value) + { + return sprintf("'%s'", str_replace('\'', '\'\'', $value)); + } +} diff --git a/vendor/Symfony/Component/Yaml/Exception/DumpException.php b/vendor/Symfony/Component/Yaml/Exception/DumpException.php new file mode 100644 index 0000000000000000000000000000000000000000..53952ce1adfd1d80b7ba23b766a266340a18bae7 --- /dev/null +++ b/vendor/Symfony/Component/Yaml/Exception/DumpException.php @@ -0,0 +1,23 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Yaml\Exception; + +/** + * Exception class thrown when an error occurs during dumping. + * + * @author Fabien Potencier <fabien@symfony.com> + * + * @api + */ +class DumpException extends \RuntimeException implements ExceptionInterface +{ +} diff --git a/vendor/Symfony/Component/Yaml/Exception/ExceptionInterface.php b/vendor/Symfony/Component/Yaml/Exception/ExceptionInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..92e5c2ea4e84118771ab94785f7e8f7d8f714983 --- /dev/null +++ b/vendor/Symfony/Component/Yaml/Exception/ExceptionInterface.php @@ -0,0 +1,23 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Yaml\Exception; + +/** + * Exception interface for all exceptions thrown by the component. + * + * @author Fabien Potencier <fabien@symfony.com> + * + * @api + */ +interface ExceptionInterface +{ +} diff --git a/vendor/Symfony/Component/Yaml/Exception/ParseException.php b/vendor/Symfony/Component/Yaml/Exception/ParseException.php new file mode 100644 index 0000000000000000000000000000000000000000..975fe6d46eb7dad98d0ed48f4b8eb6ae583e6ed2 --- /dev/null +++ b/vendor/Symfony/Component/Yaml/Exception/ParseException.php @@ -0,0 +1,143 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Yaml\Exception; + +/** + * Exception class thrown when an error occurs during parsing. + * + * @author Fabien Potencier <fabien@symfony.com> + * + * @api + */ +class ParseException extends \RuntimeException implements ExceptionInterface +{ + private $parsedFile; + private $parsedLine; + private $snippet; + private $rawMessage; + + /** + * Constructor. + * + * @param string $message The error message + * @param integer $parsedLine The line where the error occurred + * @param integer $snippet The snippet of code near the problem + * @param string $parsedFile The file name where the error occurred + * @param Exception $previous The previous exception + */ + public function __construct($message, $parsedLine = -1, $snippet = null, $parsedFile = null, Exception $previous = null) + { + $this->parsedFile = $parsedFile; + $this->parsedLine = $parsedLine; + $this->snippet = $snippet; + $this->rawMessage = $message; + + $this->updateRepr(); + + parent::__construct($this->message, 0, $previous); + } + + /** + * Gets the snippet of code near the error. + * + * @return string The snippet of code + */ + public function getSnippet() + { + return $this->snippet; + } + + /** + * Sets the snippet of code near the error. + * + * @param string $snippet The code snippet + */ + public function setSnippet($snippet) + { + $this->snippet = $snippet; + + $this->updateRepr(); + } + + /** + * Gets the filename where the error occurred. + * + * This method returns null if a string is parsed. + * + * @return string The filename + */ + public function getParsedFile() + { + return $this->parsedFile; + } + + /** + * Sets the filename where the error occurred. + * + * @param string $parsedFile The filename + */ + public function setParsedFile($parsedFile) + { + $this->parsedFile = $parsedFile; + + $this->updateRepr(); + } + + /** + * Gets the line where the error occurred. + * + * @return integer The file line + */ + public function getParsedLine() + { + return $this->parsedLine; + } + + /** + * Sets the line where the error occurred. + * + * @param integer $parsedLine The file line + */ + public function setParsedLine($parsedLine) + { + $this->parsedLine = $parsedLine; + + $this->updateRepr(); + } + + private function updateRepr() + { + $this->message = $this->rawMessage; + + $dot = false; + if ('.' === substr($this->message, -1)) { + $this->message = substr($this->message, 0, -1); + $dot = true; + } + + if (null !== $this->parsedFile) { + $this->message .= sprintf(' in %s', json_encode($this->parsedFile)); + } + + if ($this->parsedLine >= 0) { + $this->message .= sprintf(' at line %d', $this->parsedLine); + } + + if ($this->snippet) { + $this->message .= sprintf(' (near "%s")', $this->snippet); + } + + if ($dot) { + $this->message .= '.'; + } + } +} diff --git a/vendor/Symfony/Component/Yaml/Inline.php b/vendor/Symfony/Component/Yaml/Inline.php new file mode 100644 index 0000000000000000000000000000000000000000..df8928577c3c8d8c49234d90ceabf57d9c0eb7fe --- /dev/null +++ b/vendor/Symfony/Component/Yaml/Inline.php @@ -0,0 +1,424 @@ +<?php + +/* + * This file is part of the Symfony package. + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Yaml; + +use Symfony\Component\Yaml\Exception\ParseException; +use Symfony\Component\Yaml\Exception\DumpException; + +/** + * Inline implements a YAML parser/dumper for the YAML inline syntax. + * + * @author Fabien Potencier <fabien@symfony.com> + */ +class Inline +{ + const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\']*(?:\'\'[^\']*)*)\')'; + + /** + * Converts a YAML string to a PHP array. + * + * @param string $value A YAML string + * + * @return array A PHP array representing the YAML string + */ + public static function parse($value) + { + $value = trim($value); + + if (0 == strlen($value)) { + return ''; + } + + if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) { + $mbEncoding = mb_internal_encoding(); + mb_internal_encoding('ASCII'); + } + + switch ($value[0]) { + case '[': + $result = self::parseSequence($value); + break; + case '{': + $result = self::parseMapping($value); + break; + default: + $i = 0; + $result = self::parseScalar($value, null, array('"', "'"), $i); + + // some comment can end the scalar + if (preg_replace('/\s+#.*$/A', '', substr($value, $i))) { + throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i))); + } + } + + if (isset($mbEncoding)) { + mb_internal_encoding($mbEncoding); + } + + return $result; + } + + /** + * Dumps a given PHP variable to a YAML string. + * + * @param mixed $value The PHP variable to convert + * + * @return string The YAML string representing the PHP array + * + * @throws DumpException When trying to dump PHP resource + */ + public static function dump($value) + { + switch (true) { + case is_resource($value): + throw new DumpException(sprintf('Unable to dump PHP resources in a YAML file ("%s").', get_resource_type($value))); + case is_object($value): + return '!!php/object:'.serialize($value); + case is_array($value): + return self::dumpArray($value); + case null === $value: + return 'null'; + case true === $value: + return 'true'; + case false === $value: + return 'false'; + case ctype_digit($value): + return is_string($value) ? "'$value'" : (int) $value; + case is_numeric($value): + $locale = setlocale(LC_NUMERIC, 0); + if (false !== $locale) { + setlocale(LC_NUMERIC, 'C'); + } + $repr = is_string($value) ? "'$value'" : (is_infinite($value) ? str_ireplace('INF', '.Inf', strval($value)) : strval($value)); + + if (false !== $locale) { + setlocale(LC_NUMERIC, $locale); + } + + return $repr; + case Escaper::requiresDoubleQuoting($value): + return Escaper::escapeWithDoubleQuotes($value); + case Escaper::requiresSingleQuoting($value): + return Escaper::escapeWithSingleQuotes($value); + case '' == $value: + return "''"; + case preg_match(self::getTimestampRegex(), $value): + case in_array(strtolower($value), array('null', '~', 'true', 'false')): + return "'$value'"; + default: + return $value; + } + } + + /** + * Dumps a PHP array to a YAML string. + * + * @param array $value The PHP array to dump + * + * @return string The YAML string representing the PHP array + */ + private static function dumpArray($value) + { + // array + $keys = array_keys($value); + if ((1 == count($keys) && '0' == $keys[0]) + || (count($keys) > 1 && array_reduce($keys, function ($v, $w) { return (integer) $v + $w; }, 0) == count($keys) * (count($keys) - 1) / 2) + ) { + $output = array(); + foreach ($value as $val) { + $output[] = self::dump($val); + } + + return sprintf('[%s]', implode(', ', $output)); + } + + // mapping + $output = array(); + foreach ($value as $key => $val) { + $output[] = sprintf('%s: %s', self::dump($key), self::dump($val)); + } + + return sprintf('{ %s }', implode(', ', $output)); + } + + /** + * Parses a scalar to a YAML string. + * + * @param scalar $scalar + * @param string $delimiters + * @param array $stringDelimiters + * @param integer &$i + * @param Boolean $evaluate + * + * @return string A YAML string + * + * @throws ParseException When malformed inline YAML string is parsed + */ + public static function parseScalar($scalar, $delimiters = null, $stringDelimiters = array('"', "'"), &$i = 0, $evaluate = true) + { + if (in_array($scalar[$i], $stringDelimiters)) { + // quoted scalar + $output = self::parseQuotedScalar($scalar, $i); + + if (null !== $delimiters) { + $tmp = ltrim(substr($scalar, $i), ' '); + if (!in_array($tmp[0], $delimiters)) { + throw new ParseException(sprintf('Unexpected characters (%s).', substr($scalar, $i))); + } + } + } else { + // "normal" string + if (!$delimiters) { + $output = substr($scalar, $i); + $i += strlen($output); + + // remove comments + if (false !== $strpos = strpos($output, ' #')) { + $output = rtrim(substr($output, 0, $strpos)); + } + } elseif (preg_match('/^(.+?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) { + $output = $match[1]; + $i += strlen($output); + } else { + throw new ParseException(sprintf('Malformed inline YAML string (%s).', $scalar)); + } + + $output = $evaluate ? self::evaluateScalar($output) : $output; + } + + return $output; + } + + /** + * Parses a quoted scalar to YAML. + * + * @param string $scalar + * @param integer &$i + * + * @return string A YAML string + * + * @throws ParseException When malformed inline YAML string is parsed + */ + private static function parseQuotedScalar($scalar, &$i) + { + // Only check the current item we're dealing with (for sequences) + $subject = substr($scalar, $i); + $items = preg_split('/[\'"]\s*(?:[,:]|[}\]]\s*,)/', $subject); + $subject = substr($subject, 0, strlen($items[0]) + 1); + + if (!preg_match('/'.self::REGEX_QUOTED_STRING.'/Au', substr($scalar, $i), $match)) { + throw new ParseException(sprintf('Malformed inline YAML string (%s).', substr($scalar, $i))); + } + + $output = substr($match[0], 1, strlen($match[0]) - 2); + + $unescaper = new Unescaper(); + if ('"' == $scalar[$i]) { + $output = $unescaper->unescapeDoubleQuotedString($output); + } else { + $output = $unescaper->unescapeSingleQuotedString($output); + } + + $i += strlen($match[0]); + + return $output; + } + + /** + * Parses a sequence to a YAML string. + * + * @param string $sequence + * @param integer &$i + * + * @return string A YAML string + * + * @throws ParseException When malformed inline YAML string is parsed + */ + private static function parseSequence($sequence, &$i = 0) + { + $output = array(); + $len = strlen($sequence); + $i += 1; + + // [foo, bar, ...] + while ($i < $len) { + switch ($sequence[$i]) { + case '[': + // nested sequence + $output[] = self::parseSequence($sequence, $i); + break; + case '{': + // nested mapping + $output[] = self::parseMapping($sequence, $i); + break; + case ']': + return $output; + case ',': + case ' ': + break; + default: + $isQuoted = in_array($sequence[$i], array('"', "'")); + $value = self::parseScalar($sequence, array(',', ']'), array('"', "'"), $i); + + if (!$isQuoted && false !== strpos($value, ': ')) { + // embedded mapping? + try { + $value = self::parseMapping('{'.$value.'}'); + } catch (\InvalidArgumentException $e) { + // no, it's not + } + } + + $output[] = $value; + + --$i; + } + + ++$i; + } + + throw new ParseException(sprintf('Malformed inline YAML string %s', $sequence)); + } + + /** + * Parses a mapping to a YAML string. + * + * @param string $mapping + * @param integer &$i + * + * @return string A YAML string + * + * @throws ParseException When malformed inline YAML string is parsed + */ + private static function parseMapping($mapping, &$i = 0) + { + $output = array(); + $len = strlen($mapping); + $i += 1; + + // {foo: bar, bar:foo, ...} + while ($i < $len) { + switch ($mapping[$i]) { + case ' ': + case ',': + ++$i; + continue 2; + case '}': + return $output; + } + + // key + $key = self::parseScalar($mapping, array(':', ' '), array('"', "'"), $i, false); + + // value + $done = false; + while ($i < $len) { + switch ($mapping[$i]) { + case '[': + // nested sequence + $output[$key] = self::parseSequence($mapping, $i); + $done = true; + break; + case '{': + // nested mapping + $output[$key] = self::parseMapping($mapping, $i); + $done = true; + break; + case ':': + case ' ': + break; + default: + $output[$key] = self::parseScalar($mapping, array(',', '}'), array('"', "'"), $i); + $done = true; + --$i; + } + + ++$i; + + if ($done) { + continue 2; + } + } + } + + throw new ParseException(sprintf('Malformed inline YAML string %s', $mapping)); + } + + /** + * Evaluates scalars and replaces magic values. + * + * @param string $scalar + * + * @return string A YAML string + */ + private static function evaluateScalar($scalar) + { + $scalar = trim($scalar); + + switch (true) { + case 'null' == strtolower($scalar): + case '' == $scalar: + case '~' == $scalar: + return null; + case 0 === strpos($scalar, '!str'): + return (string) substr($scalar, 5); + case 0 === strpos($scalar, '! '): + return intval(self::parseScalar(substr($scalar, 2))); + case 0 === strpos($scalar, '!!php/object:'): + return unserialize(substr($scalar, 13)); + case ctype_digit($scalar): + $raw = $scalar; + $cast = intval($scalar); + + return '0' == $scalar[0] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw); + case 'true' === strtolower($scalar): + return true; + case 'false' === strtolower($scalar): + return false; + case is_numeric($scalar): + return '0x' == $scalar[0].$scalar[1] ? hexdec($scalar) : floatval($scalar); + case 0 == strcasecmp($scalar, '.inf'): + case 0 == strcasecmp($scalar, '.NaN'): + return -log(0); + case 0 == strcasecmp($scalar, '-.inf'): + return log(0); + case preg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/', $scalar): + return floatval(str_replace(',', '', $scalar)); + case preg_match(self::getTimestampRegex(), $scalar): + return strtotime($scalar); + default: + return (string) $scalar; + } + } + + /** + * Gets a regex that matches an unix timestamp + * + * @return string The regular expression + */ + private static function getTimestampRegex() + { + return <<<EOF + ~^ + (?P<year>[0-9][0-9][0-9][0-9]) + -(?P<month>[0-9][0-9]?) + -(?P<day>[0-9][0-9]?) + (?:(?:[Tt]|[ \t]+) + (?P<hour>[0-9][0-9]?) + :(?P<minute>[0-9][0-9]) + :(?P<second>[0-9][0-9]) + (?:\.(?P<fraction>[0-9]*))? + (?:[ \t]*(?P<tz>Z|(?P<tz_sign>[-+])(?P<tz_hour>[0-9][0-9]?) + (?::(?P<tz_minute>[0-9][0-9]))?))?)? + $~x +EOF; + } +} diff --git a/vendor/Symfony/Component/Yaml/LICENSE b/vendor/Symfony/Component/Yaml/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..cdffe7aebc04acd5c2b9c3042a0923d8e8f31998 --- /dev/null +++ b/vendor/Symfony/Component/Yaml/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2004-2012 Fabien Potencier + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/Symfony/Component/Yaml/Parser.php b/vendor/Symfony/Component/Yaml/Parser.php new file mode 100644 index 0000000000000000000000000000000000000000..d09227b2797ec89a8c0cb46607277c07b9893a3e --- /dev/null +++ b/vendor/Symfony/Component/Yaml/Parser.php @@ -0,0 +1,620 @@ +<?php + +/* + * This file is part of the Symfony package. + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Yaml; + +use Symfony\Component\Yaml\Exception\ParseException; + +/** + * Parser parses YAML strings to convert them to PHP arrays. + * + * @author Fabien Potencier <fabien@symfony.com> + */ +class Parser +{ + private $offset = 0; + private $lines = array(); + private $currentLineNb = -1; + private $currentLine = ''; + private $refs = array(); + + /** + * Constructor + * + * @param integer $offset The offset of YAML document (used for line numbers in error messages) + */ + public function __construct($offset = 0) + { + $this->offset = $offset; + } + + /** + * Parses a YAML string to a PHP value. + * + * @param string $value A YAML string + * + * @return mixed A PHP value + * + * @throws ParseException If the YAML is not valid + */ + public function parse($value) + { + $this->currentLineNb = -1; + $this->currentLine = ''; + $this->lines = explode("\n", $this->cleanup($value)); + + if (function_exists('mb_detect_encoding') && false === mb_detect_encoding($value, 'UTF-8', true)) { + throw new ParseException('The YAML value does not appear to be valid UTF-8.'); + } + + if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) { + $mbEncoding = mb_internal_encoding(); + mb_internal_encoding('UTF-8'); + } + + $data = array(); + $context = null; + while ($this->moveToNextLine()) { + if ($this->isCurrentLineEmpty()) { + continue; + } + + // tab? + if ("\t" === $this->currentLine[0]) { + throw new ParseException('A YAML file cannot contain tabs as indentation.', $this->getRealCurrentLineNb() + 1, $this->currentLine); + } + + $isRef = $isInPlace = $isProcessed = false; + if (preg_match('#^\-((?P<leadspaces>\s+)(?P<value>.+?))?\s*$#u', $this->currentLine, $values)) { + if ($context && 'mapping' == $context) { + throw new ParseException('You cannot define a sequence item when in a mapping'); + } + $context = 'sequence'; + + if (isset($values['value']) && preg_match('#^&(?P<ref>[^ ]+) *(?P<value>.*)#u', $values['value'], $matches)) { + $isRef = $matches['ref']; + $values['value'] = $matches['value']; + } + + // array + if (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) { + $c = $this->getRealCurrentLineNb() + 1; + $parser = new Parser($c); + $parser->refs =& $this->refs; + $data[] = $parser->parse($this->getNextEmbedBlock()); + } else { + if (isset($values['leadspaces']) + && ' ' == $values['leadspaces'] + && preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\{\[].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $values['value'], $matches) + ) { + // this is a compact notation element, add to next block and parse + $c = $this->getRealCurrentLineNb(); + $parser = new Parser($c); + $parser->refs =& $this->refs; + + $block = $values['value']; + if (!$this->isNextLineIndented()) { + $block .= "\n".$this->getNextEmbedBlock($this->getCurrentLineIndentation() + 2); + } + + $data[] = $parser->parse($block); + } else { + $data[] = $this->parseValue($values['value']); + } + } + } elseif (preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\[\{].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $this->currentLine, $values)) { + if ($context && 'sequence' == $context) { + throw new ParseException('You cannot define a mapping item when in a sequence'); + } + $context = 'mapping'; + + try { + $key = Inline::parseScalar($values['key']); + } catch (ParseException $e) { + $e->setParsedLine($this->getRealCurrentLineNb() + 1); + $e->setSnippet($this->currentLine); + + throw $e; + } + + if ('<<' === $key) { + if (isset($values['value']) && 0 === strpos($values['value'], '*')) { + $isInPlace = substr($values['value'], 1); + if (!array_key_exists($isInPlace, $this->refs)) { + throw new ParseException(sprintf('Reference "%s" does not exist.', $isInPlace), $this->getRealCurrentLineNb() + 1, $this->currentLine); + } + } else { + if (isset($values['value']) && $values['value'] !== '') { + $value = $values['value']; + } else { + $value = $this->getNextEmbedBlock(); + } + $c = $this->getRealCurrentLineNb() + 1; + $parser = new Parser($c); + $parser->refs =& $this->refs; + $parsed = $parser->parse($value); + + $merged = array(); + if (!is_array($parsed)) { + throw new ParseException('YAML merge keys used with a scalar value instead of an array.', $this->getRealCurrentLineNb() + 1, $this->currentLine); + } elseif (isset($parsed[0])) { + // Numeric array, merge individual elements + foreach (array_reverse($parsed) as $parsedItem) { + if (!is_array($parsedItem)) { + throw new ParseException('Merge items must be arrays.', $this->getRealCurrentLineNb() + 1, $parsedItem); + } + $merged = array_merge($parsedItem, $merged); + } + } else { + // Associative array, merge + $merged = array_merge($merged, $parsed); + } + + $isProcessed = $merged; + } + } elseif (isset($values['value']) && preg_match('#^&(?P<ref>[^ ]+) *(?P<value>.*)#u', $values['value'], $matches)) { + $isRef = $matches['ref']; + $values['value'] = $matches['value']; + } + + if ($isProcessed) { + // Merge keys + $data = $isProcessed; + // hash + } elseif (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) { + // if next line is less indented or equal, then it means that the current value is null + if ($this->isNextLineIndented() && !$this->isNextLineUnIndentedCollection()) { + $data[$key] = null; + } else { + $c = $this->getRealCurrentLineNb() + 1; + $parser = new Parser($c); + $parser->refs =& $this->refs; + $data[$key] = $parser->parse($this->getNextEmbedBlock()); + } + } else { + if ($isInPlace) { + $data = $this->refs[$isInPlace]; + } else { + $data[$key] = $this->parseValue($values['value']); + } + } + } else { + // 1-liner followed by newline + if (2 == count($this->lines) && empty($this->lines[1])) { + try { + $value = Inline::parse($this->lines[0]); + } catch (ParseException $e) { + $e->setParsedLine($this->getRealCurrentLineNb() + 1); + $e->setSnippet($this->currentLine); + + throw $e; + } + + if (is_array($value)) { + $first = reset($value); + if (is_string($first) && 0 === strpos($first, '*')) { + $data = array(); + foreach ($value as $alias) { + $data[] = $this->refs[substr($alias, 1)]; + } + $value = $data; + } + } + + if (isset($mbEncoding)) { + mb_internal_encoding($mbEncoding); + } + + return $value; + } + + switch (preg_last_error()) { + case PREG_INTERNAL_ERROR: + $error = 'Internal PCRE error.'; + break; + case PREG_BACKTRACK_LIMIT_ERROR: + $error = 'pcre.backtrack_limit reached.'; + break; + case PREG_RECURSION_LIMIT_ERROR: + $error = 'pcre.recursion_limit reached.'; + break; + case PREG_BAD_UTF8_ERROR: + $error = 'Malformed UTF-8 data.'; + break; + case PREG_BAD_UTF8_OFFSET_ERROR: + $error = 'Offset doesn\'t correspond to the begin of a valid UTF-8 code point.'; + break; + default: + $error = 'Unable to parse.'; + } + + throw new ParseException($error, $this->getRealCurrentLineNb() + 1, $this->currentLine); + } + + if ($isRef) { + $this->refs[$isRef] = end($data); + } + } + + if (isset($mbEncoding)) { + mb_internal_encoding($mbEncoding); + } + + return empty($data) ? null : $data; + } + + /** + * Returns the current line number (takes the offset into account). + * + * @return integer The current line number + */ + private function getRealCurrentLineNb() + { + return $this->currentLineNb + $this->offset; + } + + /** + * Returns the current line indentation. + * + * @return integer The current line indentation + */ + private function getCurrentLineIndentation() + { + return strlen($this->currentLine) - strlen(ltrim($this->currentLine, ' ')); + } + + /** + * Returns the next embed block of YAML. + * + * @param integer $indentation The indent level at which the block is to be read, or null for default + * + * @return string A YAML string + * + * @throws ParseException When indentation problem are detected + */ + private function getNextEmbedBlock($indentation = null) + { + $this->moveToNextLine(); + + if (null === $indentation) { + $newIndent = $this->getCurrentLineIndentation(); + + $unindentedEmbedBlock = $this->isStringUnIndentedCollectionItem($this->currentLine); + + if (!$this->isCurrentLineEmpty() && 0 === $newIndent && !$unindentedEmbedBlock) { + throw new ParseException('Indentation problem.', $this->getRealCurrentLineNb() + 1, $this->currentLine); + } + } else { + $newIndent = $indentation; + } + + $data = array(substr($this->currentLine, $newIndent)); + + $isItUnindentedCollection = $this->isStringUnIndentedCollectionItem($this->currentLine); + + while ($this->moveToNextLine()) { + + if ($isItUnindentedCollection && !$this->isStringUnIndentedCollectionItem($this->currentLine)) { + $this->moveToPreviousLine(); + break; + } + + if ($this->isCurrentLineEmpty()) { + if ($this->isCurrentLineBlank()) { + $data[] = substr($this->currentLine, $newIndent); + } + + continue; + } + + $indent = $this->getCurrentLineIndentation(); + + if (preg_match('#^(?P<text> *)$#', $this->currentLine, $match)) { + // empty line + $data[] = $match['text']; + } elseif ($indent >= $newIndent) { + $data[] = substr($this->currentLine, $newIndent); + } elseif (0 == $indent) { + $this->moveToPreviousLine(); + + break; + } else { + throw new ParseException('Indentation problem.', $this->getRealCurrentLineNb() + 1, $this->currentLine); + } + } + + return implode("\n", $data); + } + + /** + * Moves the parser to the next line. + * + * @return Boolean + */ + private function moveToNextLine() + { + if ($this->currentLineNb >= count($this->lines) - 1) { + return false; + } + + $this->currentLine = $this->lines[++$this->currentLineNb]; + + return true; + } + + /** + * Moves the parser to the previous line. + */ + private function moveToPreviousLine() + { + $this->currentLine = $this->lines[--$this->currentLineNb]; + } + + /** + * Parses a YAML value. + * + * @param string $value A YAML value + * + * @return mixed A PHP value + * + * @throws ParseException When reference does not exist + */ + private function parseValue($value) + { + if (0 === strpos($value, '*')) { + if (false !== $pos = strpos($value, '#')) { + $value = substr($value, 1, $pos - 2); + } else { + $value = substr($value, 1); + } + + if (!array_key_exists($value, $this->refs)) { + throw new ParseException(sprintf('Reference "%s" does not exist.', $value), $this->currentLine); + } + + return $this->refs[$value]; + } + + if (preg_match('/^(?P<separator>\||>)(?P<modifiers>\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?(?P<comments> +#.*)?$/', $value, $matches)) { + $modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : ''; + + return $this->parseFoldedScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), intval(abs($modifiers))); + } + + try { + return Inline::parse($value); + } catch (ParseException $e) { + $e->setParsedLine($this->getRealCurrentLineNb() + 1); + $e->setSnippet($this->currentLine); + + throw $e; + } + } + + /** + * Parses a folded scalar. + * + * @param string $separator The separator that was used to begin this folded scalar (| or >) + * @param string $indicator The indicator that was used to begin this folded scalar (+ or -) + * @param integer $indentation The indentation that was used to begin this folded scalar + * + * @return string The text value + */ + private function parseFoldedScalar($separator, $indicator = '', $indentation = 0) + { + $separator = '|' == $separator ? "\n" : ' '; + $text = ''; + + $notEOF = $this->moveToNextLine(); + + while ($notEOF && $this->isCurrentLineBlank()) { + $text .= "\n"; + + $notEOF = $this->moveToNextLine(); + } + + if (!$notEOF) { + return ''; + } + + if (!preg_match('#^(?P<indent>'.($indentation ? str_repeat(' ', $indentation) : ' +').')(?P<text>.*)$#u', $this->currentLine, $matches)) { + $this->moveToPreviousLine(); + + return ''; + } + + $textIndent = $matches['indent']; + $previousIndent = 0; + + $text .= $matches['text'].$separator; + while ($this->currentLineNb + 1 < count($this->lines)) { + $this->moveToNextLine(); + + if (preg_match('#^(?P<indent> {'.strlen($textIndent).',})(?P<text>.+)$#u', $this->currentLine, $matches)) { + if (' ' == $separator && $previousIndent != $matches['indent']) { + $text = substr($text, 0, -1)."\n"; + } + $previousIndent = $matches['indent']; + + $text .= str_repeat(' ', $diff = strlen($matches['indent']) - strlen($textIndent)).$matches['text'].($diff ? "\n" : $separator); + } elseif (preg_match('#^(?P<text> *)$#', $this->currentLine, $matches)) { + $text .= preg_replace('#^ {1,'.strlen($textIndent).'}#', '', $matches['text'])."\n"; + } else { + $this->moveToPreviousLine(); + + break; + } + } + + if (' ' == $separator) { + // replace last separator by a newline + $text = preg_replace('/ (\n*)$/', "\n$1", $text); + } + + switch ($indicator) { + case '': + $text = preg_replace('#\n+$#s', "\n", $text); + break; + case '+': + break; + case '-': + $text = preg_replace('#\n+$#s', '', $text); + break; + } + + return $text; + } + + /** + * Returns true if the next line is indented. + * + * @return Boolean Returns true if the next line is indented, false otherwise + */ + private function isNextLineIndented() + { + $currentIndentation = $this->getCurrentLineIndentation(); + $notEOF = $this->moveToNextLine(); + + while ($notEOF && $this->isCurrentLineEmpty()) { + $notEOF = $this->moveToNextLine(); + } + + if (false === $notEOF) { + return false; + } + + $ret = false; + if ($this->getCurrentLineIndentation() <= $currentIndentation) { + $ret = true; + } + + $this->moveToPreviousLine(); + + return $ret; + } + + /** + * Returns true if the current line is blank or if it is a comment line. + * + * @return Boolean Returns true if the current line is empty or if it is a comment line, false otherwise + */ + private function isCurrentLineEmpty() + { + return $this->isCurrentLineBlank() || $this->isCurrentLineComment(); + } + + /** + * Returns true if the current line is blank. + * + * @return Boolean Returns true if the current line is blank, false otherwise + */ + private function isCurrentLineBlank() + { + return '' == trim($this->currentLine, ' '); + } + + /** + * Returns true if the current line is a comment line. + * + * @return Boolean Returns true if the current line is a comment line, false otherwise + */ + private function isCurrentLineComment() + { + //checking explicitly the first char of the trim is faster than loops or strpos + $ltrimmedLine = ltrim($this->currentLine, ' '); + + return $ltrimmedLine[0] === '#'; + } + + /** + * Cleanups a YAML string to be parsed. + * + * @param string $value The input YAML string + * + * @return string A cleaned up YAML string + */ + private function cleanup($value) + { + $value = str_replace(array("\r\n", "\r"), "\n", $value); + + if (!preg_match("#\n$#", $value)) { + $value .= "\n"; + } + + // strip YAML header + $count = 0; + $value = preg_replace('#^\%YAML[: ][\d\.]+.*\n#su', '', $value, -1, $count); + $this->offset += $count; + + // remove leading comments + $trimmedValue = preg_replace('#^(\#.*?\n)+#s', '', $value, -1, $count); + if ($count == 1) { + // items have been removed, update the offset + $this->offset += substr_count($value, "\n") - substr_count($trimmedValue, "\n"); + $value = $trimmedValue; + } + + // remove start of the document marker (---) + $trimmedValue = preg_replace('#^\-\-\-.*?\n#s', '', $value, -1, $count); + if ($count == 1) { + // items have been removed, update the offset + $this->offset += substr_count($value, "\n") - substr_count($trimmedValue, "\n"); + $value = $trimmedValue; + + // remove end of the document marker (...) + $value = preg_replace('#\.\.\.\s*$#s', '', $value); + } + + return $value; + } + + /** + * Returns true if the next line starts unindented collection + * + * @return Boolean Returns true if the next line starts unindented collection, false otherwise + */ + private function isNextLineUnIndentedCollection() + { + $currentIndentation = $this->getCurrentLineIndentation(); + $notEOF = $this->moveToNextLine(); + + while ($notEOF && $this->isCurrentLineEmpty()) { + $notEOF = $this->moveToNextLine(); + } + + if (false === $notEOF) { + return false; + } + + $ret = false; + if ( + $this->getCurrentLineIndentation() == $currentIndentation + && + $this->isStringUnIndentedCollectionItem($this->currentLine) + ) { + $ret = true; + } + + $this->moveToPreviousLine(); + + return $ret; + } + + /** + * Returns true if the string is un-indented collection item + * + * @return Boolean Returns true if the string is un-indented collection item, false otherwise + */ + private function isStringUnIndentedCollectionItem() + { + return (0 === strpos($this->currentLine, '- ')); + } + +} diff --git a/vendor/Symfony/Component/Yaml/README.md b/vendor/Symfony/Component/Yaml/README.md new file mode 100644 index 0000000000000000000000000000000000000000..34413166991a698327010388cc3898e1825e0ed4 --- /dev/null +++ b/vendor/Symfony/Component/Yaml/README.md @@ -0,0 +1,17 @@ +Yaml Component +============== + +YAML implements most of the YAML 1.2 specification. + + use Symfony\Component\Yaml\Yaml; + + $array = Yaml::parse($file); + + print Yaml::dump($array); + +Resources +--------- + +You can run the unit tests with the following command: + + phpunit diff --git a/vendor/Symfony/Component/Yaml/Unescaper.php b/vendor/Symfony/Component/Yaml/Unescaper.php new file mode 100644 index 0000000000000000000000000000000000000000..ac3a576b677bcb53a7afd187fa4c3760c4d68619 --- /dev/null +++ b/vendor/Symfony/Component/Yaml/Unescaper.php @@ -0,0 +1,145 @@ +<?php + +/* + * This file is part of the Symfony package. + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Yaml; + +/** + * Unescaper encapsulates unescaping rules for single and double-quoted + * YAML strings. + * + * @author Matthew Lewinski <matthew@lewinski.org> + */ +class Unescaper +{ + // Parser and Inline assume UTF-8 encoding, so escaped Unicode characters + // must be converted to that encoding. + const ENCODING = 'UTF-8'; + + // Regex fragment that matches an escaped character in a double quoted + // string. + const REGEX_ESCAPED_CHARACTER = "\\\\([0abt\tnvfre \\\"\\/\\\\N_LP]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})"; + + /** + * Unescapes a single quoted string. + * + * @param string $value A single quoted string. + * + * @return string The unescaped string. + */ + public function unescapeSingleQuotedString($value) + { + return str_replace('\'\'', '\'', $value); + } + + /** + * Unescapes a double quoted string. + * + * @param string $value A double quoted string. + * + * @return string The unescaped string. + */ + public function unescapeDoubleQuotedString($value) + { + $self = $this; + $callback = function($match) use ($self) { + return $self->unescapeCharacter($match[0]); + }; + + // evaluate the string + return preg_replace_callback('/'.self::REGEX_ESCAPED_CHARACTER.'/u', $callback, $value); + } + + /** + * Unescapes a character that was found in a double-quoted string + * + * @param string $value An escaped character + * + * @return string The unescaped character + */ + public function unescapeCharacter($value) + { + switch ($value{1}) { + case '0': + return "\x0"; + case 'a': + return "\x7"; + case 'b': + return "\x8"; + case 't': + return "\t"; + case "\t": + return "\t"; + case 'n': + return "\n"; + case 'v': + return "\xb"; + case 'f': + return "\xc"; + case 'r': + return "\xd"; + case 'e': + return "\x1b"; + case ' ': + return ' '; + case '"': + return '"'; + case '/': + return '/'; + case '\\': + return '\\'; + case 'N': + // U+0085 NEXT LINE + return $this->convertEncoding("\x00\x85", self::ENCODING, 'UCS-2BE'); + case '_': + // U+00A0 NO-BREAK SPACE + return $this->convertEncoding("\x00\xA0", self::ENCODING, 'UCS-2BE'); + case 'L': + // U+2028 LINE SEPARATOR + return $this->convertEncoding("\x20\x28", self::ENCODING, 'UCS-2BE'); + case 'P': + // U+2029 PARAGRAPH SEPARATOR + return $this->convertEncoding("\x20\x29", self::ENCODING, 'UCS-2BE'); + case 'x': + $char = pack('n', hexdec(substr($value, 2, 2))); + + return $this->convertEncoding($char, self::ENCODING, 'UCS-2BE'); + case 'u': + $char = pack('n', hexdec(substr($value, 2, 4))); + + return $this->convertEncoding($char, self::ENCODING, 'UCS-2BE'); + case 'U': + $char = pack('N', hexdec(substr($value, 2, 8))); + + return $this->convertEncoding($char, self::ENCODING, 'UCS-4BE'); + } + } + + /** + * Convert a string from one encoding to another. + * + * @param string $value The string to convert + * @param string $to The input encoding + * @param string $from The output encoding + * + * @return string The string with the new encoding + * + * @throws \RuntimeException if no suitable encoding function is found (iconv or mbstring) + */ + private function convertEncoding($value, $to, $from) + { + if (function_exists('mb_convert_encoding')) { + return mb_convert_encoding($value, $to, $from); + } elseif (function_exists('iconv')) { + return iconv($from, $to, $value); + } + + throw new \RuntimeException('No suitable convert encoding function (install the iconv or mbstring extension).'); + } +} diff --git a/vendor/Symfony/Component/Yaml/Yaml.php b/vendor/Symfony/Component/Yaml/Yaml.php new file mode 100644 index 0000000000000000000000000000000000000000..85cdf3db66ec9183d6a48db052600591c9f1f287 --- /dev/null +++ b/vendor/Symfony/Component/Yaml/Yaml.php @@ -0,0 +1,113 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Yaml; + +use Symfony\Component\Yaml\Exception\ParseException; + +/** + * Yaml offers convenience methods to load and dump YAML. + * + * @author Fabien Potencier <fabien@symfony.com> + * + * @api + */ +class Yaml +{ + public static $enablePhpParsing = false; + + public static function enablePhpParsing() + { + self::$enablePhpParsing = true; + } + + /** + * Parses YAML into a PHP array. + * + * The parse method, when supplied with a YAML stream (string or file), + * will do its best to convert YAML in a file into a PHP array. + * + * Usage: + * <code> + * $array = Yaml::parse('config.yml'); + * print_r($array); + * </code> + * + * @param string $input Path to a YAML file or a string containing YAML + * + * @return array The YAML converted to a PHP array + * + * @throws ParseException If the YAML is not valid + * + * @api + */ + public static function parse($input) + { + // if input is a file, process it + $file = ''; + if (strpos($input, "\n") === false && is_file($input)) { + if (false === is_readable($input)) { + throw new ParseException(sprintf('Unable to parse "%s" as the file is not readable.', $input)); + } + + $file = $input; + if (self::$enablePhpParsing) { + ob_start(); + $retval = include($file); + $content = ob_get_clean(); + + // if an array is returned by the config file assume it's in plain php form else in YAML + $input = is_array($retval) ? $retval : $content; + + // if an array is returned by the config file assume it's in plain php form else in YAML + if (is_array($input)) { + return $input; + } + } else { + $input = file_get_contents($file); + } + } + + $yaml = new Parser(); + + try { + return $yaml->parse($input); + } catch (ParseException $e) { + if ($file) { + $e->setParsedFile($file); + } + + throw $e; + } + } + + /** + * Dumps a PHP array to a YAML string. + * + * The dump method, when supplied with an array, will do its best + * to convert the array into friendly YAML. + * + * @param array $array PHP array + * @param integer $inline The level where you switch to inline YAML + * @param integer $indent The amount of spaces to use for indentation of nested nodes. + * + * @return string A YAML string representing the original PHP array + * + * @api + */ + public static function dump($array, $inline = 2, $indent = 4) + { + $yaml = new Dumper(); + $yaml->setIndentation($indent); + + return $yaml->dump($array, $inline); + } +} diff --git a/vendor/Symfony/Component/Yaml/composer.json b/vendor/Symfony/Component/Yaml/composer.json new file mode 100644 index 0000000000000000000000000000000000000000..88460ce34b70d61fdaac152010ed55bf55840868 --- /dev/null +++ b/vendor/Symfony/Component/Yaml/composer.json @@ -0,0 +1,31 @@ +{ + "name": "symfony/yaml", + "type": "library", + "description": "Symfony Yaml Component", + "keywords": [], + "homepage": "http://symfony.com", + "license": "MIT", + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "require": { + "php": ">=5.3.3" + }, + "autoload": { + "psr-0": { "Symfony\\Component\\Yaml": "" } + }, + "target-dir": "Symfony/Component/Yaml", + "minimum-stability": "dev", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + } +} diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php index aa3636fc0ef492f088fdd279c31b35d3e40bc123..a177118d8fed903a34d3fae2ffd41d597624dc76 100644 --- a/vendor/composer/autoload_namespaces.php +++ b/vendor/composer/autoload_namespaces.php @@ -5,10 +5,10 @@ $baseDir = dirname($vendorDir); return array( 'File' => $vendorDir, - 'Horde' => $vendorDir, 'PEAR' => $vendorDir, 'SerialsSolutions' => $vendorDir, 'Structures' => $vendorDir, + 'Symfony' => $vendorDir, 'Validate' => $vendorDir, 'Zend' => $vendorDir . '/ZF2/library/', 'ZendRest' => $vendorDir . '/ZendRest/library/',