Skip to content

Releases: DaveLiddament/phpstan-effect-system

Release list

0.2.0

Choose a tag to compare

@DaveLiddament DaveLiddament released this 09 Oct 13:34
7bc6120
  • New exemptions
  • Mandate list of effects in config

New: exemptions from pattern rules (#1)

Pattern rules can now have exceptions, without ignoreErrors and without #[HandlesEffect] (which wrongly stops the effect
reaching callers).

  • exclude on a rule for classes the policy was never meant to cover:

    rules:
        -
            classPattern: 'App\Controller\*Controller'
            methodPattern: '*'
            effectFree: ['slow']
            exclude:
                - 'App\Controller\DebugController'
                - 'App\Controller\Internal\*'
    
  • #[ExemptFromEffectRule('slow', reason: '...')] for one method that is allowed to reach the effect, such as an
    endpoint only requested by a background job.

Both only drop contracts that come from pattern rules: a method's own or inherited #[EffectFree] always applies. Neither
stops the effect propagating, so callers of an exempt method are still checked.

New error identifiers:

  • effects.invalidExemption: an exemption on a method whose EffectFree contract is its own or inherited.
  • effects.unusedExemption: an exemption no rule needs, or on a method that no longer reaches the effect.
  • effects.unusedExclusion: an exclude pattern that matches nothing. It is reported against the file N/A.

allowedEffects is now required

Every effect name used in #[Effect], #[EffectFree], #[HandlesEffect],
#[ExemptFromEffectRule], stubs and pattern rules must be listed. Before, an empty list (the default) switched the check
off, so a typo such as #[EffectFree('slwo')] created a contract that could never fail. To upgrade, list your effect names:

  parameters:
      effects:
          allowedEffects: ['slow', 'io']

Until you do, each effect name in an attribute is reported as effects.unknownEffect. An unlisted name in a stub or pattern
rule stops PHPStan at startup.

0.1.0

Choose a tag to compare

@DaveLiddament DaveLiddament released this 19 Sep 08:55

Initial release

This has not been tested in the wild. Please expect and report bugs.