From 991e53799d740ed4cd34bcca310392c58acc3426 Mon Sep 17 00:00:00 2001 From: Cvetomir Lazarov Date: Wed, 15 Aug 2018 10:28:51 +0300 Subject: [PATCH 1/9] Allow returning the Placeholder helper itself when no name is specified --- src/Helper/Placeholder.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Helper/Placeholder.php b/src/Helper/Placeholder.php index aad16d4c..33632824 100644 --- a/src/Helper/Placeholder.php +++ b/src/Helper/Placeholder.php @@ -9,7 +9,6 @@ namespace Zend\View\Helper; -use Zend\View\Exception\InvalidArgumentException; use Zend\View\Helper\Placeholder\Container; /** @@ -37,15 +36,12 @@ class Placeholder extends AbstractHelper * Placeholder helper * * @param string $name - * @throws InvalidArgumentException - * @return Placeholder\Container\AbstractContainer + * @return Placeholder\Container\AbstractContainer|Placeholder */ public function __invoke($name = null) { if ($name === null) { - throw new InvalidArgumentException( - 'Placeholder: missing argument. $name is required by placeholder($name)' - ); + return $this; } $name = (string) $name; From c4c9488034764726a3f0c706e6631692a37959e2 Mon Sep 17 00:00:00 2001 From: Cvetomir Lazarov Date: Wed, 15 Aug 2018 10:29:55 +0300 Subject: [PATCH 2/9] Add test to check whether the placeholder retrieves itself when no name is specified --- test/Helper/PlaceholderTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/Helper/PlaceholderTest.php b/test/Helper/PlaceholderTest.php index 4d7ac5d6..5b33b1fa 100644 --- a/test/Helper/PlaceholderTest.php +++ b/test/Helper/PlaceholderTest.php @@ -68,6 +68,15 @@ public function testPlaceholderRetrievesContainer() $this->assertInstanceOf(AbstractContainer::class, $container); } + /** + * @return void + */ + public function testPlaceholderRetrievesItself() + { + $container = $this->placeholder->__invoke(); + $this->assertSame($container, $this->placeholder); + } + /** * @return void */ From 01e0927d8e73cc1adf2b4b69ca5f6752cfdf5fe0 Mon Sep 17 00:00:00 2001 From: Cvetomir Lazarov Date: Wed, 15 Aug 2018 10:30:45 +0300 Subject: [PATCH 3/9] Add test for the Placeholder::containerExists() method --- test/Helper/PlaceholderTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/Helper/PlaceholderTest.php b/test/Helper/PlaceholderTest.php index 5b33b1fa..05646bc7 100644 --- a/test/Helper/PlaceholderTest.php +++ b/test/Helper/PlaceholderTest.php @@ -59,6 +59,17 @@ public function testSetView() $this->assertSame($view, $this->placeholder->getView()); } + /** + * @return void + */ + public function testContainerExists() + { + $this->placeholder->__invoke('foo'); + $containerExists = $this->placeholder->__invoke()->containerExists('foo'); + + $this->assertTrue($containerExists); + } + /** * @return void */ From d00694a909823a82170a45df16d266f79b19f619 Mon Sep 17 00:00:00 2001 From: Cvetomir Lazarov Date: Wed, 15 Aug 2018 10:34:51 +0300 Subject: [PATCH 4/9] Add test to check if the created container is the same as the one from the Placeholder::getContainer() method --- test/Helper/PlaceholderTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/Helper/PlaceholderTest.php b/test/Helper/PlaceholderTest.php index 05646bc7..396332ad 100644 --- a/test/Helper/PlaceholderTest.php +++ b/test/Helper/PlaceholderTest.php @@ -97,4 +97,15 @@ public function testPlaceholderRetrievesSameContainerOnSubsequentCalls() $container2 = $this->placeholder->__invoke('foo'); $this->assertSame($container1, $container2); } + + /** + * @return void + */ + public function testGetContainerRetrievesTheCorrectContainer() + { + $container1 = $this->placeholder->__invoke('foo'); + $container2 = $this->placeholder->__invoke()->getContainer('foo'); + + $this->assertSame($container1, $container2); + } } From c105734dccd40c6e7d9dd0fb830207f3f7a3aa6b Mon Sep 17 00:00:00 2001 From: Cvetomir Lazarov Date: Wed, 15 Aug 2018 11:15:16 +0300 Subject: [PATCH 5/9] Bump the minimum version for zend-mvc to 2.7.13 to satisfy lowest dependencies on PHP 7.2 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a8da6d85..e806695c 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ "zendframework/zend-json": "^2.6.1", "zendframework/zend-log": "^2.7", "zendframework/zend-modulemanager": "^2.7.1", - "zendframework/zend-mvc": "^2.7 || ^3.0", + "zendframework/zend-mvc": "^2.7 >=2.7.13 || ^3.0", "zendframework/zend-navigation": "^2.5", "zendframework/zend-paginator": "^2.5", "zendframework/zend-permissions-acl": "^2.6", From 087b034a5847a2883a6b04639db807c27ae8dfee Mon Sep 17 00:00:00 2001 From: Cvetomir Lazarov Date: Wed, 15 Aug 2018 11:23:43 +0300 Subject: [PATCH 6/9] Switch to a range between 2.7.13 and 2.8 for zend-mvc dependency --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e806695c..6d34bae8 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ "zendframework/zend-json": "^2.6.1", "zendframework/zend-log": "^2.7", "zendframework/zend-modulemanager": "^2.7.1", - "zendframework/zend-mvc": "^2.7 >=2.7.13 || ^3.0", + "zendframework/zend-mvc": ">=2.7.13 <2.8 || ^3.0", "zendframework/zend-navigation": "^2.5", "zendframework/zend-paginator": "^2.5", "zendframework/zend-permissions-acl": "^2.6", From 4ecca91af1dbd5ee16deaaa16ef0907a44630c12 Mon Sep 17 00:00:00 2001 From: Cvetomir Lazarov Date: Wed, 15 Aug 2018 11:25:31 +0300 Subject: [PATCH 7/9] Use the caret version range to define the minimum version for zend-mvc dependency --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 6d34bae8..b01fc5d9 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ "zendframework/zend-json": "^2.6.1", "zendframework/zend-log": "^2.7", "zendframework/zend-modulemanager": "^2.7.1", - "zendframework/zend-mvc": ">=2.7.13 <2.8 || ^3.0", + "zendframework/zend-mvc": "^2.7.13 || ^3.0", "zendframework/zend-navigation": "^2.5", "zendframework/zend-paginator": "^2.5", "zendframework/zend-permissions-acl": "^2.6", From c683c29e87a73487c5929d1ba7bf8d1204ea357b Mon Sep 17 00:00:00 2001 From: Cvetomir Lazarov Date: Wed, 15 Aug 2018 11:44:32 +0300 Subject: [PATCH 8/9] Use self instead of class name for the return type of Placeholder::__invoke() --- src/Helper/Placeholder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Helper/Placeholder.php b/src/Helper/Placeholder.php index 33632824..fb7794d9 100644 --- a/src/Helper/Placeholder.php +++ b/src/Helper/Placeholder.php @@ -36,7 +36,7 @@ class Placeholder extends AbstractHelper * Placeholder helper * * @param string $name - * @return Placeholder\Container\AbstractContainer|Placeholder + * @return Placeholder\Container\AbstractContainer|self */ public function __invoke($name = null) { From 4be6723615ed2d550efa644b03db5fcc810ac22a Mon Sep 17 00:00:00 2001 From: Cvetomir Lazarov Date: Wed, 15 Aug 2018 13:13:22 +0300 Subject: [PATCH 9/9] Change the zend-mvc version constraint back to the original one --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b01fc5d9..a8da6d85 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ "zendframework/zend-json": "^2.6.1", "zendframework/zend-log": "^2.7", "zendframework/zend-modulemanager": "^2.7.1", - "zendframework/zend-mvc": "^2.7.13 || ^3.0", + "zendframework/zend-mvc": "^2.7 || ^3.0", "zendframework/zend-navigation": "^2.5", "zendframework/zend-paginator": "^2.5", "zendframework/zend-permissions-acl": "^2.6",