Skip to content

Commit cf52d7f

Browse files
committed
Fix parameter order in Factory constructor and with method
Reorders the 'class' parameter in the Factory constructor and with() method to ensure correct argument mapping. Also updates a test to use the correct exception class reference.
1 parent dc5b156 commit cf52d7f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Factory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ class Factory
2424
*/
2525
public function __construct(
2626
protected ?int $count = null,
27+
protected ?string $class = null,
2728
protected ?Closure $using = null,
2829
protected Collection $states = new Collection,
2930
protected Collection $afterMaking = new Collection,
30-
protected ?string $class = null,
3131
) {
3232
$this->faker = $this->newFaker();
3333
}
@@ -269,10 +269,10 @@ protected function newInstance(array $arguments = []): static
269269
{
270270
return new static(...array_values(array_merge([
271271
'count' => $this->count,
272+
'class' => $this->class,
272273
'using' => $this->using,
273274
'states' => $this->states,
274275
'afterMaking' => $this->afterMaking,
275-
'class' => $this->class,
276276
], $arguments)));
277277
}
278278

tests/HasFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@
5757
it('throws exception for non-existent state methods', function () {
5858
expect(function () {
5959
HasFactoryWithStatesStub::factory()->nonExistentState()->make();
60-
})->toThrow(\BadMethodCallException::class);
60+
})->toThrow(BadMethodCallException::class);
6161
});

0 commit comments

Comments
 (0)