From 1d0e607d53cafff968c7a34582e586e1e5f89e2c Mon Sep 17 00:00:00 2001 From: ingo Date: Sat, 5 Jan 2013 04:53:31 +0100 Subject: [PATCH 1/2] Added tests --- test/HydratorTest.php | 4 +++ .../ClassMethodsInvalidParameter.php | 25 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/test/HydratorTest.php b/test/HydratorTest.php index f8cddf9ce..7717099cc 100644 --- a/test/HydratorTest.php +++ b/test/HydratorTest.php @@ -215,5 +215,9 @@ public function testHydratorClassMethodsWithServiceManager() { $hydrator = new ClassMethods(false); $datas = $hydrator->extract($this->classMethodsInvalidParameter); + + $this->assertTrue($datas['hasBar']); + $this->assertEquals('Bar', $datas['foo']); + $this->assertFalse($datas['isBla']); } } diff --git a/test/TestAsset/ClassMethodsInvalidParameter.php b/test/TestAsset/ClassMethodsInvalidParameter.php index 471577373..cf9338865 100644 --- a/test/TestAsset/ClassMethodsInvalidParameter.php +++ b/test/TestAsset/ClassMethodsInvalidParameter.php @@ -15,4 +15,29 @@ public function hasAlias($alias) { return $alias; } + + public function getTest($foo) + { + return $foo; + } + + public function isTest($bar) + { + return $bar; + } + + public function hasBar() + { + return true; + } + + public function getFoo() + { + return "Bar"; + } + + public function isBla() + { + return false; + } } From a385e2a8dae6ab96ac8976cd9c3a02ecad233822 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Mon, 14 Jan 2013 10:41:22 -0600 Subject: [PATCH 2/2] [zendframework/zf2#3352] Import ReflectionMethod --- src/Hydrator/ClassMethods.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Hydrator/ClassMethods.php b/src/Hydrator/ClassMethods.php index b756d9e38..0f3dea2e2 100644 --- a/src/Hydrator/ClassMethods.php +++ b/src/Hydrator/ClassMethods.php @@ -10,6 +10,7 @@ namespace Zend\Stdlib\Hydrator; +use ReflectionMethod; use Zend\Stdlib\Exception; /** @@ -64,7 +65,7 @@ public function extract($object) continue; } - $reflectionMethod = new \ReflectionMethod(get_class($object) . '::' . $method); + $reflectionMethod = new ReflectionMethod(get_class($object) . '::' . $method); if ($reflectionMethod->getNumberOfParameters() > 0) { continue; }