diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e2ccc7b..f6a9566 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,10 +17,10 @@ jobs: - ubuntu-latest - windows-latest php-version: - - 7.1 - 7.4 + - 8.0 phpunit-version: - - 7.5.20 + - 8.5.32 dependencies: - lowest - highest diff --git a/composer.json b/composer.json index a6e56c8..5efc832 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "ext-json": "*" }, "require-dev": { - "phpunit/phpunit": "^7", + "phpunit/phpunit": "^8", "mockery/mockery": "^1", "phpstan/phpstan": "^0", "phpstan/phpstan-phpunit": "^0", @@ -47,5 +47,10 @@ "psr-4": { "Pecee\\": "src/Pecee/" } + }, + "config": { + "allow-plugins": { + "ocramius/package-versions": true + } } } \ No newline at end of file diff --git a/src/Pecee/Http/Request.php b/src/Pecee/Http/Request.php index 63bd5d6..576264c 100644 --- a/src/Pecee/Http/Request.php +++ b/src/Pecee/Http/Request.php @@ -133,7 +133,7 @@ class Request if($url !== null){ $this->setUrl(new Url($url)); }else{ - $this->setUrl(new Url(urldecode($this->getHeader('request-uri')))); + $this->setUrl(new Url(urldecode((string)$this->getHeader('request-uri')))); } $this->setContentType((string)$this->getHeader('content-type')); $this->setMethod((string)($_POST[static::FORCE_METHOD_KEY] ?? $this->getHeader('request-method'))); @@ -364,7 +364,7 @@ class Request */ public function isAjax(): bool { - return (strtolower($this->getHeader('http-x-requested-with')) === 'xmlhttprequest'); + return (strtolower((string)$this->getHeader('http-x-requested-with')) === 'xmlhttprequest'); } /** diff --git a/src/Pecee/Http/Response.php b/src/Pecee/Http/Response.php index 44a2ee0..005500c 100644 --- a/src/Pecee/Http/Response.php +++ b/src/Pecee/Http/Response.php @@ -87,11 +87,11 @@ class Response /** * Json encode * @param array|JsonSerializable $value - * @param ?int $options JSON options Bitmask consisting of JSON_HEX_QUOT, JSON_HEX_TAG, JSON_HEX_AMP, JSON_HEX_APOS, JSON_NUMERIC_CHECK, JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES, JSON_FORCE_OBJECT, JSON_PRESERVE_ZERO_FRACTION, JSON_UNESCAPED_UNICODE, JSON_PARTIAL_OUTPUT_ON_ERROR. + * @param int $options JSON options Bitmask consisting of JSON_HEX_QUOT, JSON_HEX_TAG, JSON_HEX_AMP, JSON_HEX_APOS, JSON_NUMERIC_CHECK, JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES, JSON_FORCE_OBJECT, JSON_PRESERVE_ZERO_FRACTION, JSON_UNESCAPED_UNICODE, JSON_PARTIAL_OUTPUT_ON_ERROR. * @param int $dept JSON debt. * @throws InvalidArgumentException */ - public function json($value, ?int $options = null, int $dept = 512): void + public function json($value, int $options = 0, int $dept = 512): void { if (($value instanceof JsonSerializable) === false && is_array($value) === false) { throw new InvalidArgumentException('Invalid type for parameter "value". Must be of type array or object implementing the \JsonSerializable interface.'); diff --git a/src/Pecee/SimpleRouter/Route/LoadableRoute.php b/src/Pecee/SimpleRouter/Route/LoadableRoute.php index 82754bf..0996b24 100644 --- a/src/Pecee/SimpleRouter/Route/LoadableRoute.php +++ b/src/Pecee/SimpleRouter/Route/LoadableRoute.php @@ -167,7 +167,7 @@ abstract class LoadableRoute extends Route implements ILoadableRoute if (stripos($url, $param1) !== false || stripos($url, $param) !== false) { /* Add parameter to the correct position */ - $url = str_ireplace([sprintf($param1, $param), sprintf($param2, $param)], $value, $url); + $url = str_ireplace([sprintf($param1, $param), sprintf($param2, $param)], (string)$value, $url); } else { /* Parameter aren't recognized and will be appended at the end of the url */ $url .= $value . '/'; @@ -195,7 +195,7 @@ abstract class LoadableRoute extends Route implements ILoadableRoute */ public function hasName(string $name): bool { - return strtolower($this->name) === strtolower($name); + return strtolower((string)$this->name) === strtolower((string)$name); } /** diff --git a/src/Pecee/SimpleRouter/Route/RouteController.php b/src/Pecee/SimpleRouter/Route/RouteController.php index 88c6597..c80299e 100644 --- a/src/Pecee/SimpleRouter/Route/RouteController.php +++ b/src/Pecee/SimpleRouter/Route/RouteController.php @@ -81,7 +81,7 @@ class RouteController extends LoadableRoute implements IControllerRoute $url .= '//' . $group->getDomains()[0]; } - $url .= '/' . trim($this->getUrl(), '/') . '/' . strtolower($method) . implode('/', $parameters); + $url .= '/' . trim($this->getUrl(), '/') . '/' . strtolower((string)$method) . implode('/', $parameters); return '/' . trim($url, '/') . '/'; } diff --git a/src/Pecee/SimpleRouter/Route/RouteGroup.php b/src/Pecee/SimpleRouter/Route/RouteGroup.php index 71b650b..a840784 100644 --- a/src/Pecee/SimpleRouter/Route/RouteGroup.php +++ b/src/Pecee/SimpleRouter/Route/RouteGroup.php @@ -74,7 +74,7 @@ class RouteGroup extends Route implements IGroupRoute $parsedPrefix = $this->prefix; foreach ($this->getParameters() as $parameter => $value) { - $parsedPrefix = str_ireplace('{' . $parameter . '}', $value, $parsedPrefix); + $parsedPrefix = str_ireplace('{' . $parameter . '}', (string)$value, (string)$parsedPrefix); } /* Skip if prefix doesn't match */ diff --git a/src/Pecee/SimpleRouter/Route/RouteResource.php b/src/Pecee/SimpleRouter/Route/RouteResource.php index f8be0b7..587fd10 100644 --- a/src/Pecee/SimpleRouter/Route/RouteResource.php +++ b/src/Pecee/SimpleRouter/Route/RouteResource.php @@ -106,7 +106,7 @@ class RouteResource extends LoadableRoute implements IControllerRoute return false; } - $action = strtolower(trim($this->parameters['action'])); + $action = strtolower(trim((string)$this->parameters['action'])); $id = $this->parameters['id']; // Remove action parameter diff --git a/src/Pecee/SimpleRouter/Router.php b/src/Pecee/SimpleRouter/Router.php index 509ca2a..8a66ae1 100644 --- a/src/Pecee/SimpleRouter/Router.php +++ b/src/Pecee/SimpleRouter/Router.php @@ -608,7 +608,7 @@ class Router if (strpos($name, '@') !== false) { [$controller, $method] = array_map('strtolower', explode('@', $name)); - if ($controller === strtolower($route->getClass()) && $method === strtolower($route->getMethod())) { + if ($controller === strtolower((string)$route->getClass()) && $method === strtolower((string)$route->getMethod())) { $this->debug('Found route "%s" by controller "%s" and method "%s"', $route->getUrl(), $controller, $method); return $route;