brandembassy/phpstan-forbidden-method-calls-rule

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

This package's canonical repository appears to be gone and the package has been frozen as a result. Email us for help if needed.

Package info

github.com/BrandEmbassy/phpstan-forbidden-method-calls-rule

pkg:composer/brandembassy/phpstan-forbidden-method-calls-rule

Statistics

Installs: 23 057

Dependents: 0

Suggesters: 0

Stars: 7

Open Issues: 3

1.0.1 2018-08-21 08:29 UTC

Requires

  • php: ~7.2

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 83d432f9961e2b6f9d26aab84157040408be7288

This package is not auto-updated.

Last update: 2025-06-08 09:13:52 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(). 
 ------ -----------------------------------------------------------------