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


PHP ReflectionProperty::export方法代码示例

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


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

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

示例2: catch

<?php

class TestClass
{
}
$a = 5;
echo "Non-existent class:\n";
try {
    ReflectionProperty::export("NonExistentClass", "prop", true);
} catch (Exception $e) {
    echo $e->getMessage();
}
echo "\n\nWrong property parameter type:\n";
try {
    ReflectionProperty::export($a, 'TestClass', false);
} catch (ReflectionException $e) {
    echo $e->getMessage();
}
echo "\n\nNon-existent property:\n";
try {
    ReflectionProperty::export('TestClass', "nonExistentProperty", true);
} catch (Exception $e) {
    echo $e->getMessage();
}
echo "\n\nIncorrect number of args:\n";
ReflectionProperty::export();
ReflectionProperty::export('TestClass', "nonExistentProperty", true, false);
开发者ID:lsqtongxin,项目名称:hhvm,代码行数:27,代码来源:ReflectionProperty_export_error.php

示例3: Func

<?php

class Foo
{
    public $prop;
    function Func($name)
    {
        echo "Hello {$name}";
    }
}
ReflectionClass::export('Foo');
//output: Class [ class Foo ] { @@ /home/cg/root/main.php 3-10 - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [1] { Property [ public $prop ] } - Methods [1] { Method [ public method Func ] { @@ /home/cg/root/main.php 7 - 9 - Parameters [1] { Parameter #0 [ $name ] } } } }
ReflectionObject::export(new Foo());
// output: Object of class [ class Foo ] { @@ /home/cg/root/main.php 3-10 - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [1] { Property [ public $prop ] } - Dynamic properties [0] { } - Methods [1] { Method [ public method Func ] { @@ /home/cg/root/main.php 7 - 9 - Parameters [1] { Parameter #0 [ $name ] } } } }
ReflectionMethod::export('Foo', 'func');
// output:  Method [ public method Func ] { @@ /home/cg/root/main.php 7 - 9 - Parameters [1] { Parameter #0 [ $name ] } }
ReflectionProperty::export('Foo', 'prop');
//output: Property [ public $prop ]
ReflectionExtension::export('standard');
//output: Extension [ extension #15 standard version 5.5.18 ] ...
开发者ID:KB-WEB-DEVELOPMENT,项目名称:Kami_Barut_PHP_projects,代码行数:20,代码来源:Reflection+API+example.php

示例4: testToString

 /**
  * Tests export.
  */
 public function testToString()
 {
     $tests = array('lines', 'docComment', 'noComment', 'default', 'typeNull', 'typeArray', 'typeString', 'typeInteger', 'typeFloat');
     foreach ($tests as $test) {
         $rfl = $this->getPropertyReflection($test);
         $this->assertSame($rfl->internal->__toString(), $rfl->token->__toString());
         $this->assertSame(InternalReflectionProperty::export($this->getClassName($test), $test, true), ReflectionProperty::export($this->getBroker(), $this->getClassName($test), $test, true));
         // Test loading from a string
         $rfl = $this->getPropertyReflection($test, true);
         $this->assertSame($rfl->internal->__toString(), $rfl->token->__toString());
     }
     $rfl = $this->getClassReflection('modifiers');
     $rfl_fromString = $this->getClassReflection('modifiers');
     foreach (array('public', 'protected', 'private') as $name) {
         $internal = $rfl->internal->getProperty($name);
         $token = $rfl->token->getProperty($name);
         $this->assertSame($internal->__toString(), $token->__toString());
         $this->assertSame(InternalReflectionProperty::export($this->getClassName('modifiers'), $name, true), ReflectionProperty::export($this->getBroker(), $this->getClassName('modifiers'), $name, true));
         // Test loading from a string
         $this->assertSame($internal->__toString(), $rfl_fromString->token->getProperty($name)->__toString());
     }
     $this->assertSame(InternalReflectionProperty::export('ReflectionProperty', 'name', true), ReflectionProperty::export($this->getBroker(), 'ReflectionProperty', 'name', true));
     $this->assertSame(InternalReflectionProperty::export(new InternalReflectionProperty('ReflectionProperty', 'name'), 'name', true), ReflectionProperty::export($this->getBroker(), new InternalReflectionProperty('ReflectionProperty', 'name'), 'name', true));
 }
开发者ID:eduardobenito10,项目名称:jenkins-php-quickstart,代码行数:27,代码来源:ReflectionPropertyTest.php

示例5: var_dump

<?php

class TestClass
{
    public $proper = 5;
}
var_dump(ReflectionProperty::export('TestClass', 'proper'));
开发者ID:lsqtongxin,项目名称:hhvm,代码行数:7,代码来源:ReflectionProperty_export_basic.php

示例6: export

 /**
  * Exports a ReflectionProperty instance.
  *
  * Returns the output if TRUE is specified for return, printing it otherwise.
  * This is purely a wrapper method, which calls the corresponding method of
  * the parent class.
  * @param ReflectionClass|string $class
  *        ReflectionClass object or name of the class
  * @param ReflectionProperty|string $property
  *        ReflectionProperty object or name of the class
  * @param boolean $return
  *        Whether to return (TRUE) or print (FALSE) the output
  * @return mixed
  */
 public static function export($class, $property, $return = false)
 {
     return parent::export($class, $property, $return);
 }
开发者ID:naderman,项目名称:ezc-reflection,代码行数:18,代码来源:property.php


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