From e8f563ea0ec8d5060be14c5fec195b21af8fcbb2 Mon Sep 17 00:00:00 2001 From: Marc Reichel Date: Wed, 15 Feb 2023 13:44:33 +0100 Subject: [PATCH] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Add=20support=20for=20Lara?= =?UTF-8?q?vel=2010=20(#70)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ⬆️ Add support for Laravel 10 --- .github/workflows/tests-pr.yml | 9 +++++++-- composer.json | 5 +++-- src/ApiHelper.php | 4 ++-- src/Builder.php | 2 +- src/Events/Event.php | 4 +++- src/Models/Webhook.php | 6 ++++-- 6 files changed, 20 insertions(+), 10 deletions(-) diff --git a/.github/workflows/tests-pr.yml b/.github/workflows/tests-pr.yml index bcb8e8e..cfca9c5 100644 --- a/.github/workflows/tests-pr.yml +++ b/.github/workflows/tests-pr.yml @@ -14,11 +14,16 @@ jobs: strategy: fail-fast: true matrix: - php: [ 8.1, 8.0 ] - laravel: [ 9.*, 8.* ] + php: [ '8.0', 8.1 ] + laravel: [ 8.*, 9.*, 10.* ] stability: [ prefer-stable ] os: [ ubuntu-latest, windows-latest ] + exclude: + - php: 8.0 + laravel: 10.* include: + - laravel: 10.* + testbench: 8.* - laravel: 9.* testbench: 7.* - laravel: 8.* diff --git a/composer.json b/composer.json index 8fdd3af..e2818f5 100644 --- a/composer.json +++ b/composer.json @@ -10,16 +10,17 @@ "wrapper" ], "type": "library", + "minimum-stability": "dev", "require": { "php": "^8.0.2", - "laravel/framework": "^8.40.0|^9.0", + "laravel/framework": "^8.40.0|^9.0|^10.0", "guzzlehttp/guzzle": "~6.0|~7.0", "nesbot/carbon": "^2.53.1", "ext-json": "*" }, "require-dev": { "phpunit/phpunit": "^9.5.4", - "orchestra/testbench": "^6.23|^7.0", + "orchestra/testbench": "^6.23|^7.0|^8.0", "nunomaduro/collision": "^5.3|^6.1", "roave/security-advisories": "dev-latest", "nunomaduro/larastan": "^1.0|^2.0" diff --git a/src/ApiHelper.php b/src/ApiHelper.php index c78704e..c3bb344 100644 --- a/src/ApiHelper.php +++ b/src/ApiHelper.php @@ -21,9 +21,9 @@ public static function retrieveAccessToken(): string { $accessTokenCacheKey = 'igdb_cache.access_token'; - $accessToken = Cache::get($accessTokenCacheKey, false); + $accessToken = Cache::get($accessTokenCacheKey, ''); - if ($accessToken && is_string($accessToken)) { + if ($accessToken) { return $accessToken; } diff --git a/src/Builder.php b/src/Builder.php index 5240f43..814b0c3 100644 --- a/src/Builder.php +++ b/src/Builder.php @@ -1487,7 +1487,7 @@ protected function setEndpoint(mixed $model): void $parents->push($class); } - if (is_bool($parents->last()) || is_null($parents->last())) { + if (!$parents->last()) { throw new InvalidParamsException('Last parent element is either null or false. String or {} required.'); } diff --git a/src/Events/Event.php b/src/Events/Event.php index 1c6a71b..e2b156b 100644 --- a/src/Events/Event.php +++ b/src/Events/Event.php @@ -34,7 +34,9 @@ public function __construct(Request $request) { $this->class = get_class($this); $this->url = $request->fullUrl(); - $this->method = (string) $request->route('method'); + /** @var string $method */ + $method = $request->route('method'); + $this->method = $method; $this->created_at = new Carbon(); } } diff --git a/src/Models/Webhook.php b/src/Models/Webhook.php index 2d619aa..9aa8f93 100644 --- a/src/Models/Webhook.php +++ b/src/Models/Webhook.php @@ -146,7 +146,8 @@ public static function handle(Request $request): mixed $data = json_decode((string) $request->getContent(), true, 512, JSON_THROW_ON_ERROR); - $endpoint = (string) $request->route('model'); + /** @var string $endpoint */ + $endpoint = $request->route('model'); if (!$endpoint) { return $data; @@ -159,7 +160,8 @@ public static function handle(Request $request): mixed return $data; } - $method = (string) $request->route('method'); + /** @var string $method */ + $method = $request->route('method'); $entity = new $fullClassName($data); $reflectionClass = new ReflectionClass(Method::class);