本文整理汇总了PHP中ReflectionProperty::isProtected方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionProperty::isProtected方法的具体用法?PHP ReflectionProperty::isProtected怎么用?PHP ReflectionProperty::isProtected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionProperty
的用法示例。
在下文中一共展示了ReflectionProperty::isProtected方法的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: 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";
}
示例3: parseAttribute
private function parseAttribute($class, $attribute)
{
$attr = new ReflectionProperty($class, $attribute);
$annotations = array('validate' => $attr->isProtected(), 'mandatory' => true);
$comment = $attr->getDocComment();
if (!$comment) {
return $annotations;
}
if (!preg_match_all('/\\s*\\* @(\\w+) ([^\\n\\r]*)/', $comment, $matches)) {
return $annotations;
}
foreach ($matches[1] as $index => $match) {
$value = $matches[2][$index];
switch ($value) {
case 'false':
$value = false;
break;
case 'true':
$value = true;
break;
}
$annotations[$match] = $value;
}
return $annotations;
}
示例4: testCanSetScopeGlue
public function testCanSetScopeGlue()
{
$this->parser->scopeGlue('~');
$scopeGlue = new ReflectionProperty($this->parser, 'scopeGlue');
$this->assertTrue($scopeGlue->isProtected());
$scopeGlue->setAccessible(true);
$this->assertEquals('~', $scopeGlue->getValue($this->parser));
}
示例5: isProtected
/**
* Returns true if this property has protected as access level.
*
* @return bool
*/
public function isProtected()
{
if ($this->reflectionSource instanceof ReflectionProperty) {
return $this->reflectionSource->isProtected();
} else {
return parent::isProtected();
}
}
示例6: __call
public function __call($method, $args)
{
if (property_exists($this, $method) && is_callable($this->{$method})) {
$check = new \ReflectionProperty($this, $method);
if ($check->isProtected()) {
return call_user_func_array($this->{$method}, $args);
}
}
}
示例7: getVisibilityStyle
/**
* Get output style for the given property's visibility.
*
* @param \ReflectionProperty $property
*
* @return string
*/
private function getVisibilityStyle(\ReflectionProperty $property)
{
if ($property->isPublic()) {
return self::IS_PUBLIC;
} elseif ($property->isProtected()) {
return self::IS_PROTECTED;
} else {
return self::IS_PRIVATE;
}
}
示例8: 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;
}
示例9: testPublicize_with_protected_static_property
public function testPublicize_with_protected_static_property()
{
$className = __FUNCTION__ . md5(uniqid());
eval(sprintf('class %s { protected static $foo = "foo_value"; }', $className));
$reflectionProperty = new ReflectionProperty($className, 'foo');
$this->assertTrue($reflectionProperty->isStatic());
$this->assertTrue($reflectionProperty->isProtected());
$this->assertSame($reflectionProperty, $reflectionProperty->publicize());
$this->assertSame('foo_value', $reflectionProperty->getValue($className));
}
示例10: 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;
}
}
示例11: get_topic0attop
/**
* Backwards compatibility method to get 'topic0attop' attribute value.
*
* @return boolean Value of topic0attop.
*/
private function get_topic0attop()
{
if (property_exists($this, 'topic0attop')) {
$reflectionproperty = new ReflectionProperty($this, 'topic0attop');
if ($reflectionproperty->isProtected()) {
return $this->topic0attop;
}
}
// Grid format fix #24 not implemented. Assume section 0 is at the top.
return 1;
}
示例12: 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);
}
示例13: fromReflection
public static function fromReflection(\ReflectionProperty $ref)
{
$property = new static($ref->name);
$property->setStatic($ref->isStatic())->setVisibility($ref->isPublic() ? self::VISIBILITY_PUBLIC : ($ref->isProtected() ? self::VISIBILITY_PROTECTED : self::VISIBILITY_PRIVATE));
$docblock = new Docblock($ref);
$property->setDocblock($docblock);
$property->setDescription($docblock->getShortDescription());
$defaultProperties = $ref->getDeclaringClass()->getDefaultProperties();
if (isset($defaultProperties[$ref->name])) {
$property->setDefaultValue($defaultProperties[$ref->name]);
}
return $property;
}
示例14: fromReflection
public static function fromReflection(\ReflectionProperty $ref)
{
$property = new static();
$property->setName($ref->name)->setStatic($ref->isStatic())->setVisibility($ref->isPublic() ? self::VISIBILITY_PUBLIC : ($ref->isProtected() ? self::VISIBILITY_PROTECTED : self::VISIBILITY_PRIVATE));
if ($docComment = $ref->getDocComment()) {
$property->setDocblock(ReflectionUtils::getUnindentedDocComment($docComment));
}
$defaultProperties = $ref->getDeclaringClass()->getDefaultProperties();
if (isset($defaultProperties[$ref->name])) {
$property->setDefaultValue($defaultProperties[$ref->name]);
}
return $property;
}
示例15: accessProperty
/**
* @param ReflectionProperty
* @return object get => callable(object|NULL $instance), set => callable(object|NULL $instance, mixed $value)
*/
public function accessProperty(ReflectionProperty $property)
{
if (PHP_VERSION_ID >= 50300 or $property->isPublic()) {
if (PHP_VERSION_ID >= 50300) {
$property->setAccessible(true);
}
return (object) array('get' => $this->callback('$instance', '
if ($instance)
{
return $property->getValue($instance);
}
return $property->getValue();
', array('property' => $property)), 'set' => $this->callback('$instance, $value', '
if ($instance)
{
$property->setValue($instance, $value);
}
else
{
$property->setValue($value);
}
', array('property' => $property)));
} else {
if ($property->isProtected()) {
return (object) array('get' => $this->callback('$instance', '
if ($instance AND $property->isStatic()) $instance = NULL;
return call_user_func(array($helperClassName, "__AccessAccessor_php52__get"), $instance, $propertyName);
', array('property' => $property, 'helperClassName' => $this->getHelperClass($property->getDeclaringClass()), 'propertyName' => $property->getName())), 'set' => $this->callback('$instance, $value', '
if ($instance AND $property->isStatic()) $instance = NULL;
return call_user_func(array($helperClassName, "__AccessAccessor_php52__set"), $instance, $propertyName, $value);
', array('property' => $property, 'helperClassName' => $this->getHelperClass($property->getDeclaringClass()), 'propertyName' => $property->getName())));
} else {
if ($property->isPrivate()) {
if ($property->isStatic()) {
throw new Exception('AccessProperty needs PHP 5.3.0 or newer to access static private property.');
}
return (object) array('get' => $this->callback('$instance', '
if ($instance)
{
$array = (array) $instance;
return $array["\\0{$className}\\0{$propertyName}"];
}
throw new Exception("AccessProperty needs PHP 5.3.0 or newer to access static private property.");
', array('helperClassName' => $this->getHelperClass($property->getDeclaringClass()), 'className' => $property->getDeclaringClass()->getName(), 'propertyName' => $property->getName())), 'set' => $this->callback('$instance, $value', '
throw new Exception("AccessProperty needs PHP 5.3.0 or newer to write to private property.");
'));
}
}
}
}