--- /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/github_19.0.3_ApcCache.php +++ /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/client_ApcCache.php @@ -16 +16 @@ - * + * @version 3.0.0rc6 --- /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/github_19.0.3_AutoLoader.php +++ /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/client_AutoLoader.php @@ -4,460 +4,429 @@ - /** - * Class that implements spl_autoload facilities and multiple - * conventions support. - * Supports composer libraries and 100% PSR-0 compliant. - * In addition we enable namespace prefixing and class aliases. - * - * @category Framework - * @package Restler - * @subpackage Helper - * @author Nick Lombard - * @copyright 2012 Luracast - * - */ - class AutoLoader - { - protected static $instance, // the singleton instance reference - $perfectLoaders, // used to keep the ideal list of loaders - $rogueLoaders = array(), // other auto loaders now unregistered - $classMap = array(), // the class to include file mapping - $aliases = array( // aliases and prefixes instead of null list aliases - 'Luracast\\Restler' => null, - 'Luracast\\Restler\\Format' => null, - 'Luracast\\Restler\\Data' => null, - 'Luracast\\Restler\\Filter' => null, - ); - - /** - * Singleton instance facility. - * - * @static - * @return AutoLoader the current instance or new instance if none exists. - */ - public static function instance() - { - static::$instance = static::$instance ?: new static(); - return static::thereCanBeOnlyOne(); - } - - /** - * Helper function to add a path to the include path. - * AutoLoader uses the include path to discover classes. - * - * @static - * - * @param $path string absolute or relative path. - * - * @return bool false if the path cannot be resolved - * or the resolved absolute path. - */ - public static function addPath($path) - { - if (false === $path = stream_resolve_include_path($path)) - return false; - else set_include_path($path.PATH_SEPARATOR.get_include_path()); - return $path; - } - - /** - * Other autoLoaders interfere and cause duplicate class loading. - * AutoLoader is capable enough to handle all standards so no need - * for others stumbling about. - * - * @return callable the one true auto loader. - */ - public static function thereCanBeOnlyOne() - { - if (static::$perfectLoaders === spl_autoload_functions()) - return static::$instance; - - if (false !== $loaders = spl_autoload_functions()) - if (0 < $count = count($loaders)) - for ($i = 0, static::$rogueLoaders += $loaders; - $i < $count && false != ($loader = $loaders[$i]); - $i++) - if ($loader !== static::$perfectLoaders[0]) - spl_autoload_unregister($loader); - - return static::$instance; - } - - /** - * Seen this before cache handler. - * Facilitates both lookup and persist operations as well as convenience, - * load complete map functionality. The key can only be given a non falsy - * value once, this will be truthy for life. - * - * @param $key mixed class name considered or a collection of - * classMap entries - * @param $value mixed optional not required when doing a query on - * key. Default is false we haven't seen this - * class. Most of the time it will be the filename - * for include and is set to true if we are unable - * to load this class iow true == it does not exist. - * value may also be a callable auto loader function. - * - * @return mixed The known value for the key or false if key has no value - */ - public static function seen($key, $value = false) - { - if (is_array($key)) { - static::$classMap = $key + static::$classMap; - return false; - } - - if (empty(static::$classMap[$key])) - static::$classMap[$key] = $value; - - if (is_string($alias = static::$classMap[$key])) - if (isset(static::$classMap[$alias])) - return static::$classMap[$alias]; - - return static::$classMap[$key]; - } - - /** - * Protected constructor to enforce singleton pattern. - * Populate a default include path. - * All possible includes cant possibly be catered for and if you - * require another path then simply add it calling set_include_path. - */ - protected function __construct() - { - static::$perfectLoaders = array($this); - - if (false === static::seen('__include_path')) { - $paths = explode(PATH_SEPARATOR, get_include_path()); - $slash = DIRECTORY_SEPARATOR; - $dir = dirname(__DIR__); - $source_dir = dirname($dir); - $dir = dirname($source_dir); - - foreach (array( - array($source_dir), - array($dir, '..', '..', 'composer'), - array($dir, 'vendor', 'composer'), - array($dir, '..', '..', '..', 'php'), - array($dir, 'vendor', 'php')) - as $includePath) - if (false !== $path = stream_resolve_include_path( - implode($slash, $includePath) - )) - if ('composer' == end($includePath) && - false !== $classmapPath = stream_resolve_include_path( - "$path{$slash}autoload_classmap.php" - ) - ) { - static::seen(static::loadFile( - $classmapPath - )); - $paths = array_merge( - $paths, - array_values(static::loadFile( - "$path{$slash}autoload_namespaces.php" - )) - ); - } else $paths[] = $path; - - $paths = array_filter(array_map( - function ($path) { - if (false == $realPath = @realpath($path)) - return null; - return $realPath . DIRECTORY_SEPARATOR; - }, - $paths - )); - natsort($paths); - static::seen( - '__include_path', - implode(PATH_SEPARATOR, array_unique($paths)) - ); - } - - set_include_path(static::seen('__include_path')); - } - - /** - * Attempt to include the path location. - * Called from a static context which will not expose the AutoLoader - * instance itself. - * - * @param $path string location of php file on the include path - * - * @return bool|mixed returns reference obtained from the include or false - */ - private static function loadFile($path) - { - return \Luracast_Restler_autoloaderInclude($path); - } - - /** - * Attempt to load class with namespace prefixes. - * - * @param $className string class name - * - * @return bool|mixed reference to discovered include or false - */ - private function loadPrefixes($className) - { - $currentClass = $className; - if (false !== $pos = strrpos($className, '\\')) - $className = substr($className, $pos); - else $className = "\\$className"; - - for ( - $i = 0, - $file = false, - $count = count(static::$aliases), - $prefixes = array_keys(static::$aliases); - $i < $count - && false === $file - && false === $file = $this->discover( - $variant = $prefixes[$i++].$className, - $currentClass - ); - $file = $this->loadAliases($variant) - ); - - return $file; - } - - /** - * Attempt to load configured aliases based on namespace part of class name. - * - * @param $className string fully qualified class name. - * - * @return bool|mixed reference to discovered include or false - */ - private function loadAliases($className) - { - $file = false; - if (preg_match('/(.+)(\\\\\w+$)/U', $className, $parts)) - for ( - $i = 0, - $aliases = isset(static::$aliases[$parts[1]]) - ? static::$aliases[$parts[1]] : array(), - $count = count($aliases); - $i < $count && false === $file; - $file = $this->discover( - "{$aliases[$i++]}$parts[2]", - $className - ) - ) ; - - return $file; - } - - /** - * Load from rogueLoaders as last resort. - * It may happen that a custom auto loader may load classes in a unique way, - * these classes cannot be seen otherwise nor should we attempt to cover every - * possible deviation. If we still can't find a class, as a last resort, we will - * run through the list of rogue loaders and verify if we succeeded. - * - * @param $className string className that can't be found - * @param null $loader callable loader optional when the loader is known - * - * @return bool false unless className now exists - */ - private function loadLastResort($className, $loader = null) - { - $loaders = array_unique(static::$rogueLoaders, SORT_REGULAR); - if (isset($loader)) { - if (false === array_search($loader, $loaders)) - static::$rogueLoaders[] = $loader; - return $this->loadThisLoader($className, $loader); - } - foreach ($loaders as $loader) - if (false !== $file = $this->loadThisLoader($className, $loader)) - return $file; - - return false; - } - - /** - * Helper for loadLastResort. - * Use loader with $className and see if className exists. - * - * @param $className string name of a class to load - * @param $loader callable autoLoader method - * - * @return bool false unless className exists - */ - private function loadThisLoader($className, $loader) - { - if (is_array($loader) - && is_callable($loader)) { - $b = new $loader[0]; - //avoid PHP Fatal error: Uncaught Error: Access to undeclared static property: Composer\\Autoload\\ClassLoader::$loader - //in case of multiple autoloader systems - if (property_exists($b, $loader[1])) { - if (false !== $file = $b::$loader[1]($className) - && $this->exists($className, $b::$loader[1])) { - return $file; - } - } - } elseif (is_callable($loader) - && false !== $file = $loader($className) - && $this->exists($className, $loader)) { - return $file; - } - return false; - - /* other code tested to reduce autoload conflict - $s = ''; - if (is_array($loader) - && is_callable($loader)) { - // @CHANGE DOL avoid autoload conflict - if (!preg_match('/LuraCast/', get_class($loader[0]))) { - return false; - } - $b = new $loader[0]; - // @CHANGE DOL avoid PHP Fatal error: Uncaught Error: Access to undeclared static property: Composer\\Autoload\\ClassLoader::$loader - //in case of multiple autoloader systems - if (property_exists($b, $loader[1])) { - if (false !== $file = $b::$loader[1]($className) - && $this->exists($className, $b::$loader[1])) { - return $file; - } - } - } elseif (is_callable($loader, false, $s)) { - // @CHANGE DOL avoid PHP infinite loop (detected when xdebug is on) - if ($s == 'Luracast\Restler\AutoLoader::__invoke') { - return false; - } - if (false !== ($file = $loader($className)) && $this->exists($className, $loader)) { - return $file; - } - } - return false; - */ - } - - /** - * Create an alias for class. - * - * @param $className string the name of the alias class - * @param $currentClass string the current class this alias references - * @return void - */ - private function alias($className, $currentClass) - { - if ($className == 'Luracast\Restler\string') return; - if ($className == 'Luracast\Restler\mixed') return; - if ($className != $currentClass - && false !== strpos($className, $currentClass)) - if (!class_exists($currentClass, false) - && class_alias($className, $currentClass)) - static::seen($currentClass, $className); - } - - /** - * Discovery process. - * - * @param $className string class name to discover - * @param $currentClass string optional name of current class when - * looking up an alias - * - * @return bool|mixed resolved include reference or false - */ - private function discover($className, $currentClass = null) - { - $currentClass = $currentClass ?: $className; - - /** The short version we've done this before and found it in cache */ - if (false !== $file = static::seen($className)) { - if (!$this->exists($className)) - if (is_callable($file)) - $file = $this->loadLastResort($className, $file); - elseif ($file = stream_resolve_include_path($file)) - $file = static::loadFile($file); - - $this->alias($className, $currentClass); - return $file; - } - - /** We did not find it in cache, lets look for it shall we */ - - /** replace \ with / and _ in CLASS NAME with / = PSR-0 in 3 lines */ - $file = preg_replace("/\\\|_(?=\w+$)/", DIRECTORY_SEPARATOR, $className); - if (false === $file = stream_resolve_include_path("$file.php")) - return false; - - /** have we loaded this file before could this be an alias */ - if (in_array($file, get_included_files())) { - if (false !== $sameFile = array_search($file, static::$classMap)) - if (!$this->exists($className, $file)) - if (false !== strpos($sameFile, $className)) - $this->alias($sameFile, $className); - - return $file; - } - - $state = array_merge(get_declared_classes(), get_declared_interfaces()); - - if (false !== $result = static::loadFile($file)) { - if ($this->exists($className, $file)) - $this->alias($className, $currentClass); - elseif (false != $diff = array_diff( - array_merge(get_declared_classes(), get_declared_interfaces()), $state)) - foreach ($diff as $autoLoaded) - if ($this->exists($autoLoaded, $file)) - if (false !== strpos($autoLoaded, $className)) - $this->alias($autoLoaded, $className); - - if (!$this->exists($currentClass)) - $result = false; - } - - return $result; - } - - /** - * Checks whether supplied string exists in a loaded class or interface. - * As a convenience the supplied $mapping can be the value for seen. - * - * @param $className string The class or interface to verify - * @param $mapping string (optional) value for map/seen if found to exist - * - * @return bool whether the class/interface exists without calling auto loader - */ - private function exists($className, $mapping = null) - { - if (class_exists($className, false) - || interface_exists($className, false)) - if (isset($mapping)) - return static::seen($className, $mapping); - else return true; - return false; - } - - /** - * Auto loader callback through __invoke object as function. - * - * @param $className string class/interface name to auto load - * - * @return mixed|null the reference from the include or null - */ - public function __invoke($className) - { - if (empty($className)) - return false; - - if (false !== $includeReference = $this->discover($className)) - return $includeReference; - - //static::thereCanBeOnlyOne(); - - if (false !== $includeReference = $this->loadAliases($className)) - return $includeReference; - - if (false !== $includeReference = $this->loadPrefixes($className)) - return $includeReference; - - if (false !== $includeReference = $this->loadLastResort($className)) - return $includeReference; - - static::seen($className, true); - return null; - } - } +/** + * Class that implements spl_autoload facilities and multiple + * conventions support. + * Supports composer libraries and 100% PSR-0 compliant. + * In addition we enable namespace prefixing and class aliases. + * + * @category Framework + * @package Restler + * @subpackage helper + * @author Nick Lombard + * @copyright 2012 Luracast + * @version 3.0.0rc6 + */ +class AutoLoader +{ + protected static $instance, // the singleton instance reference + $perfectLoaders, // used to keep the ideal list of loaders + $rogueLoaders = array(), // other auto loaders now unregistered + $classMap = array(), // the class to include file mapping + $aliases = array( // aliases and prefixes instead of null list aliases + 'Luracast\\Restler' => null, + 'Luracast\\Restler\\Format' => null, + 'Luracast\\Restler\\Data' => null, + 'Luracast\\Restler\\Filter' => null, + ); + + /** + * Singleton instance facility. + * + * @static + * @return AutoLoader the current instance or new instance if none exists. + */ + public static function instance() + { + static::$instance = static::$instance ?: new static(); + return static::thereCanBeOnlyOne(); + } + + /** + * Helper function to add a path to the include path. + * AutoLoader uses the include path to discover classes. + * + * @static + * + * @param $path string absolute or relative path. + * + * @return bool false if the path cannot be resolved + * or the resolved absolute path. + */ + public static function addPath($path) { + if (false === $path = stream_resolve_include_path($path)) + return false; + else + set_include_path($path.PATH_SEPARATOR.get_include_path()); + return $path; + } + + /** + * Other autoLoaders interfere and cause duplicate class loading. + * AutoLoader is capable enough to handle all standards so no need + * for others stumbling about. + * + * @return callable the one true auto loader. + */ + public static function thereCanBeOnlyOne() { + if (static::$perfectLoaders === spl_autoload_functions()) + return static::$instance; + + if (false !== $loaders = spl_autoload_functions()) + if (0 < $count = count($loaders)) + for ($i = 0, static::$rogueLoaders += $loaders; + $i < $count && false != ($loader = $loaders[$i]); + $i++) + if ($loader !== static::$perfectLoaders[0]) + spl_autoload_unregister($loader); + + return static::$instance; + } + + /** + * Seen this before cache handler. + * Facilitates both lookup and persist operations as well as convenience, + * load complete map functionality. The key can only be given a non falsy + * value once, this will be truthy for life. + * + * @param $key mixed class name considered or a collection of + * classMap entries + * @param $value mixed optional not required when doing a query on + * key. Default is false we haven't seen this + * class. Most of the time it will be the filename + * for include and is set to true if we are unable + * to load this class iow true == it does not exist. + * value may also be a callable auto loader function. + * + * @return mixed The known value for the key or false if key has no value + */ + public static function seen($key, $value = false) + { + if (is_array($key)) { + static::$classMap = $key + static::$classMap; + return false; + } + + if (empty(static::$classMap[$key])) + static::$classMap[$key] = $value; + + if (is_string($alias = static::$classMap[$key])) + if (isset(static::$classMap[$alias])) + return static::$classMap[$alias]; + + return static::$classMap[$key]; + } + + /** + * Protected constructor to enforce singleton pattern. + * Populate a default include path. + * All possible includes cant possibly be catered for and if you + * require another path then simply add it calling set_include_path. + */ + protected function __construct() + { + static::$perfectLoaders = array($this); + + if (false === static::seen('__include_path')) { + + $paths = explode(PATH_SEPARATOR, get_include_path()); + $slash = DIRECTORY_SEPARATOR; + $dir = dirname(__DIR__); + $source_dir = dirname($dir); + $dir = dirname($source_dir); + + foreach ( + array( + array($source_dir), + array($dir, '..', '..', 'composer'), + array($dir, 'vendor', 'composer'), + array($dir, '..', '..', '..', 'php'), + array($dir, 'vendor', 'php')) + as $includePath) + if (false !== $path = stream_resolve_include_path( + implode($slash, $includePath) + )) + if ('composer' == end($includePath) && + false !== $classmapPath = stream_resolve_include_path( + "$path{$slash}autoload_classmap.php" + ) + ) { + static::seen(static::loadFile( + $classmapPath + )); + $paths = array_merge( + $paths, + array_values(static::loadFile( + "$path{$slash}autoload_namespaces.php" + )) + ); + } else + $paths[] = $path; + + $paths = array_filter(array_map( + function ($path) { + if (false == $realPath = @realpath($path)) + return null; + return $realPath . DIRECTORY_SEPARATOR; + }, + $paths + )); + natsort($paths); + static::seen( + '__include_path', + implode(PATH_SEPARATOR, array_unique($paths)) + ); + } + + set_include_path(static::seen('__include_path')); + } + + /** + * Attempt to include the path location. + * Called from a static context which will not expose the AutoLoader + * instance itself. + * + * @param $path string location of php file on the include path + * + * @return bool|mixed returns reference obtained from the include or false + */ + private static function loadFile($path) + { + return \Luracast_Restler_autoloaderInclude($path); + } + + /** + * Attempt to load class with namespace prefixes. + * + * @param $className string class name + * + * @return bool|mixed reference to discovered include or false + */ + private function loadPrefixes($className) + { + $currentClass = $className; + if (false !== $pos = strrpos($className, '\\')) + $className = substr($className, $pos); + else + $className = "\\$className"; + + for ( + $i = 0, + $file = false, + $count = count(static::$aliases), + $prefixes = array_keys(static::$aliases); + $i < $count + && false === $file + && false === $file = $this->discover( + $variant = $prefixes[$i++].$className, + $currentClass + ); + $file = $this->loadAliases($variant) + ); + + return $file; + } + + /** + * Attempt to load configured aliases based on namespace part of class name. + * + * @param $className string fully qualified class name. + * + * @return bool|mixed reference to discovered include or false + */ + private function loadAliases($className) + { + $file = false; + if (preg_match('/(.+)(\\\\\w+$)/U', $className, $parts)) + for ( + $i = 0, + $aliases = isset(static::$aliases[$parts[1]]) + ? static::$aliases[$parts[1]] : array(), + $count = count($aliases); + $i < $count && false === $file; + $file = $this->discover( + "{$aliases[$i++]}$parts[2]", + $className + ) + ) ; + + return $file; + } + + /** + * Load from rogueLoaders as last resort. + * It may happen that a custom auto loader may load classes in a unique way, + * these classes cannot be seen otherwise nor should we attempt to cover every + * possible deviation. If we still can't find a class, as a last resort, we will + * run through the list of rogue loaders and verify if we succeeded. + * + * @param $className string className that can't be found + * @param null $loader callable loader optional when the loader is known + * + * @return bool false unless className now exists + */ + private function loadLastResort($className, $loader = null) { + $loaders = array_unique(static::$rogueLoaders); + if (isset($loader)) { + if (false === array_search($loader, $loaders)) + static::$rogueLoaders[] = $loader; + return $this->loadThisLoader($className, $loader); + } + foreach ($loaders as $loader) + if (false !== $file = $this->loadThisLoader($className, $loader)) + return $file; + + return false; + } + + /** + * Helper for loadLastResort. + * Use loader with $className and see if className exists. + * + * @param $className string name of a class to load + * @param $loader callable autoLoader method + * + * @return bool false unless className exists + */ + private function loadThisLoader($className, $loader) + { + if (is_array($loader) + && is_callable($loader)) { + $b = new $loader[0]; + if (false !== $file = $b::$loader[1]($className) + && $this->exists($className, $b::$loader[1])) { + return $file; + } + } elseif (is_callable($loader) + && false !== $file = $loader($className) + && $this->exists($className, $loader)) { + return $file; + } + return false; + } + + /** + * Create an alias for class. + * + * @param $className string the name of the alias class + * @param $currentClass string the current class this alias references + */ + private function alias($className, $currentClass) + { + if ($className == 'Luracast\Restler\string') return; + if ($className == 'Luracast\Restler\mixed') return; + if ($className != $currentClass + && false !== strpos($className, $currentClass)) + if (!class_exists($currentClass, false) + && class_alias($className, $currentClass)) + static::seen($currentClass, $className); + } + + /** + * Discovery process. + * + * @param $className string class name to discover + * @param $currentClass string optional name of current class when + * looking up an alias + * + * @return bool|mixed resolved include reference or false + */ + private function discover($className, $currentClass = null) + { + $currentClass = $currentClass ?: $className; + + /** The short version we've done this before and found it in cache */ + if (false !== $file = static::seen($className)) { + if (!$this->exists($className)) + if (is_callable($file)) + $file = $this->loadLastResort($className, $file); + elseif($file = stream_resolve_include_path($file)) + $file = static::loadFile($file); + + $this->alias($className, $currentClass); + return $file; + } + + /** We did not find it in cache, lets look for it shall we */ + + /** replace \ with / and _ in CLASS NAME with / = PSR-0 in 3 lines */ + $file = preg_replace("/\\\|_(?=\w+$)/", DIRECTORY_SEPARATOR, $className); + if (false === $file = stream_resolve_include_path("$file.php")) + return false; + + /** have we loaded this file before could this be an alias */ + if (in_array($file, get_included_files())) { + if (false !== $sameFile = array_search($file, static::$classMap)) + if (!$this->exists($className, $file)) + if (false !== strpos($sameFile, $className)) + $this->alias($sameFile, $className); + + return $file; + } + + $state = array_merge(get_declared_classes(), get_declared_interfaces()); + + if (false !== $result = static::loadFile($file)) { + + if ($this->exists($className, $file)) + $this->alias($className, $currentClass); + elseif (false != $diff = array_diff( + array_merge(get_declared_classes(), get_declared_interfaces()), $state)) + foreach ($diff as $autoLoaded) + if ($this->exists($autoLoaded, $file)) + if (false !== strpos($autoLoaded, $className)) + $this->alias($autoLoaded, $className); + + if (!$this->exists($currentClass)) + $result = false; + } + + return $result; + } + + /** + * Checks whether supplied string exists in a loaded class or interface. + * As a convenience the supplied $mapping can be the value for seen. + * + * @param $className string The class or interface to verify + * @param $mapping string (optional) value for map/seen if found to exist + * + * @return bool whether the class/interface exists without calling auto loader + */ + private function exists($className, $mapping = null) + { + if (class_exists($className, false) + || interface_exists($className, false)) + if (isset($mapping)) + return static::seen($className, $mapping); + else + return true; + return false; + } + + /** + * Auto loader callback through __invoke object as function. + * + * @param $className string class/interface name to auto load + * + * @return mixed|null the reference from the include or null + */ + public function __invoke($className) + { + if (empty($className)) + return false; + + if (false !== $includeReference = $this->discover($className)) + return $includeReference; + + static::thereCanBeOnlyOne(); + + if (false !== $includeReference = $this->loadAliases($className)) + return $includeReference; + + if (false !== $includeReference = $this->loadPrefixes($className)) + return $includeReference; + + if (false !== $includeReference = $this->loadLastResort($className)) + return $includeReference; + + static::seen($className, true); + return null; + } @@ -464,0 +434 @@ +} @@ -467,12 +437,11 @@ - /** - * Include function in the root namespace to include files optimized - * for the global context. - * - * @param $path string path of php file to include into the global context. - * - * @return mixed|bool false if the file could not be included. - */ - function Luracast_Restler_autoloaderInclude($path) - { - return include $path; - } + /** + * Include function in the root namespace to include files optimized + * for the global context. + * + * @param $path string path of php file to include into the global context. + * + * @return mixed|bool false if the file could not be included. + */ + function Luracast_Restler_autoloaderInclude($path) { + return include $path; + } @@ -479,0 +449 @@ + --- /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/github_19.0.3_CommentParser.php +++ /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/client_CommentParser.php @@ -2 +1,0 @@ - @@ -18 +17 @@ - * + * @version 3.0.0rc6 @@ -22,500 +21,496 @@ - /** - * name for the embedded data - * - * @var string - */ - public static $embeddedDataName = 'properties'; - /** - * Regular Expression pattern for finding the embedded data and extract - * the inner information. It is used with preg_match. - * - * @var string - */ - public static $embeddedDataPattern - = '/```(\w*)[\s]*(([^`]*`{0,2}[^`]+)*)```/ms'; - /** - * Pattern will have groups for the inner details of embedded data - * this index is used to locate the data portion. - * - * @var int - */ - public static $embeddedDataIndex = 2; - /** - * Delimiter used to split the array data. - * - * When the name portion is of the embedded data is blank auto detection - * will be used and if URLEncodedFormat is detected as the data format - * the character specified will be used as the delimiter to find split - * array data. - * - * @var string - */ - public static $arrayDelimiter = ','; - - /** - * @var array annotations that support array value - */ - public static $allowsArrayValue = array( - 'choice' => true, - 'select' => true, - 'properties' => true, - ); - - /** - * character sequence used to escape \@ - */ - const escapedAtChar = '\\@'; - - /** - * character sequence used to escape end of comment - */ - const escapedCommendEnd = '{@*}'; - - /** - * Instance of Restler class injected at runtime. - * - * @var Restler - */ - public $restler; - /** - * Comment information is parsed and stored in to this array. - * - * @var array - */ - private $_data = array(); - - /** - * Parse the comment and extract the data. - * - * @static - * - * @param $comment - * @param bool $isPhpDoc - * - * @return array associative array with the extracted values - */ - public static function parse($comment, $isPhpDoc = true) - { - $p = new self(); - if (empty($comment)) { - return $p->_data; - } - - if ($isPhpDoc) { - $comment = self::removeCommentTags($comment); - } - - $p->extractData($comment); - return $p->_data; - } - - /** - * Removes the comment tags from each line of the comment. - * - * @static - * - * @param string $comment PhpDoc style comment - * - * @return string comments with out the tags - */ - public static function removeCommentTags($comment) - { - $pattern = '/(^\/\*\*)|(^\s*\**[ \/]?)|\s(?=@)|\s\*\//m'; - return preg_replace($pattern, '', $comment); - } - - /** - * Extracts description and long description, uses other methods to get - * parameters. - * - * @param $comment - * - * @return array - */ - private function extractData($comment) - { - //to use @ as part of comment we need to - $comment = str_replace( - array(self::escapedCommendEnd, self::escapedAtChar), - array('*/', '@'), - $comment); - - $description = array(); - $longDescription = array(); - $params = array(); - - $mode = 0; // extract short description; - $comments = preg_split("/(\r?\n)/", $comment); - // remove first blank line; - array_shift($comments); - $addNewline = false; - foreach ($comments as $line) { - $line = trim($line); - $newParam = false; - if (empty($line)) { - if ($mode == 0) { - $mode++; - } else { - $addNewline = true; - } - continue; - } elseif ($line[0] == '@') { - $mode = 2; - $newParam = true; - } - switch ($mode) { - case 0 : - $description[] = $line; - if (count($description) > 3) { - // if more than 3 lines take only first line - $longDescription = $description; - $description[] = array_shift($longDescription); - $mode = 1; - } elseif (substr($line, -1) == '.') { - $mode = 1; - } - break; - case 1 : - if ($addNewline) { - $line = ' ' . $line; - } - $longDescription[] = $line; - break; - case 2 : - $newParam - ? $params[] = $line - : $params[count($params) - 1] .= ' ' . $line; - } - $addNewline = false; - } - $description = implode(' ', $description); - $longDescription = implode(' ', $longDescription); - $description = preg_replace('/\s+/msu', ' ', $description); - $longDescription = preg_replace('/\s+/msu', ' ', $longDescription); - list($description, $d1) - = $this->parseEmbeddedData($description); - list($longDescription, $d2) - = $this->parseEmbeddedData($longDescription); - $this->_data = compact('description', 'longDescription'); - $d2 += $d1; - if (!empty($d2)) { - $this->_data[self::$embeddedDataName] = $d2; - } - foreach ($params as $key => $line) { - list(, $param, $value) = preg_split('/\@|\s/', $line, 3) - + array('', '', ''); - list($value, $embedded) = $this->parseEmbeddedData($value); - $value = array_filter(preg_split('/\s+/msu', $value), 'strlen'); - $this->parseParam($param, $value, $embedded); - } - return $this->_data; - } - - /** - * Parse parameters that begin with (at) - * - * @param $param - * @param array $value - * @param array $embedded - */ - private function parseParam($param, array $value, array $embedded) - { - $data = &$this->_data; - $allowMultiple = false; - switch ($param) { - case 'param' : - case 'property' : - case 'property-read' : - case 'property-write' : - $value = $this->formatParam($value); - $allowMultiple = true; - break; - case 'var' : - $value = $this->formatVar($value); - break; - case 'return' : - $value = $this->formatReturn($value); - break; - case 'class' : - $data = &$data[$param]; - list ($param, $value) = $this->formatClass($value); - break; - case 'access' : - $value = reset($value); - break; - case 'expires' : - case 'status' : - $value = intval(reset($value)); - break; - case 'throws' : - $value = $this->formatThrows($value); - $allowMultiple = true; - break; - case 'author': - $value = $this->formatAuthor($value); - $allowMultiple = true; - break; - case 'header' : - case 'link': - case 'example': - case 'todo': - $allowMultiple = true; - //don't break, continue with code for default: - default : - $value = implode(' ', $value); - } - if (!empty($embedded)) { - if (is_string($value)) { - $value = array('description' => $value); - } - $value[self::$embeddedDataName] = $embedded; - } - if (empty($data[$param])) { - if ($allowMultiple) { - $data[$param] = array( - $value - ); - } else { - $data[$param] = $value; - } - } elseif ($allowMultiple) { - $data[$param][] = $value; - } elseif ($param == 'param') { - $arr = array( - $data[$param], - $value - ); - $data[$param] = $arr; - } else { - if (!is_string($value) && isset($value[self::$embeddedDataName]) - && isset($data[$param][self::$embeddedDataName]) - ) { - $value[self::$embeddedDataName] - += $data[$param][self::$embeddedDataName]; - } - if (!is_array($data[$param])) { - $data[$param] = array('description' => (string) $data[$param]); - } - if (is_array($value)) { - $data[$param] = $value + $data[$param]; - } - } - } - - /** - * Parses the inline php doc comments and embedded data. - * - * @param $subject - * - * @return array - * @throws Exception - */ - private function parseEmbeddedData($subject) - { - $data = array(); - - //parse {@pattern } tags specially - while (preg_match('|(?s-m)({@pattern (/.+/[imsxuADSUXJ]*)})|', $subject, $matches)) { - $subject = str_replace($matches[0], '', $subject); - $data['pattern'] = $matches[2]; - } - while (preg_match('/{@(\w+)\s?([^}]*)}/ms', $subject, $matches)) { - $name = $matches[1]; - $value = $matches[2]; - $subject = str_replace($matches[0], '', $subject); - if ($name == 'pattern') { - throw new Exception('Inline pattern tag should follow {@pattern /REGEX_PATTERN_HERE/} format and can optionally include PCRE modifiers following the ending `/`'); - } elseif (isset(static::$allowsArrayValue[$name])) { - $value = explode(static::$arrayDelimiter, $value); - } elseif ($value == 'true' || $value == 'false') { - $value = $value == 'true'; - } elseif ($value == '') { - $value = true; - } elseif ($name == 'required') { - $value = explode(static::$arrayDelimiter, $value); - } - if (defined('Luracast\\Restler\\UI\\HtmlForm::'.$name)) { - $value = constant($value); - } - $data[$name] = $value; - } - - while (preg_match(self::$embeddedDataPattern, $subject, $matches)) { - $subject = str_replace($matches[0], '', $subject); - $str = $matches[self::$embeddedDataIndex]; - if (isset($this->restler) - && self::$embeddedDataIndex > 1 - && !empty($name) - ) { - $extension = $name; - $formatMap = $this->restler->getFormatMap(); - if (isset($formatMap[$extension])) { - /** - * @var \Luracast\Restler\Format\iFormat - */ - $format = $formatMap[$extension]; - $format = new $format(); - $data = $format->decode($str); - } - } else { // auto detect - if ($str[0] == '{') { - $d = json_decode($str, true); - if (json_last_error() != JSON_ERROR_NONE) { - throw new Exception('Error parsing embedded JSON data' - . " $str"); - } - $data = $d + $data; - } else { - parse_str($str, $d); - //clean up - $d = array_filter($d); - foreach ($d as $key => $val) { - $kt = trim($key); - if ($kt != $key) { - unset($d[$key]); - $key = $kt; - $d[$key] = $val; - } - if (is_string($val)) { - if ($val == 'true' || $val == 'false') { - $d[$key] = $val == 'true' ? true : false; - } else { - $val = explode(self::$arrayDelimiter, $val); - if (count($val) > 1) { - $d[$key] = $val; - } else { - $d[$key] = - preg_replace('/\s+/msu', ' ', - $d[$key]); - } - } - } - } - $data = $d + $data; - } - } - } - return array($subject, $data); - } - - private function formatThrows(array $value) - { - $code = 500; - $exception = 'Exception'; - if (count($value) > 1) { - $v1 = empty($value[0]) ? null : $value[0]; - $v2 = empty($value[1]) ? null : $value[1]; - if (is_numeric($v1)) { - $code = $v1; - $exception = $v2; - array_shift($value); - array_shift($value); - } elseif (is_numeric($v2)) { - $code = $v2; - $exception = $v1; - array_shift($value); - array_shift($value); - } else { - $exception = $v1; - array_shift($value); - } - } elseif (count($value) && isset($value[0]) && is_numeric($value[0])) { - $code = $value[0]; - array_shift($value); - } - $message = implode(' ', $value); - if (!isset(RestException::$codes[$code])) { - $code = 500; - } elseif (empty($message)) { - $message = RestException::$codes[$code]; - } - return compact('code', 'message', 'exception'); - } - - private function formatClass(array $value) - { - $param = array_shift($value); - - if (empty($param)) { - $param = 'Unknown'; - } - $value = implode(' ', $value); - return array( - ltrim($param, '\\'), - array('description' => $value) - ); - } - - private function formatAuthor(array $value) - { - $r = array(); - $email = end($value); - if ($email[0] == '<') { - $email = substr($email, 1, -1); - array_pop($value); - $r['email'] = $email; - } - $r['name'] = implode(' ', $value); - return $r; - } - - private function formatReturn(array $value) - { - $data = explode('|', array_shift($value)); - $r = array( - 'type' => count($data) == 1 ? $data[0] : $data - ); - $r['description'] = implode(' ', $value); - return $r; - } - - private function formatParam(array $value) - { - $r = array(); - $data = array_shift($value); - if (empty($data)) { - $r['type'] = 'mixed'; - } elseif ($data[0] == '$') { - $r['name'] = substr($data, 1); - $r['type'] = 'mixed'; - } else { - $data = explode('|', $data); - $r['type'] = count($data) == 1 ? $data[0] : $data; - - $data = array_shift($value); - if (!empty($data) && $data[0] == '$') { - $r['name'] = substr($data, 1); - } - } - if (isset($r['type']) && is_string($r['type']) && Text::endsWith($r['type'], '[]')) { - $r[static::$embeddedDataName]['type'] = substr($r['type'], 0, -2); - $r['type'] = 'array'; - } - if ($value) { - $r['description'] = implode(' ', $value); - } - return $r; - } - - private function formatVar(array $value) - { - $r = array(); - $data = array_shift($value); - if (empty($data)) { - $r['type'] = 'mixed'; - } elseif ($data[0] == '$') { - $r['name'] = substr($data, 1); - $r['type'] = 'mixed'; - } else { - $data = explode('|', $data); - $r['type'] = count($data) == 1 ? $data[0] : $data; - } - if (isset($r['type']) && Text::endsWith($r['type'], '[]')) { - $r[static::$embeddedDataName]['type'] = substr($r['type'], 0, -2); - $r['type'] = 'array'; - } - if ($value) { - $r['description'] = implode(' ', $value); - } - return $r; - } + /** + * name for the embedded data + * + * @var string + */ + public static $embeddedDataName = 'properties'; + /** + * Regular Expression pattern for finding the embedded data and extract + * the inner information. It is used with preg_match. + * + * @var string + */ + public static $embeddedDataPattern + = '/```(\w*)[\s]*(([^`]*`{0,2}[^`]+)*)```/ms'; + /** + * Pattern will have groups for the inner details of embedded data + * this index is used to locate the data portion. + * + * @var int + */ + public static $embeddedDataIndex = 2; + /** + * Delimiter used to split the array data. + * + * When the name portion is of the embedded data is blank auto detection + * will be used and if URLEncodedFormat is detected as the data format + * the character specified will be used as the delimiter to find split + * array data. + * + * @var string + */ + public static $arrayDelimiter = ','; + + /** + * @var array annotations that support array value + */ + public static $allowsArrayValue = array( + 'choice' => true, + 'select' => true, + 'properties' => true, + ); + + /** + * character sequence used to escape \@ + */ + const escapedAtChar = '\\@'; + + /** + * character sequence used to escape end of comment + */ + const escapedCommendEnd = '{@*}'; + + /** + * Instance of Restler class injected at runtime. + * + * @var Restler + */ + public $restler; + /** + * Comment information is parsed and stored in to this array. + * + * @var array + */ + private $_data = array(); + + /** + * Parse the comment and extract the data. + * + * @static + * + * @param $comment + * @param bool $isPhpDoc + * + * @return array associative array with the extracted values + */ + public static function parse($comment, $isPhpDoc = true) + { + $p = new self(); + if (empty($comment)) { + return $p->_data; + } + + if ($isPhpDoc) { + $comment = self::removeCommentTags($comment); + } + + $p->extractData($comment); + return $p->_data; + + } + + /** + * Removes the comment tags from each line of the comment. + * + * @static + * + * @param string $comment PhpDoc style comment + * + * @return string comments with out the tags + */ + public static function removeCommentTags($comment) + { + $pattern = '/(^\/\*\*)|(^\s*\**[ \/]?)|\s(?=@)|\s\*\//m'; + return preg_replace($pattern, '', $comment); + } + + /** + * Extracts description and long description, uses other methods to get + * parameters. + * + * @param $comment + * + * @return array + */ + private function extractData($comment) + { + //to use @ as part of comment we need to + $comment = str_replace( + array(self::escapedCommendEnd, self::escapedAtChar), + array('*/', '@'), + $comment); + + $description = array(); + $longDescription = array(); + $params = array(); + + $mode = 0; // extract short description; + $comments = preg_split("/(\r?\n)/", $comment); + // remove first blank line; + array_shift($comments); + $addNewline = false; + foreach ($comments as $line) { + $line = trim($line); + $newParam = false; + if (empty ($line)) { + if ($mode == 0) { + $mode++; + } else { + $addNewline = true; + } + continue; + } elseif ($line[0] == '@') { + $mode = 2; + $newParam = true; + } + switch ($mode) { + case 0 : + $description[] = $line; + if (count($description) > 3) { + // if more than 3 lines take only first line + $longDescription = $description; + $description[] = array_shift($longDescription); + $mode = 1; + } elseif (substr($line, -1) == '.') { + $mode = 1; + } + break; + case 1 : + if ($addNewline) { + $line = ' ' . $line; + } + $longDescription[] = $line; + break; + case 2 : + $newParam + ? $params[] = $line + : $params[count($params) - 1] .= ' ' . $line; + } + $addNewline = false; + } + $description = implode(' ', $description); + $longDescription = implode(' ', $longDescription); + $description = preg_replace('/\s+/msu', ' ', $description); + $longDescription = preg_replace('/\s+/msu', ' ', $longDescription); + list($description, $d1) + = $this->parseEmbeddedData($description); + list($longDescription, $d2) + = $this->parseEmbeddedData($longDescription); + $this->_data = compact('description', 'longDescription'); + $d2 += $d1; + if (!empty($d2)) { + $this->_data[self::$embeddedDataName] = $d2; + } + foreach ($params as $key => $line) { + list(, $param, $value) = preg_split('/\@|\s/', $line, 3) + + array('', '', ''); + list($value, $embedded) = $this->parseEmbeddedData($value); + $value = array_filter(preg_split('/\s+/msu', $value), 'strlen'); + $this->parseParam($param, $value, $embedded); + } + return $this->_data; + } + + /** + * Parse parameters that begin with (at) + * + * @param $param + * @param array $value + * @param array $embedded + */ + private function parseParam($param, array $value, array $embedded) + { + $data = & $this->_data; + $allowMultiple = false; + switch ($param) { + case 'param' : + case 'property' : + case 'property-read' : + case 'property-write' : + $value = $this->formatParam($value); + $allowMultiple = true; + break; + case 'var' : + $value = $this->formatVar($value); + break; + case 'return' : + $value = $this->formatReturn($value); + break; + case 'class' : + $data = & $data[$param]; + list ($param, $value) = $this->formatClass($value); + break; + case 'access' : + $value = reset($value); + break; + case 'expires' : + case 'status' : + $value = intval(reset($value)); + break; + case 'throws' : + $value = $this->formatThrows($value); + $allowMultiple = true; + break; + case 'author': + $value = $this->formatAuthor($value); + $allowMultiple = true; + break; + case 'header' : + case 'link': + case 'example': + case 'todo': + $allowMultiple = true; + //don't break, continue with code for default: + default : + $value = implode(' ', $value); + } + if (!empty($embedded)) { + if (is_string($value)) { + $value = array('description' => $value); + } + $value[self::$embeddedDataName] = $embedded; + } + if (empty ($data[$param])) { + if ($allowMultiple) { + $data[$param] = array( + $value + ); + } else { + $data[$param] = $value; + } + } elseif ($allowMultiple) { + $data[$param][] = $value; + } elseif ($param == 'param') { + $arr = array( + $data[$param], + $value + ); + $data[$param] = $arr; + } else { + if (!is_string($value) && isset($value[self::$embeddedDataName]) + && isset($data[$param][self::$embeddedDataName]) + ) { + $value[self::$embeddedDataName] + += $data[$param][self::$embeddedDataName]; + } + if (!is_array($data[$param])) { + $data[$param] = array('description' => (string) $data[$param]); + } + if (is_array($value)) { + $data[$param] = $value + $data[$param]; + } + } + } + + /** + * Parses the inline php doc comments and embedded data. + * + * @param $subject + * + * @return array + * @throws Exception + */ + private function parseEmbeddedData($subject) + { + $data = array(); + + //parse {@pattern } tags specially + while (preg_match('|(?s-m)({@pattern (/.+/[imsxuADSUXJ]*)})|', $subject, $matches)) { + $subject = str_replace($matches[0], '', $subject); + $data['pattern'] = $matches[2]; + } + while (preg_match('/{@(\w+)\s?([^}]*)}/ms', $subject, $matches)) { + $subject = str_replace($matches[0], '', $subject); + if ($matches[1] == 'pattern') { + throw new Exception('Inline pattern tag should follow {@pattern /REGEX_PATTERN_HERE/} format and can optionally include PCRE modifiers following the ending `/`'); + } elseif (isset(static::$allowsArrayValue[$matches[1]])) { + $matches[2] = explode(static::$arrayDelimiter, $matches[2]); + } elseif ($matches[2] == 'true' || $matches[2] == 'false') { + $matches[2] = $matches[2] == 'true'; + } elseif ($matches[2] == '') { + $matches[2] = true; + } elseif ($matches[1] == 'required') { + $matches[2] = explode(static::$arrayDelimiter, $matches[2]); + } + $data[$matches[1]] = $matches[2]; + } + + while (preg_match(self::$embeddedDataPattern, $subject, $matches)) { + $subject = str_replace($matches[0], '', $subject); + $str = $matches[self::$embeddedDataIndex]; + if (isset ($this->restler) + && self::$embeddedDataIndex > 1 + && !empty ($matches[1]) + ) { + $extension = $matches[1]; + $formatMap = $this->restler->getFormatMap(); + if (isset ($formatMap[$extension])) { + /** + * @var \Luracast\Restler\Format\iFormat + */ + $format = $formatMap[$extension]; + $format = new $format(); + $data = $format->decode($str); + } + } else { // auto detect + if ($str[0] == '{') { + $d = json_decode($str, true); + if (json_last_error() != JSON_ERROR_NONE) { + throw new Exception('Error parsing embedded JSON data' + . " $str"); + } + $data = $d + $data; + } else { + parse_str($str, $d); + //clean up + $d = array_filter($d); + foreach ($d as $key => $val) { + $kt = trim($key); + if ($kt != $key) { + unset($d[$key]); + $key = $kt; + $d[$key] = $val; + } + if (is_string($val)) { + if ($val == 'true' || $val == 'false') { + $d[$key] = $val == 'true' ? true : false; + } else { + $val = explode(self::$arrayDelimiter, $val); + if (count($val) > 1) { + $d[$key] = $val; + } else { + $d[$key] = + preg_replace('/\s+/msu', ' ', + $d[$key]); + } + } + } + } + $data = $d + $data; + } + } + } + return array($subject, $data); + } + + private function formatThrows(array $value) + { + $code = 500; + $exception = 'Exception'; + if(count($value)>1){ + $v1 = $value[0]; + $v2 = $value[1]; + if(is_numeric($v1)){ + $code = $v1; + $exception = $v2; + array_shift($value); + array_shift($value); + } elseif(is_numeric($v2)){ + $code = $v2; + $exception = $v1; + array_shift($value); + array_shift($value); + } else { + $exception = $v1; + array_shift($value); + } + } elseif(count($value) && is_numeric($value[0])) { + $code = $value[0]; + array_shift($value); + } + $message = implode(' ', $value); + if(!isset(RestException::$codes[$code])){ + $code = 500; + } elseif(empty($message)){ + $message = RestException::$codes[$code]; + } + return compact('code','message','exception'); + } + + private function formatClass(array $value) + { + $param = array_shift($value); + + if (empty($param)) { + $param = 'Unknown'; + } + $value = implode(' ', $value); + return array( + ltrim($param, '\\'), + array('description' => $value) + ); + } + + private function formatAuthor(array $value) + { + $r = array(); + $email = end($value); + if ($email[0] == '<') { + $email = substr($email, 1, -1); + array_pop($value); + $r['email'] = $email; + } + $r['name'] = implode(' ', $value); + return $r; + } + + private function formatReturn(array $value) + { + $data = explode('|', array_shift($value)); + $r = array( + 'type' => count($data) == 1 ? $data[0] : $data + ); + $r['description'] = implode(' ', $value); + return $r; + } + + private function formatParam(array $value) + { + $r = array(); + $data = array_shift($value); + if (empty($data)) { + $r['type'] = 'mixed'; + } elseif ($data[0] == '$') { + $r['name'] = substr($data, 1); + $r['type'] = 'mixed'; + } else { + $data = explode('|', $data); + $r['type'] = count($data) == 1 ? $data[0] : $data; + + $data = array_shift($value); + if (!empty($data) && $data[0] == '$') { + $r['name'] = substr($data, 1); + } + } + if (isset($r['type']) && is_string($r['type']) && Text::endsWith($r['type'], '[]')) { + $r[static::$embeddedDataName]['type'] = substr($r['type'], 0, -2); + $r['type'] = 'array'; + } + if ($value) { + $r['description'] = implode(' ', $value); + } + return $r; + } + + private function formatVar(array $value) + { + $r = array(); + $data = array_shift($value); + if (empty($data)) { + $r['type'] = 'mixed'; + } elseif ($data[0] == '$') { + $r['name'] = substr($data, 1); + $r['type'] = 'mixed'; + } else { + $data = explode('|', $data); + $r['type'] = count($data) == 1 ? $data[0] : $data; + } + if (isset($r['type']) && Text::endsWith($r['type'], '[]')) { + $r[static::$embeddedDataName]['type'] = substr($r['type'], 0, -2); + $r['type'] = 'array'; + } + if ($value) { + $r['description'] = implode(' ', $value); + } + return $r; + } --- /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/github_19.0.3_Compose.php +++ /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/client_Compose.php @@ -14 +14 @@ - * + * @version 3.0.0rc6 --- /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/github_19.0.3_Defaults.php +++ /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/client_Defaults.php @@ -18 +18 @@ - * + * @version 3.0.0rc6 --- /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/github_19.0.3_EventDispatcher.php +++ /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/client_EventDispatcher.php @@ -12 +12 @@ - * + * @version 3.0.0rc6 --- /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/github_19.0.3_Flash.php +++ /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/client_Flash.php @@ -18 +18 @@ - * + * @version 3.0.0rc6 --- /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/github_19.0.3_HumanReadableCache.php +++ /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/client_HumanReadableCache.php @@ -13 +13 @@ - * + * @version 3.0.0rc6 --- /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/github_19.0.3_InvalidAuthCredentials.php +++ /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/client_InvalidAuthCredentials.php @@ -15 +15 @@ - * + * @version 3.0.0rc6 --- /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/github_19.0.3_PassThrough.php +++ /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/client_PassThrough.php @@ -13 +13 @@ - * + * @version 3.0.0rc6 --- /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/github_19.0.3_Redirect.php +++ /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/client_Redirect.php @@ -15 +15 @@ - * + * @version 3.0.0rc6 --- /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/github_19.0.3_Resources.php +++ /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/client_Resources.php @@ -18 +18 @@ - * + * @version 3.0.0rc6 --- /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/github_19.0.3_RestException.php +++ /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/client_RestException.php @@ -17 +17 @@ - * + * @version 3.0.0rc6 --- /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/github_19.0.3_Restler.php +++ /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/client_Restler.php @@ -18 +17,0 @@ - * @@ -25 +24 @@ - * + * @version 3.0.0rc6 @@ -52,3 +50,0 @@ - * - * @property bool|null _authenticated - * @property bool _authVerified @@ -58 +54 @@ - const VERSION = '3.1.0'; + const VERSION = '3.0.0rc6'; @@ -700,2 +695,0 @@ - * - * @throws RestException --- /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/github_19.0.3_Routes.php +++ /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/client_Routes.php @@ -20 +20 @@ - * + * @version 3.0.0rc6 --- /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/github_19.0.3_Scope.php +++ /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/client_Scope.php @@ -2,2 +1,0 @@ - - @@ -16 +14 @@ - * + * @version 3.0.0rc6 @@ -50,2 +48,2 @@ - 'Explorer1' => 'Luracast\Restler\Explorer\v1\Explorer', - 'Explorer2' => 'Luracast\Restler\Explorer\v2\Explorer', + 'Explorer1' => 'Luracast\Restler\Explorer\v1\Explorer', + 'Explorer2' => 'Luracast\Restler\Explorer\v2\Explorer', @@ -125 +122,0 @@ - /** @var Restler restler */ @@ -144 +141 @@ - $r->restler && $r->restler->_authVerified && + static::get('Restler')->_authVerified && @@ -148 +145,2 @@ - $r->__setAuthenticationStatus($r->restler->_authenticated); + $r->__setAuthenticationStatus + (static::get('Restler')->_authenticated); @@ -151 +149 @@ - $m = Util::nestedValue($r->restler, 'apiMethodInfo', 'metadata'); + $m = Util::nestedValue(static::get('Restler'), 'apiMethodInfo', 'metadata'); @@ -199 +197 @@ - if (empty($className) || !is_string($className)) { + if (empty($className) || !is_string($className)) @@ -201 +198,0 @@ - } @@ -207,0 +205 @@ + $qualified = false; @@ -215 +213 @@ - if (class_exists($qualified)) { + if (class_exists($qualified)) @@ -217 +214,0 @@ - } @@ -220 +217 @@ - if (class_exists($qualified)) { + if (class_exists($qualified)) @@ -222 +218,0 @@ - } @@ -229 +224,0 @@ - * --- /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/github_19.0.3_User.php +++ /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/client_User.php @@ -14 +14 @@ - * + * @version 3.0.0rc6 --- /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/github_19.0.3_Util.php +++ /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/client_Util.php @@ -2 +1,0 @@ - @@ -4 +2,0 @@ - @@ -14 +12 @@ - * + * @version 3.0.0rc6 @@ -55,2 +53,2 @@ - * @param array|object $from array to extract the value from - * @param string|array $key ... pass more to go deeply inside the array + * @param array $from array to extract the value from + * @param string|array $key ... pass more to go deeply inside the array @@ -82,5 +80,4 @@ - public static function getResourcePath( - $className, - $resourcePath = null, - $prefix = '' - ) { + public static function getResourcePath($className, + $resourcePath = null, + $prefix = '') + { @@ -90 +87 @@ - if (false !== ($index = strrpos($className, '\\'))) { + if (false !== ($index = strrpos($className, '\\'))) @@ -92,2 +89 @@ - } - if (false !== ($index = strrpos($resourcePath, '_'))) { + if (false !== ($index = strrpos($resourcePath, '_'))) @@ -95 +90,0 @@ - } @@ -99 +94 @@ - } else { + } else @@ -101,2 +96 @@ - } - if (strlen($resourcePath) > 0) { + if (strlen($resourcePath) > 0) @@ -104 +97,0 @@ - } @@ -124 +117 @@ - if (empty($fromPath)) { + if (empty($fromPath)) @@ -126 +118,0 @@ - } @@ -156 +148 @@ - if (empty($fromPath)) { + if (empty($fromPath)) @@ -158 +149,0 @@ - } @@ -225,12 +216,5 @@ - $parts = explode(';', $accept); - $type = trim(array_shift($parts)); - $parameters = []; - foreach ($parts as $part) { - $part = explode('=', $part); - if (2 !== count($part)) { - continue; - } - $key = strtolower(trim($part[0])); - $parameters[$key] = trim($part[1], ' "'); - } - $quality = isset($parameters['q']) ? (float)$parameters['q'] : (1000 - $pos) / 1000; + $parts = explode(';q=', trim($accept)); + $type = array_shift($parts); + $quality = count($parts) ? + floatval(array_shift($parts)) : + (1000 - $pos) / 1000; @@ -246 +230,2 @@ - if (!is_string($className)) return; + if (! is_string($className)) return ''; + //var_dump($className); --- /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/github_19.0.3_iAuthenticate.php +++ /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/client_iAuthenticate.php @@ -14 +14 @@ - * + * @version 3.0.0rc6 --- /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/github_19.0.3_iCache.php +++ /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/client_iCache.php @@ -12 +12 @@ - * + * @version 3.0.0rc6 --- /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/github_19.0.3_iCompose.php +++ /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/client_iCompose.php @@ -16 +16 @@ - * + * @version 3.0.0rc6 --- /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/github_19.0.3_iFilter.php +++ /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/client_iFilter.php @@ -15 +15 @@ - * + * @version 3.0.0rc6 --- /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/github_19.0.3_iIdentifyUser.php +++ /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/client_iIdentifyUser.php @@ -15 +15 @@ - * + * @version 3.0.0rc6 --- /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/github_19.0.3_iProvideMultiVersionApi.php +++ /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/client_iProvideMultiVersionApi.php @@ -8 +8 @@ - * + * @version 3.0.0rc6 --- /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/github_19.0.3_iUseAuthentication.php +++ /tmp/dsg/dolibarr/htdocs/includes/restler/framework/Luracast/Restler/client_iUseAuthentication.php @@ -14 +14 @@ - * + * @version 3.0.0rc6