Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Typed Collections

Typed Collections Laravel Package

vistik/typed-collections

A Laravel/PHP package for type-safe collections: enforce element types at runtime, improve IDE and static-analysis support, and keep familiar Collection ergonomics. Define typed collections for models, DTOs, scalars, and custom classes.

View on GitHub
Deep Wiki
Context7

A simple library to create type hinted collections in PHP- build on Laravals Collection class

Frequently asked questions about Typed Collections
What is vistik/typed-collections and how does it work with Laravel?
vistik/typed-collections is a small PHP library that extends Laravel's Illuminate\Support\Collection to enforce element types at runtime. You define a typed collection class and it checks items when they are added, giving you type hints alongside familiar Collection methods. It was built for Laravel 5.x-era applications and is a thin wrapper rather than a full static-analysis solution.
How do I install vistik/typed-collections with Composer?
Installation is via Composer using the package name vistik/typed-collections, typically with composer require vistik/typed-collections. Because the repository is archived and the last release was in 2017, you should check composer.json constraints and run a compatibility spike before adding it to a modern Laravel app. For legacy projects, consider vendoring or forking the source instead of relying on Packagist for an abandoned dependency.
Does vistik/typed-collections support Laravel 8, 9, 10, or 11?
The package was likely built for Laravel 5.x and PHP 7.0, and its compatibility with Laravel 8+ is unproven. Modern Illuminate\Support\Collection may include breaking changes, so a time-boxed compatibility spike and full test run are required before adoption. It is not recommended for new Laravel 8+ builds without validation and likely code changes.
What PHP versions does vistik/typed-collections require?
The package dates from 2017 and was likely designed for PHP 7.0-era projects, so modern PHP 8+ compatibility is not guaranteed. You should inspect the composer.json PHP constraint and test the exact Collection methods it overrides on your target runtime. Treat any PHP 8 adoption as requiring a fork-and-own maintenance decision.
How do I create a typed collection for Eloquent models or DTOs?
You extend the package's typed collection base class and declare the element type it should accept, then use familiar Laravel Collection methods such as map, filter, and each. The runtime check applies when items are inserted, so it can cover models, DTOs, scalars, and custom classes. Because the package is archived, isolate that class behind an interface or abstract base so you can replace it later.
Is vistik/typed-collections maintained and safe for production?
No, the repository is archived, the last release was 2017-07-27, and it has very low community adoption. There are no security or bug-fix updates, so production use creates a fork-and-own dependency with high technical risk. It may be acceptable only in low-risk legacy paths with a documented owner and replacement plan.
What are alternatives to vistik/typed-collections for type-safe Laravel collections?
Alternatives include native Laravel Collections with PHPStan or Psalm generics annotations, small in-house typed collection classes, and maintained type-safe collection libraries. For modern applications, static analysis annotations often solve the same business problem without an abandoned runtime dependency. Evaluate whether you need runtime enforcement or only IDE and static-analysis support before choosing.
Can I use vistik/typed-collections with PHPStan or Psalm generics?
The package provides runtime type hints, but it does not replace PHPStan or Psalm generic collection annotations. You may still need static-analysis annotations or stubs to get full generic type inference in your IDE and CI checks. For modern codebases, combining native Collections with generics annotations is usually a better long-term fit than an archived wrapper.
Does vistik/typed-collections enforce types on push, put, and other Collection methods?
The package is designed to enforce element types at runtime when items are inserted, but raw Collection methods such as push or put can bypass checks if they are not consistently routed through the typed class. You should review the exact overridden methods and add tests for every insertion path your application uses. Silent type bypasses are a real risk when developers mix native Collections with typed ones.
Should I fork or vendor vistik/typed-collections for a legacy Laravel 5 app?
A fork or vendored copy is the safer option if you must use it in a legacy Laravel 5.x application, because the upstream repository is archived and Packagist reliance is risky. Assign an internal owner for compatibility updates, security review, and eventual replacement. Keep usage behind an interface or base class and plan migration to an in-house typed collection or static analysis.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource