Changeset 896
- Timestamp:
- 09/06/07 16:33:08 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/reflection/annotations/parser/stubAnnotationStateParser.php
r678 r896 211 211 } 212 212 213 $matches = array(); 214 if (preg_match('/^([a-zA-Z_]{1}[a-zA-Z\.0-9_]*)::\$([a-zA-Z_]{1}[a-zA-Z0-9_]*)/', $value, $matches) != false) { 215 stubClassLoader::load('net.stubbles.lang.stubEnum'); 216 try { 217 return stubEnum::forName(new stubReflectionClass($matches[1]), $matches[2]); 218 } catch (Exception $e) { 219 echo $e->getMessage(); 220 return null; 221 } 222 } 223 213 224 if (defined($value) == true) { 214 225 return constant($value); trunk/src/test/php/net/stubbles/reflection/annotations/parser/stubAnnotationStateParserTestCase.php
r502 r896 8 8 * @subpackage reflection_annotations_parser_test 9 9 */ 10 stubClassLoader::load('net.stubbles.reflection.annotations.parser.stubAnnotationStateParser'); 10 stubClassLoader::load('net.stubbles.reflection.annotations.parser.stubAnnotationStateParser', 11 'net.stubbles.lang.stubEnum' 12 ); 11 13 define('ANNOTATION_TEST_CONSTANT', 'baz'); 12 14 /** … … 22 24 * @SingleValue(42) 23 25 * @Constant(foo=ANNOTATION_TEST_CONSTANT) 26 * @Constant2(foo=MyTestClass::TEST_CONSTANT) 27 * @Enum(foo=MyTestClass::$FOO) 24 28 * @SingleStringValue('This is a string with chars like = or ,') 25 29 * @WithEscaped(foo='This string contains \' and \\, which is possible using escaping...') … … 35 39 * class=MyTestClass.class) 36 40 */ 37 class MyTestClass { } 41 class MyTestClass extends stubEnum 42 { 43 const TEST_CONSTANT = 'baz'; 44 public static $FOO; 45 46 public static function __static() 47 { 48 self::$FOO = new self('FOO'); 49 } 50 } 51 MyTestClass::__static(); 38 52 /** 39 53 * Test for net.stubbles.reflection.annotations.parser.stubAnnotationStateParser. … … 79 93 $this->assertEqual($annotations['Constant']['type'], 'Constant'); 80 94 $this->assertEqual($annotations['Constant']['params'], array('foo' => ANNOTATION_TEST_CONSTANT)); 95 $this->assertTrue(isset($annotations['Constant2'])); 96 $this->assertEqual($annotations['Constant2']['type'], 'Constant2'); 97 $this->assertEqual($annotations['Constant2']['params'], array('foo' => MyTestClass::TEST_CONSTANT)); 98 $this->assertTrue(isset($annotations['Enum'])); 99 $this->assertEqual($annotations['Enum']['type'], 'Enum'); 100 $this->assertEqual($annotations['Enum']['params'], array('foo' => MyTestClass::$FOO)); 81 101 $this->assertTrue(isset($annotations['SingleStringValue'])); 82 102 $this->assertEqual($annotations['SingleStringValue']['type'], 'SingleStringValue');
