class BuilderHelper

Resolve the builders and queries that Eloquent models forward their calls to, as the runtime does.

Methods

__construct(ReflectionProvider $reflectionProvider, DeclarationDependencyTracker $declarationDependencyTracker, AttributeClassNameResolver $attributeClassNames)

Create a builder helper.

bool
isPassthru(ClassReflection $builderClass, string $methodName)

Determine whether the builder passes the method through to its base query.

array
queryTypes(ClassReflection $builderClass)

Return the declared types of the queries a builder forwards to: its stored query, which ordinary forwarded calls run on, and the query passthru calls run on.

Type
bindQueryRows(Type $queryType, Type $modelType)

Bind a forwarded query's row types to the model, without changing raw-query types.

Type
getBuilderType(Type $builderType, Type $modelType)

Return the builder type holding the model, as Model::newModelQuery() binds it through setModel().

Type|null
determineBuilderClass(string $modelClassName, Type $modelType, bool $modelQuery = false)

Return the builder type the model creates, with the given model type bound to it.

Type
templateType(ClassReflection $classReflection, string $ancestorClass, string $templateName)

Return an active template type from a class ancestor.

bool
hasNativeOrDocumentedMethod(ClassReflection $classReflection, string $methodName)

Determine whether a class owns a native or documented method, which a forwarded method would not replace.

Details

at line 59
__construct(ReflectionProvider $reflectionProvider, DeclarationDependencyTracker $declarationDependencyTracker, AttributeClassNameResolver $attributeClassNames)

Create a builder helper.

Parameters

ReflectionProvider $reflectionProvider
DeclarationDependencyTracker $declarationDependencyTracker
AttributeClassNameResolver $attributeClassNames

at line 70
bool isPassthru(ClassReflection $builderClass, string $methodName)

Determine whether the builder passes the method through to its base query.

Parameters

ClassReflection $builderClass
string $methodName

Return Value

bool

at line 94
array queryTypes(ClassReflection $builderClass)

Return the declared types of the queries a builder forwards to: its stored query, which ordinary forwarded calls run on, and the query passthru calls run on.

Builder::__call() passes passthru calls to toBase() and forwards others to the stored query. Read through getMethod(), so a @method tag counts, as packages replacing the query layer (such as mongodb/laravel-mongodb) declare it on toBase().

Parameters

ClassReflection $builderClass

Return Value

array

at line 112
Type bindQueryRows(Type $queryType, Type $modelType)

Bind a forwarded query's row types to the model, without changing raw-query types.

Parameters

Type $queryType
Type $modelType

Return Value

Type

at line 144
Type getBuilderType(Type $builderType, Type $modelType)

Return the builder type holding the model, as Model::newModelQuery() binds it through setModel().

setModel() rebinds only the template mapped to the Eloquent builder's model, so other type arguments and a builder that fixes its model keep their declarations.

Parameters

Type $builderType
Type $modelType

Return Value

Type

at line 281
Type|null determineBuilderClass(string $modelClassName, Type $modelType, bool $modelQuery = false)

Return the builder type the model creates, with the given model type bound to it.

Parameters

string $modelClassName
Type $modelType
bool $modelQuery

whether to return newModelQuery()'s builder instead of newQuery()'s

Return Value

Type|null

at line 306
Type templateType(ClassReflection $classReflection, string $ancestorClass, string $templateName)

Return an active template type from a class ancestor.

Parameters

ClassReflection $classReflection
string $ancestorClass
string $templateName

Return Value

Type

at line 323
bool hasNativeOrDocumentedMethod(ClassReflection $classReflection, string $methodName)

Determine whether a class owns a native or documented method, which a forwarded method would not replace.

Parameters

ClassReflection $classReflection
string $methodName

Return Value

bool