CollectionHelper
class CollectionHelper
Constants
| private FRAMEWORK_COLLECTIONS |
The framework collections, whose own method implementations the extensions and rules rely on. |
Methods
Create a new collection helper instance.
Determine whether the class runs a framework collection's own implementation of each method, which a subclass may override.
Determine whether a framework builder or relation implements the method, so the model's newCollection() creates the collections it returns. A custom builder's or relation's override keeps its declaration.
Get the collection type that collect() makes from a scalar, null or an empty array.
Determine whether the model creates its collections with HasCollection::newCollection(), which uses the
CollectedBy attribute or the static $collectionClass.
Get the collection type of the model, with the model and key types filled in.
Replace each Eloquent collection in the type with its model's collection type.
Details
at line 65
__construct(ReflectionProvider $reflectionProvider, DeclarationDependencyTracker $declarationDependencyTracker, AttributeClassNameResolver $attributeClassNames)
Create a new collection helper instance.
at line 78
static bool
usesFrameworkMethods(ClassReflection $classReflection, array $methods)
Determine whether the class runs a framework collection's own implementation of each method, which a subclass may override.
at line 94
static bool
isFrameworkQueryMethod(MethodReflection $methodReflection)
Determine whether a framework builder or relation implements the method, so the model's newCollection() creates the collections it returns. A custom builder's or relation's override keeps its declaration.
at line 117
GenericObjectType|null
determineGenericCollectionTypeFromType(Type $type)
Get the collection type that collect() makes from a scalar, null or an empty array.
collect()'s declared signature already describes objects and other arrays. Upstream also typed objects here, casting Arrayable objects with (array) instead of reading toArray(), and forcing integer keys onto Eloquent collections.
at line 214
bool
usesFrameworkNewCollection(ClassReflection $modelReflection)
Determine whether the model creates its collections with HasCollection::newCollection(), which uses the
CollectedBy attribute or the static $collectionClass.
at line 223
Type
determineCollectionClass(string $modelClassName, Type|null $modelType = null, Type|null $keyType = null)
Get the collection type of the model, with the model and key types filled in.
at line 270
Type
replaceCollectionsInType(Type $type)
Replace each Eloquent collection in the type with its model's collection type.