Skip to content

Commit bc158a1

Browse files
authored
Add AllowDynamicProperties Attribute to cooperate with php8.2 deprecation (#1428)
* Add `AllowDynamicProperties` Attribute to cooperate with php8.2 deprecation * lint snapshot
1 parent 341c0ab commit bc158a1

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/Console/ModelsCommand.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,9 +1081,11 @@ protected function createPhpDocs($class)
10811081
}
10821082

10831083
$classname = $this->write_mixin ? $mixinClassName : $classname;
1084-
$output = "namespace {$namespace}{\n{$docComment}\n\t{$keyword}class {$classname} ";
10851084

1086-
if (!$this->write_mixin) {
1085+
$allowDynamicAttributes = $this->write_mixin ? "#[\AllowDynamicProperties]\n\t" : '';
1086+
$output = "namespace {$namespace}{\n{$docComment}\n\t{$keyword}{$allowDynamicAttributes}class {$classname} ";
1087+
1088+
if (! $this->write_mixin) {
10871089
$output .= "extends \Eloquent ";
10881090

10891091
if ($interfaceNames) {

tests/Console/ModelsCommand/GeneratePhpdocWithMixin/__snapshots__/Test__test__1.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ class Post extends Model
184184
* @method static \Illuminate\Database\Eloquent\Builder|Post whereYearNullable($value)
185185
* @mixin \Eloquent
186186
*/
187+
#[\AllowDynamicProperties]
187188
class IdeHelperPost {}
188189
}
189190

0 commit comments

Comments
 (0)