Skip to content

Commit

Permalink
refactor: remove not working BC layer on Factory::__construct() (#529)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikophil authored Dec 14, 2023
1 parent 58e06c2 commit 9e55f9a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/AnonymousFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
6 changes: 1 addition & 5 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,13 @@ class Factory
/**
* @param class-string<TObject> $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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Persistence/PersistentObjectFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ abstract class PersistentObjectFactory extends Factory
{
public function __construct()
{
parent::__construct(static::class(), calledInternally: true);
parent::__construct(static::class());
}

/**
Expand Down

0 comments on commit 9e55f9a

Please sign in to comment.