本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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;
}
示例5: getParentClass
public function getParentClass()
{
$parent = parent::getParentClass();
if ($parent) {
$parent = new self($parent->getName());
}
return $parent;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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) {
示例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']);
}
示例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;
//.........这里部分代码省略.........
示例14: _reflectionParent
private function _reflectionParent(\ReflectionObject $reflection)
{
if ($pc = $reflection->getParentClass()) {
$name = '<span class="d-information" title="Class this object extends"></span> ';
$name .= '<span class="d-obj-info">Extends</span>';
// $inst = $pc->newInstanceWithoutConstructor();
$this->render($pc->name, $name);
}
}
示例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;
}