本文整理汇总了PHP中ReflectionClass::getMethods方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionClass::getMethods方法的具体用法?PHP ReflectionClass::getMethods怎么用?PHP ReflectionClass::getMethods使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionClass
的用法示例。
在下文中一共展示了ReflectionClass::getMethods方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: procesar
function procesar()
{
toba::logger_ws()->debug('Servicio Llamado: ' . $this->info['basica']['item']);
toba::logger_ws()->set_checkpoint();
set_error_handler('toba_logger_ws::manejador_errores_recuperables', E_ALL);
$this->validar_componente();
//-- Pide los datos para construir el componente, WSF no soporta entregar objetos creados
$clave = array();
$clave['proyecto'] = $this->info['objetos'][0]['objeto_proyecto'];
$clave['componente'] = $this->info['objetos'][0]['objeto'];
list($tipo, $clase, $datos) = toba_constructor::get_runtime_clase_y_datos($clave, $this->info['objetos'][0]['clase'], false);
agregar_dir_include_path(toba_dir() . '/php/3ros/wsf');
$opciones_extension = toba_servicio_web::_get_opciones($this->info['basica']['item'], $clase);
$wsdl = strpos($_SERVER['REQUEST_URI'], "?wsdl") !== false;
$sufijo = 'op__';
$metodos = array();
$reflexion = new ReflectionClass($clase);
foreach ($reflexion->getMethods() as $metodo) {
if (strpos($metodo->name, $sufijo) === 0) {
$servicio = substr($metodo->name, strlen($sufijo));
$prefijo = $wsdl ? '' : '_';
$metodos[$servicio] = $prefijo . $metodo->name;
}
}
$opciones = array();
$opciones['serviceName'] = $this->info['basica']['item'];
$opciones['classes'][$clase]['operations'] = $metodos;
$opciones = array_merge($opciones, $opciones_extension);
$this->log->debug("Opciones del servidor: " . var_export($opciones, true), 'toba');
$opciones['classes'][$clase]['args'] = array($datos);
toba::logger_ws()->set_checkpoint();
$service = new WSService($opciones);
$service->reply();
$this->log->debug("Fin de servicio web", 'toba');
}
示例2: run
public static function run()
{
foreach (glob(app_path() . '/Http/Controllers/*.php') as $filename) {
$file_parts = explode('/', $filename);
$file = array_pop($file_parts);
$file = rtrim($file, '.php');
if ($file == 'Controller') {
continue;
}
$controllerName = 'App\\Http\\Controllers\\' . $file;
$controller = new $controllerName();
if (isset($controller->exclude) && $controller->exclude === true) {
continue;
}
$methods = [];
$reflector = new \ReflectionClass($controller);
foreach ($reflector->getMethods(\ReflectionMethod::IS_PUBLIC) as $rMethod) {
// check whether method is explicitly defined in this class
if ($rMethod->getDeclaringClass()->getName() == $reflector->getName()) {
$methods[] = $rMethod->getName();
}
}
\Route::resource(strtolower(str_replace('Controller', '', $file)), $file, ['only' => $methods]);
}
}
示例3: __callStatic
/**
* Call to undefined static method.
* @throws LogicException
*/
public static function __callStatic($name, $args)
{
$rc = new \ReflectionClass(get_called_class());
$items = array_intersect($rc->getMethods(\ReflectionMethod::IS_PUBLIC), $rc->getMethods(\ReflectionMethod::IS_STATIC));
$hint = ($t = Helpers::getSuggestion($items, $name)) ? ", did you mean {$t}()?" : '.';
throw new LogicException("Call to undefined static method {$rc->getName()}::{$name}(){$hint}");
}
示例4: _parseMethods
protected function _parseMethods()
{
$methods = $this->_class->getMethods();
foreach ($methods as $method) {
$this->_methods[] = new AnnotatedMethod($method);
}
}
示例5: construct
/**
* Construct and return Array-Object
* @param String $class
* @return Array
*/
public static function construct($class)
{
// If is already an object return the object
// If not create an instance of the object bypassing a possible
// class constructor
if (is_object($class)) {
$instantiatedClass = $class;
$class = get_class($class);
} else {
$instantiatedClass = self::instantiate($class);
}
// Clean arrays
$properties = array('protected' => array(), 'public' => array());
$methods = array('protected' => array(), 'public' => array());
// Reflection get properties and methods names (public and protected)
$reflect = new \ReflectionClass($instantiatedClass);
$reflectedClass = array('properties' => array('protected' => $reflect->getProperties(\ReflectionProperty::IS_PROTECTED), 'public' => $reflect->getProperties(\ReflectionProperty::IS_PUBLIC)), 'methods' => array('protected' => $reflect->getMethods(\ReflectionProperty::IS_PROTECTED), 'public' => $reflect->getMethods(\ReflectionProperty::IS_PUBLIC)));
// Properties foreach's
foreach ($reflectedClass['properties']['protected'] as $prop) {
$properties['protected'][] = $prop->name;
}
foreach ($reflectedClass['properties']['public'] as $prop) {
$properties['public'][] = $prop->name;
}
// Methods foreach's
foreach ($reflectedClass['methods']['protected'] as $method) {
$methods['protected'][] = $method->name;
}
foreach ($reflectedClass['methods']['public'] as $method) {
$methods['public'][] = $method->name;
}
// Return Array-Object
return array('name' => $class, 'object' => $instantiatedClass, 'methods' => $methods, 'properties' => $properties);
}
示例6: readInterface
/**
* Derives properties from constructor, public instance variables, getters and setters.
*
* @param object|null $object If provided, dynamic (run-time) variables are read as well
* @return \watoki\collections\Map|Property[] indexed by property name
*/
public function readInterface($object = null)
{
$properties = new Map();
if ($this->class->getConstructor()) {
foreach ($this->class->getConstructor()->getParameters() as $parameter) {
$this->accumulate($properties, new property\ConstructorProperty($this->factory, $this->class->getConstructor(), $parameter));
}
}
$declaredProperties = array();
foreach ($this->class->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) {
if (!$property->isStatic()) {
$declaredProperties[] = $property->name;
$this->accumulate($properties, new property\InstanceVariableProperty($this->factory, $property));
}
}
if (is_object($object)) {
foreach ($object as $name => $value) {
if (!in_array($name, $declaredProperties)) {
$this->accumulate($properties, new property\DynamicProperty($this->factory, new \ReflectionClass($object), $name));
}
}
}
foreach ($this->class->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
if (property\AccessorProperty::isAccessor($method) && !$method->isStatic()) {
$this->accumulate($properties, new property\AccessorProperty($this->factory, $method));
}
}
return $properties;
}
示例7: exportCode
/**
* Exports the PHP code
*
* @return string
*/
public function exportCode()
{
$code_lines = array();
$code_lines[] = '<?php';
// Export the namespace
if ($this->_reflection_class->getNamespaceName()) {
$code_lines[] = '';
$code_lines[] = 'namespace ' . $this->_reflection_class->getNamespaceName() . ';';
$code_lines[] = '';
}
// Export the class' signature
$code_lines[] = sprintf('%s%s%s %s%s%s', $this->_reflection_class->isAbstract() ? 'abstract ' : '', $this->_reflection_class->isFinal() ? 'final ' : '', $this->_reflection_class->isInterface() ? 'interface' : ($this->_reflection_class->isTrait() ? 'trait' : 'class'), $this->getClassName(), $this->_getParentClassName() ? " extends {$this->_getParentClassName()}" : '', $this->_getInterfaceNames() ? " implements " . join(', ', $this->_getInterfaceNames()) : '');
$code_lines[] = '{';
$code_lines[] = '';
// Export constants
foreach ($this->_reflection_class->getConstants() as $name => $value) {
$reflection_constant = new ReflectionConstant($name, $value);
$code_lines[] = "\t" . $reflection_constant->exportCode();
$code_lines[] = '';
}
// Export properties
foreach ($this->_reflection_class->getProperties() as $property) {
$reflection_property = new ReflectionProperty($property);
$code_lines[] = "\t" . $reflection_property->exportCode();
$code_lines[] = '';
}
// Export methods
foreach ($this->_reflection_class->getMethods() as $method) {
$reflection_method = new ReflectionMethod($method);
$code_lines[] = "\t" . $reflection_method->exportCode();
$code_lines[] = '';
}
$code_lines[] = '}';
return join("\n", $code_lines);
}
示例8: getMethodNames
function getMethodNames()
{
$ret = [];
foreach ($this->refl->getMethods() as $method) {
$ret[] = $method->name;
}
return $ret;
}
示例9: mockInjectedMethods
/**
* @param string $className
*/
private static function mockInjectedMethods($className)
{
foreach (self::$reflectedClass->getMethods() as $method) {
if (substr($method->getName(), 0, 6) === 'inject') {
self::mockDependenciesFromMethod($className, $method->getName());
}
}
}
示例10: testGetMethods
/**
* @covers PhSpring\Reflection\ReflectionClass::getMethods
*/
public function testGetMethods()
{
$methods = $this->object->getMethods();
$this->assertInternalType('array', $methods);
$this->assertNotEmpty($methods);
$method = array_shift($methods);
$this->assertInstanceOf(ReflectionMethod::class, $method);
}
示例11: testGetMethods
/**
*/
public function testGetMethods()
{
$this->assertTrue(is_array($this->object->getMethods()));
$this->assertEquals(0, count($this->object->getMethods()));
$method = new ReflectionMethod('testMethod');
$this->object->addMethod($method);
$this->assertEquals(1, count($this->object->getMethods()));
$this->assertEquals($method, array_pop($this->object->getMethods()));
}
示例12: getMethods
/**
* Gets the methods of the object provided.
*
* @param int $filter
*
* @return array
*/
public function getMethods($filter = \ReflectionProperty::IS_PUBLIC)
{
$methods = array();
$reflectionMethods = $this->reflectionEntity->getMethods($filter);
foreach ($reflectionMethods as $method) {
$methods[] = new Method($method->name, $method->isStatic());
}
return $methods;
}
示例13: getPublicStaticMethods
public function getPublicStaticMethods()
{
$methods = array();
foreach ($this->reflector->getMethods(ReflectionMethod::IS_STATIC) as $method) {
if ($method->isPublic() && $method->getDeclaringClass() == $this->reflector) {
$methods[] = new FactoryMethod($this, $method);
}
}
return $methods;
}
示例14: getMethods
/**
* Get public methods to be exposed over API
*
* @return ReflectionMethod[]
*/
private function getMethods()
{
$methods = array();
foreach ($this->reflectionClass->getMethods() as $method) {
if ($method->isPublic() && !$method->isStatic() && substr($method->getName(), 0, 2) != '__') {
$methods[$method->getName()] = $method;
}
}
return $methods;
}
示例15: getMethods
/**
* @return ReflectedMethod[]
*/
public function getMethods()
{
if (NULL === $this->methods) {
$this->methods = [];
foreach ($this->reflectionClass->getMethods() as $method) {
$this->methods[] = new ReflectedMethod($this, $method);
}
}
return $this->methods;
}