Skip to content
Open
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: 2 additions & 0 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public static function createOne(array|callable $attributes = []): mixed
* @phpstan-param Attributes $attributes
*
* @return list<T>
* @phpstan-return ($number is positive-int ? non-empty-list<T> : list<T>)
*/
final public static function createMany(int $number, array|callable $attributes = []): array
{
Expand All @@ -80,6 +81,7 @@ final public static function createMany(int $number, array|callable $attributes
* @phpstan-param Attributes $attributes
*
* @return list<T>
* @phpstan-return ($min is positive-int ? non-empty-list<T> : list<T>)
*/
final public static function createRange(int $min, int $max, array|callable $attributes = []): array
{
Expand Down
10 changes: 6 additions & 4 deletions src/Persistence/PersistentObjectFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ public static function randomOrCreate(array $criteria = []): object

/**
* @param positive-int $count
* @phpstan-param Parameters $criteria
* @phpstan-param Parameters $criteria
*
* @return list<T>
* @return non-empty-list<T>
*/
public static function randomSet(int $count, array $criteria = []): array
{
Expand All @@ -112,9 +112,10 @@ public static function randomSet(int $count, array $criteria = []): array
/**
* @param int<0, max> $min
* @param int<0, max> $max
* @phpstan-param Parameters $criteria
* @phpstan-param Parameters $criteria
*
* @return list<T>
* @phpstan-return ($min is positive-int ? non-empty-list<T> : list<T>)
*/
public static function randomRange(int $min, int $max, array $criteria = []): array
{
Expand All @@ -124,9 +125,10 @@ public static function randomRange(int $min, int $max, array $criteria = []): ar
/**
* @param int<0, max> $min
* @param int<0, max> $max
* @phpstan-param Parameters $criteria
* @phpstan-param Parameters $criteria
*
* @return list<T>
* @phpstan-return ($min is positive-int ? non-empty-list<T> : list<T>)
*/
public static function randomRangeOrCreate(int $min, int $max, array $criteria = []): array
{
Expand Down
4 changes: 2 additions & 2 deletions stubs/psalm/ObjectFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ protected function defaults(): array|callable
$var = UserObjectFactory::new()->with()->create();

// methods returning a list of objects
/** @psalm-check-type-exact $var = list<UserForObjectFactory> */
/** @psalm-check-type-exact $var = non-empty-list<UserForObjectFactory> */
$var = UserObjectFactory::createMany(1);
/** @psalm-check-type-exact $var = list<UserForObjectFactory> */
/** @psalm-check-type-exact $var = non-empty-list<UserForObjectFactory> */
$var = UserObjectFactory::createRange(1, 2);
/** @psalm-check-type-exact $var = list<UserForObjectFactory> */
$var = UserObjectFactory::createSequence([]);
Expand Down
8 changes: 4 additions & 4 deletions stubs/psalm/PersistentObjectFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ protected function defaults(): array|callable
// methods returning a list of objects
/** @psalm-check-type-exact $var = list<UserForPersistentFactory> */
$var = UserFactory::all();
/** @psalm-check-type-exact $var = list<UserForPersistentFactory> */
/** @psalm-check-type-exact $var = non-empty-list<UserForPersistentFactory> */
$var = UserFactory::createMany(1);
/** @psalm-check-type-exact $var = list<UserForPersistentFactory> */
/** @psalm-check-type-exact $var = non-empty-list<UserForPersistentFactory> */
$var = UserFactory::createRange(1, 2);
/** @psalm-check-type-exact $var = list<UserForPersistentFactory> */
$var = UserFactory::createSequence([]);
/** @psalm-check-type-exact $var = list<UserForPersistentFactory> */
/** @psalm-check-type-exact $var = non-empty-list<UserForPersistentFactory> */
$var = UserFactory::randomRange(1, 2);
/** @psalm-check-type-exact $var = list<UserForPersistentFactory> */
/** @psalm-check-type-exact $var = non-empty-list<UserForPersistentFactory> */
$var = UserFactory::randomSet(2);
/** @psalm-check-type-exact $var = list<UserForPersistentFactory> */
$var = UserFactory::findBy(['name' => 'foo']);
Expand Down
Loading