brandembassy/phpstan-forbidden-method-calls-rule

Rule for PHPStan that enables you to forbid some methods from being called.

1.0.1 2018-08-21 08:29 UTC

This package is not auto-updated.

Last update: 2024-11-10 05:51:24 UTC


README

This PHPStan rule was created by Petr Morávek (https://github.com/xificurk).

Usage

composer require --dev brandembassy/phpstan-forbidden-method-calls-rule 

And then in your phpstan.neon register service:

services:
    -
        class: BrandEmbasssy\ForbiddenMethodCallsRule\ForbiddenMethodCallsRule
        setup:
            - addForbiddenMethod(Psr\Http\Message\StreamInterface, getContents)
        tags:
            - phpstan.rules.rule

Example

 ------ ----------------------------------------------------------------- 
  Line   foo/Bar/Baz.php (in context of class Foo\Bar\Baz)  
 ------ ----------------------------------------------------------------- 
  95     Calling forbidden method                                                                                                                                        
         Psr\Http\Message\StreamInterface:getContents().                                                                                                                 
 ------ -----------------------------------------------------------------