cspray/phinal

在您的类上强制执行final!

维护者

详细信息

github.com/cspray/phinal

源代码

问题

安装次数: 103,913

依赖项: 6

建议者: 0

安全性: 0

星标: 12

关注者: 2

分支: 1

开放性问题: 0

类型:psalm-plugin

2.0.0 2023-01-26 13:36 UTC

This package is auto-updated.

Last update: 2024-08-26 17:38:44 UTC


README

你喜欢final吗?真的很喜欢?那么就在所有的类上强制执行它!当你需要回退到继承时,你可以通过显式地标记你的类并解释为什么它应该被继承来完成。

安装

运行Psalm 5

composer require --dev cspray/phinal
vendor/bin/psalm-plugin enable cspray/phinal

运行Psalm 4

composer require --dev cspray/phinal:1.0.0
vendor/bin/psalm-plugin enable cspray/phinal

代码示例

太好了!👍

<?php declare(strict_types=1);

use Cspray\Phinal\AllowInheritance;

final class ProperlyMarkedFinal {}

#[AllowInheritance('Explain why you would need to inherit this.')]
class YouCanInheritThis {}

不好!👎

<?php declare(strict_types=1);

class NotMarkedFinal {}

你为什么需要继承这个?你可能不需要,应该标记为final!