From b44fdda42b8ab69d19a6299c0e161207f9b3e850 Mon Sep 17 00:00:00 2001 From: Mat Wright Date: Fri, 9 Jan 2015 11:41:24 +0100 Subject: [PATCH 1/5] added missing return $this to setValue method. added return $this to the setValue method to implement fluid interface like other setters in this class. --- library/Zend/Form/Element/DateSelect.php | 1 + 1 file changed, 1 insertion(+) diff --git a/library/Zend/Form/Element/DateSelect.php b/library/Zend/Form/Element/DateSelect.php index 490f6013bc2..17c3a5b6bd7 100644 --- a/library/Zend/Form/Element/DateSelect.php +++ b/library/Zend/Form/Element/DateSelect.php @@ -112,6 +112,7 @@ public function setValue($value) $this->yearElement->setValue($value['year']); $this->monthElement->setValue($value['month']); $this->dayElement->setValue($value['day']); + return $this; } /** From 754aa7fa5a51cf098250014d33b333fdfb81bb85 Mon Sep 17 00:00:00 2001 From: matwright Date: Fri, 9 Jan 2015 13:24:47 +0100 Subject: [PATCH 2/5] Updated method Docblock return value --- library/Zend/Form/Element/DateSelect.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Zend/Form/Element/DateSelect.php b/library/Zend/Form/Element/DateSelect.php index 17c3a5b6bd7..aedfec1c9b0 100644 --- a/library/Zend/Form/Element/DateSelect.php +++ b/library/Zend/Form/Element/DateSelect.php @@ -89,7 +89,7 @@ public function getDayAttributes() /** * @param string|array|\ArrayAccess|PhpDateTime $value * @throws \Zend\Form\Exception\InvalidArgumentException - * @return void|\Zend\Form\Element + * @return DateSelect */ public function setValue($value) { From 15d2f1e41dfe9fc33ded367d294ef4efd42c2337 Mon Sep 17 00:00:00 2001 From: matwright Date: Fri, 9 Jan 2015 19:09:35 +0100 Subject: [PATCH 3/5] Added test to assert that getValue returns the same type of object as the object upon which the method was called. --- tests/ZendTest/Form/Element/DateSelectTest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/ZendTest/Form/Element/DateSelectTest.php b/tests/ZendTest/Form/Element/DateSelectTest.php index 81ee3d03f5d..863b361d11a 100644 --- a/tests/ZendTest/Form/Element/DateSelectTest.php +++ b/tests/ZendTest/Form/Element/DateSelectTest.php @@ -83,4 +83,10 @@ public function testConstructAcceptsDayAttributes() $dayAttributes = $sut->getDayAttributes(); $this->assertEquals('test', $dayAttributes['class']); } + + public function testValueSetterReturnsSameObjectType() + { + $element = new DateSelectElement(); + $this->assertInstanceOf(get_class($element), $element->setValue('hello world')); + } } From 448c1ad8a58df38a97e44abc07a6c6a56cffecee Mon Sep 17 00:00:00 2001 From: matwright Date: Fri, 9 Jan 2015 19:16:18 +0100 Subject: [PATCH 4/5] updated test to use assertSame --- tests/ZendTest/Form/Element/DateSelectTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ZendTest/Form/Element/DateSelectTest.php b/tests/ZendTest/Form/Element/DateSelectTest.php index 863b361d11a..14ae641d16b 100644 --- a/tests/ZendTest/Form/Element/DateSelectTest.php +++ b/tests/ZendTest/Form/Element/DateSelectTest.php @@ -87,6 +87,6 @@ public function testConstructAcceptsDayAttributes() public function testValueSetterReturnsSameObjectType() { $element = new DateSelectElement(); - $this->assertInstanceOf(get_class($element), $element->setValue('hello world')); + $this->assertSame($element, $element->setValue('2014-01-01')); } } From 792bad281dab570b3c888c853e459f5a34bf0f59 Mon Sep 17 00:00:00 2001 From: matwright Date: Fri, 9 Jan 2015 19:44:51 +0100 Subject: [PATCH 5/5] change docblock to use @return self --- library/Zend/Form/Element/DateSelect.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Zend/Form/Element/DateSelect.php b/library/Zend/Form/Element/DateSelect.php index aedfec1c9b0..d5cf5939565 100644 --- a/library/Zend/Form/Element/DateSelect.php +++ b/library/Zend/Form/Element/DateSelect.php @@ -89,7 +89,7 @@ public function getDayAttributes() /** * @param string|array|\ArrayAccess|PhpDateTime $value * @throws \Zend\Form\Exception\InvalidArgumentException - * @return DateSelect + * @return self Provides a fluent interface */ public function setValue($value) {