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


PHP ReflectionClass::getStaticProperties方法代码示例

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


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

示例1: test_function

 /**
  * @return void
  */
 public function test_function()
 {
     // prepare
     Base::init([]);
     $reflection = new \ReflectionClass('\\DbMockLibrary\\Base');
     $staticProperties = $reflection->getStaticProperties();
     // test
     $this->assertInstanceOf('\\DbMockLibrary\\Base', $staticProperties['instance']);
     // invoke logic
     Base::getInstance()->destroy();
     // prepare
     $staticProperties = $reflection->getStaticProperties();
     // test
     $this->assertNull($staticProperties['instance']);
 }
开发者ID:komita1981,项目名称:DbMockLibrary,代码行数:18,代码来源:DestroyTest.php

示例2: addTestFile

 public function addTestFile($file, $internalcall = false)
 {
     global $CFG;
     if ($this->performcoverage) {
         $refinfo = moodle_reflect_file($file);
         require_once $file;
         if ($refinfo->classes) {
             foreach ($refinfo->classes as $class) {
                 $reflection = new ReflectionClass($class);
                 if ($staticprops = $reflection->getStaticProperties()) {
                     if (isset($staticprops['includecoverage']) && is_array($staticprops['includecoverage'])) {
                         foreach ($staticprops['includecoverage'] as $toinclude) {
                             $this->add_coverage_include_path($toinclude);
                         }
                     }
                     if (isset($staticprops['excludecoverage']) && is_array($staticprops['excludecoverage'])) {
                         foreach ($staticprops['excludecoverage'] as $toexclude) {
                             $this->add_coverage_exclude_path($toexclude);
                         }
                     }
                 }
             }
             // Automatically add the test dir itself, so nothing will be covered there
             $this->add_coverage_exclude_path(dirname($file));
         }
     }
     parent::addTestFile($file, $internalcall);
 }
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:28,代码来源:simpletestcoveragelib.php

示例3: testRegisterValidator

 public function testRegisterValidator()
 {
     Comfort::registerValidator('flex', ComfortTestCustomerValidator::class);
     $reflClass = new \ReflectionClass(Comfort::class);
     $staticProperties = $reflClass->getStaticProperties();
     $this->assertEquals(['registeredValidators' => ['flex' => ComfortTestCustomerValidator::class]], $staticProperties);
 }
开发者ID:mrferos,项目名称:comfort,代码行数:7,代码来源:ComfortTest.php

示例4: __toString

 /**
  * Dump all class members to array including objects
  *
  * @return  string  print_r() formatted array string;
  */
 public function __toString()
 {
     # Dump all object vars to string
     # Recursively list all object vars
     $members = function ($object) use(&$members) {
         # Recursive closure... cool!
         if (!is_object($object) && !is_array($object)) {
             # We've found an actual member value
             return is_array($object) ? print_r($object) : $object;
         }
         # We've found a member that's an object, explore it's properties
         if (is_object($object)) {
             # Duplicate our object for inspection
             $reflection = new \ReflectionClass($object);
             # Get dynamic members
             $dynamics = get_object_vars($object);
             # Get constant members
             $constants = $reflection->getConstants();
             # Get static members
             $statics = $reflection->getStaticProperties();
             # = array_diff(get_class_vars(get_class($object)), $dynamic); # alternate method
             # Merge them
             $object = array_merge($constants, $statics, $dynamics);
         }
         # Recurse to check if the array has any further objects
         return array_map($members, $object);
     };
     # All done build our string!
     return '<pre>' . print_r($members($this), true) . '</pre>';
 }
开发者ID:tundratech,项目名称:alpine,代码行数:35,代码来源:MagicMethods.php

示例5: testCounterNotNull

 /** 
  * Test the initialization of the static counter (!== 0)
  */
 public function testCounterNotNull()
 {
     $rand = new MicroTime();
     $reflection_class = new \ReflectionClass("RandomLib\\Source\\MicroTime");
     $static = $reflection_class->getStaticProperties();
     $this->assertTrue($static['counter'] !== 0);
 }
开发者ID:sunkangtaichi,项目名称:PHPAPPLISTION_START,代码行数:10,代码来源:MicroTimeTest.php

示例6: load

 public static function load($path = '')
 {
     if (!empty($path) and !in_array($path, self::$loaded)) {
         $path = !empty($path) ? '\\' . trim($path, '\\') : '';
         $lang_class = '\\GCore' . $path . '\\Locales\\EnGb\\Lang';
         $cutsom_lang = '\\GCore' . $path . '\\Locales\\' . Str::camilize(str_replace('-', '_', strtolower(Base::getConfig('site_language', 'en-gb')))) . '\\Lang';
         if (class_exists($cutsom_lang)) {
             if (class_exists($lang_class)) {
                 //load default language as well
                 $lang_class_loaded = new \ReflectionClass($lang_class);
                 self::$translations = array_merge((array) self::$translations, $lang_class_loaded->getConstants(), $lang_class_loaded->getStaticProperties());
                 self::$loaded[] = $path;
             }
             $lang_class = $cutsom_lang;
         }
         if (!class_exists($lang_class)) {
             return false;
         }
         $lang_class_loaded = new \ReflectionClass($lang_class);
         self::$translations = array_merge((array) self::$translations, $lang_class_loaded->getConstants(), $lang_class_loaded->getStaticProperties());
         self::$loaded[] = $path;
         return true;
     }
     return false;
 }
开发者ID:ejailesb,项目名称:repo_empr,代码行数:25,代码来源:lang.php

示例7: setFormat

 public function setFormat($f)
 {
     //use reflection to valid value
     $ref = new ReflectionClass(__CLASS__);
     if (in_array($f, $ref->getStaticProperties())) {
         $this->_format = $f;
     }
 }
开发者ID:tilitala,项目名称:nForum,代码行数:8,代码来源:authimg.php

示例8: rewind

 public function rewind()
 {
     $class_name = get_class($this);
     $reflection = new \ReflectionClass($class_name);
     $this->staticFieldIteratorData = $reflection->getStaticProperties();
     $this->staticFieldIteratorKey = 0;
     reset($this->staticFieldIteratorData);
 }
开发者ID:anddorua,项目名称:biblio,代码行数:8,代码来源:StaticFieldIterator.php

示例9: testBasicValidSchemes

 public function testBasicValidSchemes()
 {
     $mirror = new \ReflectionClass(Url::class);
     $validSchemes = $mirror->getStaticProperties()['validSchemes'];
     foreach ($validSchemes as $scheme) {
         $this->assertTrue(Url::isValidScheme($scheme));
     }
 }
开发者ID:bogdananton,项目名称:vsc,代码行数:8,代码来源:isValidSchemeTest.php

示例10: testCounterNotNull

 /**
  * Test the initialization of the static counter (!== 0)
  */
 public function testCounterNotNull()
 {
     $class = static::getTestedClass();
     $rand = new $class();
     $reflection_class = new \ReflectionClass($class);
     $static = $reflection_class->getStaticProperties();
     $this->assertTrue($static['counter'] !== 0);
 }
开发者ID:dukt,项目名称:craft-oauth,代码行数:11,代码来源:MicroTimeTest.php

示例11: get_all

 /**
  * Get all the states in an array.
  * @return of question_state objects.
  */
 public static function get_all()
 {
     $states = array();
     $us = new ReflectionClass('question_state');
     foreach ($us->getStaticProperties() as $name => $notused) {
         $states[] = self::${$name};
     }
     return $states;
 }
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:13,代码来源:states.php

示例12: testLoadVendorDatabaseFromFile

 public function testLoadVendorDatabaseFromFile()
 {
     // Clear database first to ensure that data actually gets loaded
     MacAddress::loadVendorDatabase(array());
     // Pass default database. It should load without errors.
     MacAddress::loadVendorDatabaseFromFile(\Library\Module::getPath('data/MacAddress/manuf'));
     $reflectionClass = new \ReflectionClass('Library\\MacAddress');
     $this->assertNotEmpty($reflectionClass->getStaticProperties()['_vendorList']);
 }
开发者ID:patrickpreuss,项目名称:Braintacle,代码行数:9,代码来源:MacAddressTest.php

示例13: testExitCode

 public function testExitCode()
 {
     $ref = new ReflectionClass("Application");
     $static_values = $ref->getStaticProperties();
     //    $success_code = $ref->getStaticPropertyValue("SUCCESS");
     $this->assertEquals(0, $static_values["SUCCESS"]);
     //    $error_code = $ref->getStaticPropertyValue("ERROR");
     $this->assertEquals(1, $static_values["ERROR"]);
 }
开发者ID:hirakiuc,项目名称:pask,代码行数:9,代码来源:application_test.php

示例14: GetKeys

		/**
		 * List all available properties through reflection
		 * FIXME: Move to parent class Struct, when php will have late static binding
		 *
		 * @return array or names
		 */
		public static function GetKeys()
		{ 
			$retval = array();
			$ReflectionClassThis = new ReflectionClass(__CLASS__);
			foreach($ReflectionClassThis->getStaticProperties() as $Property)
			{
				$retval[] = $Property->name;
			}
			return($retval);
		}
开发者ID:rchicoria,项目名称:epp-drs,代码行数:16,代码来源:enum.LICENSE_FLAGS.php

示例15: importGlobals

 /**
  * A function to be used for compatibility with legacy code: it gets the values of all global variables which used
  * to be declared, such as library version etc... and sets them to php classes.
  * It should be used by code which changed the values of those global variables to alter the working of the library.
  * Example code:
  * 1. include xmlrpc.inc
  * 2. set the values, e.g. $GLOBALS['xmlrpc_internalencoding'] = 'UTF-8';
  * 3. import them: PhpXmlRpc\PhpXmlRpc::importGlobals();
  * 4. run your own code.
  */
 public static function importGlobals()
 {
     $reflection = new \ReflectionClass('PhpXmlRpc\\PhpXmlRpc');
     $staticProperties = $reflection->getStaticProperties();
     foreach ($staticProperties as $name => $value) {
         if (isset($GLOBALS[$name])) {
             self::${$name} = $GLOBALS[$name];
         }
     }
 }
开发者ID:shahzadsab,项目名称:phpxmlrpc,代码行数:20,代码来源:PhpXmlRpc.php


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