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


PHP ReflectionObject::getNamespaceName方法代码示例

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


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

示例1: getNamespace

 /**
  * Gets the Module namespace.
  *
  * @return string The Module namespace
  *
  * @api
  */
 public function getNamespace()
 {
     if (null === $this->reflected) {
         $this->reflected = new \ReflectionObject($this);
     }
     return $this->reflected->getNamespaceName();
 }
开发者ID:dragoonis,项目名称:framework,代码行数:14,代码来源:AbstractModule.php

示例2: generateInheritedClass

 public function generateInheritedClass($newClassName, $obj)
 {
     $refObj = new \ReflectionObject($obj);
     $innerCode = $this->s->generateCode($newClassName, $obj);
     $innerCode = str_replace("\n", "\n\t", $innerCode);
     $className = array_pop(explode("\\", $refObj->getName()));
     $namespace = $refObj->getNamespaceName();
     return "<?php\nnamespace {$namespace};\nclass {$newClassName} extends {$className} implements \\hvasoares\\phplombok\\GeneratedClass{\n\tpublic function setAnnotatedObject(\$object){\n\t\t\$this->annotatedObject = \$object;\n\t\t\$this->reflectedObject = new \\ReflectionObject(\$object);\n\t}\n\n\tpublic function getAnnotatedObject(){\n\t\treturn \$this->annotatedObject;\n\t}\n\t{$innerCode}\t\n}\n?>";
 }
开发者ID:hvasoares,项目名称:phplombok,代码行数:9,代码来源:Template.php

示例3: resolveHandlerClass

 /**
  * Resolves an instance of the handler class
  * corresponding to $command.
  *
  * @param Command $command
  *
  * @return CommandHandler
  * @throws \Exception
  */
 private function resolveHandlerClass(Command $command)
 {
     $reflectionObject = new \ReflectionObject($command);
     $shortName = $reflectionObject->getShortName();
     $className = $reflectionObject->getNamespaceName() . '\\Handlers\\' . $shortName . 'Handler';
     if (!class_exists($className)) {
         throw new \Exception("Command handler {$className} not found.");
     }
     // Let the container resolve the instance and inject the required dependencies.
     return $this->container->get($className);
 }
开发者ID:domynation,项目名称:domynation-framework,代码行数:20,代码来源:BasicCommandBus.php

示例4: generate

 public function generate($obj)
 {
     $refObj = new \ReflectionObject($obj);
     if ($refObj->implementsInterface("\\hvasoares\\phplombok\\GeneratedClass")) {
         return $obj;
     }
     $oldClassName = array_pop(explode("\\", $refObj->getName()));
     $newClassName = $oldClassName . (time() + rand());
     if (!$this->c->classExists(get_class($obj))) {
         $this->c->generateAndLoadClassFile(get_class($obj), $this->t->generateInheritedClass($newClassName, $obj));
         $this->f->configure($refObj->getName(), $refObj->getNamespaceName() . "\\" . $newClassName);
     }
     return $this->f->get($obj);
 }
开发者ID:hvasoares,项目名称:phplombok,代码行数:14,代码来源:ChildClassGenerator.php

示例5: _mapObject

 /**
  * @param $interface
  * @param array $data
  * @param array|null $mappings
  * @return mixed
  * @throws RuntimeException
  */
 protected function _mapObject($interface, array $data, array $mappings)
 {
     $object = $this->getObjectInstance($interface);
     $reflectionObject = new \ReflectionObject($object);
     $this->logger->debug(sprintf('Map object %s from interface %s', $reflectionObject->getNamespaceName(), $interface), array('data' => $data, 'mappings' => $mappings));
     foreach ($mappings as $attribute => $definition) {
         $property = $reflectionObject->getProperty($attribute);
         if ($property->isPrivate() || $property->isProtected()) {
             $property->setAccessible(true);
         }
         $value = $this->getAttributeValue($attribute, $definition, $data);
         $property->setValue($object, $value);
         $this->logger->debug(sprintf('Set attribute %s value ', $attribute), array('value' => $value));
     }
     return $object;
 }
开发者ID:mehdi-ghezal,项目名称:sellsy-api,代码行数:23,代码来源:YmlMapper.php

示例6: makeView

 /**
  * Return the view specified by the controller and view name, using data from the ViewBag
  * 
  * @param string $view_name
  * @param \MyArtJaub\Webtrees\Mvc\Controller\MvcControllerInterface $mvc_ctrl
  * @param \Fisharebest\Webtrees\Controller\BaseController $ctrl
  * @param \MyArtJaub\Webtrees\Mvc\View\ViewBag $data
  * @return \MyArtJaub\Webtrees\Mvc\View\AbstractView View
  * @throws \Exception
  */
 public function makeView($view_name, MvcController $mvc_ctrl, BaseController $ctrl, ViewBag $data)
 {
     if (!$mvc_ctrl) {
         throw new \Exception('Mvc Controller not defined');
     }
     if (!$ctrl) {
         throw new \Exception('Base Controller not defined');
     }
     if (!$view_name) {
         throw new \Exception('View not defined');
     }
     $mvc_ctrl_refl = new \ReflectionObject($mvc_ctrl);
     $view_class = $mvc_ctrl_refl->getNamespaceName() . '\\Views\\' . $view_name . 'View';
     if (!class_exists($view_class)) {
         throw new \Exception('View does not exist');
     }
     return new $view_class($ctrl, $data);
 }
开发者ID:jon48,项目名称:webtrees-lib,代码行数:28,代码来源:ViewFactory.php

示例7: getResponse

 /**
  *
  * @author leeboo
  *        
  * @param string $view_tpl
  *            模板的路径
  * @param string $format            
  * @return \yangzie\YZE_Simple_View
  *
  * @return
  *
  */
 protected function getResponse($view_tpl = null, $format = null)
 {
     $request = $this->request;
     $method = $request->the_method();
     if ($request->is_post()) {
         $method = substr($method, 5);
     }
     $view_data = $this->get_datas();
     $class_name = strtolower(get_class($this));
     $ref = new \ReflectionObject($this);
     if ($this->view) {
         $tpl = $this->view;
     } else {
         $tpl = substr(str_replace($ref->getNamespaceName() . "\\", "", $class_name), 0, -11) . "-" . $method;
     }
     $view = $view_tpl ? $view_tpl : $request->view_path() . "/" . $tpl;
     if (!$format) {
         $format = $request->get_output_format();
     }
     return new YZE_Simple_View($view, $view_data, $this, $format);
 }
开发者ID:ydhl,项目名称:yangzie,代码行数:33,代码来源:controller.php

示例8: autoload

 /**
  * Autoloader for classes
  *
  * @param string $class
  */
 function autoload($class)
 {
     if (!preg_match('/^(?P<namespace>.+)\\\\(?P<autoload>[^\\\\]+)$/', $class, $matches)) {
         return;
     }
     static $reflection;
     if (empty($reflection)) {
         $reflection = new \ReflectionObject($this);
     }
     if ($reflection->getNamespaceName() !== $matches['namespace']) {
         return;
     }
     $autoload_name = $matches['autoload'];
     $autoload_dir = \trailingslashit($this->locations['class_dir']);
     $autoload_path = sprintf('%sclass-%s.php', $autoload_dir, strtolower(str_replace('_', '-', $autoload_name)));
     if (is_readable($autoload_path)) {
         require_once $autoload_path;
     }
 }
开发者ID:selectSIFISO,项目名称:.comsite,代码行数:24,代码来源:class-plugin.php

示例9: detectAppNamespace

 protected function detectAppNamespace()
 {
     $ref = new \ReflectionObject($this);
     return $ref->getNamespaceName();
 }
开发者ID:mercari,项目名称:dietcube,代码行数:5,代码来源:Application.php

示例10: getWorkflowSourceClassName

 /**
  * Returns the complete name for the IWorkflowSource class used to retrieve the definition of workflow $workflowId.
  * The class name is built by appending the workflow id to the `workflowSourceNamespace` parameter set for this factory component.
  *
  * @param string $workflowId a workflow id
  * @param Component|ActiveWorkflowBehavior $model the model that owns the workflow.
  *
  * @return string the full qualified class name implements IWorkflowSource used to provide definition for the workflow
  * @throws WorkflowException
  */
 public function getWorkflowSourceClassName($workflowId, $model)
 {
     if (isset($workflowId) && !$this->isValidWorkflowId($workflowId)) {
         throw new WorkflowException('Not a valid workflow Id : ' . $workflowId);
     }
     if (!isset($workflowId)) {
         $workflowId = $this->getDefaultWorkflowId($model);
     }
     $ns = $this->workflowSourceNamespace;
     if (!isset($ns)) {
         if (isset($model)) {
             $ro = new \ReflectionObject($model);
             $ns = $ro->getNamespaceName();
         }
         if (!isset($ns)) {
             $ns = self::DEFAULT_WORKFLOW_SOURCE_NAMESPACE;
         }
     }
     return $ns . '\\' . $workflowId . $this->workflowSourceSuffix;
 }
开发者ID:fproject,项目名称:workflowii,代码行数:30,代码来源:ArrayWorkflowItemFactory.php

示例11: buildFromObject

 /**
  * @param $param
  * @param \ReflectionObject $reflection
  */
 private function buildFromObject($param, $reflection = null)
 {
     foreach ($param as $key => $value) {
         $this->object['Object default'][$key] = $value;
     }
     // Get info on the object
     $this->object['Reflection']['In namespace'] = $reflection->inNamespace() ? 'Yes' : 'No';
     if ($reflection->inNamespace()) {
         $this->object['Class namespace'] = $reflection->getNamespaceName();
     }
     $this->object['Reflection']['Class name'] = $reflection->getName();
     $this->object['Reflection']['Is internal'] = $reflection->isInternal() ? 'Yes' : 'No';
     $this->object['Reflection']['Is iterable'] = $reflection->isIterateable() ? 'Yes' : 'No';
     $this->object['Reflection']['Is abstract'] = $reflection->isAbstract() ? 'Yes' : 'No';
     $this->object['Reflection']['Is final'] = $reflection->isFinal() ? 'Yes' : 'No';
     $this->object['Reflection']['Is user defined'] = $reflection->isUserDefined() ? 'Yes' : 'No';
     $this->object['Reflection']['Is instantiable'] = $reflection->isInstantiable() ? 'Yes' : 'No';
     $this->object['Reflection']['Is clonable'] = $reflection->isCloneable() ? 'Yes' : 'No';
     $this->object['Reflection']['Is interface'] = $reflection->isInterface() ? 'Yes' : 'No';
     $this->object['Reflection']['Class constants'] = !empty($reflection->getConstants()) ? $reflection->getConstants() : 'Class has no constants';
     $this->object['Reflection']['Class static properties'] = !empty($reflection->getStaticProperties()) ? $reflection->getStaticProperties() : 'Class has no static properties';
     $this->object['Reflection']['Class default properties'] = !empty($reflection->getDefaultProperties()) ? $reflection->getDefaultProperties() : 'Class has no default properties';
     if (null === $reflection->getConstructor()) {
         $this->object['Reflection']['Class construct'] = 'Class has no construct.';
     } else {
         $this->object['Reflection']['Class construct'] = $reflection->getConstructor();
     }
     $this->object['Reflection']['Class interfaces'] = !empty($reflection->getInterfaces()) ? $reflection->getInterfaces() : 'Class implements no interfaces';
     $this->object['Reflection']['Class traits'] = !empty($reflection->getTraits()) ? $reflection->getTraits() : 'Class has no traits';
     $this->object['Reflection']['Class parent'] = $reflection->getParentClass() !== false ? $reflection->getParentClass() : 'Class has no parent';
     if (false === $reflection->getFileName()) {
         $this->object['Reflection']['Defined in'] = 'Class is internal, no definition to provide.';
     } else {
         $this->object['Reflection']['Defined in'] = $reflection->getFileName();
     }
     if (false === $reflection->getFileName()) {
         $this->object['Reflection']['Start line'] = 'Class is internal, no start line to provide.';
     } else {
         $this->object['Reflection']['Start line'] = $reflection->getFileName();
     }
     if (false === $reflection->getEndLine()) {
         $this->object['Reflection']['End line'] = 'Class is internal, no end line to provide.';
     } else {
         $this->object['Reflection']['End line'] = $reflection->getEndLine();
     }
     if (false === $reflection->getDocComment()) {
         $this->object['Reflection']['Doc comments'] = 'No documents to provide.';
     } else {
         $this->object['Reflection']['Doc comments'] = $reflection->getDocComment();
     }
     // End get info
     $this->html .= "<span class=\"js-parent-object\">";
     if (!empty($this->object['Object default'])) {
         $this->html .= "<div class=\"js-object-default-tab \"><button class=\"button-reflection button\">Show reflection</button></div>";
         $this->html .= "<div class=\"js-object-default \">";
         $this->buildFromObjectIterationInformationRecursive($this->object['Object default']);
         $this->html .= "</div>";
     }
     if ($param instanceof \Closure) {
         $this->html .= "<div class=\"js-object-default-tab \"><button class=\"button-reflection button\">Show reflection</button></div>";
         $this->html .= "<div class=\"js-object-default \">";
         $this->html .= "<span class=\"css-type-string\">Nothing here...</span>";
         $this->html .= "</div>";
     }
     $this->html .= "<div class=\"js-object-reflection-tab hide\"><button class=\"button-class-default button\">Show default</button></div>";
     $this->html .= "<div class=\"js-object-reflection hide\">";
     $this->buildFromObjectReflectionInformationRecursive($this->object['Reflection']);
     $this->html .= "</div>";
     $this->html .= "</span>";
     $this->object = [];
 }
开发者ID:junky-pic,项目名称:php-pretty-print,代码行数:75,代码来源:HtmlBuilder.php

示例12: guessSettings

 /**
  * Initialize application settings base on reflection
  *
  * Set Path to folder where application is run
  * Set namespace of the appliacation class
  *
  * @return string
  */
 private function guessSettings()
 {
     $reflection = new \ReflectionObject($this);
     $this->appPath = str_replace('\\', '/', dirname($reflection->getFileName()));
     $this->namespace = $reflection->getNamespaceName();
 }
开发者ID:nexik,项目名称:nest-core,代码行数:14,代码来源:Application.php

示例13: get_root_namespace

 public function get_root_namespace()
 {
     $r = new \ReflectionObject($this);
     return $r->getNamespaceName();
 }
开发者ID:phpwax,项目名称:core,代码行数:5,代码来源:Application.php

示例14: getAnalyzeHtml_Object

 private function getAnalyzeHtml_Object($obj, $index)
 {
     $reflector = new \ReflectionObject($obj);
     $result = '';
     $result .= '<h4>About</h4>';
     $result .= '<table class="aboutTable">';
     $result .= '<tbody>';
     $result .= '<tr>';
     $result .= '<td class="colLeft"><strong>Name</strong></td>';
     $result .= '<td class="colRight">' . htmlentities($reflector->getShortName()) . '</td>';
     $result .= '</tr>';
     $result .= '<tr>';
     $result .= '<td class="colLeft"><strong>Namespace</strong></td>';
     $result .= '<td class="colRight">' . htmlentities($reflector->getNamespaceName()) . '</td>';
     $result .= '</tr>';
     $result .= '</tbody>';
     $result .= '<tr>';
     $result .= '<td class="colLeft"><strong>File</strong></td>';
     $result .= '<td class="colRight">' . htmlentities($reflector->getFileName()) . '</td>';
     $result .= '</tr>';
     $result .= '</tbody>';
     $result .= '</table>';
     $result .= '<h4>Members</h4>';
     $result .= '<ul class="accordion" data-accordion>';
     $accId = "objConstants{$index}";
     $constants = $reflector->getConstants();
     uksort($constants, function ($x, $y) {
         return strcmp(trim(strtolower($x)), trim(strtolower($y)));
     });
     $content = 'No constants found.';
     if (!empty($constants)) {
         $content = '<table class="memberTable">';
         $content .= '<thead>';
         $content .= '<tr>';
         $content .= '<th class="memberName">Name</th>';
         $content .= '<th>Value</th>';
         $content .= '</tr>';
         $content .= '</thead>';
         $content .= '<tbody>';
         foreach ($constants as $name => $value) {
             $content .= '<tr>';
             $content .= '<td>' . htmlentities($name) . '</td>';
             $content .= '<td>' . htmlentities(var_export($value, true)) . '</td>';
             $content .= '</tr>';
         }
         $content .= '</tbody>';
         $content .= '</table>';
     }
     $result .= '<li class="accordion-navigation">';
     $result .= '<a href="#' . $accId . '" aria-expanded="false">Constants (' . trim(count($constants)) . ')</a>';
     $result .= '<div id="' . $accId . '" class="content">' . $content . '</div>';
     $result .= '</li>';
     $accId = "objMethods{$index}";
     $methods = $reflector->getMethods();
     usort($methods, function (\ReflectionMethod $x, \ReflectionMethod $y) {
         return strcmp(trim(strtolower($x->getName())), trim(strtolower($y->getName())));
     });
     foreach ($methods as $i => $m) {
         if (!$m->isPublic()) {
             unset($methods[$i]);
         }
     }
     $content = 'No methods found.';
     if (!empty($methods)) {
         $content = '<table class="memberTable">';
         $content .= '<thead>';
         $content .= '<tr>';
         $content .= '<th class="memberName">Name</th>';
         $content .= '</tr>';
         $content .= '</thead>';
         $content .= '<tbody>';
         foreach ($methods as $m) {
             $content .= '<tr>';
             $content .= '<td>' . htmlentities($m->getName()) . '</td>';
             $content .= '</tr>';
         }
         $content .= '</tbody>';
         $content .= '</table>';
     }
     $result .= '<li class="accordion-navigation">';
     $result .= '<a href="#' . $accId . '" aria-expanded="false">Methods (' . trim(count($methods)) . ')</a>';
     $result .= '<div id="' . $accId . '" class="content">' . $content . '</div>';
     $result .= '</li>';
     $accId = "objProperties{$index}";
     $properties = $reflector->getProperties();
     usort($properties, function (\ReflectionProperty $x, \ReflectionProperty $y) {
         return strcmp(trim(strtolower($x->getName())), trim(strtolower($y->getName())));
     });
     foreach ($properties as $i => $p) {
         if (!$p->isPublic()) {
             unset($properties[$i]);
         }
     }
     $content = 'No properties found.';
     if (!empty($properties)) {
         $content = '<table class="memberTable">';
         $content .= '<thead>';
         $content .= '<tr>';
         $content .= '<th class="memberName">Name</th>';
         $content .= '<th>Current value</th>';
//.........这里部分代码省略.........
开发者ID:bbehbudi,项目名称:phpDeeBuk,代码行数:101,代码来源:phpDeeBuk.php


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