Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove not working BC layer on Factory::__construct() #529

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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