From a0b931364779cced5ee72037dd0ce323c637cd82 Mon Sep 17 00:00:00 2001 From: edalzell Date: Thu, 19 Mar 2020 17:56:31 -0700 Subject: [PATCH 1/3] Updates as per Laravel 7 upgrade guide --- composer.json | 6 +++--- src/Exceptions/Handler.php | 7 ++++--- src/Http/Resources/API/AssetResource.php | 4 ++-- src/Http/Resources/API/EntryResource.php | 4 ++-- src/Http/Resources/API/GlobalSetResource.php | 4 ++-- src/Http/Resources/API/TermResource.php | 4 ++-- src/Http/Resources/API/UserResource.php | 4 ++-- src/Providers/ExtensionServiceProvider.php | 9 ++------- 8 files changed, 19 insertions(+), 23 deletions(-) diff --git a/composer.json b/composer.json index 295e84e642..f66609cbd7 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "composer/composer": "^1.7", "facade/ignition-contracts": "^1.0", "guzzlehttp/guzzle": "^6.3", - "laravel/framework": "5.6.* || 5.7.* || 5.8.* || ^6.0", + "laravel/framework": "5.6.* || 5.7.* || 5.8.* || ^6.0 || ^7.0", "laravel/helpers": "^1.1", "league/commonmark": "^1.3", "league/csv": "^9.0", @@ -32,7 +32,7 @@ "fzaninotto/faker": "~1.4", "google/cloud-translate": "^1.6", "mockery/mockery": "~1.0", - "nunomaduro/collision": "^3.0", + "nunomaduro/collision": "3.0 || ^4.1", "orchestra/testbench": "3.8 || 4.0" }, "config": { @@ -68,4 +68,4 @@ "Foo\\Bar\\": "tests/fixtures/Addon" } } -} +} \ No newline at end of file diff --git a/src/Exceptions/Handler.php b/src/Exceptions/Handler.php index a49b434db4..1663bbbb47 100755 --- a/src/Exceptions/Handler.php +++ b/src/Exceptions/Handler.php @@ -3,6 +3,7 @@ namespace Statamic\Exceptions; use Exception; +use Throwable; use Statamic\Statamic; use Illuminate\Support\Facades\View; use App\Exceptions\Handler as ExceptionHandler; @@ -11,7 +12,7 @@ class Handler extends ExceptionHandler { - public function render($request, Exception $e) + public function render($request, Throwable $e) { if ($e instanceof NotFoundHttpException && Statamic::isApiRoute()) { return response()->json(['message' => $e->getMessage() ?: 'Not found.'], 404); @@ -27,11 +28,11 @@ public function render($request, Exception $e) /** * Render an exception to a string using Symfony. * - * @param \Exception $e + * @param Throwable $e * @param bool $debug * @return string */ - protected function renderExceptionWithSymfony(Exception $e, $debug) + protected function renderExceptionWithSymfony(Throwable $e, $debug) { return (new SymfonyExceptionHandler($debug))->getHtml( FlattenException::create($e) diff --git a/src/Http/Resources/API/AssetResource.php b/src/Http/Resources/API/AssetResource.php index 412bf76b22..67945700ae 100644 --- a/src/Http/Resources/API/AssetResource.php +++ b/src/Http/Resources/API/AssetResource.php @@ -2,9 +2,9 @@ namespace Statamic\Http\Resources\API; -use Illuminate\Http\Resources\Json\Resource; +use Illuminate\Http\Resources\Json\JSONResource; -class AssetResource extends Resource +class AssetResource extends JSONResource { /** * Transform the resource into an array. diff --git a/src/Http/Resources/API/EntryResource.php b/src/Http/Resources/API/EntryResource.php index 45efc53013..79f1997ddb 100644 --- a/src/Http/Resources/API/EntryResource.php +++ b/src/Http/Resources/API/EntryResource.php @@ -2,9 +2,9 @@ namespace Statamic\Http\Resources\API; -use Illuminate\Http\Resources\Json\Resource; +use Illuminate\Http\Resources\Json\JSONResource; -class EntryResource extends Resource +class EntryResource extends JSONResource { /** * Transform the resource into an array. diff --git a/src/Http/Resources/API/GlobalSetResource.php b/src/Http/Resources/API/GlobalSetResource.php index 313726cee3..0db0ea0d79 100644 --- a/src/Http/Resources/API/GlobalSetResource.php +++ b/src/Http/Resources/API/GlobalSetResource.php @@ -2,10 +2,10 @@ namespace Statamic\Http\Resources\API; -use Illuminate\Http\Resources\Json\Resource; use Statamic\Statamic; +use Illuminate\Http\Resources\Json\JSONResource; -class GlobalSetResource extends Resource +class GlobalSetResource extends JSONResource { /** * Transform the resource into an array. diff --git a/src/Http/Resources/API/TermResource.php b/src/Http/Resources/API/TermResource.php index adbdcc0bf8..41bf178824 100644 --- a/src/Http/Resources/API/TermResource.php +++ b/src/Http/Resources/API/TermResource.php @@ -2,9 +2,9 @@ namespace Statamic\Http\Resources\API; -use Illuminate\Http\Resources\Json\Resource; +use Illuminate\Http\Resources\Json\JSONResource; -class TermResource extends Resource +class TermResource extends JSONResource { /** * Transform the resource into an array. diff --git a/src/Http/Resources/API/UserResource.php b/src/Http/Resources/API/UserResource.php index 217bb3813d..649216e336 100644 --- a/src/Http/Resources/API/UserResource.php +++ b/src/Http/Resources/API/UserResource.php @@ -2,10 +2,10 @@ namespace Statamic\Http\Resources\API; -use Illuminate\Http\Resources\Json\Resource; use Statamic\Statamic; +use Illuminate\Http\Resources\Json\JSONResource; -class UserResource extends Resource +class UserResource extends JSONResource { /** * Transform the resource into an array. diff --git a/src/Providers/ExtensionServiceProvider.php b/src/Providers/ExtensionServiceProvider.php index 1fb4f10c0a..154a950564 100644 --- a/src/Providers/ExtensionServiceProvider.php +++ b/src/Providers/ExtensionServiceProvider.php @@ -6,19 +6,14 @@ use Statamic\Actions; use Statamic\Fieldtypes; use Statamic\Query\Scopes; +use Statamic\Extend\Manifest; use Statamic\Modifiers\Modifier; -use Statamic\Extensions\FileStore; -use Statamic\Modifiers\CoreModifiers; use Illuminate\Filesystem\Filesystem; -use Illuminate\Support\Facades\Cache; +use Statamic\Modifiers\CoreModifiers; use Illuminate\Support\ServiceProvider; -use Statamic\Extend\Manifest; -use Illuminate\Console\DetectsApplicationNamespace; class ExtensionServiceProvider extends ServiceProvider { - use DetectsApplicationNamespace; - /** * Aliases for modifiers bundled with Statamic. * From fec53e7ee43a50ef1c437b921d5aa14168c11020 Mon Sep 17 00:00:00 2001 From: edalzell Date: Thu, 19 Mar 2020 18:08:43 -0700 Subject: [PATCH 2/3] use the correct class name, sheesh --- src/Http/Resources/API/AssetResource.php | 4 ++-- src/Http/Resources/API/EntryResource.php | 4 ++-- src/Http/Resources/API/GlobalSetResource.php | 4 ++-- src/Http/Resources/API/TermResource.php | 4 ++-- src/Http/Resources/API/UserResource.php | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Http/Resources/API/AssetResource.php b/src/Http/Resources/API/AssetResource.php index 67945700ae..d6ae1433d3 100644 --- a/src/Http/Resources/API/AssetResource.php +++ b/src/Http/Resources/API/AssetResource.php @@ -2,9 +2,9 @@ namespace Statamic\Http\Resources\API; -use Illuminate\Http\Resources\Json\JSONResource; +use Illuminate\Http\Resources\Json\JsonResource; -class AssetResource extends JSONResource +class AssetResource extends JsonResource { /** * Transform the resource into an array. diff --git a/src/Http/Resources/API/EntryResource.php b/src/Http/Resources/API/EntryResource.php index 79f1997ddb..a50fd5cc4f 100644 --- a/src/Http/Resources/API/EntryResource.php +++ b/src/Http/Resources/API/EntryResource.php @@ -2,9 +2,9 @@ namespace Statamic\Http\Resources\API; -use Illuminate\Http\Resources\Json\JSONResource; +use Illuminate\Http\Resources\Json\JsonResource; -class EntryResource extends JSONResource +class EntryResource extends JsonResource { /** * Transform the resource into an array. diff --git a/src/Http/Resources/API/GlobalSetResource.php b/src/Http/Resources/API/GlobalSetResource.php index 0db0ea0d79..9ad8eb54b0 100644 --- a/src/Http/Resources/API/GlobalSetResource.php +++ b/src/Http/Resources/API/GlobalSetResource.php @@ -3,9 +3,9 @@ namespace Statamic\Http\Resources\API; use Statamic\Statamic; -use Illuminate\Http\Resources\Json\JSONResource; +use Illuminate\Http\Resources\Json\JsonResource; -class GlobalSetResource extends JSONResource +class GlobalSetResource extends JsonResource { /** * Transform the resource into an array. diff --git a/src/Http/Resources/API/TermResource.php b/src/Http/Resources/API/TermResource.php index 41bf178824..85600c1ea4 100644 --- a/src/Http/Resources/API/TermResource.php +++ b/src/Http/Resources/API/TermResource.php @@ -2,9 +2,9 @@ namespace Statamic\Http\Resources\API; -use Illuminate\Http\Resources\Json\JSONResource; +use Illuminate\Http\Resources\Json\JsonResource; -class TermResource extends JSONResource +class TermResource extends JsonResource { /** * Transform the resource into an array. diff --git a/src/Http/Resources/API/UserResource.php b/src/Http/Resources/API/UserResource.php index 649216e336..c36e3f133a 100644 --- a/src/Http/Resources/API/UserResource.php +++ b/src/Http/Resources/API/UserResource.php @@ -3,9 +3,9 @@ namespace Statamic\Http\Resources\API; use Statamic\Statamic; -use Illuminate\Http\Resources\Json\JSONResource; +use Illuminate\Http\Resources\Json\JsonResource; -class UserResource extends JSONResource +class UserResource extends JsonResource { /** * Transform the resource into an array. From 7fe1196d788cbf97277126a675a11366a5130434 Mon Sep 17 00:00:00 2001 From: edalzell Date: Thu, 19 Mar 2020 18:22:20 -0700 Subject: [PATCH 3/3] fix another deprecation warning --- src/Exceptions/Handler.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Exceptions/Handler.php b/src/Exceptions/Handler.php index 1663bbbb47..13d4cf0159 100755 --- a/src/Exceptions/Handler.php +++ b/src/Exceptions/Handler.php @@ -2,12 +2,11 @@ namespace Statamic\Exceptions; -use Exception; use Throwable; use Statamic\Statamic; use Illuminate\Support\Facades\View; use App\Exceptions\Handler as ExceptionHandler; -use Symfony\Component\Debug\Exception\FlattenException; +use Symfony\Component\ErrorHandler\Exception\FlattenException; use Illuminate\Auth\Access\AuthorizationException as IlluminateAuthException; class Handler extends ExceptionHandler