Changeset 1773
- Timestamp:
- 08/06/08 14:20:36 (3 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
labs/incubator/src/main/php/net/stubbles/lang/mop/stubMetaClass.php
r1772 r1773 11 11 'net::stubbles::lang::exceptions::stubMethodNotSupportedException', 12 12 'net::stubbles::lang::mop::stubMetaObjectProtocol', 13 'net::stubbles::reflection::stubReflectionMethod', 13 14 'net::stubbles::reflection::stubReflectionObject' 14 15 ); … … 72 73 73 74 /** 75 * returns true of the implementing MetaClass has a method of the given name 76 * 77 * Note that this method will only return true for realised method and does 78 * not take into account implementation of invokeMethod or invokeMissingMethod 79 * 80 * @return boolean 81 */ 82 public function hasMethod($methodName) 83 { 84 return in_array($methodName, $this->getMethods()); 85 } 86 87 /** 74 88 * invokes a method on the given receiver with the specified arguments 75 89 * … … 80 94 * @throws stubMethodNotSupportedException 81 95 */ 82 public function invokeMethod(stubMetaObjectProtocol $receiver, $method, array $arguments )96 public function invokeMethod(stubMetaObjectProtocol $receiver, $method, array $arguments = array()) 83 97 { 84 if ( in_array($method, $this->getMethods())) {85 return $this->getClass()->getMethod($method)->invoke($arguments);98 if ($this->hasMethod($method)) { 99 return ($this->getClass()->getMethod($method)->invokeArgs($this, $arguments)); 86 100 } 87 101 labs/incubator/src/test/php/net/stubbles/lang/mop/stubMetaClassTestCase.php
r1771 r1773 7 7 * @subpackage lang_mop_test 8 8 */ 9 stubClassLoader::load('net::stubbles::lang::mop::stubMetaClass'); 9 stubClassLoader::load('net::stubbles::lang::mop::stubMetaClass', 10 'net::stubbles::lang::mop::stubMetaObject' 11 ); 10 12 /** 11 13 * Tests for net::stubbles::lang::mop::stubMetaClass. … … 45 47 'getProperties', 46 48 'getMethods', 49 'hasMethod', 47 50 'invokeMethod', 48 51 'invokeMissingMethod', … … 71 74 ); 72 75 } 76 77 /** 78 * test invoke a method on meta class 79 * 80 * @test 81 */ 82 public function canInvokeMethodSuccessfulIfExists() 83 { 84 $this->assertEquals( 85 $this->stubMetaClass->invokeMethod(new stubMetaObject, 'getClass'), 86 'net::stubbles::lang::mop::stubMetaClass' 87 ); 88 } 73 89 } 74 90 ?>
