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


PHP ReflectionClass::setStaticPropertyValue方法代码示例

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


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

示例1: load

 static function load($filename)
 {
     self::$stream = IO_FS::FileStream($filename);
     while ($line = self::get()) {
         $line = trim($line);
         if ($m = Core_Regexps::match_with_results('{^!DUMP\\s+([^\\s]+)(.*)$}', $line)) {
             $module = trim($m[1]);
             $parms = trim($m[2]);
             $dumper = trim(self::$dumpers[$module]);
             if ($dumper == '') {
                 throw new CMS_Dumps_UnknownDumperException("Unknown dumper: {$module}");
             }
             $dumper_class_name = str_replace('.', '_', $dumper);
             if (!class_exists($dumper_class_name)) {
                 Core::load($dumper);
             }
             $class = new ReflectionClass($dumper_class_name);
             $class->setStaticPropertyValue('stream', self::$stream);
             $method = $class->getMethod('load');
             $rc = $method->invokeArgs(null, array($parms));
             if (trim($rc) != '') {
                 return $rc;
             }
         }
     }
     return true;
 }
开发者ID:techart,项目名称:tao,代码行数:27,代码来源:Dumps.php

示例2: __construct

 public function __construct()
 {
     // TODO: caching of parsed ll-config
     // TODO: check if file is readable
     // read config stuff
     $reflectedClass = new \ReflectionClass('\\Slimpd\\modules\\localization\\Localization');
     $reflectedClass->setStaticPropertyValue('lang', parse_ini_file(APP_ROOT . "config/i18n.ini", FALSE));
 }
开发者ID:daskleinesys,项目名称:slimpd,代码行数:8,代码来源:Localization.php

示例3: setValue

 private function setValue(&$val)
 {
     yTest_debugCC('setValue ' . $this->className . '::' . $this->propertyName . ' = ' . var_export($val, true));
     if ($this->isPublic) {
         $refl = new ReflectionClass($this->className);
         $refl->setStaticPropertyValue($this->propertyName, $val);
     } else {
         call_user_func(array($this->className, yTest_AddPublicAccessors::getSetterName($this->className, $this->propertyName)), $val);
     }
 }
开发者ID:rsaugier,项目名称:ytest,代码行数:10,代码来源:yTest_SetStaticProperty.php

示例4: fill_values

 /**
  * Add each provided value, as long as it exists as a property - i.e ignore others!
  * @param array $arr_values
  */
 private function fill_values(array $arr_values)
 {
     $reflection_class = new \ReflectionClass(get_called_class());
     foreach ($arr_values as $label => $value) {
         if (property_exists(get_called_class(), $label)) {
             if (isset($arr_values[$label])) {
                 $reflection_class->setStaticPropertyValue($label, $arr_values[$label]);
             }
         }
     }
 }
开发者ID:phongvan212,项目名称:ttctxh,代码行数:15,代码来源:my-plugin-installer.php

示例5: enumerate

 public static function enumerate()
 {
     if (PHP_VERSION_ID < 50300) {
         $class = callerName();
     } else {
         $class = get_called_class();
     }
     $ref = new ReflectionClass($class);
     $statics = $ref->getStaticProperties();
     foreach ($statics as $name => $value) {
         $ref->setStaticPropertyValue($name, new $class($value));
     }
 }
开发者ID:binq2,项目名称:borealpaddle,代码行数:13,代码来源:ptpanel.php

示例6: testing

 static function testing()
 {
     $ref = new ReflectionClass('Test');
     foreach (array('pub', 'pro', 'pri') as $name) {
         try {
             var_dump($ref->getStaticPropertyValue($name));
             var_dump($ref->getStaticPropertyValue($name));
             $ref->setStaticPropertyValue($name, 'updated');
             var_dump($ref->getStaticPropertyValue($name));
         } catch (Exception $e) {
             echo "EXCEPTION\n";
         }
     }
 }
开发者ID:gleamingthecube,项目名称:php,代码行数:14,代码来源:ext_reflection_tests_006.php

示例7: ReflectionClass

 static function __static()
 {
     if (__CLASS__ === ($class = get_called_class())) {
         return;
     }
     // Automatically initialize this enum's public static members
     $i = 0;
     $c = new ReflectionClass($class);
     foreach ($c->getStaticProperties() as $name => $prop) {
         if (NULL !== $prop) {
             $i = $prop;
         }
         $c->setStaticPropertyValue($name, $c->newInstance($i++, $name));
     }
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:15,代码来源:Enum.class.php

示例8: initLogger

function initLogger()
{
    $loggerName = "log";
    // Iterate over all declared classes
    $classes = get_declared_classes();
    foreach ($classes as $class) {
        $reflection = new ReflectionClass($class);
        // If the class is internally defined by PHP or has no property called "logger", skip it.
        if ($reflection->isInternal() || !$reflection->hasProperty($loggerName)) {
            continue;
        }
        // Get information regarding the "logger" property of this class.
        $property = new ReflectionProperty($class, $loggerName);
        // If the "logger" property is not static or not public, then it is not the one we are interested in. Skip this class.
        if (!$property->isStatic() || !$property->isPublic()) {
            continue;
        }
        // Initialize the logger for this class.
        $reflection->setStaticPropertyValue($loggerName, getLogger());
    }
}
开发者ID:vladikius,项目名称:tephlon,代码行数:21,代码来源:AELogger.php

示例9: each

 public function each($cb)
 {
     $b = null;
     foreach ($this as $row) {
         if ($this->set_ref) {
             $ref = array();
             foreach ($row as $i => $name) {
                 $ref[$name] = $i;
             }
             $reflectedClass = new \ReflectionClass('Row');
             $reflectedClass->setStaticPropertyValue('r', $ref);
             $this->set_ref = false;
         } else {
             $b = $cb(new Row($row));
             if ($b === false) {
                 break;
             }
         }
     }
     $this->set_ref = true;
 }
开发者ID:hharchani,项目名称:mail-merge-portal,代码行数:21,代码来源:Excel_reader.php

示例10: setEnvironment

 /**
  * Allows easy setting & backing up of enviroment config
  *
  * Option types are checked in the following order:
  *
  * * Server Var
  * * Static Variable
  * * Config option
  *
  * @param array $environment List of environment to set
  */
 function setEnvironment(array $environment)
 {
     if (!count($environment)) {
         return FALSE;
     }
     foreach ($environment as $option => $value) {
         $backup_needed = !array_key_exists($option, $this->environmentBackup);
         // Handle changing superglobals
         if (in_array($option, array('_GET', '_POST', '_SERVER', '_FILES'))) {
             // For some reason we need to do this in order to change the superglobals
             global ${$option};
             if ($backup_needed) {
                 $this->environmentBackup[$option] = ${$option};
             }
             // PHPUnit makes a backup of superglobals automatically
             ${$option} = $value;
         } elseif (strpos($option, '::$') !== FALSE) {
             list($class, $var) = explode('::$', $option, 2);
             $class = new ReflectionClass($class);
             if ($backup_needed) {
                 $this->environmentBackup[$option] = $class->getStaticPropertyValue($var);
             }
             $class->setStaticPropertyValue($var, $value);
         } elseif (preg_match('/^[A-Z_-]+$/', $option) or isset($_SERVER[$option])) {
             if ($backup_needed) {
                 $this->environmentBackup[$option] = isset($_SERVER[$option]) ? $_SERVER[$option] : '';
             }
             $_SERVER[$option] = $value;
         } else {
             if ($backup_needed) {
                 $this->environmentBackup[$option] = Kohana::config($option);
             }
             list($group, $var) = explode('.', $option, 2);
             Kohana::config($group)->set($var, $value);
         }
     }
 }
开发者ID:ukd1,项目名称:unittest,代码行数:48,代码来源:testcase.php

示例11: testGetPath

 /**
  * @covers  FOF30\Layout\LayoutFile::getPath
  *
  * @dataProvider FOF30\Tests\Layout\LayoutFileTestProvider::getTestGetPath
  *
  * @param string $layoutId      The layout to load
  * @param array  $platformSetup Platform setup (baseDirs, template, templateSuffixes)
  * @param string $expectedPath  The expected path which should be returned
  * @param string $message       Failure message
  */
 public function testGetPath($layoutId, $platformSetup, $expectedPath, $message)
 {
     // Set up the platform
     $defaultPlatformSetup = array('baseDirs' => null, 'template' => null, 'templateSuffixes' => null);
     if (!is_array($platformSetup)) {
         $platformSetup = array();
     }
     $platformSetup = array_merge($defaultPlatformSetup, $platformSetup);
     $reflector = new \ReflectionClass('FOF30\\Tests\\Helpers\\TestJoomlaPlatform');
     foreach ($platformSetup as $k => $v) {
         $reflector->setStaticPropertyValue($k, $v);
     }
     unset($reflector);
     // Set up a fake options JRegistry object
     $fakeOptions = new \JRegistry(array('option' => 'com_foobar', 'client' => 0));
     $fakeBase = realpath(__DIR__ . '/../_data/layout/base');
     // Create the layout file object
     $layoutFile = new LayoutFile($layoutId, $fakeBase, $fakeOptions);
     $layoutFile->container = static::$container;
     // Call the protected method. Dirty, but that's what we have to test without loading and displaying an actual
     // PHP file.
     $actual = ReflectionHelper::invoke($layoutFile, 'getPath');
     $this->assertEquals($expectedPath, $actual, $message);
 }
开发者ID:Joal01,项目名称:fof,代码行数:34,代码来源:LayoutFileTest.php

示例12: setStaticPropertyValue

 /**
  * {@inheritdoc}
  */
 public function setStaticPropertyValue($propertyName, $value)
 {
     $this->reflectionClass->setStaticPropertyValue($propertyName, $value);
 }
开发者ID:roave,项目名称:better-reflection,代码行数:7,代码来源:ReflectionObject.php

示例13: _setStaticVariable

 /**
  * Set static variable on a class
  *
  * @param string $classname
  * @param string $name
  * @param mixed $value
  * @return Robo47_Application_Resource_Object *Provides Fluent Interface*
  */
 protected function _setStaticVariable($classname, $name, $value)
 {
     $ref = new ReflectionClass($classname);
     $ref->setStaticPropertyValue($name, $value);
     return $this;
 }
开发者ID:robo47,项目名称:robo47-components,代码行数:14,代码来源:Object.php

示例14: ReflectionClass

<?php

class C
{
    public static $x;
}
$rc = new ReflectionClass('C');
try {
    var_dump($rc->setStaticPropertyValue("x", "default value", 'blah'));
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
}
try {
    var_dump($rc->setStaticPropertyValue());
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
}
try {
    var_dump($rc->setStaticPropertyValue(null));
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
}
try {
    var_dump($rc->setStaticPropertyValue(null, null));
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
}
try {
    var_dump($rc->setStaticPropertyValue(1.5, 'def'));
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:ReflectionClass_setStaticPropertyValue_002.php

示例15: propertyFactory

 /**
  * property factory set/get properties on passed class which can either be a instance of class
  * or class name as string. pass the property name in the second parameter and set the third
  * parameter to a the value to set to blank to read the property value.
  *
  * @error 10604
  * @param string|object $class expects the class name as string or class instance
  * @param string $property expects the property name
  * @param null|mixed $value expects if set a value to set or none to get the value
  * @return mixed|null
  * @throws Xapp_Error
  */
 public static final function propertyFactory($class, $property, $value = 'NIL')
 {
     $prop = null;
     $obj = null;
     $array = null;
     $return = null;
     try {
         $_class = is_object($class) ? get_class($class) : $class;
         $property = trim($property);
         $jailbreak = func_num_args() === 4 && (bool) func_get_arg(3) ? true : false;
         if (!is_object($class)) {
             $class = (string) $class;
         }
         $obj = new ReflectionClass($class);
         if ($obj->hasProperty($property)) {
             $prop = $obj->getProperty($property);
             if ($prop->isStatic()) {
                 $props = $obj->getStaticProperties();
                 if (array_key_exists($property, $props)) {
                     if ($value !== 'NIL') {
                         if ($prop->isProtected() && $jailbreak) {
                             $prop->setAccessible(true);
                             $prop->setValue($class, $value);
                             $prop->setAccessible(false);
                         } else {
                             $obj->setStaticPropertyValue($property, $value);
                         }
                     } else {
                         return $props[$property];
                     }
                 } else {
                     throw new Xapp_Error(xapp_sprintf(_("static property: %s does not exist in class: %s"), $property, $_class), 1060404);
                 }
             } else {
                 if (is_object($class)) {
                     if ($value !== 'NIL') {
                         if ($prop->isProtected() && $jailbreak) {
                             $prop->setAccessible(true);
                             $prop->setValue($class, $value);
                             $prop->setAccessible(false);
                         } else {
                             $prop->setValue($class, $value);
                         }
                     } else {
                         if ($prop->isProtected() && $jailbreak) {
                             $prop->setAccessible(true);
                             $value = $prop->getValue($class);
                             $prop->setAccessible(false);
                             $return = $value;
                         } else {
                             $return = $prop->getValue($class);
                         }
                     }
                     $obj = null;
                     $prop = null;
                     return $return;
                 } else {
                     throw new Xapp_Error(xapp_sprintf(_("unable to set/get non static property for class: %s passed as string"), $_class), 1060403);
                 }
             }
         } else {
             throw new Xapp_Error(xapp_sprintf(_("class: %s or property: %s does not exist"), $_class, $property), 1060402);
         }
     } catch (ReflectionException $e) {
         throw new Xapp_Error($e, 1060401);
     }
     return null;
 }
开发者ID:xamiro-dev,项目名称:xamiro,代码行数:80,代码来源:Reflection.php


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