From 19b6ebd58fe7c0e9aeeffb53691046f860955e87 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Thu, 9 Mar 2023 16:45:39 +0200 Subject: [PATCH] Add `AllowDynamicProperties` Attribute to cooperate with php8.2 deprecation --- src/Console/ModelsCommand.php | 6 ++++-- .../GeneratePhpdocWithMixin/__snapshots__/Test__test__1.php | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index 9f9931f..2aecdf2 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -1055,9 +1055,11 @@ class ModelsCommand extends Command } $classname = $this->write_mixin ? $mixinClassName : $classname; - $output = "namespace {$namespace}{\n{$docComment}\n\t{$keyword}class {$classname} "; - if (!$this->write_mixin) { + $allowDynamicAttributes = $this->write_mixin ? "#[\AllowDynamicProperties]\n\t" : ''; + $output = "namespace {$namespace}{\n{$docComment}\n\t{$keyword}{$allowDynamicAttributes}class {$classname} "; + + if (! $this->write_mixin) { $output .= "extends \Eloquent "; if ($interfaceNames) { diff --git a/tests/Console/ModelsCommand/GeneratePhpdocWithMixin/__snapshots__/Test__test__1.php b/tests/Console/ModelsCommand/GeneratePhpdocWithMixin/__snapshots__/Test__test__1.php index 88e7eb6..b8a826c 100644 --- a/tests/Console/ModelsCommand/GeneratePhpdocWithMixin/__snapshots__/Test__test__1.php +++ b/tests/Console/ModelsCommand/GeneratePhpdocWithMixin/__snapshots__/Test__test__1.php @@ -183,6 +183,7 @@ namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWi * @method static \Illuminate\Database\Eloquent\Builder|Post whereYearNullable($value) * @mixin \Eloquent */ - class IdeHelperPost {} + #[\AllowDynamicProperties] + class IdeHelperPost {} }