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


PHP ReflectionProperty::isStatic方法代码示例

本文整理汇总了PHP中ReflectionProperty::isStatic方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionProperty::isStatic方法的具体用法?PHP ReflectionProperty::isStatic怎么用?PHP ReflectionProperty::isStatic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ReflectionProperty的用法示例。


在下文中一共展示了ReflectionProperty::isStatic方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __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);
     }
 }
开发者ID:xiaodin1,项目名称:myqee,代码行数:49,代码来源:docs_roperty.php

示例2: __construct

 public function __construct($class, $property, $default = null)
 {
     $property = new \ReflectionProperty($class, $property);
     list($description, $tags) = $this->userguide->parse($property->getDocComment());
     $this->description = $description;
     if ($modifiers = $property->getModifiers()) {
         $this->modifiers = '<small>' . implode(' ', \Reflection::getModifierNames($modifiers)) . '</small> ';
     }
     if (isset($tags['var'])) {
         if (preg_match('/^(\\S*)(?:\\s*(.+?))?$/s', $tags['var'][0], $matches)) {
             $this->type = $matches[1];
             if (isset($matches[2])) {
                 $this->description = $this->markdown->transform($matches[2]);
             }
         }
     }
     $this->property = $property;
     // Show the value of static properties, but only if they are public or we are php 5.3 or
     // higher and can force them to be accessible
     if ($property->isStatic()) {
         $property->setAccessible(true);
         // Don't debug the entire object, just say what kind of object it is
         if (is_object($property->getValue($class))) {
             $this->value = '<pre>object ' . get_class($property->getValue($class)) . '()</pre>';
         } else {
             $this->value = Debug::vars($property->getValue($class));
         }
     }
     // Store the defult property
     $this->default = Debug::vars($default);
 }
开发者ID:braf,项目名称:phalcana-userguide,代码行数:31,代码来源:DocProperty.php

示例3: __set

 /**
  * __set.
  *
  * Overloading method to set any $key property to $this->class or if not static,
  * to $this->object.
  *
  * @param  $key
  * @param  $value
  * @return $this
  */
 public function __set($key, $value)
 {
     $property = new \ReflectionProperty($this->class, $key);
     $property->setAccessible(true);
     $property->isStatic() ? $property->setValue($value) : $property->setValue($this->object, $value);
     return $this;
 }
开发者ID:nark3d,项目名称:PhalueObjects,代码行数:17,代码来源:AbstractReflection.php

示例4: __construct

 public function __construct($class, $property)
 {
     $property = new ReflectionProperty($class, $property);
     list($description, $tags) = Kodoc::parse($property->getDocComment());
     $this->description = $description;
     if ($modifiers = $property->getModifiers()) {
         $this->modifiers = '<small>' . implode(' ', Reflection::getModifierNames($modifiers)) . '</small> ';
     }
     if (isset($tags['var'])) {
         if (preg_match('/^(\\S*)(?:\\s*(.+?))?$/', $tags['var'][0], $matches)) {
             $this->type = $matches[1];
             if (isset($matches[2])) {
                 $this->description = Markdown($matches[2]);
             }
         }
     }
     $this->property = $property;
     // Show the value of static properties, but only if they are public or we are php 5.3 or higher and can force them to be accessible
     if ($property->isStatic() and ($property->isPublic() or version_compare(PHP_VERSION, '5.3', '>='))) {
         // Force the property to be accessible
         if (version_compare(PHP_VERSION, '5.3', '>=')) {
             $property->setAccessible(TRUE);
         }
         // Don't debug the entire object, just say what kind of object it is
         if (is_object($property->getValue($class))) {
             $this->value = '<pre>object ' . get_class($property->getValue($class)) . '()</pre>';
         } else {
             $this->value = Kohana::debug($property->getValue($class));
         }
     }
 }
开发者ID:azuya,项目名称:Wi3,代码行数:31,代码来源:property.php

示例5: _abstract_properties_validate

 /**
  * Make sure our class properties exist in extended classes.
  *
  * PHP doesn't accept abstract class properties, so this class method adds
  * this capability.
  */
 protected final function _abstract_properties_validate()
 {
     //check if the child class has defined the abstract properties or not
     $child = get_class($this);
     foreach ($this->_abstract_properties as $name => $settings) {
         if (isset($settings['type']) && 'string' == $settings['type']) {
             if (isset($settings['static']) && true === $settings['static']) {
                 $prop = new ReflectionProperty($child, $name);
                 if (!$prop->isStatic()) {
                     // property does not exist
                     $error = $child . ' class must define $' . $name . ' property as static ' . $settings['type'];
                     unset($prop, $child);
                     throw new \LogicException($error);
                 }
             } else {
                 if (property_exists($this, $name) && strtolower(gettype($this->{$name})) == $settings['type']) {
                     continue;
                 }
                 // property does not exist
                 $error = $child . ' class must define $' . $name . ' property as ' . $settings['type'];
                 throw new \LogicException($error);
             }
         }
     }
     unset($error, $child);
 }
开发者ID:r-a-y,项目名称:bp-reply-by-email,代码行数:32,代码来源:bp-reply-by-email-inbound-provider.php

示例6: 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

示例7: call

 /**
  * Call to undefined method.
  *
  * @param  string  method name
  * @param  array   arguments
  * @return mixed
  * @throws \MemberAccessException
  */
 public static function call($_this, $name, $args)
 {
     $class = get_class($_this);
     if ($name === '') {
         throw new MemberAccessException("Call to class '{$class}' method without name.");
     }
     // event functionality
     if (preg_match('#^on[A-Z]#', $name)) {
         $rp = new ReflectionProperty($class, $name);
         if ($rp->isPublic() && !$rp->isStatic()) {
             $list = $_this->{$name};
             if (is_array($list) || $list instanceof Traversable) {
                 foreach ($list as $handler) {
                     /**/
                     fixCallback($handler);
                     /**/
                     if (!is_callable($handler)) {
                         $able = is_callable($handler, TRUE, $textual);
                         throw new InvalidStateException("Event handler '{$textual}' is not " . ($able ? 'callable.' : 'valid PHP callback.'));
                     }
                     call_user_func_array($handler, $args);
                 }
             }
             return NULL;
         }
     }
     // extension methods
     if ($cb = self::extensionMethod($class, $name)) {
         array_unshift($args, $_this);
         return call_user_func_array($cb, $args);
     }
     throw new MemberAccessException("Call to undefined method {$class}::{$name}().");
 }
开发者ID:jakubkulhan,项目名称:guestbook,代码行数:41,代码来源:ObjectMixin.php

示例8: __call

 public function __call($name, $args)
 {
     $class = get_class($this);
     if ($name === '') {
         throw new MemberAccessException("Call to class '{$class}' method without name.");
     }
     if (preg_match('#^on[A-Z]#', $name)) {
         $rp = new ReflectionProperty($class, $name);
         if ($rp->isPublic() && !$rp->isStatic()) {
             $list = $this->{$name};
             if (is_array($list) || $list instanceof Traversable) {
                 foreach ($list as $handler) {
                     if (is_object($handler)) {
                         call_user_func_array(array($handler, '__invoke'), $args);
                     } else {
                         call_user_func_array($handler, $args);
                     }
                 }
             }
             return NULL;
         }
     }
     if ($cb = self::extensionMethod("{$class}::{$name}")) {
         array_unshift($args, $this);
         return call_user_func_array($cb, $args);
     }
     throw new MemberAccessException("Call to undefined method {$class}::{$name}().");
 }
开发者ID:radimklaska,项目名称:Drupal.cz,代码行数:28,代码来源:texy.compact.5.php

示例9: getProperty

 private function getProperty($classOrObject, $property)
 {
     $property = new \ReflectionProperty(is_object($classOrObject) ? get_class($classOrObject) : $classOrObject, $property);
     if (!$property->isPublic()) {
         $property->setAccessible(true);
     }
     return $property->isStatic() ? $property->getValue($classOrObject) : $property->getValue();
 }
开发者ID:ptrofimov,项目名称:xpmock,代码行数:8,代码来源:TestCaseTraitTest.php

示例10: isStatic

 /**
  * Returns true if this property has is a static property.
  *
  * @return bool
  */
 public function isStatic()
 {
     if ($this->reflectionSource instanceof ReflectionProperty) {
         return $this->reflectionSource->isStatic();
     } else {
         return parent::isStatic();
     }
 }
开发者ID:naderman,项目名称:ezc-reflection,代码行数:13,代码来源:property.php

示例11: 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

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

示例13: hydrate

 protected function hydrate($data)
 {
     $reflection = new ReflectionClass($this);
     $fields = $reflection->getProperties(ReflectionProperty::IS_PUBLIC);
     foreach ($fields as $f) {
         $prop = $f->name;
         $met = new ReflectionProperty($this, $prop);
         if (!$met->isStatic()) {
             $this->{$prop} = $data[$prop];
         }
     }
 }
开发者ID:nikuta,项目名称:paczkomaty,代码行数:12,代码来源:PakomatoOrder.php

示例14: 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

示例15: getClassPropertyValue

 /**
  * 获取一个类属性值
  * @param string $class
  * @param string $propertyName
  */
 public static function getClassPropertyValue($class, $propertyName)
 {
     if (!property_exists($class, $propertyName)) {
         return null;
     }
     $reflectionProperty = new ReflectionProperty($class, $propertyName);
     if ($reflectionProperty->isStatic()) {
         return $reflectionProperty->getValue();
     } else {
         $reflectionClass = new ReflectionClass($class);
         return $reflectionProperty->getValue($reflectionClass->newInstance($class));
     }
 }
开发者ID:noikiy,项目名称:dophin,代码行数:18,代码来源:ReflectionClassExt.class.php


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