当前位置: 首页>>代码示例>>PHP>>正文


PHP ReflectionClass::getdefaultProperties方法代码示例

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


在下文中一共展示了ReflectionClass::getdefaultProperties方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: extractArray

 /**
  * Extract array of var in object
  * @param   Object $object
  * @returns array Array extracted of the object
  */
 public function extractArray($object, $isRecursive = false)
 {
     if (method_exists($object, "toArray")) {
         return $object->toArray();
     }
     $arrayCollection = new \ArrayIterator();
     $reflection = new \ReflectionClass($object);
     $vars = array_keys($reflection->getdefaultProperties());
     foreach ($vars as $key) {
         $value = $this->resolveGetNameMethod($key, $object);
         if ($value !== null) {
             if (is_object($value) && !$isRecursive) {
                 $arrayCollection->offsetSet($key, $this->extractArray($value, true));
             } else {
                 $arrayCollection->offsetSet($key, $value);
             }
         }
     }
     return $arrayCollection->getArrayCopy();
 }
开发者ID:brenodouglas,项目名称:doctrineconfig,代码行数:25,代码来源:SimpleHydrator.php

示例2: load

 /**
  * {@inheritdoc}
  */
 public function load($controller, $type = null)
 {
     list($prefix, $class) = $this->getControllerLocator($controller);
     $collection = $this->controllerReader->read(new \ReflectionClass($class));
     $collection->prependRouteControllersWithPrefix($prefix);
     $collection->setDefaultFormat($this->defaultFormat);
     $entityManager = $this->container->get('doctrine.orm.entity_manager');
     $inflector = $this->container->get('fos_rest.inflector');
     $reflection = new \ReflectionClass($controller);
     if ($reflection->isSubclassOf('uebb\\HateoasBundle\\Controller\\HateoasController')) {
         $defaultProperties = $reflection->getdefaultProperties();
         /** @var ClassMetadata $metadata */
         $metadata = $entityManager->getMetadataFactory()->getMetadataFor($defaultProperties['entityName']);
         foreach ($metadata->getAssociationNames() as $associationName) {
             if ($metadata->isCollectionValuedAssociation($associationName)) {
                 foreach (array('get', 'patch') as $method) {
                     if (!$reflection->hasMethod($method . ucfirst($associationName) . 'Action')) {
                         $resource = preg_split('/([A-Z][^A-Z]*)Controller/', $reflection->getShortName(), -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
                         $routeName = $method . '_' . strtolower(implode('_', $resource)) . '_' . strtolower($associationName);
                         $urlParts = array();
                         $urlParts[] = $inflector->pluralize(strtolower(implode('_', $resource)));
                         $urlParts[] = '{id}';
                         $urlParts[] = strtolower($associationName);
                         $pattern = implode('/', $urlParts);
                         $defaults = array('_controller' => $prefix . $method . 'Linkcollection', 'rel' => $associationName);
                         $requirements = array('_method' => strtoupper($method));
                         $options = array();
                         $host = '';
                         $schemes = array();
                         $condition = null;
                         $route = new Route($pattern, $defaults, $requirements, $options, $host, $schemes, null, $condition);
                         $collection->add($routeName, $route);
                     }
                 }
             }
         }
     }
     return $collection;
 }
开发者ID:uebb,项目名称:hateoas-bundle,代码行数:42,代码来源:HateoasRouteLoader.php

示例3: resolveRouteName

 /**
  * @param String $resourceClass
  * @param String $action
  * @return mixed
  * @throws \Doctrine\Common\Persistence\Mapping\MappingException
  * @throws \Exception
  */
 public function resolveRouteName($resourceClass, $action, $args = array())
 {
     $key = serialize(array($resourceClass, $action, $args));
     if ($this->cache->contains('routes', $key)) {
         return $this->cache->fetch('routes', $key);
     }
     foreach ($this->router->getRouteCollection()->all() as $name => $route) {
         $defaults = $route->getDefaults();
         $parts = explode('::', $defaults['_controller']);
         if (count($parts) === 2) {
             $reflection = new \ReflectionClass($parts[0]);
             $defaultProperties = $reflection->getdefaultProperties();
             if (is_subclass_of($parts[0], '\\uebb\\HateoasBundle\\Controller\\HateoasController') && $parts[1] === $action && $this->entityManager->getMetadataFactory()->getMetadataFor($defaultProperties['entityName'])->getName() === $resourceClass) {
                 if ($args === array_intersect_key($defaults, $args)) {
                     $this->cache->save('routes', $key, $name);
                     return $name;
                 }
             }
         }
     }
     $this->cache->save('routes', $key, null);
     return null;
 }
开发者ID:uebb,项目名称:hateoas-bundle,代码行数:30,代码来源:RouteResolver.php

示例4: getChildClassVariables

 protected function getChildClassVariables()
 {
     $objReflection = new \ReflectionClass($this);
     $arrVars = array_keys($objReflection->getdefaultProperties());
     $objReflection = new \ReflectionClass(__CLASS__);
     $arrParentVars = array_keys($objReflection->getdefaultProperties());
     $arrChildVars = array();
     foreach ($arrVars as $strKey) {
         if (!in_array($strKey, $arrParentVars)) {
             $arrChildVars[] = $strKey;
         }
     }
     return $arrChildVars;
 }
开发者ID:richardhoppes,项目名称:Yarbles,代码行数:14,代码来源:Model.php

示例5: strtolower

 /**
  * Overload Extension support
  *  - enables setCOLNAME/getCOLNAME
  *  if you define a set/get method for the item it will be called.
  * otherwise it will just return/set the value.
  * NOTE this currently means that a few Names are NO-NO's 
  * eg. links,link,linksarray, from, Databaseconnection,databaseresult
  *
  * note 
  *  - set is automatically called by setFrom.
  *   - get is automatically called by toArray()
  *  
  * setters return true on success. = strings on failure
  * getters return the value!
  *
  * this fires off trigger_error - if any problems.. pear_error, 
  * has problems with 4.3.2RC2 here
  *
  * @access public
  * @return true?
  * @see overload
  */
 function _call($method, $params, &$return)
 {
     //$this->debug("ATTEMPTING OVERLOAD? $method");
     // ignore constructors : - mm
     if (strtolower($method) == strtolower(get_class($this))) {
         return true;
     }
     $type = strtolower(substr($method, 0, 3));
     $class = get_class($this);
     if ($type != 'set' && $type != 'get') {
         return false;
     }
     // deal with naming conflick of setFrom = this is messy ATM!
     if (strtolower($method) == 'set_from') {
         $return = $this->toValue('from', isset($params[0]) ? $params[0] : null);
         return true;
     }
     $element = substr($method, 3);
     // dont you just love php's case insensitivity!!!!
     $array = array_keys(get_class_vars($class));
     /* php5 version which segfaults on 5.0.3 */
     if (class_exists('ReflectionClass')) {
         $reflection = new ReflectionClass($class);
         $array = array_keys($reflection->getdefaultProperties());
     }
     if (!in_array($element, $array)) {
         // munge case
         foreach ($array as $k) {
             $case[strtolower($k)] = $k;
         }
         if (substr(phpversion(), 0, 1) == 5 && isset($case[strtolower($element)])) {
             trigger_error("PHP5 set/get calls should match the case of the variable", E_USER_WARNING);
             $element = strtolower($element);
         }
         // does it really exist?
         if (!isset($case[$element])) {
             return false;
         }
         // use the mundged case
         $element = $case[$element];
         // real case !
     }
     if ($type == 'get') {
         $return = $this->toValue($element, isset($params[0]) ? $params[0] : null);
         return true;
     }
     $return = $this->fromValue($element, $params[0]);
     return true;
 }
开发者ID:bigpussy,项目名称:statusnet,代码行数:71,代码来源:DataObject.php

示例6: make

 public function make(Model $_prClasse, $_prInsert = true, $_prCondicao = '')
 {
     $reflection = new ReflectionClass($_prClasse);
     $propertis = $reflection->getdefaultProperties();
     foreach ($propertis as $key => $value) {
         if ($_prClasse->get($key) === null or $key == 'chave') {
             continue;
         }
         if ($key == 'tabela') {
             if ($_prInsert) {
                 $this->insert($_prClasse->get($key));
             } else {
                 $this->update($_prClasse->get($key), $_prCondicao);
             }
         } else {
             if ($key != $_prClasse->get("chave")) {
                 $this->add($key, $_prClasse->get($key));
             }
         }
     }
     $this->geraSql();
 }
开发者ID:jhonleandres,项目名称:estagio,代码行数:22,代码来源:Sql.php

示例7: trim

 /**
  * Handles a [url] tag. Creates a link to another web page.
  *
  * @param	string	If tag has option, the displayable name. Else, the URL.
  * @param	string	If tag has option, the URL.
  *
  * @return	string	HTML representation of the tag.
  */
 function handle_bbcode_url($text, $link)
 {
     $rightlink = trim($link);
     if (empty($rightlink)) {
         // no option -- use param
         $rightlink = trim($text);
     }
     $rightlink = str_replace(array('`', '"', "'", '['), array('`', '"', ''', '['), $this->strip_smilies($rightlink));
     // remove double spaces -- fixes issues with wordwrap
     $rightlink = str_replace('  ', '', $rightlink);
     if (!preg_match('#^[a-z0-9]+(?<!about|javascript|vbscript|data):#si', $rightlink)) {
         $rightlink = "http://{$rightlink}";
     }
     if (!trim($link) or str_replace('  ', '', $text) == $rightlink) {
         $tmp = unhtmlspecialchars($rightlink);
         if (vbstrlen($tmp) > 55 and $this->is_wysiwyg() == false) {
             $text = htmlspecialchars_uni(vbchop($tmp, 36) . '...' . substr($tmp, -14));
         } else {
             // under the 55 chars length, don't wordwrap this
             $text = str_replace('  ', '', $text);
         }
     }
     static $current_url, $current_host, $allowed, $friendlyurls = array();
     if (!isset($current_url)) {
         $current_url = @vB_String::parseUrl($this->registry->options['bburl']);
     }
     $is_external = $this->registry->options['url_nofollow'];
     if ($this->registry->options['url_nofollow']) {
         if (!isset($current_host)) {
             $current_host = preg_replace('#:(\\d)+$#', '', VB_HTTP_HOST);
             $allowed = preg_split('#\\s+#', $this->registry->options['url_nofollow_whitelist'], -1, PREG_SPLIT_NO_EMPTY);
             $allowed[] = preg_replace('#^www\\.#i', '', $current_host);
             $allowed[] = preg_replace('#^www\\.#i', '', $current_url['host']);
         }
         $target_url = preg_replace('#^([a-z0-9]+:(//)?)#', '', $rightlink);
         foreach ($allowed as $host) {
             if (stripos($target_url, $host) !== false) {
                 $is_external = false;
             }
         }
     }
     // API need to convert link to vb:action/param1=val1/param2=val2...
     if (defined('VB_API') and VB_API === true) {
         $current_link = @vB_String::parseUrl($rightlink);
         if ($current_link !== false) {
             $current_link['host'] = strtolower($current_link['host']);
             $current_url['host'] = strtolower($current_url['host']);
             if (($current_link['host'] == $current_url['host'] or 'www.' . $current_link['host'] == $current_url['host'] or $current_link['host'] == 'www.' . $current_url['host']) and (!$current_url['path'] or stripos($current_link['path'], $current_url['path']) !== false)) {
                 // This is a vB link.
                 if ($current_link['path'] == $current_url['path'] or $current_link['path'] . '/' == $current_url['path'] or $current_link['path'] == $current_url['path'] . '/') {
                     $rightlink = 'vb:index';
                 } else {
                     // Get a list of declared friendlyurl classes
                     if (!$friendlyurls) {
                         require_once DIR . '/includes/class_friendly_url.php';
                         $classes = get_declared_classes();
                         foreach ($classes as $classname) {
                             if (strpos($classname, 'vB_Friendly_Url_') !== false) {
                                 $reflect = new ReflectionClass($classname);
                                 $props = $reflect->getdefaultProperties();
                                 if ($classname == 'vB_Friendly_Url_vBCms') {
                                     $props['idvar'] = $props['ignorelist'][] = $this->registry->options['route_requestvar'];
                                     $props['script'] = 'content.php';
                                     $props['rewrite_segment'] = 'content';
                                 }
                                 if ($props['idvar']) {
                                     $friendlyurls[$classname]['idvar'] = $props['idvar'];
                                     $friendlyurls[$classname]['idkey'] = $props['idkey'];
                                     $friendlyurls[$classname]['titlekey'] = $props['titlekey'];
                                     $friendlyurls[$classname]['ignorelist'] = $props['ignorelist'];
                                     $friendlyurls[$classname]['script'] = $props['script'];
                                     $friendlyurls[$classname]['rewrite_segment'] = $props['rewrite_segment'];
                                 }
                             }
                             $friendlyurls['vB_Friendly_Url_vBCms']['idvar'] = $this->registry->options['route_requestvar'];
                             $friendlyurls['vB_Friendly_Url_vBCms']['ignorelist'][] = $this->registry->options['route_requestvar'];
                             $friendlyurls['vB_Friendly_Url_vBCms']['script'] = 'content.php';
                             $friendlyurls['vB_Friendly_Url_vBCms']['rewrite_segment'] = 'content';
                             $friendlyurls['vB_Friendly_Url_vBCms2']['idvar'] = $this->registry->options['route_requestvar'];
                             $friendlyurls['vB_Friendly_Url_vBCms2']['ignorelist'][] = $this->registry->options['route_requestvar'];
                             $friendlyurls['vB_Friendly_Url_vBCms2']['script'] = 'list.php';
                             $friendlyurls['vB_Friendly_Url_vBCms2']['rewrite_segment'] = 'list';
                         }
                     }
                     /*
                      * 	FRIENDLY_URL_OFF
                      *	showthread.php?t=1234&p=2
                      *
                      *	FRIENDLY_URL_BASIC
                      *	showthread.php?1234-Thread-Title/page2&pp=2
                      *
                      *	FRIENDLY_URL_ADVANCED
//.........这里部分代码省略.........
开发者ID:cedwards-reisys,项目名称:nexus-web,代码行数:101,代码来源:class_bbcode.php


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