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


PHP ReflectionClass::getDefaultProperties方法代码示例

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


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

示例1: matches

 /**
  * Tests if an object has the required attributes and they have the correct value.
  *
  * Returns true, if and only if the object defines ALL attributes and they have the expected value
  *
  * @param object $other
  *
  * @return bool
  */
 protected function matches($other)
 {
     $this->result = [];
     $success = true;
     $reflection = new \ReflectionClass($other);
     $properties = $reflection->getDefaultProperties();
     foreach ($this->defaultAttributes as $prop => $value) {
         if (is_int($prop)) {
             $prop = $value;
             $value = null;
         }
         if (array_key_exists($prop, $properties)) {
             try {
                 \PHPUnit_Framework_Assert::assertSame($value, $properties[$prop]);
                 $this->result[$prop] = true;
             } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
                 $message = $e->toString();
                 if ($comparisonFailure = $e->getComparisonFailure()) {
                     $message .= sprintf("\n%30sExpected: %s\n%30sActual  : %s\n", '', $comparisonFailure->getExpectedAsString(), '', $comparisonFailure->getActualAsString());
                 }
                 $this->result[$prop] = $message;
                 $success = false;
             }
         } else {
             $this->result[$prop] = 'Attribute is not defined.';
             $success = false;
         }
     }
     return $success;
 }
开发者ID:cross-solution,项目名称:yawik,代码行数:39,代码来源:DefaultAttributesValues.php

示例2: define

 /**
  * put your comment there...
  * 
  * @param mixed $class
  * @param mixed $options
  */
 public function define($className, $options = array())
 {
     $definition = array();
     $definition['options'] = $options;
     // Get class properties to find out the events!
     $class = new ReflectionClass($className);
     $properties = $class->getProperties(ReflectionProperty::IS_PROTECTED);
     $values = $class->getDefaultProperties();
     // protected (static + non-static) represent an event!
     foreach ($properties as $property) {
         $propertyName = $property->getName();
         $propertyClass = $property->getDeclaringClass()->getName();
         if (strpos($propertyName, $options['prefix']) === 0) {
             // Get event properties!
             $eventName = substr($propertyName, strlen($options['prefix']));
             // If the event is already defined inherits the options!
             $inheritedOptions = array();
             if (isset($this->definitions[$propertyClass]['events'][$propertyName])) {
                 $inheritedOptions = $this->definitions[$propertyClass]['events'][$propertyName]['type'];
             }
             $definition['events'][$propertyName] = array('fullName' => $propertyName, 'name' => $eventName, 'class' => $propertyClass, 'id' => $eventName, 'type' => array_merge($options, $inheritedOptions, (array) $values[$propertyName]));
         }
     }
     $this->definitions[$className] = $this->extend($definition);
     return $this;
 }
开发者ID:JSreactor,项目名称:MarketCrater.com,代码行数:32,代码来源:definition.class.php

示例3: initialize

 /**
  * Initialize preferences
  *
  * @access	public
  * @param	array
  * @return	void
  */
 public function initialize(array $config = array(), $reset = TRUE)
 {
     $reflection = new ReflectionClass($this);
     if ($reset === TRUE) {
         $defaults = $reflection->getDefaultProperties();
         foreach (array_keys($defaults) as $key) {
             if ($key[0] === '_') {
                 continue;
             }
             if (isset($config[$key])) {
                 if ($reflection->hasMethod('set_' . $key)) {
                     $this->{'set_' . $key}($config[$key]);
                 } else {
                     $this->{$key} = $config[$key];
                 }
             } else {
                 $this->{$key} = $defaults[$key];
             }
         }
     } else {
         foreach ($config as $key => &$value) {
             if ($key[0] !== '_' && $reflection->hasProperty($key)) {
                 if ($reflection->hasMethod('set_' . $key)) {
                     $this->{'set_' . $key}($value);
                 } else {
                     $this->{$key} = $value;
                 }
             }
         }
     }
     // if a file_name was provided in the config, use it instead of the user input
     // supplied file name for all uploads until initialized again
     $this->_file_name_override = $this->file_name;
     return $this;
 }
开发者ID:brandon-bailey,项目名称:osdms,代码行数:42,代码来源:MY_Upload.php

示例4: testAnnotations

 /**
  * Testing annotations.
  *
  * @test
  * @covers \Bairwell\Hydrator\Annotations\From
  */
 public function testAnnotations()
 {
     $sut = new From();
     $reflection = new \ReflectionClass($sut);
     $this->assertTrue($reflection->isFinal());
     $properties = $reflection->getDefaultProperties();
     $expectedProperties = ['sources' => [], 'field' => null, 'conditions' => []];
     foreach ($expectedProperties as $k => $v) {
         $this->assertArrayHasKey($k, $properties);
         $this->assertEquals($v, $properties[$k]);
     }
     $comments = $reflection->getDocComment();
     $expected = preg_quote('@Annotation');
     $results = preg_match_all('/(\\n|\\r)\\s*\\*\\s+' . $expected . '\\s*(\\n|\\r)/', $comments, $matches);
     $this->assertEquals(1, $results);
     $expected = preg_quote('@Target({"PROPERTY"})');
     $this->assertEquals(1, preg_match_all('/(\\n|\\r)\\s*\\*\\s+' . $expected . '\\s*(\\n|\\r)/', $comments, $matches));
     //
     $property = $reflection->getProperty('sources');
     $comments = $property->getDocComment();
     $expected = '@var\\s+array';
     $this->assertEquals(1, preg_match_all('/(\\n|\\r)\\s*\\*\\s+' . $expected . '\\s*(\\n|\\r)/', $comments, $matches));
     $expected = '@Required';
     $this->assertEquals(1, preg_match_all('/(\\n|\\r)\\s*\\*\\s+' . $expected . '\\s*(\\n|\\r)/', $comments, $matches));
     // field
     $property = $reflection->getProperty('field');
     $comments = $property->getDocComment();
     $expected = '@var\\s+string';
     $this->assertEquals(1, preg_match_all('/(\\n|\\r)\\s*\\*\\s+' . $expected . '\\s*(\\n|\\r)/', $comments, $matches));
     // conditions
     $property = $reflection->getProperty('conditions');
     $comments = $property->getDocComment();
     $expected = '@var\\s+array';
     $this->assertEquals(1, preg_match_all('/(\\n|\\r)\\s*\\*\\s+' . $expected . '\\s*(\\n|\\r)/', $comments, $matches));
 }
开发者ID:bairwell,项目名称:hydrator,代码行数:41,代码来源:FromTest.php

示例5: __construct

 /**
  * reads the form members and fills __formdata
  */
 public function __construct()
 {
     $this->__formdata = new \stdClass();
     $reflection = new \ReflectionClass(get_class($this));
     $this->__formdata->fields = $reflection->getDefaultProperties();
     unset($this->__formdata->fields['__formdata']);
 }
开发者ID:scandio,项目名称:lmvc-modules,代码行数:10,代码来源:AbstractForm.php

示例6: columns_get_standard

/**
 * Get a list of standard columns.
 */
function columns_get_standard()
{
    $t_reflection = new ReflectionClass('BugData');
    $t_columns = $t_reflection->getDefaultProperties();
    $t_columns['selection'] = null;
    $t_columns['edit'] = null;
    # Overdue icon column (icons appears if an issue is beyond due_date)
    $t_columns['overdue'] = null;
    if (OFF == config_get('enable_profiles')) {
        unset($t_columns['os']);
        unset($t_columns['os_build']);
        unset($t_columns['platform']);
    }
    if (config_get('enable_eta') == OFF) {
        unset($t_columns['eta']);
    }
    if (config_get('enable_projection') == OFF) {
        unset($t_columns['projection']);
    }
    if (config_get('enable_product_build') == OFF) {
        unset($t_columns['build']);
    }
    # The following fields are used internally and don't make sense as columns
    unset($t_columns['_stats']);
    unset($t_columns['profile_id']);
    unset($t_columns['sticky']);
    unset($t_columns['loading']);
    return array_keys($t_columns);
}
开发者ID:nourchene-benslimane,项目名称:mantisV0,代码行数:32,代码来源:columns_api.php

示例7: discriminateClass

 private function discriminateClass(\ReflectionClass $class, array $data)
 {
     $properties = $class->getDefaultProperties();
     if (!empty($properties["modelDiscriminatorMap"])) {
         $discriminator = $properties["modelDiscriminatorMap"];
         if (empty($discriminator["discriminatorField"])) {
             throw new ModelException("Cannot use the discriminator map for '{$class->getName()}'. No discriminator field was configured.");
         }
         $field = $discriminator["discriminatorField"];
         if (empty($data[$field])) {
             throw new ModelException("The discriminator field '{$field}' for '{$class->getName()}' was not found in the data set.");
         }
         $baseNamespace = !empty($discriminator["subclassNamespace"]) ? $discriminator["subclassNamespace"] : $class->getNamespaceName();
         $classNameSuffix = !empty($discriminator["subclassSuffix"]) ? $discriminator["subclassSuffix"] : "";
         $map = !empty($discriminator["map"]) ? $discriminator["map"] : [];
         // generate the class name
         $value = $data[$field];
         if (empty($map[$value])) {
             throw new ModelException("The discriminator value '{$value}' was not registered in the map");
         }
         $className = $map[$value] !== true ? $map[$value] : $this->toStudlyCaps($value);
         // if this is not a valid class, try it with the base namespace
         if (!class_exists($className)) {
             $className = $baseNamespace . "\\" . $className;
             if (!class_exists($className)) {
                 $className .= $classNameSuffix;
             }
         }
         // create the reflection object. This will throw an exception if the class does not exist, as is expected.
         $class = new \ReflectionClass($className);
     }
     return $class;
 }
开发者ID:downsider,项目名称:clay,代码行数:33,代码来源:ClassDiscriminatorTrait.php

示例8: testHtmlBuilderQuoteFlags

 /**
  * A basic functional test example.
  *
  * @return void
  */
 public function testHtmlBuilderQuoteFlags()
 {
     $htmlBuilderReflection = new ReflectionClass(new HtmlBuilder());
     $quoteFlags = $htmlBuilderReflection->getDefaultProperties()['quoteFlags'];
     $this->assertArrayHasKey('ENT_COMPAT', $quoteFlags);
     $this->assertArrayHasKey('ENT_QUOTES', $quoteFlags);
     $this->assertArrayHasKey('ENT_NOQUOTES', $quoteFlags);
     $this->assertArrayHasKey('ENT_IGNORE', $quoteFlags);
     $this->assertArrayHasKey('ENT_SUBSTITUTE', $quoteFlags);
     $this->assertArrayHasKey('ENT_DISALLOWED', $quoteFlags);
     $this->assertArrayHasKey('ENT_HTML401', $quoteFlags);
     $this->assertArrayHasKey('ENT_XML1', $quoteFlags);
     $this->assertArrayHasKey('ENT_XHTML', $quoteFlags);
     $this->assertArrayHasKey('ENT_HTML5', $quoteFlags);
     $this->assertContains(2, $quoteFlags);
     $this->assertContains(3, $quoteFlags);
     $this->assertContains(0, $quoteFlags);
     $this->assertContains(4, $quoteFlags);
     $this->assertContains(8, $quoteFlags);
     $this->assertContains(128, $quoteFlags);
     $this->assertContains(16, $quoteFlags);
     $this->assertContains(32, $quoteFlags);
     $this->assertContains(48, $quoteFlags);
     $this->assertEquals(ENT_COMPAT, $quoteFlags['ENT_COMPAT']);
     $this->assertEquals(ENT_QUOTES, $quoteFlags['ENT_QUOTES']);
     $this->assertEquals(ENT_NOQUOTES, $quoteFlags['ENT_NOQUOTES']);
     $this->assertEquals(ENT_IGNORE, $quoteFlags['ENT_IGNORE']);
     $this->assertEquals(ENT_SUBSTITUTE, $quoteFlags['ENT_SUBSTITUTE']);
     $this->assertEquals(ENT_DISALLOWED, $quoteFlags['ENT_DISALLOWED']);
     $this->assertEquals(ENT_HTML401, $quoteFlags['ENT_HTML401']);
     $this->assertEquals(ENT_XML1, $quoteFlags['ENT_XML1']);
     $this->assertEquals(ENT_XHTML, $quoteFlags['ENT_XHTML']);
     $this->assertEquals(ENT_HTML5, $quoteFlags['ENT_HTML5']);
 }
开发者ID:junky-pic,项目名称:php-pretty-print,代码行数:39,代码来源:HtmlBuilderTest.php

示例9: addComplexType

 /**
  * Add a complex type by recursivly using all the class properties fetched via Reflection.
  *
  * @param  string $type Name of the class to be specified
  * @return string XSD Type for the given PHP type
  */
 public function addComplexType($type)
 {
     if (!class_exists($type)) {
         #require_once "Zend/Soap/Wsdl/Exception.php";
         throw new Zend_Soap_Wsdl_Exception(sprintf("Cannot add a complex type %s that is not an object or where " . "class could not be found in 'DefaultComplexType' strategy.", $type));
     }
     $dom = $this->getContext()->toDomDocument();
     $class = new ReflectionClass($type);
     $defaultProperties = $class->getDefaultProperties();
     $complexType = $dom->createElement('xsd:complexType');
     $complexType->setAttribute('name', $type);
     $all = $dom->createElement('xsd:all');
     foreach ($class->getProperties() as $property) {
         if ($property->isPublic() && preg_match_all('/@var\\s+([^\\s]+)/m', $property->getDocComment(), $matches)) {
             /**
              * @todo check if 'xsd:element' must be used here (it may not be compatible with using 'complexType'
              * node for describing other classes used as attribute types for current class
              */
             $element = $dom->createElement('xsd:element');
             $element->setAttribute('name', $propertyName = $property->getName());
             $element->setAttribute('type', $this->getContext()->getType(trim($matches[1][0])));
             // If the default value is null, then this property is nillable.
             if ($defaultProperties[$propertyName] === null) {
                 $element->setAttribute('nillable', 'true');
             }
             $all->appendChild($element);
         }
     }
     $complexType->appendChild($all);
     $this->getContext()->getSchema()->appendChild($complexType);
     $this->getContext()->addType($type);
     return "tns:{$type}";
 }
开发者ID:par-orillonsoft,项目名称:Magento,代码行数:39,代码来源:DefaultComplexType.php

示例10: restoreStaticAttributes

 /**
  * Restores all static attributes in user-defined classes from this snapshot.
  *
  * @param Snapshot $snapshot
  */
 public function restoreStaticAttributes(Snapshot $snapshot)
 {
     $current = new Snapshot($snapshot->blacklist(), false, false, false, false, true, false, false, false, false);
     $newClasses = array_diff($current->classes(), $snapshot->classes());
     unset($current);
     foreach ($snapshot->staticAttributes() as $className => $staticAttributes) {
         foreach ($staticAttributes as $name => $value) {
             $reflector = new ReflectionProperty($className, $name);
             $reflector->setAccessible(true);
             $reflector->setValue($value);
         }
     }
     foreach ($newClasses as $className) {
         $class = new \ReflectionClass($className);
         $defaults = $class->getDefaultProperties();
         foreach ($class->getProperties() as $attribute) {
             if (!$attribute->isStatic()) {
                 continue;
             }
             $name = $attribute->getName();
             if ($snapshot->blacklist()->isStaticAttributeBlacklisted($className, $name)) {
                 continue;
             }
             if (!isset($defaults[$name])) {
                 continue;
             }
             $attribute->setAccessible(true);
             $attribute->setValue($defaults[$name]);
         }
     }
 }
开发者ID:Ceciceciceci,项目名称:MySJSU-Class-Registration,代码行数:36,代码来源:Restorer.php

示例11: getPages

 public static function getPages($exclude_filled = false, $add_page = false)
 {
     $selected_pages = array();
     if (!($files = Tools::scandir(_PS_ROOT_DIR_ . '/controllers/front/', 'php', '', true))) {
         die(Tools::displayError('Cannot scan root directory'));
     }
     // Exclude pages forbidden
     $exlude_pages = array('category', 'changecurrency', 'cms', 'footer', 'header', 'pagination', 'product', 'product-sort', 'statistics');
     foreach ($files as $file) {
         if ($file != 'index.php' && !in_array(strtolower(str_replace('Controller.php', '', $file)), $exlude_pages)) {
             $class_name = str_replace('.php', '', $file);
             if (class_exists($class_name)) {
                 $reflection = new ReflectionClass(str_replace('.php', '', $file));
             }
             if (isset($reflection) && $reflection) {
                 $properties = $reflection->getDefaultProperties();
             }
             if (isset($properties['php_self'])) {
                 $selected_pages[$properties['php_self']] = $properties['php_self'];
             } else {
                 if (preg_match('/^[a-z0-9_.-]*\\.php$/i', $file)) {
                     $selected_pages[strtolower(str_replace('Controller.php', '', $file))] = strtolower(str_replace('Controller.php', '', $file));
                 } else {
                     if (preg_match('/^([a-z0-9_.-]*\\/)?[a-z0-9_.-]*\\.php$/i', $file)) {
                         $selected_pages[strtolower(sprintf(Tools::displayError('%2$s (in %1$s)'), dirname($file), str_replace('Controller.php', '', basename($file))))] = strtolower(str_replace('Controller.php', '', basename($file)));
                     }
                 }
             }
         }
     }
     // Add modules controllers to list (this function is cool !)
     foreach (glob(_PS_MODULE_DIR_ . '*/controllers/front/*.php') as $file) {
         $filename = Tools::strtolower(basename($file, '.php'));
         if ($filename == 'index') {
             continue;
         }
         $module = Tools::strtolower(basename(dirname(dirname(dirname($file)))));
         $selected_pages[$module . ' - ' . $filename] = 'module-' . $module . '-' . $filename;
     }
     // Exclude page already filled
     if ($exclude_filled) {
         $metas = Meta::getMetas();
         foreach ($metas as $meta) {
             if (in_array($meta['page'], $selected_pages)) {
                 unset($selected_pages[array_search($meta['page'], $selected_pages)]);
             }
         }
     }
     // Add selected page
     if ($add_page) {
         $name = $add_page;
         if (preg_match('#module-([a-z0-9_-]+)-([a-z0-9]+)$#i', $add_page, $m)) {
             $add_page = $m[1] . ' - ' . $m[2];
         }
         $selected_pages[$add_page] = $name;
         asort($selected_pages);
     }
     return $selected_pages;
 }
开发者ID:toufikadfab,项目名称:PrestaShop-1.5,代码行数:59,代码来源:Meta.php

示例12: offsetUnset

 public function offsetUnset($offset)
 {
     if ($this->offsetExists($offset)) {
         $rc = new \ReflectionClass(static::class);
         $defaults = $rc->getDefaultProperties();
         $this->{$offset} = $defaults[$offset];
     }
 }
开发者ID:hpolthof,项目名称:laravel-docmail,代码行数:8,代码来源:DocmailArrayAccessTrait.php

示例13: yamlToViewDefinition

 public function yamlToViewDefinition($path)
 {
     $definitionContent = file_get_contents($path);
     $yaml = new Parser();
     $definition = $yaml->parse($definitionContent);
     $reflection = new \ReflectionClass(ObjectCrud::class);
     return array_merge($reflection->getDefaultProperties(), $definition);
 }
开发者ID:jarves,项目名称:jarves,代码行数:8,代码来源:CrudViewTrait.php

示例14: _processSpecialties

 protected function _processSpecialties()
 {
     $specialties = array();
     if ($this->_providerReflection->hasMethod('getSpecialties')) {
         $specialties = $this->_provider->getSpecialties();
         if (!is_array($specialties)) {
             throw new ZendL_Tool_Rpc_Exception('Provider ' . get_class($this->_provider) . ' must return an array for method getSpecialties().');
         }
     } else {
         $defaultProperties = $this->_providerReflection->getDefaultProperties();
         $specialties = isset($defaultProperties['_specialties']) ? $defaultProperties['_specialties'] : array();
         if (!is_array($specialties)) {
             throw new ZendL_Tool_Rpc_Exception('Provider ' . get_class($this->_provider) . '\'s property $_specialties must be an array.');
         }
     }
     $this->_specialties = array_merge(array('_Global'), $specialties);
 }
开发者ID:lortnus,项目名称:zf1,代码行数:17,代码来源:Signature.php

示例15: jsonSerialize

 /**
  * @return array
  */
 public function jsonSerialize()
 {
     $reflection = new \ReflectionClass($this);
     $properties = $reflection->getDefaultProperties();
     foreach ($properties as $field => $value) {
         $data[$field] = $this->{'get' . $field}();
     }
     return $data;
 }
开发者ID:gordalina,项目名称:mangopay-php,代码行数:12,代码来源:AbstractModel.php


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