topotru/phpstan-conditional-final

Smart final/abstract class enforcement with attributes-based exclusions for PHPStan. Perfect for Doctrine entities.

Maintainers

Package info

github.com/topotru/phpstan-conditional-final

Type:phpstan-extension

pkg:composer/topotru/phpstan-conditional-final

Statistics

Installs: 18

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.1 2026-05-14 12:55 UTC

This package is auto-updated.

Last update: 2026-05-14 12:56:45 UTC


README

Smart final/abstract class enforcement with attributes-based exclusions for PHPStan.

Installation

composer require --dev topotru/phpstan-conditional-final

Usage

By default, the extension requires all classes to be final or abstract and has an empty exclusion list.

Integration with Doctrine ORM

If your project uses Doctrine, include the preconfigured preset in your phpstan.neon:

includes:
    - vendor/topotru/phpstan-conditional-final/doctrine.neon

This preset automatically protects #[Entity] and #[MappedSuperclass] classes from being marked as final.

Custom Configurations

You can add any custom proxy or framework attributes to the exclusion list manually:

parameters:
    conditionalFinal:
        forbiddenFinalAttributes:
            - App\Attributes\CustomProxy
            - ApiPlatform\Metadata\ApiResource

For classes, specified in forbiddenFinalAttributes, an error will be issued if they are finalized.

License

MIT