class MyClass { public function myMethod() { // method body } } $refMethod = new ReflectionMethod('MyClass', 'myMethod'); $endLine = $refMethod->getEndLine(); echo "End Line of myMethod: " . $endLine; // Output: End Line of myMethod: 4
namespace MyNamespace; class MyClass { public function myMethod() { // method body } } $refMethod = new \ReflectionMethod('MyNamespace\MyClass', 'myMethod'); $endLine = $refMethod->getEndLine(); echo "End Line of myMethod: " . $endLine; // Output: End Line of myMethod: 5This example is similar to the first one, but it includes a namespace declaration. The `ReflectionMethod` instance is constructed using the fully-qualified name of the class (`MyNamespace\MyClass`). The output will be the end line number of the `myMethod` method within the namespace. Package/Library: The `ReflectionMethod` class is a built-in class in PHP, so it does not belong to any external package or library.