本文整理汇总了PHP中ReflectionClass类的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionClass类的具体用法?PHP ReflectionClass怎么用?PHP ReflectionClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ReflectionClass类的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: generateRoute
/**
* Add all the routes in the router in parameter
* @param $router Router
*/
public function generateRoute(Router $router)
{
foreach ($this->classes as $class) {
$classMethods = get_class_methods($this->namespace . $class . 'Controller');
$rc = new \ReflectionClass($this->namespace . $class . 'Controller');
$parent = $rc->getParentClass();
$parent = get_class_methods($parent->name);
$className = $this->namespace . $class . 'Controller';
foreach ($classMethods as $methodName) {
if (in_array($methodName, $parent) || $methodName == 'index') {
continue;
} else {
foreach (Router::getSupportedHttpMethods() as $httpMethod) {
if (strstr($methodName, $httpMethod)) {
continue 2;
}
if (in_array($methodName . $httpMethod, $classMethods)) {
$router->add('/' . strtolower($class) . '/' . $methodName, new $className(), $methodName . $httpMethod, $httpMethod);
unset($classMethods[$methodName . $httpMethod]);
}
}
$router->add('/' . strtolower($class) . '/' . $methodName, new $className(), $methodName);
}
}
$router->add('/' . strtolower($class), new $className(), 'index');
}
}
示例3: 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]);
}
}
示例4: addComplexType
/**
* Add a complex type by recursivly using all the class properties fetched via Reflection.
*
* @param string $type Name of the class to be specified
* @return string XSD Type for the given PHP type
*/
public function addComplexType($type)
{
if (!class_exists($type)) {
throw new \Zend\Soap\WSDL\Exception(sprintf('Cannot add a complex type %s that is not an object or where ' . 'class could not be found in \'DefaultComplexType\' strategy.', $type));
}
$dom = $this->getContext()->toDomDocument();
$class = new \ReflectionClass($type);
$complexType = $dom->createElement('xsd:complexType');
$complexType->setAttribute('name', $type);
$all = $dom->createElement('xsd:all');
foreach ($class->getProperties() as $property) {
if ($property->isPublic() && preg_match_all('/@var\\s+([^\\s]+)/m', $property->getDocComment(), $matches)) {
/**
* @todo check if 'xsd:element' must be used here (it may not be compatible with using 'complexType'
* node for describing other classes used as attribute types for current class
*/
$element = $dom->createElement('xsd:element');
$element->setAttribute('name', $property->getName());
$element->setAttribute('type', $this->getContext()->getType(trim($matches[1][0])));
$all->appendChild($element);
}
}
$complexType->appendChild($all);
$this->getContext()->getSchema()->appendChild($complexType);
$this->getContext()->addType($type);
return "tns:{$type}";
}
示例5: generateAlias
/**
* Auto-Generate an alias for an entity.
*
* @param string $alias
* @param \DC_General $dc
*
* @return string
* @throws Exception
*/
public static function generateAlias($alias, \DC_General $dc)
{
/** @var EntityInterface $entity */
$entity = $dc->getCurrentModel()->getEntity();
$autoAlias = false;
// Generate alias if there is none
if (!strlen($alias)) {
$autoAlias = true;
if ($entity->__has('title')) {
$alias = standardize($entity->getTitle());
} elseif ($entity->__has('name')) {
$alias = standardize($entity->getName());
} else {
return '';
}
}
$entityClass = new \ReflectionClass($entity);
$keys = explode(',', $entityClass->getConstant('KEY'));
$entityManager = EntityHelper::getEntityManager();
$queryBuilder = $entityManager->createQueryBuilder();
$queryBuilder->select('COUNT(e.' . $keys[0] . ')')->from($entityClass->getName(), 'e')->where($queryBuilder->expr()->eq('e.alias', ':alias'))->setParameter(':alias', $alias);
static::extendQueryWhereId($queryBuilder, $dc->getCurrentModel()->getID(), $entity);
$query = $queryBuilder->getQuery();
$duplicateCount = $query->getResult(Query::HYDRATE_SINGLE_SCALAR);
// Check whether the news alias exists
if ($duplicateCount && !$autoAlias) {
throw new Exception(sprintf($GLOBALS['TL_LANG']['ERR']['aliasExists'], $alias));
}
// Add ID to alias
if ($duplicateCount && $autoAlias) {
$alias .= '-' . $dc->getCurrentModel()->getID();
}
return $alias;
}
示例6: callConstructor
public function callConstructor()
{
$parent = new \ReflectionClass(parent::class);
if ($parent->getConstructor()) {
parent::__construct();
}
}
示例7: doLog
public static function doLog($logmethod, array $data, &$output)
{
$log = new Logger('ezperflogger');
// constructor args for the specific handler can be set via ini
/// @todo how to create resources instead?
foreach (eZPerfLoggerINI::variable('MonologSettings', 'LogHandlers') as $handlerName) {
$handlerClass = 'Monolog\\Handler\\' . $handlerName . "Handler";
if (eZPerfLoggerINI::hasVariable('MonologSettings', 'LogHandler_' . $handlerName)) {
$r = new ReflectionClass($handlerClass);
$handler = $r->newInstanceArgs(eZPerfLoggerINI::variable('MonologSettings', 'LogHandler_' . $handlerName));
} else {
$handler = new $handlerClass();
}
$log->pushHandler($handler);
}
// the default severity level: taken from config file
$level = (int) eZPerfLoggerINI::variable('MonologSettings', 'SeverityLevel');
// either coalesce messages or not: taken from config file
if (eZPerfLoggerINI::variable('MonologSettings', 'Coalescevariables') == 'enabled') {
/// @todo allow via ini file the specification of custom formatters?
$msg = array();
foreach ($data as $varname => $value) {
$msg[] = "{$varname}: {$value}";
}
$log->addRecord($level, implode(', ', $msg));
} else {
foreach ($data as $varname => $value) {
$log->addRecord($level, "{$varname}: {$value}");
}
}
}
示例8: callMethod
function callMethod()
{
$resultMethod = $this->createJSON();
$apiName = stripcslashes($this->apiFunctionName[0]) . 'Api';
$status = ApiConstants::$STATUS;
if (file_exists(SERVER_DIR . 'app/Controller/Api/method/' . $apiName . '.php')) {
$apiClass = ApiCore::getApiEngineByName($apiName);
$apiReflection = new ReflectionClass($apiName);
try {
$functionName = $this->apiFunctionName[1];
$apiReflection->getMethod($functionName);
$response = ApiConstants::$RESPONSE;
$res = $apiClass->{$functionName}($this->apiFunctionParams);
if ($res == null) {
$resultMethod->{$status} = ApiConstants::$ERROR_NOT_FOUND_RECORD;
} else {
if ($res->err == ApiConstants::$ERROR_PARAMS) {
$resultMethod->{$status} = ApiConstants::$ERROR_PARAMS;
$resultMethod->params = json_encode($apiFunctionParams);
} else {
$resultMethod->{$response} = $res;
$resultMethod->{$status} = ApiConstants::$ERROR_NO;
}
}
} catch (Exception $ex) {
$resultMethod->errStr = $ex->getMessage();
}
} else {
$resultMethod->errStr = 'Not found method';
$resultMethod->{$status} = ApiConstants::$ERROR_NOT_FOUND_METHOD;
$resultMethod->params = $this->apiFunctionParams;
}
return json_encode($resultMethod, JSON_UNESCAPED_UNICODE);
}
示例9: _callProtectedFunction
/**
* Call protected functions by making the visibitlity to public.
*
* @param string $name method name
* @param array $params parameters for the invocation
*
* @return the output from the protected method.
*/
private function _callProtectedFunction($name, $params)
{
$class = new ReflectionClass('PMA_DbSearch');
$method = $class->getMethod($name);
$method->setAccessible(true);
return $method->invokeArgs($this->object, $params);
}
示例10: query
function query($sql, $params = [])
{
if (!$params) {
return $this->pquery($sql);
}
$stmt = $this->mysqli->prepare($sql);
$stmt or $this->_sqlError($this->mysqli->error, $sql);
$ref = new ReflectionClass('mysqli_stmt');
$method = $ref->getMethod('bind_param');
$method->invokeArgs($stmt, $this->_refValues($params));
$rs = $stmt->execute();
$result = $stmt->get_result();
if ($result) {
while ($row = $result->fetch_assoc()) {
$data[] = $row;
}
return isset($data) ? $data : null;
} else {
if ($this->mysqli->insert_id) {
return $this->mysqli->insert_id;
}
if ($this->mysqli->affected_rows) {
return $this->mysqli->affected_rows;
}
}
}
示例11: executeIndex
public function executeIndex()
{
//perlu di rapihkan
$field_name = $this->name;
$reflection = new ReflectionClass($this->model . 'Peer');
$method = $reflection->getMethod('doSelect');
$c = new Criteria();
$filter_field = strtoupper($this->filter_field);
$filter_content = $this->filter_content;
if (!empty($filter_field)) {
if ($this->case == 'equal') {
$c->add($reflection->getConstant($filter_field), $filter_content, Criteria::EQUAL);
} else {
if ($this->case == 'not_equal') {
$c->add($reflection->getConstant($filter_field), $filter_content, Criteria::NOT_EQUAL);
}
}
}
$order_column = $this->order_column;
$order_type = $this->order_type;
if (!empty($order_column)) {
if ($order_type == 'desc') {
$c->addDescendingOrderByColumn($order_column);
} else {
$c->addAscendingOrderByColumn($order_column);
}
}
$reg_info = $method->invoke($method, $c);
$this->data = $reg_info;
$this->name = $field_name;
$this->desc = !isset($this->desc) ? 'Name' : $this->desc;
}
示例12: restoreStaticAttributes
/**
* Restores all static attributes in user-defined classes from this snapshot.
*
* @param Snapshot $snapshot
*/
public function restoreStaticAttributes(Snapshot $snapshot)
{
$current = new Snapshot($snapshot->blacklist(), false, false, false, false, true, false, false, false, false);
$newClasses = array_diff($current->classes(), $snapshot->classes());
unset($current);
foreach ($snapshot->staticAttributes() as $className => $staticAttributes) {
foreach ($staticAttributes as $name => $value) {
$reflector = new ReflectionProperty($className, $name);
$reflector->setAccessible(true);
$reflector->setValue($value);
}
}
foreach ($newClasses as $className) {
$class = new \ReflectionClass($className);
$defaults = $class->getDefaultProperties();
foreach ($class->getProperties() as $attribute) {
if (!$attribute->isStatic()) {
continue;
}
$name = $attribute->getName();
if ($snapshot->blacklist()->isStaticAttributeBlacklisted($className, $name)) {
continue;
}
if (!isset($defaults[$name])) {
continue;
}
$attribute->setAccessible(true);
$attribute->setValue($defaults[$name]);
}
}
}
示例13: getAccessibleMethod
protected static function getAccessibleMethod($class, $name)
{
$class = new ReflectionClass($class);
$method = $class->getMethod($name);
$method->setAccessible(true);
return $method;
}
示例14: getMethod
public static function getMethod($obj, $name)
{
$class = new \ReflectionClass($obj);
$method = $class->getMethod($name);
$method->setAccessible(true);
return $method;
}
示例15: setUpBeforeClass
public static function setUpBeforeClass()
{
$reflect = new \ReflectionClass(__CLASS__);
self::$directory = @tempnam(sys_get_temp_dir(), $reflect->getShortName() . '-');
@unlink(self::$directory);
@mkdir(self::$directory);
}