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


PHP ReflectionProperty::isProtected方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:agnetsolutions,项目名称:common,代码行数:13,代码来源:DefaultPropertyMetadata.php

示例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";
}
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:ReflectionProperty_basic1.php

示例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;
 }
开发者ID:BGCX067,项目名称:ezerphp-svn-to-git,代码行数:25,代码来源:Ezer_Loadable.php

示例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));
 }
开发者ID:ivantcholakov,项目名称:lex,代码行数:8,代码来源:ParserTest.php

示例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();
     }
 }
开发者ID:naderman,项目名称:ezc-reflection,代码行数:13,代码来源:property.php

示例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);
         }
     }
 }
开发者ID:JordanRL,项目名称:eden,代码行数:9,代码来源:PreparedProviderTrait.php

示例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;
     }
 }
开发者ID:saj696,项目名称:pipe,代码行数:17,代码来源:PropertyEnumerator.php

示例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;
 }
开发者ID:pavel81,项目名称:php-generator,代码行数:13,代码来源:Property.php

示例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));
 }
开发者ID:suin,项目名称:php-expose,代码行数:10,代码来源:ReflectionPropertyTest.php

示例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;
     }
 }
开发者ID:jaczkog,项目名称:json-rpc,代码行数:16,代码来源:AbstractTestCase.php

示例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;
 }
开发者ID:jpahullo,项目名称:moodle-theme_essential,代码行数:16,代码来源:format_grid_renderer.php

示例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);
 }
开发者ID:Debenson,项目名称:openwan,代码行数:12,代码来源:property.php

示例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;
 }
开发者ID:jmcclell,项目名称:php-code-generator,代码行数:13,代码来源:PhpProperty.php

示例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;
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:13,代码来源:PhpProperty.php

示例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.");
				'));
                }
            }
        }
    }
开发者ID:newPOPE,项目名称:web-addons.nette.org,代码行数:54,代码来源:AccessorPhp52.php


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