本文整理汇总了PHP中ReflectionProperty::isPrivate方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionProperty::isPrivate方法的具体用法?PHP ReflectionProperty::isPrivate怎么用?PHP ReflectionProperty::isPrivate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionProperty
的用法示例。
在下文中一共展示了ReflectionProperty::isPrivate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
*
* @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);
}
}
示例2: ReflectionProperty
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;
}
示例3: reflectProperty
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";
}
示例4: test_before
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));
}
示例5: isPrivate
/**
* 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();
}
}
示例6: repoter_has_observers
/**
* @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);
}
示例7: from
/**
* @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;
}
示例8: __isset
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;
}
}
示例9: testPublicize_with_private_static_property
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));
}
示例10: processAnnotation
/**
* @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;
}
示例11: setPrivatePropertyValue
/**
* @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;
}
}
示例12: test___construct
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());
}
}
示例13: list
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);
}
示例14: __construct
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);
}
}
示例15: __construct
/**
* 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());
}