Skip to content

Commit efffda0

Browse files
authored
Change cached boolean to map with late static binding
Co-authored-by: Choraimy Kroonstuiver <[email protected]> See #56078 (comment)
1 parent 9fa35d8 commit efffda0

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/Illuminate/Database/Eloquent/Model.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -252,18 +252,24 @@ abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToSt
252252

253253
/**
254254
* Whether it implements the SoftDeletes trait.
255+
*
256+
* @var array<class-string<self>, bool>
255257
*/
256-
protected static bool $isSoftDeletable;
258+
protected static array $isSoftDeletable;
257259

258260
/**
259261
* Whether it implements the Prunable trait.
262+
*
263+
* @var array<class-string<self>, bool>
260264
*/
261-
protected static bool $isPrunable;
265+
protected static array $isPrunable;
262266

263267
/**
264268
* Whether it implements the MassPrunable trait.
269+
*
270+
* @var array<class-string<self>, bool>
265271
*/
266-
protected static bool $isMassPrunable;
272+
protected static array $isMassPrunable;
267273

268274
/**
269275
* The name of the "created at" column.
@@ -2309,23 +2315,23 @@ public function setPerPage($perPage)
23092315
*/
23102316
public static function isSoftDeletable(): bool
23112317
{
2312-
return self::$isSoftDeletable ??= in_array(SoftDeletes::class, class_uses_recursive(static::class));
2318+
return static::$isSoftDeletable[static::class] ??= in_array(SoftDeletes::class, class_uses_recursive(static::class));
23132319
}
23142320

23152321
/**
23162322
* Determine if the model is prunable.
23172323
*/
23182324
protected function isPrunable(): bool
23192325
{
2320-
return self::$isPrunable ??= in_array(Prunable::class, class_uses_recursive(static::class)) || static::isMassPrunable();
2326+
return self::$isPrunable[static::class] ??= in_array(Prunable::class, class_uses_recursive(static::class)) || static::isMassPrunable();
23212327
}
23222328

23232329
/**
23242330
* Determine if the model is mass prunable.
23252331
*/
23262332
protected function isMassPrunable(): bool
23272333
{
2328-
return self::$isMassPrunable ??= in_array(MassPrunable::class, class_uses_recursive(static::class));
2334+
return self::$isMassPrunable[static::class] ??= in_array(MassPrunable::class, class_uses_recursive(static::class));
23292335
}
23302336

23312337
/**

0 commit comments

Comments
 (0)