From 5f05cdb26c3916d6ddb8c9d8647849025a81d24b Mon Sep 17 00:00:00 2001 From: Dennis Iversen Date: Mon, 7 Sep 2015 15:21:00 +0200 Subject: [PATCH 01/17] UTF8 error --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index efc20f328..390f5d1e5 100644 --- a/README.md +++ b/README.md @@ -298,7 +298,7 @@ They are documented in detail under [Annotations](ANNOTATIONS.md) ### 6. Authorize -In order to protect your api, authenticate and allow valid users +In order to protect your api, authenticate and allow valid users ```php Date: Tue, 20 Oct 2015 15:28:45 +0100 Subject: [PATCH 02/17] Fix: typos --- public/examples/_015_oauth2_server/index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/examples/_015_oauth2_server/index.php b/public/examples/_015_oauth2_server/index.php index 3f00fa7e7..c867bf995 100755 --- a/public/examples/_015_oauth2_server/index.php +++ b/public/examples/_015_oauth2_server/index.php @@ -12,7 +12,7 @@ 1. run composer update to make sure you have - twig template library - - bshaffer's oauth2 libaray + - bshaffer's oauth2 libarary 2. make sure `public/examples/_015_oauth2_server/cache` has write permissions to create the compiled template files 3. make sure `public/examples/_015_oauth2_server/Auth/db` has write permission, this is where `oauth.sqlite` file be created at run time @@ -51,7 +51,7 @@ - **Implicit**: typically for browser based or mobile apps - **Authorization Code**: typically for apps running on a server -- **Password Credentials**: typically used for apps that are owned by the same organisation as the OAuth service +- **Password Credentials**: typically used for apps that are owned by the same organization as the OAuth service provider (aka, the Twitter client, etc.) - **Client Credentials**: used by client's who want to update meta information about their site (URL's, logo's, etc.) - **JWT Auth Grant**: the client submits a *JSON Web Token* in a request to the token endpoint. An access token @@ -136,4 +136,4 @@ $r = new Restler(); $r->addAuthenticationClass('Auth\\Server', ''); $r->setOverridingFormats('JsonFormat', 'HtmlFormat', 'UploadFormat'); -$r->handle(); \ No newline at end of file +$r->handle(); From a1b76c701cce8fa63142d8dc74911365b8d1b886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Pina?= Date: Tue, 20 Oct 2015 16:16:08 +0100 Subject: [PATCH 03/17] fix library typo --- public/examples/_015_oauth2_server/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/examples/_015_oauth2_server/index.php b/public/examples/_015_oauth2_server/index.php index c867bf995..edc82a1ad 100755 --- a/public/examples/_015_oauth2_server/index.php +++ b/public/examples/_015_oauth2_server/index.php @@ -12,7 +12,7 @@ 1. run composer update to make sure you have - twig template library - - bshaffer's oauth2 libarary + - bshaffer's oauth2 library 2. make sure `public/examples/_015_oauth2_server/cache` has write permissions to create the compiled template files 3. make sure `public/examples/_015_oauth2_server/Auth/db` has write permission, this is where `oauth.sqlite` file be created at run time From ac780ed5f89babcd964f89beb0bd1be9c5c49889 Mon Sep 17 00:00:00 2001 From: Alexander Makhaev Date: Sat, 9 Jan 2016 19:21:18 +0900 Subject: [PATCH 04/17] Fix for #357 --- vendor/Luracast/Restler/AutoLoader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/Luracast/Restler/AutoLoader.php b/vendor/Luracast/Restler/AutoLoader.php index 9bb34bad9..6e9a3dd17 100644 --- a/vendor/Luracast/Restler/AutoLoader.php +++ b/vendor/Luracast/Restler/AutoLoader.php @@ -263,7 +263,7 @@ private function loadAliases($className) * @return bool false unless className now exists */ private function loadLastResort($className, $loader = null) { - $loaders = array_unique(static::$rogueLoaders); + $loaders = array_unique(static::$rogueLoaders, SORT_REGULAR); if (isset($loader)) { if (false === array_search($loader, $loaders)) static::$rogueLoaders[] = $loader; From d7b76ba99d8e76b4e1ab70b67db92a92a200d993 Mon Sep 17 00:00:00 2001 From: Tymoteusz Motylewski Date: Wed, 12 Oct 2016 17:09:19 +0200 Subject: [PATCH 05/17] Fix typo @pformat => @format --- public/annotations.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/annotations.html b/public/annotations.html index 9663ae22f..f6032c553 100644 --- a/public/annotations.html +++ b/public/annotations.html @@ -325,7 +325,7 @@

@format

Example:

-
@pformat HtmlFormat
+
@format HtmlFormat
 

IF you want to force the request and or response format for a specific api method @format comment can be used

@@ -364,4 +364,4 @@

@errorView

- \ No newline at end of file + From 581d8d6dc5d37f439765f89725a92f85e98f1826 Mon Sep 17 00:00:00 2001 From: Luracast Date: Wed, 11 Jan 2017 11:42:36 +0800 Subject: [PATCH 06/17] Fix: PHP 7 compatibility by renaming String class as Text --- features/bootstrap/RestContext.php | 4 ++-- .../Restler/Data/{String.php => Text.php} | 2 +- vendor/Luracast/Restler/Resources.php | 16 ++++++++-------- vendor/Luracast/Restler/Routes.php | 4 ++-- vendor/Luracast/Restler/UI/Forms.php | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-) rename vendor/Luracast/Restler/Data/{String.php => Text.php} (99%) diff --git a/features/bootstrap/RestContext.php b/features/bootstrap/RestContext.php index 0f5cd0c1f..91fab2f3c 100644 --- a/features/bootstrap/RestContext.php +++ b/features/bootstrap/RestContext.php @@ -1,7 +1,7 @@ _data); - if (!String::contains($data, $response)) + if (!Text::contains($data, $response)) throw new Exception("Response value does not contain '$response' only\n\n" . $this->echoLastResponse()); } diff --git a/vendor/Luracast/Restler/Data/String.php b/vendor/Luracast/Restler/Data/Text.php similarity index 99% rename from vendor/Luracast/Restler/Data/String.php rename to vendor/Luracast/Restler/Data/Text.php index 268ca40c1..803d9a761 100644 --- a/vendor/Luracast/Restler/Data/String.php +++ b/vendor/Luracast/Restler/Data/Text.php @@ -11,7 +11,7 @@ * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link http://luracast.com/products/restler/ */ -class String +class Text { /** * Given haystack contains the needle or not? diff --git a/vendor/Luracast/Restler/Resources.php b/vendor/Luracast/Restler/Resources.php index 23d2407c4..420d26460 100644 --- a/vendor/Luracast/Restler/Resources.php +++ b/vendor/Luracast/Restler/Resources.php @@ -1,7 +1,7 @@ $tLen + 1 && $fullPath{$tLen + 1} != '{' && !String::beginsWith($fullPath, '{')) { + } elseif ($fLen > $tLen + 1 && $fullPath{$tLen + 1} != '{' && !Text::beginsWith($fullPath, '{')) { //when mapped to root exclude paths that have static parts //they are listed else where under that static part name continue; @@ -246,7 +246,7 @@ public function get($id = '') if (empty($exclude)) { if ($fullPath == $exclude) continue 2; - } elseif (String::beginsWith($fullPath, $exclude)) { + } elseif (Text::beginsWith($fullPath, $exclude)) { continue 2; } } @@ -891,7 +891,7 @@ public function index() } $this->_mapResources($allRoutes, $map, $version); foreach ($map as $path => $description) { - if (!String::contains($path, '{')) { + if (!Text::contains($path, '{')) { //add id $r->apis[] = array( 'path' => $path . $this->formatString, @@ -934,7 +934,7 @@ protected function _mapResources(array $allRoutes, array &$map, $version = 1) foreach ($allRoutes as $fullPath => $routes) { $path = explode('/', $fullPath); $resource = isset($path[0]) ? $path[0] : ''; - if ($resource == 'resources' || String::endsWith($resource, 'index')) + if ($resource == 'resources' || Text::endsWith($resource, 'index')) continue; foreach ($routes as $httpMethod => $route) { if (in_array($httpMethod, static::$excludedHttpMethods)) { @@ -948,7 +948,7 @@ protected function _mapResources(array $allRoutes, array &$map, $version = 1) if (empty($exclude)) { if ($fullPath == $exclude) continue 2; - } elseif (String::beginsWith($fullPath, $exclude)) { + } elseif (Text::beginsWith($fullPath, $exclude)) { continue 2; } } diff --git a/vendor/Luracast/Restler/Routes.php b/vendor/Luracast/Restler/Routes.php index 5b1128cb5..77209c7ac 100644 --- a/vendor/Luracast/Restler/Routes.php +++ b/vendor/Luracast/Restler/Routes.php @@ -2,7 +2,7 @@ namespace Luracast\Restler; use Luracast\Restler\Data\ApiMethodInfo; -use Luracast\Restler\Data\String; +use Luracast\Restler\Data\Text; use ReflectionClass; use ReflectionMethod; use ReflectionProperty; @@ -587,7 +587,7 @@ protected static function getTypeAndModel(ReflectionClass $class, array $scope) $children[$name] = $child; } } catch (Exception $e) { - if (String::endsWith($e->getFile(), 'CommentParser.php')) { + if (Text::endsWith($e->getFile(), 'CommentParser.php')) { throw new RestException(500, "Error while parsing comments of `$className` class. " . $e->getMessage()); } throw $e; diff --git a/vendor/Luracast/Restler/UI/Forms.php b/vendor/Luracast/Restler/UI/Forms.php index 289f40b6f..03a89dfbb 100644 --- a/vendor/Luracast/Restler/UI/Forms.php +++ b/vendor/Luracast/Restler/UI/Forms.php @@ -3,7 +3,7 @@ use Luracast\Restler\CommentParser; use Luracast\Restler\Data\ApiMethodInfo; -use Luracast\Restler\Data\String; +use Luracast\Restler\Data\Text; use Luracast\Restler\Data\ValidationInfo; use Luracast\Restler\Defaults; use Luracast\Restler\Format\UploadFormat; @@ -292,7 +292,7 @@ public static function field(ValidationInfo $p, $dataOnly = false) $options[] = $option; } } elseif ($p->type == 'boolean' || $p->type == 'bool') { - if (String::beginsWith($type, 'radio')) { + if (Text::beginsWith($type, 'radio')) { $options[] = array('name' => $p->name, 'text' => ' Yes ', 'value' => 'true'); $options[] = array('name' => $p->name, 'text' => ' No ', @@ -411,7 +411,7 @@ public function __isAllowed() if (empty($exclude)) { if ($url == $exclude) return true; - } elseif (String::beginsWith($url, $exclude)) { + } elseif (Text::beginsWith($url, $exclude)) { return true; } } From e94da23dae0d8524789c632404588cc668ec66bd Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Mon, 20 Mar 2017 17:02:16 +0900 Subject: [PATCH 07/17] Fix typo --- ANNOTATIONS.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ANNOTATIONS.md b/ANNOTATIONS.md index 2f307c4f9..ae980cd2c 100644 --- a/ANNOTATIONS.md +++ b/ANNOTATIONS.md @@ -179,7 +179,7 @@ iValueObject. @var int policy age {@min 18} {@max 100} When an api method is returning or having one of the parameters as an instance -of a custom class @var comments can be used with properties of that class. +of a custom class @var comments can be used with properties of that class. They will be used for validation and documentation. Supported child attributes are same as that of @param so they are documented under [@param](PARAM.md) @@ -223,4 +223,4 @@ Specify the view file to be loaded by HtmlFormat for the given api method as rel Similar to the `@view` but only used when an exception is thrown ---------------- \ No newline at end of file +--------------- From 3d454c8280995a941b968a424208ac0d70f1e299 Mon Sep 17 00:00:00 2001 From: Luracast Date: Thu, 16 Nov 2017 21:45:54 +0800 Subject: [PATCH 08/17] Fix for Notice: Only variables should be passed by reference in public/examples/_007_crud/DB/Session.php on line 58 --- public/examples/_007_crud/DB/Session.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/examples/_007_crud/DB/Session.php b/public/examples/_007_crud/DB/Session.php index 844c6650c..37244983a 100755 --- a/public/examples/_007_crud/DB/Session.php +++ b/public/examples/_007_crud/DB/Session.php @@ -55,7 +55,8 @@ function delete ($id) $index = $this->find($id); if ($index === FALSE) return FALSE; - return array_shift(array_splice($_SESSION['rs'], $index, 1)); + $record = array_splice($_SESSION['rs'], $index, 1); + return array_shift($record); } private function install () { From 097608f0772ca42f2858820e8886533a3cb99232 Mon Sep 17 00:00:00 2001 From: Luracast Date: Thu, 16 Nov 2017 21:57:30 +0800 Subject: [PATCH 09/17] [BUGFIX] Fix PHP 7.2 compatibility. Object is a reserved keyword. Fixes #591 --- .../Restler/Data/{Object.php => Obj.php} | 2 +- vendor/Luracast/Restler/Format/CsvFormat.php | 26 ++++---- vendor/Luracast/Restler/Format/HtmlFormat.php | 4 +- vendor/Luracast/Restler/Format/JsonFormat.php | 10 +-- .../Luracast/Restler/Format/PlistFormat.php | 4 +- vendor/Luracast/Restler/Format/XmlFormat.php | 4 +- vendor/Luracast/Restler/Format/YamlFormat.php | 4 +- vendor/Luracast/Restler/Scope.php | 64 +++++++++---------- 8 files changed, 59 insertions(+), 59 deletions(-) rename vendor/Luracast/Restler/Data/{Object.php => Obj.php} (99%) diff --git a/vendor/Luracast/Restler/Data/Object.php b/vendor/Luracast/Restler/Data/Obj.php similarity index 99% rename from vendor/Luracast/Restler/Data/Object.php rename to vendor/Luracast/Restler/Data/Obj.php index b34f82f0b..5978dbae9 100644 --- a/vendor/Luracast/Restler/Data/Object.php +++ b/vendor/Luracast/Restler/Data/Obj.php @@ -13,7 +13,7 @@ * @link http://luracast.com/products/restler/ * @version 3.0.0rc5 */ -class Object +class Obj { /** * @var bool|string|callable diff --git a/vendor/Luracast/Restler/Format/CsvFormat.php b/vendor/Luracast/Restler/Format/CsvFormat.php index c0dedf1b5..265070562 100644 --- a/vendor/Luracast/Restler/Format/CsvFormat.php +++ b/vendor/Luracast/Restler/Format/CsvFormat.php @@ -2,7 +2,7 @@ namespace Luracast\Restler\Format; -use Luracast\Restler\Data\Object; +use Luracast\Restler\Data\Obj; use Luracast\Restler\RestException; /** @@ -44,10 +44,10 @@ class CsvFormat extends Format implements iDecodeStream */ public function encode($data, $humanReadable = false) { - $char = Object::$separatorChar; - Object::$separatorChar = false; - $data = Object::toArray($data); - Object::$separatorChar = $char; + $char = Obj::$separatorChar; + Obj::$separatorChar = false; + $data = Obj::toArray($data); + Obj::$separatorChar = $char; if (is_array($data) && array_values($data) == $data) { //if indexed array $lines = array(); @@ -109,10 +109,10 @@ public function decode($data) while (($row = static::getRow(array_shift($lines), $keys)) !== FALSE) $decoded [] = $row; - $char = Object::$separatorChar; - Object::$separatorChar = false; - $decoded = Object::toArray($decoded); - Object::$separatorChar = $char; + $char = Obj::$separatorChar; + Obj::$separatorChar = false; + $decoded = Obj::toArray($decoded); + Obj::$separatorChar = $char; return $decoded; } @@ -172,10 +172,10 @@ public function decodeStream($stream) while (($row = static::getRow(stream_get_line($stream, 0, PHP_EOL), $keys)) !== FALSE) $decoded [] = $row; - $char = Object::$separatorChar; - Object::$separatorChar = false; - $decoded = Object::toArray($decoded); - Object::$separatorChar = $char; + $char = Obj::$separatorChar; + Obj::$separatorChar = false; + $decoded = Obj::toArray($decoded); + Obj::$separatorChar = $char; return $decoded; } } \ No newline at end of file diff --git a/vendor/Luracast/Restler/Format/HtmlFormat.php b/vendor/Luracast/Restler/Format/HtmlFormat.php index 65d2bb627..c9679990d 100644 --- a/vendor/Luracast/Restler/Format/HtmlFormat.php +++ b/vendor/Luracast/Restler/Format/HtmlFormat.php @@ -11,7 +11,7 @@ use Illuminate\View\FileViewFinder; use Illuminate\View\View; use Luracast\Restler\Data\ApiMethodInfo; -use Luracast\Restler\Data\Object; +use Luracast\Restler\Data\Obj; use Luracast\Restler\Defaults; use Luracast\Restler\RestException; use Luracast\Restler\Restler; @@ -313,7 +313,7 @@ public function encode($data, $humanReadable = false) $success = is_null($exception); $error = $success ? null : $exception->getMessage(); $data = array( - 'response' => Object::toArray($data), + 'response' => Obj::toArray($data), 'stages' => $this->restler->getEvents(), 'success' => $success, 'error' => $error diff --git a/vendor/Luracast/Restler/Format/JsonFormat.php b/vendor/Luracast/Restler/Format/JsonFormat.php index 1b7fd938c..e853181af 100644 --- a/vendor/Luracast/Restler/Format/JsonFormat.php +++ b/vendor/Luracast/Restler/Format/JsonFormat.php @@ -1,7 +1,7 @@ formatJson($result); if (self::$unEscapedUnicode) { $result = preg_replace_callback('/\\\u(\w\w\w\w)/', @@ -110,7 +110,7 @@ public function decode($data) if (function_exists('json_last_error')) { switch (json_last_error()) { case JSON_ERROR_NONE : - return Object::toArray($decoded); + return Obj::toArray($decoded); break; case JSON_ERROR_DEPTH : $message = 'maximum stack depth exceeded'; @@ -137,7 +137,7 @@ public function decode($data) throw new RestException (400, 'Error parsing JSON'); } - return Object::toArray($decoded); + return Obj::toArray($decoded); } /** diff --git a/vendor/Luracast/Restler/Format/PlistFormat.php b/vendor/Luracast/Restler/Format/PlistFormat.php index 2c645eb0d..d01a1c338 100644 --- a/vendor/Luracast/Restler/Format/PlistFormat.php +++ b/vendor/Luracast/Restler/Format/PlistFormat.php @@ -1,7 +1,7 @@ toCFType( - Object::toArray($data) + Obj::toArray($data) ); $plist->add($guessedStructure); diff --git a/vendor/Luracast/Restler/Format/XmlFormat.php b/vendor/Luracast/Restler/Format/XmlFormat.php index 52fe50c67..172544806 100644 --- a/vendor/Luracast/Restler/Format/XmlFormat.php +++ b/vendor/Luracast/Restler/Format/XmlFormat.php @@ -1,7 +1,7 @@ openMemory(); $xml->startDocument('1.0', $this->charset); diff --git a/vendor/Luracast/Restler/Format/YamlFormat.php b/vendor/Luracast/Restler/Format/YamlFormat.php index d87ad7bbc..373247220 100644 --- a/vendor/Luracast/Restler/Format/YamlFormat.php +++ b/vendor/Luracast/Restler/Format/YamlFormat.php @@ -2,7 +2,7 @@ namespace Luracast\Restler\Format; use Symfony\Component\Yaml\Yaml; -use Luracast\Restler\Data\Object; +use Luracast\Restler\Data\Obj; /** * YAML Format for Restler Framework @@ -24,7 +24,7 @@ class YamlFormat extends Format public function encode($data, $humanReadable = false) { // require_once 'sfyaml.php'; - return @Yaml::dump(Object::toArray($data)); + return @Yaml::dump(Obj::toArray($data)); } public function decode($data) diff --git a/vendor/Luracast/Restler/Scope.php b/vendor/Luracast/Restler/Scope.php index a6b1baae5..e6156c023 100644 --- a/vendor/Luracast/Restler/Scope.php +++ b/vendor/Luracast/Restler/Scope.php @@ -17,45 +17,45 @@ class Scope { public static $classAliases = array( - //Core - 'Restler' => 'Luracast\Restler\Restler', + //Core + 'Restler' => 'Luracast\Restler\Restler', - //Format classes - 'AmfFormat' => 'Luracast\Restler\Format\AmfFormat', - 'JsFormat' => 'Luracast\Restler\Format\JsFormat', - 'JsonFormat' => 'Luracast\Restler\Format\JsonFormat', - 'HtmlFormat' => 'Luracast\Restler\Format\HtmlFormat', - 'PlistFormat' => 'Luracast\Restler\Format\PlistFormat', - 'UploadFormat' => 'Luracast\Restler\Format\UploadFormat', - 'UrlEncodedFormat' => 'Luracast\Restler\Format\UrlEncodedFormat', - 'XmlFormat' => 'Luracast\Restler\Format\XmlFormat', - 'YamlFormat' => 'Luracast\Restler\Format\YamlFormat', - 'CsvFormat' => 'Luracast\Restler\Format\CsvFormat', - 'TsvFormat' => 'Luracast\Restler\Format\TsvFormat', + //Format classes + 'AmfFormat' => 'Luracast\Restler\Format\AmfFormat', + 'JsFormat' => 'Luracast\Restler\Format\JsFormat', + 'JsonFormat' => 'Luracast\Restler\Format\JsonFormat', + 'HtmlFormat' => 'Luracast\Restler\Format\HtmlFormat', + 'PlistFormat' => 'Luracast\Restler\Format\PlistFormat', + 'UploadFormat' => 'Luracast\Restler\Format\UploadFormat', + 'UrlEncodedFormat' => 'Luracast\Restler\Format\UrlEncodedFormat', + 'XmlFormat' => 'Luracast\Restler\Format\XmlFormat', + 'YamlFormat' => 'Luracast\Restler\Format\YamlFormat', + 'CsvFormat' => 'Luracast\Restler\Format\CsvFormat', + 'TsvFormat' => 'Luracast\Restler\Format\TsvFormat', - //Filter classes - 'RateLimit' => 'Luracast\Restler\Filter\RateLimit', + //Filter classes + 'RateLimit' => 'Luracast\Restler\Filter\RateLimit', - //UI classes - 'Forms' => 'Luracast\Restler\UI\Forms', - 'Nav' => 'Luracast\Restler\UI\Nav', - 'Emmet' => 'Luracast\Restler\UI\Emmet', - 'T' => 'Luracast\Restler\UI\Tags', + //UI classes + 'Forms' => 'Luracast\Restler\UI\Forms', + 'Nav' => 'Luracast\Restler\UI\Nav', + 'Emmet' => 'Luracast\Restler\UI\Emmet', + 'T' => 'Luracast\Restler\UI\Tags', - //API classes - 'Resources' => 'Luracast\Restler\Resources', + //API classes + 'Resources' => 'Luracast\Restler\Resources', - //Cache classes - 'HumanReadableCache' => 'Luracast\Restler\HumanReadableCache', - 'ApcCache' => 'Luracast\Restler\ApcCache', + //Cache classes + 'HumanReadableCache' => 'Luracast\Restler\HumanReadableCache', + 'ApcCache' => 'Luracast\Restler\ApcCache', - //Utility classes - 'Object' => 'Luracast\Restler\Data\Object', - 'String' => 'Luracast\Restler\Data\String', - 'Arr' => 'Luracast\Restler\Data\Arr', + //Utility classes + 'Obj' => 'Luracast\Restler\Data\Obj', + 'String' => 'Luracast\Restler\Data\String', + 'Arr' => 'Luracast\Restler\Data\Arr', - //Exception - 'RestException' => 'Luracast\Restler\RestException' + //Exception + 'RestException' => 'Luracast\Restler\RestException' ); public static $properties = array(); protected static $instances = array(); From cd0c21b4f7c0a99261ad618e90a5263483e78007 Mon Sep 17 00:00:00 2001 From: Luracast Date: Wed, 17 Jan 2018 16:18:17 +0800 Subject: [PATCH 10/17] [BUGFIX] making sure get source.php is not allow access files outside examples folder --- public/examples/resources/getsource.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/public/examples/resources/getsource.php b/public/examples/resources/getsource.php index 0a2104888..efc1c55c2 100755 --- a/public/examples/resources/getsource.php +++ b/public/examples/resources/getsource.php @@ -4,15 +4,19 @@ $require_comments = $file[0] == '.'; $file = '../' . $file; $filepath = realpath($file); - $basepath = realpath('../../'); - if (strpos($basepath, $filepath) === 0) { + $basepath = realpath('../../examples'); + if (strpos($filepath, $basepath) !== 0) { #trying to get the source outside restler examples die('not allowed'); } - if (!file_exists($file)) die('file not found'); + if (!file_exists($file)) { + die('file not found'); + } $text = file_get_contents($file); $file = pathinfo($file, PATHINFO_FILENAME) . '.php'; - if (!$require_comments) $text = strip_comments($text); + if (!$require_comments) { + $text = strip_comments($text); + } die($file . '
' . htmlspecialchars($text) . "
"); } else { die('no file specified'); From 188968f6a15796077350f1be9c461f8d02c559a8 Mon Sep 17 00:00:00 2001 From: Luracast Date: Fri, 16 Mar 2018 13:08:02 +0800 Subject: [PATCH 11/17] [BUGFIX] Fixes CommentParser to leave out 0 in @param and @var comments. Closes #504 --- vendor/Luracast/Restler/CommentParser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/Luracast/Restler/CommentParser.php b/vendor/Luracast/Restler/CommentParser.php index 839983b73..e86d1fbad 100644 --- a/vendor/Luracast/Restler/CommentParser.php +++ b/vendor/Luracast/Restler/CommentParser.php @@ -195,7 +195,7 @@ private function extractData($comment) list(, $param, $value) = preg_split('/\@|\s/', $line, 3) + array('', '', ''); list($value, $embedded) = $this->parseEmbeddedData($value); - $value = array_filter(preg_split('/\s+/msu', $value)); + $value = array_filter(preg_split('/\s+/msu', $value),'strlen'); $this->parseParam($param, $value, $embedded); } return $this->_data; From 565adbea26da4c6fc42808d6ab69e1c8f183cd69 Mon Sep 17 00:00:00 2001 From: Guillaume NOUET Date: Tue, 15 Jan 2019 13:10:03 +0100 Subject: [PATCH 12/17] Rename __getWWWAuthenticateString fonction PHP has reserved all method names with a double underscore prefix for future use. --- public/examples/_005_protected_api/SimpleAuth.php | 4 ++-- public/examples/_009_rate_limiting/KeyAuth.php | 2 +- public/examples/_010_access_control/AccessControl.php | 2 +- public/examples/_015_oauth2_server/Auth/Server.php | 2 +- vendor/Luracast/Restler/Restler.php | 2 +- vendor/Luracast/Restler/iAuthenticate.php | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/public/examples/_005_protected_api/SimpleAuth.php b/public/examples/_005_protected_api/SimpleAuth.php index 938d8ac67..78f9deca9 100755 --- a/public/examples/_005_protected_api/SimpleAuth.php +++ b/public/examples/_005_protected_api/SimpleAuth.php @@ -10,7 +10,7 @@ function __isAllowed() return isset($_GET['key']) && $_GET['key'] == SimpleAuth::KEY ? TRUE : FALSE; } - public function __getWWWAuthenticateString() + public function getWWWAuthenticateString() { return 'Query name="key"'; } @@ -19,4 +19,4 @@ function key() { return SimpleAuth::KEY; } -} \ No newline at end of file +} diff --git a/public/examples/_009_rate_limiting/KeyAuth.php b/public/examples/_009_rate_limiting/KeyAuth.php index 0309040aa..f9a07cd4b 100755 --- a/public/examples/_009_rate_limiting/KeyAuth.php +++ b/public/examples/_009_rate_limiting/KeyAuth.php @@ -8,7 +8,7 @@ public function __isAllowed() return isset($_GET['api_key']) && $_GET['api_key'] == 'r3rocks'; } - public function __getWWWAuthenticateString() + public function getWWWAuthenticateString() { return 'Query name="api_key"'; } diff --git a/public/examples/_010_access_control/AccessControl.php b/public/examples/_010_access_control/AccessControl.php index b242d947b..b9670f42c 100755 --- a/public/examples/_010_access_control/AccessControl.php +++ b/public/examples/_010_access_control/AccessControl.php @@ -28,7 +28,7 @@ public function __isAllowed() return static::$requires == static::$role || static::$role == 'admin'; } - public function __getWWWAuthenticateString() + public function getWWWAuthenticateString() { return 'Query name="api_key"'; } diff --git a/public/examples/_015_oauth2_server/Auth/Server.php b/public/examples/_015_oauth2_server/Auth/Server.php index e5fd11ab1..bdef647be 100644 --- a/public/examples/_015_oauth2_server/Auth/Server.php +++ b/public/examples/_015_oauth2_server/Auth/Server.php @@ -139,7 +139,7 @@ public function __isAllowed() return self::$server->verifyResourceRequest(static::$request); } - public function __getWWWAuthenticateString() + public function getWWWAuthenticateString() { return 'Bearer realm="example"'; } diff --git a/vendor/Luracast/Restler/Restler.php b/vendor/Luracast/Restler/Restler.php index 99c00a89e..a9b9417e7 100644 --- a/vendor/Luracast/Restler/Restler.php +++ b/vendor/Luracast/Restler/Restler.php @@ -1080,7 +1080,7 @@ protected function respond() } if ($this->responseCode == 401) { $authString = count($this->authClasses) - ? Scope::get($this->authClasses[0])->__getWWWAuthenticateString() + ? Scope::get($this->authClasses[0])->getWWWAuthenticateString() : 'Unknown'; @header('WWW-Authenticate: ' . $authString, false); } diff --git a/vendor/Luracast/Restler/iAuthenticate.php b/vendor/Luracast/Restler/iAuthenticate.php index 6e71f0fc2..8908acc7f 100644 --- a/vendor/Luracast/Restler/iAuthenticate.php +++ b/vendor/Luracast/Restler/iAuthenticate.php @@ -21,5 +21,5 @@ interface iAuthenticate extends iFilter * @example Digest * @example OAuth */ - public function __getWWWAuthenticateString(); + public function getWWWAuthenticateString(); } From bbe64656a0ddd32fed141303ce16ff4063776db0 Mon Sep 17 00:00:00 2001 From: Guillaume NOUET Date: Tue, 15 Jan 2019 13:15:31 +0100 Subject: [PATCH 13/17] Rename __isAllowed fonction PHP has reserved all method names with a double underscore prefix for future use. --- public/examples/_005_protected_api/SimpleAuth.php | 2 +- public/examples/_009_rate_limiting/KeyAuth.php | 2 +- public/examples/_010_access_control/AccessControl.php | 2 +- public/examples/_015_oauth2_server/Auth/Server.php | 2 +- vendor/Luracast/Restler/Defaults.php | 2 +- vendor/Luracast/Restler/Filter/RateLimit.php | 4 ++-- vendor/Luracast/Restler/Restler.php | 2 +- vendor/Luracast/Restler/UI/Forms.php | 4 ++-- vendor/Luracast/Restler/iFilter.php | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/public/examples/_005_protected_api/SimpleAuth.php b/public/examples/_005_protected_api/SimpleAuth.php index 78f9deca9..e15686e71 100755 --- a/public/examples/_005_protected_api/SimpleAuth.php +++ b/public/examples/_005_protected_api/SimpleAuth.php @@ -5,7 +5,7 @@ class SimpleAuth implements iAuthenticate { const KEY = 'rEsTlEr2'; - function __isAllowed() + function isAllowed() { return isset($_GET['key']) && $_GET['key'] == SimpleAuth::KEY ? TRUE : FALSE; } diff --git a/public/examples/_009_rate_limiting/KeyAuth.php b/public/examples/_009_rate_limiting/KeyAuth.php index f9a07cd4b..a444e3e83 100755 --- a/public/examples/_009_rate_limiting/KeyAuth.php +++ b/public/examples/_009_rate_limiting/KeyAuth.php @@ -3,7 +3,7 @@ class KeyAuth implements iAuthenticate { - public function __isAllowed() + public function isAllowed() { return isset($_GET['api_key']) && $_GET['api_key'] == 'r3rocks'; } diff --git a/public/examples/_010_access_control/AccessControl.php b/public/examples/_010_access_control/AccessControl.php index b9670f42c..cc548621e 100755 --- a/public/examples/_010_access_control/AccessControl.php +++ b/public/examples/_010_access_control/AccessControl.php @@ -8,7 +8,7 @@ class AccessControl implements iAuthenticate public static $requires = 'user'; public static $role = 'user'; - public function __isAllowed() + public function isAllowed() { //hardcoded api_key=>role for brevity $roles = array('12345' => 'user', '67890' => 'admin'); diff --git a/public/examples/_015_oauth2_server/Auth/Server.php b/public/examples/_015_oauth2_server/Auth/Server.php index bdef647be..c3bed96dd 100644 --- a/public/examples/_015_oauth2_server/Auth/Server.php +++ b/public/examples/_015_oauth2_server/Auth/Server.php @@ -134,7 +134,7 @@ public function access() * * @return boolean true when api access is allowed; false otherwise */ - public function __isAllowed() + public function isAllowed() { return self::$server->verifyResourceRequest(static::$request); } diff --git a/vendor/Luracast/Restler/Defaults.php b/vendor/Luracast/Restler/Defaults.php index 98b972024..b6ec83272 100644 --- a/vendor/Luracast/Restler/Defaults.php +++ b/vendor/Luracast/Restler/Defaults.php @@ -233,7 +233,7 @@ class Defaults * @var string authentication method to be called in iAuthenticate * Interface */ - public static $authenticationMethod = '__isAllowed'; + public static $authenticationMethod = 'isAllowed'; /** * @var int time in milliseconds for bandwidth throttling, diff --git a/vendor/Luracast/Restler/Filter/RateLimit.php b/vendor/Luracast/Restler/Filter/RateLimit.php index 99539f70e..fb8a82805 100644 --- a/vendor/Luracast/Restler/Filter/RateLimit.php +++ b/vendor/Luracast/Restler/Filter/RateLimit.php @@ -74,7 +74,7 @@ public static function setLimit( is_null($authenticatedUsagePerUnit) ? $usagePerUnit : $authenticatedUsagePerUnit; } - public function __isAllowed() + public function isAllowed() { if (static::$authenticatedUsagePerUnit == static::$usagePerUnit @@ -175,4 +175,4 @@ private function duration($secs) } return implode(' ', $ret); //." $unit."; } -} \ No newline at end of file +} diff --git a/vendor/Luracast/Restler/Restler.php b/vendor/Luracast/Restler/Restler.php index a9b9417e7..8a551b084 100644 --- a/vendor/Luracast/Restler/Restler.php +++ b/vendor/Luracast/Restler/Restler.php @@ -850,7 +850,7 @@ protected function preAuthFilter() throw new RestException ( 500, 'Filter Class ' . 'should implement iFilter'); - } else if (!($ok = $filterObj->__isAllowed())) { + } else if (!($ok = $filterObj->isAllowed())) { if (is_null($ok) && $filterObj instanceof iUseAuthentication ) { diff --git a/vendor/Luracast/Restler/UI/Forms.php b/vendor/Luracast/Restler/UI/Forms.php index 03a89dfbb..6b8c67780 100644 --- a/vendor/Luracast/Restler/UI/Forms.php +++ b/vendor/Luracast/Restler/UI/Forms.php @@ -399,7 +399,7 @@ public static function key($method = 'POST', $action = null) * * @throws RestException 403 security violation */ - public function __isAllowed() + public function isAllowed() { if (session_id() == '') { session_start(); @@ -431,4 +431,4 @@ public function __isAllowed() } return true; } -} \ No newline at end of file +} diff --git a/vendor/Luracast/Restler/iFilter.php b/vendor/Luracast/Restler/iFilter.php index 40205e5de..4fd79676b 100644 --- a/vendor/Luracast/Restler/iFilter.php +++ b/vendor/Luracast/Restler/iFilter.php @@ -24,7 +24,7 @@ interface iFilter * @abstract * @return boolean true when api access is allowed false otherwise */ - public function __isAllowed(); + public function isAllowed(); } From 198f56a2f8f92c41fab6b50f4c7536787639f345 Mon Sep 17 00:00:00 2001 From: Guillaume NOUET Date: Tue, 15 Jan 2019 13:18:50 +0100 Subject: [PATCH 14/17] Rename __setAuthenticationStatus fonction PHP has reserved all method names with a double underscore prefix for future use. --- vendor/Luracast/Restler/Filter/RateLimit.php | 2 +- vendor/Luracast/Restler/Resources.php | 2 +- vendor/Luracast/Restler/Scope.php | 2 +- vendor/Luracast/Restler/iUseAuthentication.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/vendor/Luracast/Restler/Filter/RateLimit.php b/vendor/Luracast/Restler/Filter/RateLimit.php index fb8a82805..24daa9c81 100644 --- a/vendor/Luracast/Restler/Filter/RateLimit.php +++ b/vendor/Luracast/Restler/Filter/RateLimit.php @@ -82,7 +82,7 @@ public function isAllowed() return null; } - public function __setAuthenticationStatus($isAuthenticated = false) + public function setAuthenticationStatus($isAuthenticated = false) { header('X-Auth-Status: ' . ($isAuthenticated ? 'true' : 'false')); $this->check($isAuthenticated); diff --git a/vendor/Luracast/Restler/Resources.php b/vendor/Luracast/Restler/Resources.php index 420d26460..0ad40127f 100644 --- a/vendor/Luracast/Restler/Resources.php +++ b/vendor/Luracast/Restler/Resources.php @@ -137,7 +137,7 @@ public function __construct() * * @return mixed */ - public function __setAuthenticationStatus($isAuthenticated = false) + public function setAuthenticationStatus($isAuthenticated = false) { $this->_authenticated = $isAuthenticated; } diff --git a/vendor/Luracast/Restler/Scope.php b/vendor/Luracast/Restler/Scope.php index e6156c023..57dd4ac0f 100644 --- a/vendor/Luracast/Restler/Scope.php +++ b/vendor/Luracast/Restler/Scope.php @@ -116,7 +116,7 @@ public static function get($name) !isset(static::$instances[$name]->authVerified) ) { static::$instances[$name]->authVerified = true; - $r->__setAuthenticationStatus + $r->setAuthenticationStatus (static::get('Restler')->_authenticated); } if (isset(static::$instances[$name]->initPending)) { diff --git a/vendor/Luracast/Restler/iUseAuthentication.php b/vendor/Luracast/Restler/iUseAuthentication.php index e4e24c02a..e23962ace 100644 --- a/vendor/Luracast/Restler/iUseAuthentication.php +++ b/vendor/Luracast/Restler/iUseAuthentication.php @@ -27,6 +27,6 @@ interface iUseAuthentication * * @return mixed */ - public function __setAuthenticationStatus($isAuthenticated=false); + public function setAuthenticationStatus($isAuthenticated=false); } From bced3a37eb09e3155070ce3d5e6384456de77648 Mon Sep 17 00:00:00 2001 From: Guillaume NOUET Date: Tue, 15 Jan 2019 13:20:44 +0100 Subject: [PATCH 15/17] Rename __getMaximumSupportedVersion function PHP has reserved all method names with a double underscore prefix for future use. --- public/examples/_011_versioning/index.php | 4 ++-- vendor/Luracast/Restler/Resources.php | 2 +- vendor/Luracast/Restler/Restler.php | 2 +- vendor/Luracast/Restler/iProvideMultiVersionApi.php | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/public/examples/_011_versioning/index.php b/public/examples/_011_versioning/index.php index 4c972f419..4c9640774 100755 --- a/public/examples/_011_versioning/index.php +++ b/public/examples/_011_versioning/index.php @@ -38,7 +38,7 @@ Which will be `Luracast\WeightManagement\v2` for this example If a class remains the same across few versions of the api, we can implement -`iProvideMultiVersionApi` interface which is simply defining `__getMaximumSupportedVersion` +`iProvideMultiVersionApi` interface which is simply defining `getMaximumSupportedVersion` method which returns the maximum supported version. Take a look at `Resources` class for a sample implementation. @@ -111,4 +111,4 @@ class for a sample implementation. $r->setAPIVersion(2); $r->addAPIClass('BMI'); $r->addAPIClass('Resources'); -$r->handle(); \ No newline at end of file +$r->handle(); diff --git a/vendor/Luracast/Restler/Resources.php b/vendor/Luracast/Restler/Resources.php index 0ad40127f..f65a37510 100644 --- a/vendor/Luracast/Restler/Resources.php +++ b/vendor/Luracast/Restler/Resources.php @@ -970,7 +970,7 @@ protected function _mapResources(array $allRoutes, array &$map, $version = 1) * Maximum api version supported by the api class * @return int */ - public static function __getMaximumSupportedVersion() + public static function getMaximumSupportedVersion() { return Scope::get('Restler')->getApiVersion(); } diff --git a/vendor/Luracast/Restler/Restler.php b/vendor/Luracast/Restler/Restler.php index 8a551b084..65deec642 100644 --- a/vendor/Luracast/Restler/Restler.php +++ b/vendor/Luracast/Restler/Restler.php @@ -1231,7 +1231,7 @@ public function addAPIClass($className, $resourcePath = null) $className = Scope::$classAliases[$className]; } if (!$this->cached) { - $maxVersionMethod = '__getMaximumSupportedVersion'; + $maxVersionMethod = 'getMaximumSupportedVersion'; if (class_exists($className)) { if (method_exists($className, $maxVersionMethod)) { $max = $className::$maxVersionMethod(); diff --git a/vendor/Luracast/Restler/iProvideMultiVersionApi.php b/vendor/Luracast/Restler/iProvideMultiVersionApi.php index ed74dd1b9..e9dd249fa 100644 --- a/vendor/Luracast/Restler/iProvideMultiVersionApi.php +++ b/vendor/Luracast/Restler/iProvideMultiVersionApi.php @@ -7,5 +7,5 @@ interface iProvideMultiVersionApi { * Maximum api version supported by the api class * @return int */ - public static function __getMaximumSupportedVersion(); -} \ No newline at end of file + public static function getMaximumSupportedVersion(); +} From 2c3ce7812ed27cb28a6c8fe26079df15c047432e Mon Sep 17 00:00:00 2001 From: Guillaume NOUET Date: Tue, 15 Jan 2019 13:22:55 +0100 Subject: [PATCH 16/17] Rename __toArray function PHP has reserved all method names with a double underscore prefix for future use. --- vendor/Luracast/Restler/Data/ValueObject.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/Luracast/Restler/Data/ValueObject.php b/vendor/Luracast/Restler/Data/ValueObject.php index 811c170ac..9b36235d1 100644 --- a/vendor/Luracast/Restler/Data/ValueObject.php +++ b/vendor/Luracast/Restler/Data/ValueObject.php @@ -45,7 +45,7 @@ public static function __set_state(array $properties) return $instance; } - public function __toArray() + public function toArray() { $r = get_object_vars($this); $methods = get_class_methods($this); From 6a1a8ec4b4702737636405fee24c8dd3c2febf1a Mon Sep 17 00:00:00 2001 From: Guillaume NOUET Date: Tue, 15 Jan 2019 13:29:47 +0100 Subject: [PATCH 17/17] Rename __isAuthenticated function PHP has reserved all method names with a double underscore prefix for future use. --- vendor/Luracast/Restler/compatibility/iAuthenticate.php | 4 ++-- vendor/Luracast/Restler/compatibility/restler2.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/vendor/Luracast/Restler/compatibility/iAuthenticate.php b/vendor/Luracast/Restler/compatibility/iAuthenticate.php index 0463df948..ad0b4b0f9 100644 --- a/vendor/Luracast/Restler/compatibility/iAuthenticate.php +++ b/vendor/Luracast/Restler/compatibility/iAuthenticate.php @@ -6,5 +6,5 @@ */ interface iAuthenticate { - public function __isAuthenticated(); -} \ No newline at end of file + public function isAuthenticated(); +} diff --git a/vendor/Luracast/Restler/compatibility/restler2.php b/vendor/Luracast/Restler/compatibility/restler2.php index c985ae5bd..e9837c727 100644 --- a/vendor/Luracast/Restler/compatibility/restler2.php +++ b/vendor/Luracast/Restler/compatibility/restler2.php @@ -26,7 +26,7 @@ AutoLoader::seen($classMap); //changes in iAuthenticate -Defaults::$authenticationMethod = '__isAuthenticated'; +Defaults::$authenticationMethod = 'isAuthenticated'; include __DIR__ . '/iAuthenticate.php'; @@ -37,4 +37,4 @@ //changes in parsing embedded data in comments CommentParser::$embeddedDataPattern = '/\((\S+)\)/ms'; -CommentParser::$embeddedDataIndex = 1; \ No newline at end of file +CommentParser::$embeddedDataIndex = 1;