cspray/phinal
Enforce final on your classes!
Maintainers
2.1.1
2025-06-11 13:11 UTC
Requires
- php: ^8.1
- ext-simplexml: *
- vimeo/psalm: ^5.0.0|^6.0.0
Requires (Dev)
- behat/behat: ^3.18.1
- codeception/codeception: ^5.1.2
- phpunit/phpunit: ^10.5.40
- psalm/plugin-phpunit: ^0.19.2
- squizlabs/php_codesniffer: ^3.11.3
- weirdan/codeception-psalm-module: ^0.14.0
- weirdan/prophecy-shim: ^2.0.2
Suggests
None
Provides
None
Conflicts
None
Replaces
None
MIT f7d1535ab4ec560d8f6b1c75a7661068caa83c70
README
Do you like final? Really like it? Then enforce it on all your classes! When you have to fallback to inheritance you can do so by explicitly marking your class with an Attribute and explaining why it should be inherited.
Installation
Running Psalm 6
composer require --dev cspray/phinal
vendor/bin/psalm-plugin enable cspray/phinal
Running Psalm 5
composer require --dev cspray/phinal:2.1
vendor/bin/psalm-plugin enable cspray/phinal
Running Psalm 4
composer require --dev cspray/phinal:1.0.0
vendor/bin/psalm-plugin enable cspray/phinal
Code Examples
Good! 👍
<?php declare(strict_types=1); use Cspray\Phinal\AllowInheritance; final class ProperlyMarkedFinal {} #[AllowInheritance('Explain why you would need to inherit this.')] class YouCanInheritThis {}
Bad! 👎
<?php declare(strict_types=1); class NotMarkedFinal {}
Why do you need to inherit this? You probably don't need to and should mark it final!
