From 9e55f9a8b487868bacd6a83ec00b805ebe171713 Mon Sep 17 00:00:00 2001 From: Nicolas PHILIPPE Date: Thu, 14 Dec 2023 08:15:28 +0100 Subject: [PATCH] refactor: remove not working BC layer on Factory::__construct() (#529) --- src/AnonymousFactory.php | 2 +- src/Factory.php | 6 +----- src/Persistence/PersistentObjectFactory.php | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/AnonymousFactory.php b/src/AnonymousFactory.php index e83da54d..24dac49d 100644 --- a/src/AnonymousFactory.php +++ b/src/AnonymousFactory.php @@ -36,7 +36,7 @@ public function __construct(string $class, array|callable $defaultAttributes = [ trigger_deprecation('zenstruck\foundry', '1.30', 'Class "AnonymousFactory" is deprecated and will be removed in 2.0. Use the "anonymous()" or "repository()" functions instead.'); - parent::__construct($class, $defaultAttributes, calledInternally: true); + parent::__construct($class, $defaultAttributes); } /** diff --git a/src/Factory.php b/src/Factory.php index b1ad767f..0aa03093 100644 --- a/src/Factory.php +++ b/src/Factory.php @@ -58,17 +58,13 @@ class Factory /** * @param class-string $class */ - public function __construct(string $class, array|callable $defaultAttributes = [], bool $calledInternally = false) + public function __construct(string $class, array|callable $defaultAttributes = []) { /** @phpstan-ignore-next-line */ if (self::class === static::class) { trigger_deprecation('zenstruck/foundry', '1.9', 'Instantiating "%s" directly is deprecated and this class will be abstract in 2.0, use "anonymous()" function instead.', self::class); } - if (!$calledInternally) { - trigger_deprecation('zenstruck\foundry', '1.37.0', 'Constructor of class Zenstruck\Foundry\Factory is deprecated and will be removed in version 2.0. You should not call parent::__construct() anymore from your factories.'); - } - $this->class = $class; $this->attributes[] = $defaultAttributes; } diff --git a/src/Persistence/PersistentObjectFactory.php b/src/Persistence/PersistentObjectFactory.php index 9880a475..257db864 100644 --- a/src/Persistence/PersistentObjectFactory.php +++ b/src/Persistence/PersistentObjectFactory.php @@ -29,7 +29,7 @@ abstract class PersistentObjectFactory extends Factory { public function __construct() { - parent::__construct(static::class(), calledInternally: true); + parent::__construct(static::class()); } /**