smpita / makeas
Typed Container Resolver for Laravel
Installs: 8 527
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: ^8.1
- illuminate/contracts: ^10.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.8
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.4
- pestphp/pest: ^2.0
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
README
- Do you fight the
mixed
signature ofapp()->make()
when resolving objects? - Do you want to effortlessly guarantee the resolved object is the expected object?
- Do you use static analysis on your Laravel app?
MakeAs will make sure you make the object you expect, and nicely type the return for static analysis.
Installation
You can install the package via composer:
composer require smpita/makeas
Usage
If you bound an object to its class-string
$typed = app()->makeAs(Bound::class);
Of course, you can pass in parameters
$typed = app()->makeAs(Bound::class, []);
If you bound an object with a magic string
$typed = app()->makeAs('magic-string', [], Bound::class);
Signature
makeAs(string $abstract, array $parameters = [], string $expected = null): mixed
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.