PHP 8.5.0 Alpha 2 available for testing

ReflectionMethod::getPrototype

(PHP 5 >= 5.1.2, PHP 7, PHP 8)

ReflectionMethod::getPrototypeObtiene el prototipo del método (si existe)

Descripción

public ReflectionMethod::getPrototype(): ReflectionMethod

Devuelve el prototipo del método.

Parámetros

Esta función no contiene ningún parámetro.

Valores devueltos

Un objeto ReflectionMethod instancia del método.

Errores/Excepciones

Se lanzará una excepción ReflectionException si el método no posee un prototipo.

Ejemplos

Ejemplo #1 Ejemplo con ReflectionMethod::getPrototype()

<?php
class Hello {

public function
sayHelloTo($name) {
return
'Hello ' . $name;
}

}
class
HelloWorld extends Hello {

public function
sayHelloTo($name) {
return
'Hello world: ' . $name;
}

}

$reflectionMethod = new ReflectionMethod('HelloWorld', 'sayHelloTo');
var_dump($reflectionMethod->getPrototype());
?>

El ejemplo anterior mostrará :

object(ReflectionMethod)#2 (2) {
  ["name"]=>
  string(10) "sayHelloTo"
  ["class"]=>
  string(5) "Hello"
}

Ver también

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top