Changeset 103
- Timestamp:
- 09/21/07 14:10:12 (1 year ago)
- Files:
-
- trunk/XJConf/converters/AbstractObjectValueConverter.php (modified) (3 diffs)
- trunk/autopackage2.php (modified) (3 diffs)
- trunk/examples/AnotherDog.php (added)
- trunk/examples/Dog.php (added)
- trunk/examples/Test__setExplicit.php (added)
- trunk/examples/Test__setImplicit.php (added)
- trunk/examples/Test__setPublicProperties.php (added)
- trunk/examples/xml/defines-__setExplicit.xml (added)
- trunk/examples/xml/defines-__setImplicit.xml (added)
- trunk/examples/xml/defines-__setPublicProperties.xml (added)
- trunk/examples/xml/test-__set.xml (added)
- trunk/package.php (modified) (2 diffs)
- trunk/tests/integration/Test__setExplicitTestCase.php (added)
- trunk/tests/integration/Test__setImplicitTestCase.php (added)
- trunk/tests/integration/Test__setPublicPropertiesTestCase.php (added)
- trunk/tests/runIntegration.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/XJConf/converters/AbstractObjectValueConverter.php
r95 r103 34 34 $children = $tag->getChildren(); 35 35 foreach ($children as $child) { 36 if (!$child instanceof ValueModifier) {37 continue;38 }36 if (!$child instanceof ValueModifier) { 37 continue; 38 } 39 39 } 40 40 } … … 61 61 62 62 try { 63 $method = $class->getMethod($att->getSetterMethod($tag)); 64 $method->invoke($instance, $val); 63 if ($class->hasMethod($att->getSetterMethod($tag)) == true) { 64 $method = $class->getMethod($att->getSetterMethod($tag)); 65 } elseif ($class->hasMethod('__set') == true) { 66 $method = $class->getMethod('__set'); 67 } elseif ($class->hasProperty($att->getName()) == true) { 68 $property = $class->getProperty($att->getName()); 69 if ($property->isPublic() == true) { 70 $property->setValue($instance, $val); 71 continue; 72 } 73 74 throw new ValueConversionException('Could not add attribute "' . $att->getName() . '" to "' . $this->getType() . '" using "' . $att->getSetterMethod($tag) . '()" or "__set()" or public property "' . $att->getName() . '", no such method defined.'); 75 } else { 76 throw new ValueConversionException('Could not add attribute "' . $att->getName() . '" to "' . $this->getType() . '" using "' . $att->getSetterMethod($tag) . '()" or "__set()" or public property "' . $att->getName() . '", no such method defined.'); 77 } 78 79 if ($method->getName() != '__set') { 80 $method->invoke($instance, $val); 81 } else { 82 $method->invokeArgs($instance, array($att->getName(), $val)); 83 } 65 84 } catch (ReflectionException $re) { 66 throw new ValueConversionException('Could not set attribute "' . $att->getName() . '" of "' . $this->getType() . '" using "' . $att->getSetterMethod($tag) . '()" , exception message: "' . $re->getMessage() . '".');85 throw new ValueConversionException('Could not set attribute "' . $att->getName() . '" of "' . $this->getType() . '" using "' . $att->getSetterMethod($tag) . '()" or "__set()" or public property "' . $att->getName() . '", exception message: "' . $re->getMessage() . '".'); 67 86 } 68 87 } … … 97 116 continue; 98 117 } 118 99 119 try { 100 $class->getMethod($child->getSetterMethod())->invoke($instance, $child->getConvertedValue()); 120 if ($class->hasMethod($child->getSetterMethod()) == true) { 121 $method = $class->getMethod($child->getSetterMethod()); 122 } elseif ($class->hasMethod('__set') == true) { 123 $method = $class->getMethod('__set'); 124 } elseif ($class->hasProperty($child->getKey()) == true) { 125 $property = $class->getProperty($child->getKey()); 126 if ($property->isPublic() == true) { 127 $property->setValue($instance, $child->getConvertedValue()); 128 continue; 129 } 130 131 throw new ValueConversionException('Could not add attribute "' . $child->getKey() . '" to "' . $this->getType() . '" using "' . $child->getSetterMethod() . '()" or "__set()" or public property "' . $child->getKey() . '", no such method defined.'); 132 } else { 133 throw new ValueConversionException('Could not add attribute "' . $child->getKey() . '" to "' . $this->getType() . '" using "' . $child->getSetterMethod() . '()" or "__set()" or public property "' . $child->getKey() . '", no such method defined.'); 134 } 135 136 if ($method->getName() != '__set') { 137 $method->invoke($instance, $child->getConvertedValue()); 138 } else { 139 $method->invokeArgs($instance, array($child->getName(), $child->getConvertedValue())); 140 } 101 141 } catch (ReflectionException $re) { 102 throw new ValueConversionException('Could not add child "' . $child->getKey() . '" to "' . $this->getType() . '" using "' . $child->getSetterMethod() . '()" , exception message: "' . $re->getMessage() . '".');142 throw new ValueConversionException('Could not add child "' . $child->getKey() . '" to "' . $this->getType() . '" using "' . $child->getSetterMethod() . '()" or "__set()" or public property "' . $child->getKey() . '", exception message: "' . $re->getMessage() . '".'); 103 143 } 104 144 } trunk/autopackage2.php
r92 r103 25 25 * current version 26 26 */ 27 $version = $baseVersion . 'dev' . $argv[1];28 $dir = dirname( __FILE__ );27 $version = $baseVersion . 'dev' . $argv[1]; 28 $dir = dirname( __FILE__ ); 29 29 30 30 /** … … 54 54 - Added possibility to package XJConfForPHP as a STAR archive (mikey, schst) 55 55 - Added new value type "xjonf:auto-primitive" to guess the type of a scalar value (schst) 56 - Added implicit and explicit call to __set as well as possibility for setting public properties (mikey) 56 57 Bugfixes: 57 58 - Fixed bug #6: Enable factory methods without parameters in PHP 5.0.x (schst) … … 78 79 'packagedirectory' => './', 79 80 'dir_roles' => array( 80 'docs' => 'doc',81 'docs' => 'doc', 81 82 'examples' => 'doc', 82 83 'tests' => 'test', trunk/package.php
r92 r103 48 48 - Added possibility to package XJConfForPHP as a STAR archive (mikey, schst) 49 49 - Added new value type "xjonf:auto-primitive" to guess the type of a scalar value (schst) 50 - Added implicit and explicit call to __set as well as possibility for setting public properties (mikey) 50 51 Bugfixes: 51 52 - Fixed bug #6: Enable factory methods without parameters in PHP 5.0.x (schst) … … 72 73 'packagedirectory' => './', 73 74 'dir_roles' => array( 74 'docs' => 'doc',75 'docs' => 'doc', 75 76 'examples' => 'doc', 76 77 'tests' => 'test', trunk/tests/runIntegration.php
r91 r103 30 30 $test->addTestFile(TEST_CWD . '/integration/ExampleCollectionTestCase.php'); 31 31 $test->addTestFile(TEST_CWD . '/integration/ExampleExtensionTestCase.php'); 32 $test->addTestFile(TEST_CWD . '/integration/Test__setExplicitTestCase.php'); 33 $test->addTestFile(TEST_CWD . '/integration/Test__setImplicitTestCase.php'); 34 $test->addTestFile(TEST_CWD . '/integration/Test__setPublicPropertiesTestCase.php'); 32 35 $test->addTestFile(TEST_CWD . '/integration/TestAttributesRequiredTestCase.php'); 33 36 $test->addTestFile(TEST_CWD . '/integration/TestCDataSetterTestCase.php');
