- 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.