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


PHP ReflectionObject::getParentClass方法代码示例

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


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

示例1: setForm

 public function setForm(Form &$form, array $request)
 {
     $errors = array();
     $form->befor_set();
     $reflex = new ReflectionObject($form);
     $propts = $reflex->getParentClass()->getProperties();
     foreach ($propts as $propt) {
         $name = $propt->getName();
         $exis = method_exists($form, self::VALIDATE . $name);
         $value = isset($request[$name]) ? $request[$name] : null;
         $valid = self::VALIDATE . $name;
         $setvl = self::SET_METHOD . ucfirst($name);
         $respn = $exis ? $form->{$valid}($value) : true;
         if ($respn === true) {
             if (method_exists($form, $setvl)) {
                 if ($value != null) {
                     $form->{$setvl}($value);
                 }
             } else {
                 if ($value != null) {
                     $propt->setAccessible(true);
                     $propt->setValue($form, $value);
                     $propt->setAccessible(false);
                 }
             }
         } else {
             $errors[$name] = $respn;
         }
     }
     $form->after_set();
     return count($errors) > 0 ? $errors : true;
 }
开发者ID:exildev,项目名称:corvus,代码行数:32,代码来源:View.php

示例2: getViewTemplate

 /**
  * @return string
  */
 public function getViewTemplate()
 {
     // set default view name
     if (is_null($this->viewTemplate)) {
         $reflected = new \ReflectionObject($this);
         $viewTemplate = substr($reflected->getFileName(), 0, -4);
         $templateFound = false;
         foreach (self::$viewExtensions as $extension) {
             if (file_exists($viewTemplate . '.' . ltrim($extension, '.'))) {
                 $templateFound = true;
                 break;
             }
         }
         if (!$templateFound) {
             // try to get parent template if any
             $parentReflectedClass = $reflected->getParentClass();
             if ($parentReflectedClass->isInstantiable() && $parentReflectedClass->implementsInterface(RenderableActionInterface::class)) {
                 $parentViewTemplate = $parentReflectedClass->newInstance()->getViewTemplate();
                 $viewTemplate = $parentViewTemplate;
             }
         }
         $this->viewTemplate = $viewTemplate;
     }
     return $this->viewTemplate;
 }
开发者ID:objective-php,项目名称:application,代码行数:28,代码来源:RenderableAction.php

示例3: run

 /**
  * Executes the application.
  *
  * Available options:
  *
  *  * interactive:               Sets the input interactive flag
  *  * decorated:                 Sets the output decorated flag
  *  * verbosity:                 Sets the output verbosity flag
  *  * capture_stderr_separately: Make output of stdOut and stdErr separately available
  *
  * @param array $input   An array of arguments and options
  * @param array $options An array of options
  *
  * @return int The command exit code
  */
 public function run(array $input, $options = array())
 {
     $this->input = new ArrayInput($input);
     if (isset($options['interactive'])) {
         $this->input->setInteractive($options['interactive']);
     }
     $this->captureStreamsIndependently = array_key_exists('capture_stderr_separately', $options) && $options['capture_stderr_separately'];
     if (!$this->captureStreamsIndependently) {
         $this->output = new StreamOutput(fopen('php://memory', 'w', false));
         if (isset($options['decorated'])) {
             $this->output->setDecorated($options['decorated']);
         }
         if (isset($options['verbosity'])) {
             $this->output->setVerbosity($options['verbosity']);
         }
     } else {
         $this->output = new ConsoleOutput(isset($options['verbosity']) ? $options['verbosity'] : ConsoleOutput::VERBOSITY_NORMAL, isset($options['decorated']) ? $options['decorated'] : null);
         $errorOutput = new StreamOutput(fopen('php://memory', 'w', false));
         $errorOutput->setFormatter($this->output->getFormatter());
         $errorOutput->setVerbosity($this->output->getVerbosity());
         $errorOutput->setDecorated($this->output->isDecorated());
         $reflectedOutput = new \ReflectionObject($this->output);
         $strErrProperty = $reflectedOutput->getProperty('stderr');
         $strErrProperty->setAccessible(true);
         $strErrProperty->setValue($this->output, $errorOutput);
         $reflectedParent = $reflectedOutput->getParentClass();
         $streamProperty = $reflectedParent->getProperty('stream');
         $streamProperty->setAccessible(true);
         $streamProperty->setValue($this->output, fopen('php://memory', 'w', false));
     }
     return $this->statusCode = $this->application->run($this->input, $this->output);
 }
开发者ID:Ener-Getick,项目名称:symfony,代码行数:47,代码来源:ApplicationTester.php

示例4: getClassesToRead

 /**
  * Get a list of classes and traits to analyze.
  *
  * @param \ReflectionObject $reflectionObject The object to get the parents from.
  *
  * @return array The list of classes to read.
  */
 public static function getClassesToRead(\ReflectionObject $reflectionObject)
 {
     $cacheId = md5("classesToRead:" . $reflectionObject->getName());
     $objectClasses = self::getFromCache($cacheId);
     if ($objectClasses !== null) {
         return $objectClasses;
     }
     $objectClasses = array($reflectionObject);
     $objectTraits = $reflectionObject->getTraits();
     if (!empty($objectTraits)) {
         foreach ($objectTraits as $trait) {
             $objectClasses[] = $trait;
         }
     }
     $parentClass = $reflectionObject->getParentClass();
     while ($parentClass) {
         $objectClasses[] = $parentClass;
         $parentTraits = $parentClass->getTraits();
         if (!empty($parentTraits)) {
             foreach ($parentTraits as $trait) {
                 $objectClasses[] = $trait;
             }
         }
         $parentClass = $parentClass->getParentClass();
     }
     self::saveToCache($cacheId, $objectClasses);
     return $objectClasses;
 }
开发者ID:antarestupin,项目名称:Accessible,代码行数:35,代码来源:Reader.php

示例5: getParentClass

 public function getParentClass()
 {
     $parent = parent::getParentClass();
     if ($parent) {
         $parent = new self($parent->getName());
     }
     return $parent;
 }
开发者ID:crodas,项目名称:notoj,代码行数:8,代码来源:ReflectionObject.php

示例6: getClassDeclaration

 /**
  * Return class declaration
  *
  * @param unknown_type $class
  */
 public function getClassDeclaration($class)
 {
     //instantiate class
     $obj = new $class();
     $ref = new ReflectionObject($obj);
     $parentClass = $ref->getParentClass()->getname();
     $declaration = 'class ' . $class . ' extends ' . $parentClass;
     return $declaration;
 }
开发者ID:praxigento,项目名称:mage_app_prxgt_store,代码行数:14,代码来源:Extension.php

示例7: set_document_owner_type

 protected function set_document_owner_type($type = null)
 {
     if (is_null($type)) {
         $class = get_class($this);
         $r = new ReflectionObject($this);
         while (__CLASS__ != ($current_class = $r->getParentClass()->getName())) {
             $class = $current_class;
             $r = $r->getParentClass();
         }
         $type = substr($class, 19);
     }
     $this->documentOwnerType = $type;
 }
开发者ID:HaakonME,项目名称:porticoestate,代码行数:13,代码来源:class.uidocument.inc.php

示例8: serialize

 /**
  * @param ReferenceRepository $referenceRepository
  *
  * @throws \RuntimeException
  *
  * @return string
  */
 public function serialize(ReferenceRepository $referenceRepository)
 {
     $references = array();
     $isORM = $referenceRepository->getManager() instanceof EntityManager;
     foreach ($referenceRepository->getReferences() as $name => $reference) {
         $reference = $referenceRepository->getReference($name);
         $references[$name]['identifier'] = $referenceRepository->getManager()->getUnitOfWork()->getEntityIdentifier($reference);
         if ($reference instanceof Proxy) {
             $ro = new \ReflectionObject($reference);
             $references[$name]['class'] = $ro->getParentClass()->getName();
         } else {
             $references[$name]['class'] = get_class($reference);
         }
     }
     return serialize($references);
 }
开发者ID:ruslan-polutsygan,项目名称:dev-bundle,代码行数:23,代码来源:FixtureReferenceRepositorySerializer.php

示例9: props

 public function props($originalObject)
 {
     $convertedObject = new \stdClass();
     $reflectionObject = new \ReflectionObject($originalObject);
     $properties = $reflectionObject->getProperties();
     // Если у класса есть родитльский класс
     // получаем свойства родительского класса
     $parentObject = $reflectionObject->getParentClass();
     if ($parentObject instanceof \ReflectionClass) {
         $properties = array_merge($parentObject->getProperties(), $properties);
     }
     foreach ($properties as $item) {
         $annotation = $this->reader->getPropertyAnnotation($item, $this->annotationClass);
         if (null !== $annotation) {
             $propertyName = $annotation->getPropertyName();
             $convertedObject->{$propertyName} = $annotation;
         }
     }
     return $convertedObject;
 }
开发者ID:busaev,项目名称:s3,代码行数:20,代码来源:DescriptionConverter.php

示例10: getHttpCachePartialMock

    /**
     * @return \FOS\HttpCacheBundle\HttpCache|\PHPUnit_Framework_MockObject_MockObject
     */
    protected function getHttpCachePartialMock(array $mockedMethods = null)
    {
        $mock = $this->getMockBuilder('\FOS\HttpCacheBundle\HttpCache')
                     ->setMethods( $mockedMethods )
                     ->disableOriginalConstructor()
                     ->getMock();

        // Force setting options property since we can't use original constructor.
        $options = array(
            'debug' => false,
            'default_ttl' => 0,
            'private_headers' => array( 'Authorization', 'Cookie' ),
            'allow_reload' => false,
            'allow_revalidate' => false,
            'stale_while_revalidate' => 2,
            'stale_if_error' => 60,
        );

        $refMock = new \ReflectionObject($mock);
        $refHttpCache = $refMock
            // \FOS\HttpCacheBundle\HttpCache
            ->getParentClass()
            // \Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache
            ->getParentClass()
            // \Symfony\Component\HttpKernel\HttpCache\HttpCache
            ->getParentClass();
        // Workaround for Symfony 2.3 where $options property is not defined.
        if (!$refHttpCache->hasProperty('options')) {
            $mock->options = $options;
        } else {
            $refOptions = $refHttpCache
                ->getProperty('options');
            $refOptions->setAccessible(true);
            $refOptions->setValue($mock, $options );
        }

        return $mock;
    }
开发者ID:ataxel,项目名称:tp,代码行数:41,代码来源:HttpCacheTest.php

示例11: dump


//.........这里部分代码省略.........
                echo "(Recursion)";
            }
            $aclass = $c > 0 && array_key_exists(0, $var) && array_key_exists($c - 1, $var) ? 'array' : 'struct';
            $var['fw1recursionsentinel'] = true;
            echo "{$tabs}<table class=\"dump {$aclass}\">{$tabs}<thead><tr><th colspan=\"2\">" . ($label != '' ? $label . ' - ' : '') . "array" . ($c > 0 ? "" : " [empty]") . "</th></tr></thead>{$tabs}<tbody>";
            foreach ($var as $index => $aval) {
                if ($index === 'fw1recursionsentinel') {
                    continue;
                }
                echo "{$tabs}<tr><td class=\"key\">" . $he($index) . "</td><td class=\"value\">";
                $this->dump($aval, $limit, '', $depth);
                echo "</td></tr>";
                $printCount++;
                if ($limit > 0 && $printCount >= $limit && $aclass === 'array') {
                    break;
                }
            }
            echo "{$tabs}</tbody>{$tabs}</table>";
            // unset($var['fw1recursionsentinel']);
        } elseif (is_string($var)) {
            echo $var === '' ? '[EMPTY STRING]' : htmlentities($var);
        } elseif (is_bool($var)) {
            echo $var ? "TRUE" : "FALSE";
        } elseif (is_callable($var) || is_object($var) && is_subclass_of($var, 'ReflectionFunctionAbstract')) {
            $echoFunction($var, $tabs, $label);
        } elseif (is_float($var)) {
            echo "(float) " . htmlentities($var);
        } elseif (is_int($var)) {
            echo "(int) " . htmlentities($var);
        } elseif (is_null($var)) {
            echo "NULL";
        } elseif (is_object($var)) {
            $ref = new \ReflectionObject($var);
            $parent = $ref->getParentClass();
            $interfaces = implode("<br/>implements ", $ref->getInterfaceNames());
            try {
                $serial = serialize($var);
            } catch (\Exception $e) {
                $serial = 'hasclosure' . $ref->getName();
            }
            $objHash = 'o' . md5($serial);
            $refHash = 'r' . md5($ref);
            echo "{$tabs}<table class=\"dump object\"" . (isset($seen[$refHash]) ? "" : "id=\"{$refHash}\"") . ">{$tabs}<thead>{$tabs}<tr><th colspan=\"2\">" . ($label != '' ? $label . ' - ' : '') . "object " . htmlentities($ref->getName()) . ($parent ? "<br/>extends " . $parent->getName() : "") . ($interfaces !== '' ? "<br/>implements " . $interfaces : "") . "</th></tr>{$tabs}<tbody>";
            if (isset($seen[$objHash])) {
                echo "{$tabs}<tr><td colspan=\"2\"><a href=\"#{$refHash}\">[see above for details]</a></td></tr>";
            } else {
                $seen[$objHash] = TRUE;
                $constants = $ref->getConstants();
                if (count($constants) > 0) {
                    echo "{$tabs}<tr><td class=\"key\">CONSTANTS</td><td class=\"values\">{$tabs}<table class=\"dump object\">";
                    foreach ($constants as $constant => $cval) {
                        echo "{$tabs}<tr><td class=\"key\">" . htmlentities($constant) . "</td><td class=\"value constant\">";
                        $this->dump($cval, $limit, '', $depth);
                        echo "</td></tr>";
                    }
                    echo "{$tabs}</table>{$tabs}</td></tr>";
                }
                $properties = $ref->getProperties();
                if (count($properties) > 0) {
                    echo "{$tabs}<tr><td class=\"key\">PROPERTIES</td><td class=\"values\">{$tabs}<table class=\"dump object\">";
                    foreach ($properties as $property) {
                        echo "{$tabs}<tr><td class=\"key\">" . htmlentities(implode(' ', \Reflection::getModifierNames($property->getModifiers()))) . " " . $he($property->getName()) . "</td><td class=\"value property\">";
                        $wasHidden = $property->isPrivate() || $property->isProtected();
                        $property->setAccessible(TRUE);
                        $this->dump($property->getValue($var), $limit, '', $depth);
                        if ($wasHidden) {
开发者ID:rickosborne,项目名称:rickosborne,代码行数:67,代码来源:Framework.php

示例12: clientConfigurationIsPassedToHttpClient

 /**
  * This test tests if the clientConfiguration from the Configuration object
  * is actually passed to the client if the constructor creates it's own client.
  *
  * @dataProvider booleanValues
  * @test
  */
 public function clientConfigurationIsPassedToHttpClient($verify)
 {
     $configurationArray = $this->mergeConfigurationWithMinimalConfiguration();
     $clientConfiguration = ['verify' => $verify];
     $configurationArray['clientConfiguration'] = $clientConfiguration;
     $configuration = new Configuration($configurationArray);
     $client = $this->createClient($configuration);
     $reflectionObject = new \ReflectionObject($client);
     $clientProperty = $reflectionObject->getParentClass()->getProperty('client');
     $clientProperty->setAccessible(true);
     $httpClient = $clientProperty->getValue($client);
     $this->assertEquals($clientConfiguration['verify'], $httpClient->getConfig()['verify']);
 }
开发者ID:simplyadmire,项目名称:zaaksysteem,代码行数:20,代码来源:AbstractClientTest.php

示例13: outInfo

 /**
  *  prints out information about the $this arg
  *
  *  @since  9-23-09
  *  
  *  object info uses the reflection class http://nz.php.net/manual-lookup.php?pattern=oop5.reflection&lang=en  
  *  
  *  @todo
  *    - get the parent classes methods and values and stuff, then organize the methods by visible and invisible (private, protected)
  *    - this might be a good way for aIter to display classes also, but just get the properties of the object
  *
  *  @param  string  $calling_class  the class name of the class that made the call
  *  @return string  information about the arg                        
  */
 function outInfo($calling_class = '')
 {
     $this->useName(false);
     $config = $this->config();
     $config->outEnquote(false);
     $config->outObject(false);
     $type = $this->type();
     $format_handler = new out_format($config);
     $name = $this->name();
     $val = $this->value();
     $info_list = array();
     $info_type = 'undefined';
     switch ($type) {
         case self::TYPE_NULL:
             $info_type = 'NULL';
             break;
         case self::TYPE_STRING_VAL:
         case self::TYPE_STRING_LITERAL:
         case self::TYPE_STRING_GENERATED:
             $info_type = 'string';
             $info_list[] = sprintf('value: %s', $format_handler->enquote($val));
             $info_list[] = sprintf('%d characters', mb_strlen($val));
             break;
             ///case self::TYPE_STRING_EMPTY: break;
         ///case self::TYPE_STRING_EMPTY: break;
         case self::TYPE_NUMERIC:
             if (is_int($val)) {
                 $info_type = 'integer';
             } else {
                 if (is_float($val)) {
                     $info_type = 'float';
                 }
             }
             //if/else if
             $info_list[] = sprintf('value: %s', $val);
             break;
         case self::TYPE_ARRAY:
             $info_type = 'array';
             // find out if it is an indexed array...
             $info_list = array();
             $info_list[] = 'length: ' . count($val);
             if (!empty($val)) {
                 $info_list[] = ctype_digit(join('', array_keys($val))) ? 'keys are numeric' : 'keys are associative';
             }
             //if
             break;
         case self::TYPE_OBJECT:
             $rclass = new ReflectionObject($val);
             $info_type = $rclass->getName() . ' instance';
             $indent = $this->indent;
             if ($path = $rclass->getFileName()) {
                 $file_map = new out_file($path);
                 $file_map->config($config);
                 $info_list[] = sprintf('%s %s %s', $format_handler->wrap('b', 'Defined:'), $rclass->getName(), $file_map->out(true, false));
             }
             //if
             $class_name_list = array($rclass->getName());
             // get all the classes this object extends...
             if ($parent_class = $rclass->getParentClass()) {
                 $info_list[] = $format_handler->wrap('b', 'Extends:');
                 while (!empty($parent_class)) {
                     $class_name_list[] = $parent_class->getName();
                     $file_map = new out_file($parent_class->getFileName());
                     $file_map->config($config);
                     $info_list[] = sprintf('%s%s %s', $indent, $parent_class->getName(), $file_map->out(true, false));
                     $parent_class = $parent_class->getParentClass();
                 }
                 //while
             }
             //if
             // handle properties...
             $properties = $rclass->getProperties();
             $info_list[] = $format_handler->wrap('b', sprintf('%s (%d):', 'Properties', count($properties)));
             $prop_val = null;
             $prop_check = true;
             foreach ($properties as $property) {
                 // setAccessible only around >5.3...
                 if (method_exists($property, 'setAccessible')) {
                     $property->setAccessible(true);
                     $prop_val = $property->getValue($val);
                 } else {
                     if ($property->isPublic()) {
                         $prop_val = $property->getValue($val);
                     } else {
                         $prop_val = $format_handler->wrap('i', 'Not Accessible');
                         $prop_check = false;
//.........这里部分代码省略.........
开发者ID:Jaymon,项目名称:out,代码行数:101,代码来源:out_class.php

示例14: _reflectionParent

 private function _reflectionParent(\ReflectionObject $reflection)
 {
     if ($pc = $reflection->getParentClass()) {
         $name = '<span class="d-information" title="Class this object extends"></span>&nbsp;';
         $name .= '<span class="d-obj-info">Extends</span>';
         // $inst = $pc->newInstanceWithoutConstructor();
         $this->render($pc->name, $name);
     }
 }
开发者ID:aronduby,项目名称:dump,代码行数:9,代码来源:ump.php

示例15: fetch

 function fetch()
 {
     $this->setup();
     $this->_slots = $this->_event->filter('template.slots', $this, $this->_slots);
     ob_start();
     $this->content();
     $this->assign('_content', trim(ob_get_clean()));
     $extends = $this->_extends;
     if (null === $extends) {
         $r = new \ReflectionObject($this);
         $p = $r->getParentClass();
         if ($p && $p->name != 'greebo\\conveniences\\Template') {
             $extends = $p->name;
         }
     }
     return $extends ? $this->render($extends, $this->_raw) : $this->_content;
 }
开发者ID:blerou,项目名称:greebo,代码行数:17,代码来源:Template.php


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