• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ReflectionClass类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中ReflectionClass的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionClass类的具体用法?PHP ReflectionClass怎么用?PHP ReflectionClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ReflectionClass类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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');
 }
开发者ID:emma5021,项目名称:toba,代码行数:35,代码来源:toba_solicitud_servicio_web.php


示例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');
     }
 }
开发者ID:kazuohirai,项目名称:awayfromswag,代码行数:31,代码来源:ClassRouting.php


示例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]);
     }
 }
开发者ID:avnir,项目名称:easyrouting,代码行数:25,代码来源:Easyrouting.php


示例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}";
 }
开发者ID:hjr3,项目名称:zf2,代码行数:33,代码来源:DefaultComplexType.php


示例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;
 }
开发者ID:bit3,项目名称:contao-doctrine-orm,代码行数:43,代码来源:Helper.php


示例6: callConstructor

 public function callConstructor()
 {
     $parent = new \ReflectionClass(parent::class);
     if ($parent->getConstructor()) {
         parent::__construct();
     }
 }
开发者ID:OzanKurt,项目名称:KurtModules-Blog,代码行数:7,代码来源:BlogController.php


示例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}");
         }
     }
 }
开发者ID:gggeek,项目名称:ezperformancelogger,代码行数:31,代码来源:ezperfloggermonologlogger.php


示例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);
 }
开发者ID:smilexx,项目名称:quest.dev,代码行数:34,代码来源:apiCore.php


示例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);
 }
开发者ID:nhodges,项目名称:phpmyadmin,代码行数:15,代码来源:PMA_DbSearch_test.php


示例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;
         }
     }
 }
开发者ID:renjun0106,项目名称:blog,代码行数:26,代码来源:db.php


示例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;
 }
开发者ID:taryono,项目名称:school,代码行数:32,代码来源:components.class.php


示例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]);
         }
     }
 }
开发者ID:Ceciceciceci,项目名称:MySJSU-Class-Registration,代码行数:36,代码来源:Restorer.php


示例13: getAccessibleMethod

 protected static function getAccessibleMethod($class, $name)
 {
     $class = new ReflectionClass($class);
     $method = $class->getMethod($name);
     $method->setAccessible(true);
     return $method;
 }
开发者ID:tungnguyenson,项目名称:slackpi,代码行数:7,代码来源:DownloaderTest.php


示例14: getMethod

 public static function getMethod($obj, $name)
 {
     $class = new \ReflectionClass($obj);
     $method = $class->getMethod($name);
     $method->setAccessible(true);
     return $method;
 }
开发者ID:locomotivemtl,项目名称:charcoal-admin,代码行数:7,代码来源:LogoutTemplateTest.php


示例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);
 }
开发者ID:mhlavac,项目名称:GeonamesBundle,代码行数:7,代码来源:GuzzleDownloadAdapterTest.php


示例16: __construct

 function __construct()
 {
     global $adb, $log, $current_user;
     echo "<table width=80% align=center border=1>";
     $reflector = new ReflectionClass(get_class($this));
     $fname = basename($reflector->getFileName(), '.php');
     $cburs = $adb->pquery('select * from vtiger_cbupdater where filename=? and classname=?', array($fname, get_class($this)));
     if ($cburs and $adb->num_rows($cburs) > 0) {
         // it exists, we load it
         $cbu = $adb->fetch_array($cburs);
         $this->cbupdid = $cbu['cbupdaterid'];
         $this->cbupd_no = $cbu['cbupd_no'];
         $this->author = $cbu['author'];
         $this->filename = $cbu['filename'];
         $this->classname = $cbu['classname'];
         $this->execstate = $cbu['execstate'];
         $this->systemupdate = $cbu['systemupdate'] == '1' ? true : false;
         $this->perspective = (isset($cbu['perspective']) and $cbu['perspective'] == '1') ? true : false;
         $this->blocked = (isset($cbu['blocked']) and $cbu['blocked'] == '1') ? true : false;
         $this->execdate = $cbu['execdate'];
         $this->updError = false;
     } else {
         // it doesn't exist, we fail because it MUST exist
         $this->sendError();
     }
 }
开发者ID:mslokhat,项目名称:corebos,代码行数:26,代码来源:cbupdaterWorker.php


示例17: getComponentRouter

 /**
  * Tries to create a new router object for given component, returns NULL
  * if object not supported
  * 
  * @staticvar JComponentRouterInterface[] $cache
  * @param string $component Component name in format "com_xxx"
  * @return \JComponentRouterInterface
  */
 protected static function getComponentRouter($component)
 {
     static $cache = array();
     if (!array_key_exists($component, $cache)) {
         $router = null;
         $compName = ucfirst(substr($component, 4));
         $class = $compName . 'Router';
         if (class_exists($class)) {
             // Check if it supports the Joomla router interface, because
             // some components use classes with the same name causing
             // fatal error then (eg. EasyBlog)
             $reflection = new ReflectionClass($class);
             if (in_array('JComponentRouterInterface', $reflection->getInterfaceNames())) {
                 // Create the router object
                 $app = JFactory::getApplication();
                 $menu = $app->getMenu('site');
                 $router = new $class($app, $menu);
             }
         }
         // If router class not supported, create legacy router object (Joomla 3)
         if (!$router && class_exists('JComponentRouterLegacy')) {
             $router = new JComponentRouterLegacy($compName);
         }
         // Cache the router object
         $cache[$component] = $router;
     }
     return $cache[$component];
 }
开发者ID:01J,项目名称:bealtine,代码行数:36,代码来源:joomsef.php


示例18: store

 public function store($object)
 {
     if (!is_object($object)) {
         throw new Exception('Invalid Entity. Should be object');
     }
     $table = $this->getTableName($object);
     $values = array();
     $reflector = new ReflectionClass($object);
     foreach ($reflector->getProperties() as $prop) {
         $comment = $prop->getDocComment();
         if (strpos($comment, '@primary') || strpos($comment, '@field')) {
             $values[$prop->getName()] = $prop->getValue($object);
         }
     }
     $keys = array_keys($values);
     if (is_null($object->id)) {
         $str = '`' . implode('`, `', $keys) . '`';
         $str2 = ':' . implode(', :', $keys);
         $sql = "INSERT INTO {$table} ({$str}) VALUES ({$str2})";
         $this->execute($sql, $values);
         $object->id = $this->lastInsertId();
     } else {
         $str = '';
         foreach ($keys as $k) {
             if ($k == 'id') {
                 continue;
             }
             $str .= " {$k}=:{$k},";
         }
         $str = rtrim($str, ',');
         $sql = "UPDATE {$table} SET {$str} WHERE id = :id";
         $this->execute($sql, $values);
     }
     return $object;
 }
开发者ID:fordnox,项目名称:mikron,代码行数:35,代码来源:Mikron.php


示例19: getProperties

 /**
  * {@inheritdoc}
  */
 public function getProperties($class, array $context = array())
 {
     try {
         $reflectionClass = new \ReflectionClass($class);
     } catch (\ReflectionException $reflectionException) {
         return;
     }
     $reflectionProperties = $reflectionClass->getProperties();
     $properties = array();
     foreach ($reflectionProperties as $reflectionProperty) {
         if ($reflectionProperty->isPublic()) {
             $properties[$reflectionProperty->name] = true;
         }
     }
     foreach ($reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $reflectionMethod) {
         $propertyName = $this->getPropertyName($reflectionMethod->name, $reflectionProperties);
         if (!$propertyName || isset($properties[$propertyName])) {
             continue;
         }
         if (!preg_match('/^[A-Z]{2,}/', $propertyName)) {
             $propertyName = lcfirst($propertyName);
         }
         $properties[$propertyName] = true;
     }
     return array_keys($properties);
 }
开发者ID:Gladhon,项目名称:symfony,代码行数:29,代码来源:ReflectionExtractor.php


示例20: invokeMethod

 /**
  * Call protected/private method of a class.
  *
  * @param object &$object    Instantiated object that we will run method on.
  * @param string $methodName Method name to call
  * @param array  $parameters Array of parameters to pass into method.
  *
  * @return mixed Method return.
  */
 public function invokeMethod(&$object, $methodName, array $parameters = array())
 {
     $reflection = new \ReflectionClass(get_class($object));
     $method = $reflection->getMethod($methodName);
     $method->setAccessible(true);
     return $method->invokeArgs($object, $parameters);
 }
开发者ID:bossjones,项目名称:puphpet,代码行数:16,代码来源:BaseTest.php



注:本文中的ReflectionClass类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ReflectionExtension类代码示例发布时间:2022-05-23
下一篇:
PHP Reflection类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap