Skip to content

[13.x] Revert "Correct Factory::configure @return to $this (#59963)"#60004

Merged
taylorotwell merged 1 commit into
laravel:13.xfrom
jnoordsij:revert-factory-this
May 6, 2026
Merged

[13.x] Revert "Correct Factory::configure @return to $this (#59963)"#60004
taylorotwell merged 1 commit into
laravel:13.xfrom
jnoordsij:revert-factory-this

Conversation

@jnoordsij
Copy link
Copy Markdown
Contributor

@jnoordsij jnoordsij commented May 6, 2026

This reverts commit 4727569 (#59963).

This change reverts the strict $this return to static, as returning new static instances (rather than (re-)configuring the existing one) is a common pattern for factories. For example, the documentation on factory callbacks illustrating the usage of configure does this by calling afterMaking and afterCreating, which both return new static instances (rather than $this); see https://laravel.com/docs/13.x/eloquent-factories#factory-callbacks.

Although the base implementation does indeed return $this, imposing this on child implementations seems too restrictive to me given these considerations.

/cc @mosabbirrakib was there any reason in particular you needed the restricted type?

@jnoordsij jnoordsij changed the title [13.xRevert "Correct Factory::configure @return to $this (#59963)" [13.x] Revert "Correct Factory::configure @return to $this (#59963)" May 6, 2026
@taylorotwell taylorotwell merged commit 328e74a into laravel:13.x May 6, 2026
53 of 54 checks passed
@jnoordsij jnoordsij deleted the revert-factory-this branch May 6, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants