From de7dd57fd2a8917fcfe8ada83ae0deda51045cae Mon Sep 17 00:00:00 2001 From: Anton Stasyuk <33395021+anstapol@users.noreply.github.com> Date: Wed, 26 Feb 2025 11:16:41 +0100 Subject: [PATCH 1/2] Updated composer dependencies --- .github/workflows/test-code.yml | 3 +++ .gitignore | 3 +++ composer.json | 13 +++++++------ src/Events/EditorJsImageUploaded.php | 4 +--- src/Events/EditorJsThumbnailCreated.php | 4 +--- .../Controllers/EditorJsImageUploadController.php | 2 +- src/Http/Controllers/EditorJsLinkController.php | 2 +- src/NovaEditorJsConverter.php | 2 +- src/NovaEditorJsField.php | 2 +- .../EditorJsImageUploadControllerTest.php | 2 +- tests/Feature/Views/ViewTestHelpers.php | 2 +- tests/TestCase.php | 2 +- 12 files changed, 22 insertions(+), 19 deletions(-) diff --git a/.github/workflows/test-code.yml b/.github/workflows/test-code.yml index 2ceda30..24da715 100644 --- a/.github/workflows/test-code.yml +++ b/.github/workflows/test-code.yml @@ -23,12 +23,15 @@ jobs: laravel: - '10.0' - '11.0' + - '12.0' include: - laravel: '10.0' testbench: '8.0' - laravel: '11.0' testbench: '9.0' + - laravel: '12.0' + testbench: '10.0' - php: 8.3 laravel: '11.0' stable: true diff --git a/.gitignore b/.gitignore index 689301b..580726e 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,6 @@ Thumbs.db .php-cs-fixer.cache /composer.lock +/auth.json +/report-junit.xml +/.env diff --git a/composer.json b/composer.json index 264ebfc..d00d0ee 100644 --- a/composer.json +++ b/composer.json @@ -15,14 +15,15 @@ "ext-json": "*", "codex-team/editor.js": "*", "guzzlehttp/guzzle": "^7.0", - "illuminate/support": "^10.0 || ^11.0", - "illuminate/events": "^10.0 || ^11.0", - "laravel/nova": "^4.0", + "illuminate/events": "^10.0 || ^11.0 || ^12.0", + "illuminate/support": "^10.0 || ^11.0 || ^12.0", + "laravel/laravel": "^12", + "laravel/nova": "^4.0 || ^5.0", "spatie/image": "^3.0" }, "require-dev": { "laravel/pint": "^1.15", - "orchestra/testbench": "^8.0 || ^9.0", + "orchestra/testbench": "^10", "php-parallel-lint/php-parallel-lint": "^1.3" }, "autoload": { @@ -66,8 +67,8 @@ "prefer-stable": true, "repositories": [ { - "type": "composer", - "url": "https://nova.laravel.com" + "type": "path", + "url": "./tests/Fixtures/nova" } ] } diff --git a/src/Events/EditorJsImageUploaded.php b/src/Events/EditorJsImageUploaded.php index 17366bc..d80e70f 100644 --- a/src/Events/EditorJsImageUploaded.php +++ b/src/Events/EditorJsImageUploaded.php @@ -10,7 +10,5 @@ class EditorJsImageUploaded { use Dispatchable; - public function __construct(public string $disk, public string $path) - { - } + public function __construct(public string $disk, public string $path) {} } diff --git a/src/Events/EditorJsThumbnailCreated.php b/src/Events/EditorJsThumbnailCreated.php index 1099335..f5552ce 100644 --- a/src/Events/EditorJsThumbnailCreated.php +++ b/src/Events/EditorJsThumbnailCreated.php @@ -10,7 +10,5 @@ class EditorJsThumbnailCreated { use Dispatchable; - public function __construct(public string $disk, public string $path) - { - } + public function __construct(public string $disk, public string $path) {} } diff --git a/src/Http/Controllers/EditorJsImageUploadController.php b/src/Http/Controllers/EditorJsImageUploadController.php index a1db47f..fa6a5e9 100644 --- a/src/Http/Controllers/EditorJsImageUploadController.php +++ b/src/Http/Controllers/EditorJsImageUploadController.php @@ -103,7 +103,7 @@ public function url(Request $request): JsonResponse } // Validate mime type - $mime = (new finfo())->buffer($response->body(), FILEINFO_MIME_TYPE); + $mime = (new finfo)->buffer($response->body(), FILEINFO_MIME_TYPE); if (! in_array($mime, self::VALID_IMAGE_MIMES, true)) { return response()->json([ 'success' => 0, diff --git a/src/Http/Controllers/EditorJsLinkController.php b/src/Http/Controllers/EditorJsLinkController.php index aea6fc4..5e77241 100644 --- a/src/Http/Controllers/EditorJsLinkController.php +++ b/src/Http/Controllers/EditorJsLinkController.php @@ -40,7 +40,7 @@ public function fetch(Request $request): JsonResponse ]); } - $doc = new DOMDocument(); + $doc = new DOMDocument; @$doc->loadHTML((string) $response->getBody()); $nodes = $doc->getElementsByTagName('title'); $title = $nodes->item(0)->nodeValue; diff --git a/src/NovaEditorJsConverter.php b/src/NovaEditorJsConverter.php index b018eb4..f9bbb02 100644 --- a/src/NovaEditorJsConverter.php +++ b/src/NovaEditorJsConverter.php @@ -43,7 +43,7 @@ public function addRender(string $block, callable $callback): void */ public function generateHtmlOutput(mixed $data): HtmlString { - if (empty($data) || $data == new stdClass()) { + if (empty($data) || $data == new stdClass) { return new HtmlString(''); } diff --git a/src/NovaEditorJsField.php b/src/NovaEditorJsField.php index 7a5749a..62b4558 100644 --- a/src/NovaEditorJsField.php +++ b/src/NovaEditorJsField.php @@ -51,7 +51,7 @@ public function resolveForDisplay($resource, $attribute = null) return; } - $value = data_get($resource, str_replace('->', '.', $attribute), $placeholder = new \stdClass()); + $value = data_get($resource, str_replace('->', '.', $attribute), $placeholder = new \stdClass); if (is_callable($this->resolveCallback)) { $value = call_user_func($this->resolveCallback, $value, $resource, $attribute); diff --git a/tests/Feature/Http/Controllers/EditorJsImageUploadControllerTest.php b/tests/Feature/Http/Controllers/EditorJsImageUploadControllerTest.php index 3501e7e..456ee6e 100644 --- a/tests/Feature/Http/Controllers/EditorJsImageUploadControllerTest.php +++ b/tests/Feature/Http/Controllers/EditorJsImageUploadControllerTest.php @@ -46,7 +46,7 @@ public function testImageUpload(string $path): void $fake = Event::fake(); DB::setEventDispatcher($fake); - $uploadedFile = UploadedFile::fake()->create('file', 1024, (new finfo())->file($path, FILEINFO_MIME_TYPE)); + $uploadedFile = UploadedFile::fake()->create('file', 1024, (new finfo)->file($path, FILEINFO_MIME_TYPE)); if ($fp = $uploadedFile->openFile('w')) { $fp->fwrite(file_get_contents($path)); } diff --git a/tests/Feature/Views/ViewTestHelpers.php b/tests/Feature/Views/ViewTestHelpers.php index 27b4a44..b55cc8c 100644 --- a/tests/Feature/Views/ViewTestHelpers.php +++ b/tests/Feature/Views/ViewTestHelpers.php @@ -9,7 +9,7 @@ trait ViewTestHelpers { - protected function view(string $view, array $args = []): TestView + protected function view(string $view, $args = []): TestView { return new TestView(View::make($view, $args)); } diff --git a/tests/TestCase.php b/tests/TestCase.php index 7925363..bade797 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -23,7 +23,7 @@ class TestCase extends OrchestraTestCase */ protected function repairLaravel8Compatibiliy() { - if (! \Composer\InstalledVersions::satisfies(new \Composer\Semver\VersionParser(), 'illuminate/support', '^8.0')) { + if (! \Composer\InstalledVersions::satisfies(new \Composer\Semver\VersionParser, 'illuminate/support', '^8.0')) { return; } From 32d9354cd5dc5a833e6c8c10ca88bd8294ccbd11 Mon Sep 17 00:00:00 2001 From: Anton Stasyuk Date: Wed, 26 Feb 2025 15:44:24 +0100 Subject: [PATCH 2/2] fix(nova-5): nova's field resolveForDisplay method signature --- composer.json | 4 ++-- src/NovaEditorJsField.php | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index d00d0ee..d0e714a 100644 --- a/composer.json +++ b/composer.json @@ -67,8 +67,8 @@ "prefer-stable": true, "repositories": [ { - "type": "path", - "url": "./tests/Fixtures/nova" + "type": "composer", + "url": "https://nova.laravel.com" } ] } diff --git a/src/NovaEditorJsField.php b/src/NovaEditorJsField.php index 62b4558..9af723b 100644 --- a/src/NovaEditorJsField.php +++ b/src/NovaEditorJsField.php @@ -40,11 +40,10 @@ public function __construct($name, $attribute = null, ?callable $resolveCallback /** * Resolve the field's value for display. * - * @param string|null $attribute * * @throws \Throwable */ - public function resolveForDisplay($resource, $attribute = null) + public function resolveForDisplay($resource, ?string $attribute = null): void { $attribute = $attribute ?? $this->attribute; if ($attribute === 'ComputedField') {