Download the PHP package soyhuce/empty-collection without Composer
On this page you can find all versions of the php package soyhuce/empty-collection. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download soyhuce/empty-collection
More information about soyhuce/empty-collection
Files in soyhuce/empty-collection
Package empty-collection
Short Description Empty Laravel collections correctly understood by PHPStan
License MIT
Informations about the package empty-collection
Empty Laravel collections correctly understood by PHPStan
Installation
You can install the package via composer:
Add the provided PHPStan extension in your PHPStan configuration:
This package does not require phpstan/phpstan
to be installed in order to keep it in your dev dependencies.
Be sure to use version 1.4.6
or higher.
Usage
Have you ever had some issue with incorrectly typed empty collections in Laravel ? Have you ever seen these PHPStan errors ?
We get you covered !
This package provides an easy way to initialise empty collections, correctly typed for PHPStan.
Let's take an example:
This way, PHPStan won't complain about the type of the collection.
Available functions
empty_collection(string $keyType, string $valueType) : \Illuminate\Support\Collection
$keyType
must be 'int'
or 'string'
.
$valueType
must be some type PHPStan will understand.
Exemples:
empty_eloquent_collection(string $keyType, string $valueType) : \Illuminate\Database\Eloquent\Collection
$keyType
must be 'int'
or 'string'
.
$valueType
must be a class name.
Exemples:
Testing
Testing is done via PHPStan and can be run with
Changelog
Please see CHANGELOG for more information on what has changed recently.
License
The MIT License (MIT). Please see License File for more information.