kafkiansky/service-locator-interrupter

Psalm plugin for Laravel that interrupt service locator calls.

5.0.0 2024-06-24 07:03 UTC

README

test Software License Quality Score StyleCI Total Downloads Latest Stable Version

Contents:

Installation

Install this package with Composer:

WHY

Laravel-like developers prefer to use some kinds of ioc bad practices. In example: facades, helpers method, container injection and container instances creation anywhere: controllers, services, routes and even in models. You need inject necessary services in method and constructor, not call container to do it for you. Any services must has it own contract, container injection - it's not legal contract, it's hack.

This plugin can found issues of service locator usage - helpers, facades, container injection, container instances creation - and prevent them.

Even if you have your own facade, the plugin will be found it.

Even if you have inherited Container/Application classes, the plugin will be found it.

Even if you have implemented any fo ContainerInterface, the plugin also prevent that.

Dependency Injection

Replacement map

Testing

$ composer codeception

License

The MIT License (MIT). See License File for more information.