PHP - Manual: ReflectionProperty::isFinal
2025-10-24
(PHP 8 >= 8.4.0)
ReflectionProperty::isFinal — Determines if this property is final or not
本函数还未编写文档,仅有参数列表。
Returns whether the property is
final.
If the property is marked private(set),
then it will also be implicitly final.
此函数没有参数。
Returns true if the property is explicitly marked final,
or if it is implicitly final due to being private(set).
Returns false otherwise.
示例 #1 ReflectionProperty::isFinal() example
<?php
class Example
{
public string $name;
final protected int $age;
public private(set) string $job;
}
$rClass = new \ReflectionClass(Example::class);
var_dump($rClass->getProperty('name')->isFinal());
var_dump($rClass->getProperty('age')->isFinal());
var_dump($rClass->getProperty('job')->isFinal());
?>以上示例会输出:
bool(false) bool(true) bool(true)
官方地址:https://www.php.net/manual/en/reflectionproperty.isfinal.php