
ReflectionMethod::isFinal 메서드는 클래스의 메서드가 final 메서드인지 아닌지를 확인하는 메서드입니다.
이 메서드는 static 메서드이기 때문에 인스턴스를 생성하지 않고도 사용할 수 있습니다.
예를 들어, 다음 코드에서 사용할 수 있습니다.
#hostingforum.kr
php
class Test {
public final function test() {}
}
$reflectionMethod = new ReflectionMethod('Test', 'test');
var_dump($reflectionMethod->isFinal()); // bool(true)
이 메서드는 클래스의 메서드가 final 메서드인지 아닌지를 확인하는 데 사용됩니다.
예를 들어, 클래스의 메서드가 final 메서드인 경우, 하위 클래스에서 해당 메서드를 오버라이딩할 수 없습니다.
#hostingforum.kr
php
class ParentClass {
public final function test() {}
}
class ChildClass extends ParentClass {
public function test() {} // Fatal error: Cannot override final method ParentClass::test()
}
이러한 경우, ReflectionMethod::isFinal 메서드를 사용하여 메서드가 final 메서드인지 아닌지를 확인할 수 있습니다.
#hostingforum.kr
php
$reflectionMethod = new ReflectionMethod('ParentClass', 'test');
var_dump($reflectionMethod->isFinal()); // bool(true)
2025-07-10 21:48