class FactoryCountResetTypeSpecifyingExtension implements MethodTypeSpecifyingExtension, TypeSpecifierAwareExtension

Clear a factory's count after createMany(), createManyQuietly() or makeMany(), which clear it at runtime.

PHPStan applies this to a call used as a statement or an assigned value. A @phpstan-self-out tag would cover every call, but PHPStan stores a self-out type even for a receiver such as User::factory(), so later calls to User::factory() would lose their count too.

Methods

string
getClass()

Get the class the extension applies to.

bool
isMethodSupported(MethodReflection $methodReflection, MethodCall $node, TypeSpecifierContext $context)

Determine whether the call is a statement-level call of a base method that clears the count.

SpecifiedTypes
specifyTypes(MethodReflection $methodReflection, MethodCall $node, Scope $scope, TypeSpecifierContext $context)

Mark the receiving factory as making a single model.

void
setTypeSpecifier(TypeSpecifier $typeSpecifier)

Set the type specifier used to narrow the factory.

Details

at line 38
string getClass()

Get the class the extension applies to.

Return Value

string

at line 46
bool isMethodSupported(MethodReflection $methodReflection, MethodCall $node, TypeSpecifierContext $context)

Determine whether the call is a statement-level call of a base method that clears the count.

Parameters

MethodReflection $methodReflection
MethodCall $node
TypeSpecifierContext $context

Return Value

bool

at line 59
SpecifiedTypes specifyTypes(MethodReflection $methodReflection, MethodCall $node, Scope $scope, TypeSpecifierContext $context)

Mark the receiving factory as making a single model.

Parameters

MethodReflection $methodReflection
MethodCall $node
Scope $scope
TypeSpecifierContext $context

Return Value

SpecifiedTypes

at line 83
void setTypeSpecifier(TypeSpecifier $typeSpecifier)

Set the type specifier used to narrow the factory.

Parameters

TypeSpecifier $typeSpecifier

Return Value

void