/** * * @param \AgNetSolutions\Common\Metadata\PropertyAnnotation $annotation * @param \ReflectionProperty $reflection */ public function __construct(PropertyAnnotation $annotation, \ReflectionProperty $reflection) { $this->reflection = $reflection; $this->annotation = $annotation; if ($this->reflection->isPrivate() || $this->reflection->isProtected()) { $this->reflection->setAccessible(true); } }
function __get($index) { //Funcionalidade original, para trabalhar com funções set/get if (method_exists($this, $method = 'get_' . $index)) { return $this->{$method}(); } else { //Nova funcionálidade - Verifica se a propriedade existe //Se não existir, verifica se está dentro do globals //Se não tiver, retorna os erros padrões do PHP $stack = debug_backtrace(); try { //Verifica se é uma propriedade private $rp = new ReflectionProperty(get_class($this), $index); if ($rp->isPrivate()) { trigger_error('Uncaught Error: Cannot access private property ' . get_class($this) . '::' . $index . ' called from ' . $stack[0]['file'] . ' on line ' . $stack[0]['line'], E_USER_ERROR); //Se não for private, retorna a propriedade } else { return $this->{$index}; } //Só chega aqui se a propriedade não existir } catch (Exception $e) { //Se ela existe dentro do globals (E o globals existe), retorna if (isset($this->globals) && isset($this->globals->{$index})) { return $this->globals->{$index}; //Caso não exista a propriedade, dispara o erro padrão do PHP } else { trigger_error('Undefined property ' . get_class($this) . '::' . $index . ' called from ' . $stack[0]['file'] . ' on line ' . $stack[0]['line']); } } } return null; }
function reflectProperty($class, $property) { $propInfo = new ReflectionProperty($class, $property); echo "**********************************\n"; echo "Reflecting on property {$class}::{$property}\n\n"; echo "__toString():\n"; var_dump($propInfo->__toString()); echo "export():\n"; var_dump(ReflectionProperty::export($class, $property, true)); echo "export():\n"; var_dump(ReflectionProperty::export($class, $property, false)); echo "getName():\n"; var_dump($propInfo->getName()); echo "isPublic():\n"; var_dump($propInfo->isPublic()); echo "isPrivate():\n"; var_dump($propInfo->isPrivate()); echo "isProtected():\n"; var_dump($propInfo->isProtected()); echo "isStatic():\n"; var_dump($propInfo->isStatic()); $instance = new $class(); if ($propInfo->isPublic()) { echo "getValue():\n"; var_dump($propInfo->getValue($instance)); $propInfo->setValue($instance, "NewValue"); echo "getValue() after a setValue():\n"; var_dump($propInfo->getValue($instance)); } echo "\n**********************************\n"; }
public function test_before() { $this->time->before(); $begin = new ReflectionProperty($this->time, 'begin'); $begin->setAccessible(true); $this->assertTrue($begin->isPrivate()); $this->assertInternalType('float', $begin->getValue($this->time)); }
/** * Returns true if this property has private as access level. * * @return bool */ public function isPrivate() { if ($this->reflectionSource instanceof ReflectionProperty) { return $this->reflectionSource->isPrivate(); } else { return parent::isPrivate(); } }
/** * @test */ public function repoter_has_observers() { $property_observers = new ReflectionProperty($this->reporter, 'observers'); $property_observers->setAccessible(true); $this->assertTrue($property_observers->isPrivate()); $observers = $property_observers->getValue($this->reporter); $this->assertEquals(1, count($observers)); $this->assertArrayHasKey('time', $observers); }
/** * @return self */ public static function from(\ReflectionProperty $from) { $prop = new static($from->getName()); $defaults = $from->getDeclaringClass()->getDefaultProperties(); $prop->value = isset($defaults[$prop->name]) ? $defaults[$prop->name] : NULL; $prop->static = $from->isStatic(); $prop->visibility = $from->isPrivate() ? 'private' : ($from->isProtected() ? 'protected' : 'public'); $prop->comment = $from->getDocComment() ? preg_replace('#^\\s*\\* ?#m', '', trim($from->getDocComment(), "/* \r\n\t")) : NULL; return $prop; }
public function __isset($property) { if (!property_exists($this, $property)) { throw new UnknownPropertyException($property, __CLASS__); } $reflect = new \ReflectionProperty($this, $property); if (!$reflect->isPrivate() && $this->property) { return true; } }
public function testPublicize_with_private_static_property() { $className = __FUNCTION__ . md5(uniqid()); eval(sprintf('class %s { private static $foo = "foo_value"; }', $className)); $reflectionProperty = new ReflectionProperty($className, 'foo'); $this->assertTrue($reflectionProperty->isStatic()); $this->assertTrue($reflectionProperty->isPrivate()); $this->assertSame($reflectionProperty, $reflectionProperty->publicize()); $this->assertSame('foo_value', $reflectionProperty->getValue($className)); }
/** * @param \Apha\Annotations\Annotation\AggregateIdentifier $annotation, * @param \ReflectionProperty $reflectionProperty * @return \Apha\Annotations\Annotation\AggregateIdentifier * @throws AnnotationReaderException */ private function processAnnotation(\Apha\Annotations\Annotation\AggregateIdentifier $annotation, \ReflectionProperty $reflectionProperty) : \Apha\Annotations\Annotation\AggregateIdentifier { if (!in_array($annotation->getType(), $this->validScalarTypes) && !class_exists($annotation->getType(), true)) { throw new AnnotationReaderException("Type '{$annotation->getType()}' is not a valid AggregateIdentifier type."); } if ($reflectionProperty->isPrivate()) { throw new AnnotationReaderException("Property must not be private."); } $annotation->setPropertyName($reflectionProperty->getName()); return $annotation; }
/** * @param object $object * @param string $property * @param mixed $value */ protected function setPrivatePropertyValue($object, $property, $value) { $reflectionProperty = new \ReflectionProperty($object, $property); if ($reflectionProperty->isPrivate() || $reflectionProperty->isProtected()) { $reflectionProperty->setAccessible(true); $reflectionProperty->setValue($object, $value); $reflectionProperty->setAccessible(false); } else { $object->{$property} = $value; } }
public function test___construct() { $instance = new $this->myclass(); $this->assertInstanceOf($this->myclass, $instance); $this->assertInstanceOf('XoopsEditor', $instance); $items = array('_hiddenText'); foreach ($items as $item) { $reflection = new ReflectionProperty($this->myclass, $item); $this->assertTrue($reflection->isPrivate()); } }
function __construct(ReflectionProperty $property) { $this->name = $property->getName(); $this->is_public = $property->isPublic(); $this->is_private = $property->isPrivate(); $this->is_protected = $property->isProtected(); $this->is_static = $property->isStatic(); $this->declaring_class = API_Doc_Class::instance($property->getDeclaringClass()); list($comment, $meta) = $this->_docComment($property->getDocComment()); $this->_processDescription($comment); $this->_processMeta($meta); }
public function __construct($class, $property) { $property = new ReflectionProperty($class, $property); list($description, $tags) = self::parse($property->getDocComment()); $this->data['title'] = $description[0]; $this->data['description'] = trim(implode("\n", $description)); if ($modifiers = $property->getModifiers()) { $this->data['modifiers'] = implode(' ', Reflection::getModifierNames($modifiers)); } else { $this->data['modifiers'] = 'public'; } if (isset($tags['var'])) { if (preg_match('/^(\\S*)(?:\\s*(.+?))?$/', $tags['var'][0], $matches)) { $this->data['type'] = $matches[1]; if (isset($matches[2])) { $this->data['description'] = array($matches[2]); } } } $this->data['name'] = $property->name; $this->data['class_name'] = $property->class; $this->data['is_static'] = $property->isStatic(); $this->data['is_public'] = $property->isPublic(); $class_rf = $property->getDeclaringClass(); if ($property->class != $class) { $this->data['is_php_class'] = $class_rf->getStartLine() ? 0 : 1; } else { $this->data['is_php_class'] = false; } $have_value = false; if ($property->isStatic()) { $v = $class_rf->getStaticProperties(); if (isset($v[$property->name])) { $value = $v[$property->name]; $have_value = true; } } else { if (!$property->isPrivate()) { if (!$class_rf->isFinal() && !$class_rf->isAbstract()) { $value = self::getValue($class, $property->name); $have_value = true; } } } if ($have_value) { $this->data['value'] = self::dump($value); $this->data['value_serialized'] = serialize($value); } }
/** * Constructor * * @param string $declaringAspectClassName Name of the aspect containing the declaration for this introduction * @param string $propertyName Name of the property to introduce * @param \TYPO3\Flow\Aop\Pointcut\Pointcut $pointcut The pointcut for this introduction */ public function __construct($declaringAspectClassName, $propertyName, \TYPO3\Flow\Aop\Pointcut\Pointcut $pointcut) { $this->declaringAspectClassName = $declaringAspectClassName; $this->propertyName = $propertyName; $this->pointcut = $pointcut; $propertyReflection = new \ReflectionProperty($declaringAspectClassName, $propertyName); if ($propertyReflection->isPrivate()) { $this->propertyVisibility = 'private'; } elseif ($propertyReflection->isProtected()) { $this->propertyVisibility = 'protected'; } else { $this->propertyVisibility = 'public'; } $this->propertyDocComment = preg_replace('/@(TYPO3\\\\Flow\\\\Annotations|Flow)\\\\Introduce.+$/mi', 'introduced by ' . $declaringAspectClassName, $propertyReflection->getDocComment()); }
public static function getPropertyIdentifier(\ReflectionProperty $reflectionProperty, $className) { $key = null; if ($reflectionProperty->isPrivate()) { $key = '\\0' . $className . '\\0' . $reflectionProperty->getName(); } elseif ($reflectionProperty->isProtected()) { $key = '' . "" . '*' . "" . $reflectionProperty->getName(); } elseif ($reflectionProperty->isPublic()) { $key = $reflectionProperty->getName(); } if (null === $key) { throw new \InvalidArgumentException('Unable to detect property visibility'); } return $key; }
private function emulate($action, $property, $value = null) { // requested property converted to method (test => getTest()) $method = $action . ucfirst($property); if (method_exists($this, $method)) { return $this->{$method}($value); } if (property_exists($this, $property)) { $ref = new \ReflectionProperty($this, $property); if ($ref->isProtected() || $ref->isPrivate()) { return; // prevent private and protected ivars from getting out. } } // catchall method that gets and sets undeclared variables. return $this->synthesize($action, $property, $value); }
protected function getNonpublicProperty($object, $property_name) { if (version_compare(PHP_VERSION, '5.3.0') >= 0) { $ref = new ReflectionProperty(get_class($object), $property_name); $ref->setAccessible(true); return $ref->getValue($object); } else { $arr = (array) $object; $key = $property_name; $ref = new ReflectionProperty(get_class($object), $property_name); if ($ref->isProtected()) { $key = "*" . $key; } elseif ($ref->isPrivate()) { $key = "" . get_class($object) . "" . $key; } return $arr[$key]; } }
/** * Constructor * * @param string $declaringAspectClassName Name of the aspect containing the declaration for this introduction * @param string $propertyName Name of the property to introduce * @param Pointcut $pointcut The pointcut for this introduction */ public function __construct($declaringAspectClassName, $propertyName, Pointcut $pointcut) { $this->declaringAspectClassName = $declaringAspectClassName; $this->propertyName = $propertyName; $this->pointcut = $pointcut; $propertyReflection = new \ReflectionProperty($declaringAspectClassName, $propertyName); $classReflection = new \ReflectionClass($declaringAspectClassName); $defaultProperties = $classReflection->getDefaultProperties(); $this->initialValue = $defaultProperties[$propertyName]; if ($propertyReflection->isPrivate()) { $this->propertyVisibility = 'private'; } elseif ($propertyReflection->isProtected()) { $this->propertyVisibility = 'protected'; } else { $this->propertyVisibility = 'public'; } $this->propertyDocComment = preg_replace('/@(Neos\\\\Flow\\\\Annotations|Flow)\\\\Introduce.+$/mi', 'introduced by ' . $declaringAspectClassName, $propertyReflection->getDocComment()); }
protected function buildFieldSignature(\ReflectionProperty $prop) : string { if ($prop->isProtected()) { $code = 'protected '; } elseif ($prop->isPrivate()) { $code = 'private '; } else { $code = 'public '; } if ($prop->isStatic()) { $code .= 'static '; } $code .= '$' . $prop->name; $defaults = $prop->getDeclaringClass()->getDefaultProperties(); if (array_key_exists($prop->name, $defaults)) { $code .= ' = ' . $this->buildLiteralCode($defaults[$prop->name]); } return $code; }
/** * @param ClassMetadata $meta * @param \ReflectionProperty $property * @return bool */ protected function isInherited(ClassMetadata $meta, \ReflectionProperty $property) { return $meta->isMappedSuperclass && !$property->isPrivate() || $meta->isInheritedField($property->name) || isset($meta->associationMappings[$property->name]['inherited']); }
/** * Property access level label. * * @param \ReflectionProperty $property * @return string */ private function getAccess(\ReflectionProperty $property) { if ($property->isPrivate()) { return 'private'; } elseif ($property->isProtected()) { return 'protected'; } return 'public'; }
/** * @param string $class * @param string $property * * @return string */ public static function reflectClassProperty($class, $property, $output = true) { $data = ''; $reflectionClass = new \ReflectionClass($class); $reflectionProperty = new \ReflectionProperty($class, $property); $defaultPropertyValues = $reflectionClass->getDefaultProperties(); $comment = $reflectionProperty->getDocComment(); if (!empty($comment)) { $data .= "\n"; $data .= "\t"; $data .= $comment; } $data .= "\n"; $data .= "\t"; $data .= $reflectionProperty->isPublic() ? 'public ' : ''; $data .= $reflectionProperty->isPrivate() ? 'private ' : ''; $data .= $reflectionProperty->isProtected() ? 'protected ' : ''; $data .= $reflectionProperty->isStatic() ? 'static ' : ''; $data .= '$' . $reflectionProperty->name; if (isset($defaultPropertyValues[$property])) { $data .= ' = ' . self::getDebugInformation($defaultPropertyValues[$property]); } $data .= ';'; if ($output) { self::output($data); } return $data; }
public final function __construct() { $this->_class_ = get_class($this); if (!empty($this->_mixin_)) { foreach (explode(',', $this->_mixin_) as $type) { $this->add_object($type); } } $private = array(); foreach (array_keys(get_object_vars($this)) as $name) { if ($name[0] == "_") { $private[] = $name; } else { $ref = new ReflectionProperty($this->_class_, $name); if (!$ref->isPrivate()) { $this->_props_[] = $name; } } } $a = func_num_args() > 0 ? func_get_arg(0) : null; $dict = array(); if (!empty($a) && is_string($a) && preg_match_all("/.+?[^\\\\],|.+?\$/", $a, $m)) { foreach ($m[0] as $g) { if (strpos($g, '=') !== false) { list($n, $v) = explode('=', $g, 2); if (substr($v, -1) == ',') { $v = substr($v, 0, -1); } $dict[$n] = $v === '' ? null : str_replace("\\,", ",", preg_replace("/^([\"\\'])(.*)\\1\$/", "\\2", $v)); } } } if (isset($dict["_static_"]) && $dict["_static_"] === "true") { $this->_static_ = true; } else { if (method_exists($this, '__new__')) { $args = func_get_args(); call_user_func_array(array($this, '__new__'), $args); } else { foreach ($dict as $n => $v) { if (in_array($n, $this->_props_)) { $this->{$n}($v); } else { if (in_array($n, $private)) { $this->{$n} = $v === "true" ? true : ($v === "false" ? false : $v); } else { throw new ErrorException($this > _class_ . "::" . $n . " property not found"); } } } } } if (!$this->_static_ && $this->_init_ && method_exists($this, '__init__')) { $this->__init__(); } /*** $name1 = create_class('protected $aaa="A";'); $name2 = create_class(' protected $_mixin_ = "'.$name1.'"; protected $bbb="B"; '); $obj2 = new $name2; eq("A",$obj2->aaa()); eq("B",$obj2->bbb()); $name1 = create_class('protected $aaa="a";'); $name2 = create_class(' protected $_mixin_ = "'.$name1.'"; protected $bbb="B"; protected $aaa="A"; public function aaa2(){ return $this->aaa; } '); $obj2 = new $name2; eq("A",$obj2->aaa()); eq("B",$obj2->bbb()); eq("A",$obj2->aaa2()); $obj2->aaa("Z"); eq("Z",$obj2->aaa()); eq("B",$obj2->bbb()); eq("Z",$obj2->aaa2()); $name = create_class(' static protected $__ccc__ = "type=boolean"; static protected $__ddd__ = "type=number"; public $aaa; public $bbb; public $ccc; public $ddd; '); $hoge = new $name("aaa=hoge"); eq("hoge",$hoge->aaa()); eq(null,$hoge->bbb()); $hoge = new $name("ccc=true"); eq(true,$hoge->ccc()); $hoge = new $name("ddd=123"); eq(123,$hoge->ddd()); $hoge = new $name("ddd=123.45"); eq(123.45,$hoge->ddd()); $hoge = new $name("bbb=fuga,aaa=hoge"); eq("hoge",$hoge->aaa()); eq("fuga",$hoge->bbb()); */ }
public function scan() { require_once $this->path; $ns = ""; $_ns = ""; $ns_bracket = false; $aliases = []; $tokens = new Tokenizer(FS::get($this->path)); while ($tokens->valid()) { if ($tokens->is(T_NAMESPACE)) { $ns = ""; $_ns = ""; $tokens->next(); if ($tokens->is(T_STRING)) { $ns = $this->_parseName($tokens); if ($tokens->is('{')) { $tokens->skip(); $ns_bracket = true; } else { $tokens->skipIf(';'); } $_ns = $ns . '\\'; } elseif ($tokens->is('{')) { $ns_bracket = true; $tokens->next(); } } elseif ($tokens->is(T_USE)) { do { $tokens->next(); $name = $this->_parseName($tokens); if ($tokens->is(T_AS)) { $aliases[$tokens->next()->get(T_STRING)] = $name; $tokens->next(); } else { if (strpos($name, '\\') === false) { $aliases[$name] = $name; } else { $aliases[ltrim('\\', strrchr($name, '\\'))] = $name; } } } while ($tokens->is(',')); $tokens->need(';')->next(); } elseif ($tokens->is(T_CONST)) { $name = $tokens->next()->get(T_STRING); $constant = new EntityConstant($_ns . $name); $constant->setValue(constant($_ns . $name)); $constant->setLine($this->line($tokens->getLine())); $this->constants[$_ns . $name] = $constant; $tokens->forwardTo(';')->next(); } elseif ($tokens->is(T_FUNCTION)) { $name = $tokens->next()->get(T_STRING); $function = new EntityFunction($_ns . $name); $function->setLine($this->line($tokens->getLine())); $function->setAliases($aliases); $this->parseCallable($function, new \ReflectionFunction($function->name)); $function->setBody($tokens->forwardTo('{')->getScope()); $tokens->next(); $this->functions[$function->name] = $function; } elseif ($tokens->is(T_FINAL, T_ABSTRACT, T_INTERFACE, T_TRAIT, T_CLASS)) { $tokens->forwardTo(T_STRING); $name = $tokens->current(); $class = new EntityClass($_ns . $name); $ref = new \ReflectionClass($class->name); $doc = $ref->getDocComment(); // if($name == "NamesInterface") { // drop($ref); // } if ($ref->isInterface()) { $class->addFlag(Flags::IS_INTERFACE); } elseif ($ref->isTrait()) { $class->addFlag(Flags::IS_TRAIT); } else { $class->addFlag(Flags::IS_CLASS); } if ($ref->isAbstract()) { $class->addFlag(Flags::IS_ABSTRACT); } elseif ($ref->isFinal()) { $class->addFlag(Flags::IS_FINAL); } if ($doc) { $info = ToolKit::parseDoc($doc); $class->setDescription($info['desc']); $class->addOptions($info['options']); } $class->setAliases($aliases); $class->setLine($this->line($tokens->getLine())); $tokens->next(); if ($tokens->is(T_EXTENDS)) { // process 'extends' keyword do { $tokens->next(); $root = $tokens->is(T_NS_SEPARATOR); $parent = $this->_parseName($tokens); if ($root) { // extends from root namespace $class->setParent($parent, $class->isInterface()); } elseif (isset($aliases[$parent])) { $class->setParent($aliases[$parent], $class->isInterface()); } else { $class->setParent($_ns . $parent, $class->isInterface()); } } while ($tokens->is(',')); } if ($tokens->is(T_IMPLEMENTS)) { // process 'implements' keyword do { $tokens->next(); $root = $tokens->is(T_NS_SEPARATOR); $parent = $this->_parseName($tokens); if ($root) { // extends from root namespace $class->addInterface($parent); } elseif (isset($aliases[$parent])) { $class->addInterface($aliases[$parent]); } else { $class->addInterface($_ns . $parent); } } while ($tokens->is(',')); } $tokens->forwardTo('{')->next(); while ($tokens->forwardTo(T_CONST, T_FUNCTION, '{', '}', T_VARIABLE) && $tokens->valid()) { switch ($tokens->key()) { case T_CONST: $constant = new EntityConstant($class->name . '::' . $tokens->next()->get(T_STRING)); $constant->setValue(constant($constant->name)); $constant->setLine(new Line($this, $tokens->getLine())); $class->addConstant($constant); break; case T_VARIABLE: $property = new EntityProperty(ltrim($tokens->getAndNext(), '$')); $ref = new \ReflectionProperty($class->name, $property->name); $doc = $ref->getDocComment(); if ($doc) { $property->setDescription(ToolKit::parseDoc($doc)['desc']); } if ($ref->isPrivate()) { $property->addFlag(Flags::IS_PRIVATE); } elseif ($ref->isProtected()) { $property->addFlag(Flags::IS_PROTECTED); } else { $property->addFlag(Flags::IS_PUBLIC); } if ($ref->isStatic()) { $property->addFlag(Flags::IS_STATIC); } if ($ref->isDefault()) { $property->setValue($ref->getDeclaringClass()->getDefaultProperties()[$property->name]); } $class->addProperty($property); break; case T_FUNCTION: $method = new EntityMethod($name . '::' . $tokens->next()->get(T_STRING)); $method->setLine($this->line($tokens->getLine())); $this->parseCallable($method, $ref = new \ReflectionMethod($class->name, $method->short)); if ($ref->isPrivate()) { $method->addFlag(Flags::IS_PRIVATE); } elseif ($ref->isProtected()) { $method->addFlag(Flags::IS_PROTECTED); } else { $method->addFlag(Flags::IS_PUBLIC); } if ($ref->isStatic()) { $method->addFlag(Flags::IS_STATIC); } if ($ref->isAbstract()) { $method->addFlag(Flags::IS_ABSTRACT); $method->addFlag(Flags::IS_ABSTRACT_IMPLICIT); } elseif ($ref->isFinal()) { $method->addFlag(Flags::IS_FINAL); } if (isset($method->options['deprecated'])) { $method->addFlag(Flags::IS_DEPRECATED); } $tokens->forwardTo(')')->next(); if ($tokens->is('{')) { $method_body = $tokens->getScope(); $method->setBody($method_body); } $tokens->next(); $class->addMethod($method); break; case '{': // use traits scope $tokens->forwardTo('}')->next(); break; case '}': // end of class $tokens->next(); $this->classes[$class->name] = $class; break 2; } } } elseif ($tokens->is('}') && $ns_bracket) { $tokens->next(); $ns_bracket = false; } else { drop($tokens->curr); if ($tokens->valid()) { throw new UnexpectedTokenException($tokens); } break; } } }
function serializePropertyName(ReflectionClass $class, ReflectionProperty $property) { $propertyName = $property->getName(); if ($property->isProtected()) { $propertyName = chr(0) . '*' . chr(0) . $propertyName; } elseif ($property->isPrivate()) { $propertyName = chr(0) . $class->getName() . chr(0) . $propertyName; } return serialize($propertyName); }
<?php class C { public static $p; } var_dump(new ReflectionProperty()); var_dump(new ReflectionProperty('C::p')); var_dump(new ReflectionProperty('C', 'p', 'x')); $rp = new ReflectionProperty('C', 'p'); var_dump($rp->getName(1)); var_dump($rp->isPrivate(1)); var_dump($rp->isProtected(1)); var_dump($rp->isPublic(1)); var_dump($rp->isStatic(1)); var_dump($rp->getModifiers(1)); var_dump($rp->isDefault(1));
function _pprintr_object_ReflectionProperty(ReflectionProperty $property, $var, $indent, $indentStep) { $modifiers = array(); $property->setAccessible(true); if (defined('PPRINTR_INCLUDE_PROTECTED') && PPRINTR_INCLUDE_PROTECTED) { $property->isPublic() && ($modifiers[] = "[92mpublic[0m"); $property->isProtected() && ($modifiers[] = "[91mprotected[0m"); $property->isPrivate() && ($modifiers[] = "[91mprivate[0m"); } $property->isStatic() && ($modifiers[] = "static"); $modifiers = implode(' ', $modifiers); $name = $property->getName(); $value = pprintr($property->getValue($var), $indent + $indentStep, $indentStep); $str = "[0m[1m{$name}[0m => {$value}"; if ($modifiers != []) { $str = "[0m{$modifiers}[1m {$str}"; } return $str; }
/** * takes a reflection property and returns a nicely formatted key of the property name * * @param ReflectionProperty * @return string */ protected function _getPropertyKey(ReflectionProperty $property) { $static = $property->isStatic() ? ' static' : ''; if ($property->isPublic()) { return 'public' . $static . ' ' . $property->getName(); } if ($property->isProtected()) { return 'protected' . $static . ' ' . $property->getName(); } if ($property->isPrivate()) { return 'private' . $static . ' ' . $property->getName(); } }
/** * Adds the given property to the result array when it does not already * exist and is not declared as private. * * @param ReflectionProperty $property The current property * instance that should be added to the result of available properties. * @param array(string=>\ReflectionProperty) $result An array with all * properties that have already been collected for the reflected class. * * @return array(string=>\ReflectionProperty) */ private function _collectPropertyFromParentClass(\ReflectionProperty $property, array $result) { if (!$property->isPrivate() && !isset($result[$property->getName()])) { $result[$property->getName()] = $property; } return $result; }