worksome/phpstan-request-factories

A PHPStan rule for enforcing that every request has a corresponding factory.

v1.1.0 2024-02-13 14:39 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Static Analysis Action Status Total Downloads

A PHPStan rule for enforcing that every request has a corresponding factory.

Installation

You can install the package via composer:

composer require --dev worksome/phpstan-request-factories

If you have also installed phpstan/extension-installer then everything will work out of the box.

Manual installation

If you don't want to use phpstan/extension-installer, include extension.neon in your project's PHPStan config:

includes:
    - vendor/worksome/phpstan-request-factories/extension.neon

Usage

Choosing different namespaces

The request and factory namespaces are both configurable. They can be configured using the following parameters:

  • requestFactories.requestsNamespace (default is App\\Http\\Requests)
  • requestFactories.factoriesNamespace (default is Tests\\RequestFactories)

For example:

parameters:
  requestFactories:
    requestsNamespace: App\Http\Requests
    factoriesNamespace: Tests\RequestFactories

Excluding request classes

If there are certain request classes that you want to exclude, you can exclude these using the excludedRequestClasses parameter.

For example:

parameters:
  requestFactories:
    excludedRequestClasses:
        - App\Http\Requests\IgnorableRequest

Testing

composer test

Changelog

Please see GitHub Releases 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.