summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2019-10-11 08:03:35 +0200
committerRemi Collet <remi@remirepo.net>2019-10-11 08:03:35 +0200
commit00c0d0b107fa4ffc42d1cbaec2e2feaece2fcaff (patch)
tree271b8ba1455fe5f3c4a9b4f090f66e207aeac8c2
parente461731788a186edc6b3abe3d97101f478bda96b (diff)
- add patches for PHP 7.4 from
https://github.com/zendframework/zend-view/pull/192 https://github.com/zendframework/zend-view/pull/195
-rw-r--r--192.patch28
-rw-r--r--195.patch155
-rw-r--r--php-zendframework-zend-view.spec14
3 files changed, 195 insertions, 2 deletions
diff --git a/192.patch b/192.patch
new file mode 100644
index 0000000..7385eff
--- /dev/null
+++ b/192.patch
@@ -0,0 +1,28 @@
+From 26679ddafc593e5163df30e98d3ce98b764aa13f Mon Sep 17 00:00:00 2001
+From: webimpress <contact@webimpress.com>
+Date: Tue, 27 Aug 2019 23:29:41 +0100
+Subject: [PATCH] Fix: replace curly offset access brace with square brackets
+
+As of PHP 7.4:
+the array and string offset access syntax using curly braces is deprecated.
+---
+ src/Helper/Navigation/Sitemap.php | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/Helper/Navigation/Sitemap.php b/src/Helper/Navigation/Sitemap.php
+index 76acb227..08aa922e 100644
+--- a/src/Helper/Navigation/Sitemap.php
++++ b/src/Helper/Navigation/Sitemap.php
+@@ -267,10 +267,10 @@ public function url(AbstractPage $page)
+ {
+ $href = $page->getHref();
+
+- if (! isset($href{0})) {
++ if (! isset($href[0])) {
+ // no href
+ return '';
+- } elseif ($href{0} == '/') {
++ } elseif ($href[0] == '/') {
+ // href is relative to root; use serverUrl helper
+ $url = $this->getServerUrl() . $href;
+ } elseif (preg_match('/^[a-z]+:/im', (string) $href)) {
diff --git a/195.patch b/195.patch
new file mode 100644
index 0000000..6ccd989
--- /dev/null
+++ b/195.patch
@@ -0,0 +1,155 @@
+From cd691f9a6e3f97812c98e7385208e3dc3661bb4d Mon Sep 17 00:00:00 2001
+From: Remi Collet <remi@remirepo.net>
+Date: Thu, 10 Oct 2019 10:57:31 +0200
+Subject: [PATCH 1/3] fix Using array_key_exists() on objects
+
+---
+ src/Model/ViewModel.php | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/Model/ViewModel.php b/src/Model/ViewModel.php
+index 04e76498..6c330dab 100644
+--- a/src/Model/ViewModel.php
++++ b/src/Model/ViewModel.php
+@@ -239,7 +239,7 @@ public function clearOptions()
+ public function getVariable($name, $default = null)
+ {
+ $name = (string) $name;
+- if (array_key_exists($name, $this->variables)) {
++ if (isset($this->variables[$name])) {
+ return $this->variables[$name];
+ }
+
+
+From c711fbddaedc322cf5cbdfaa5f4dce8c201e35d7 Mon Sep 17 00:00:00 2001
+From: webimpress <contact@webimpress.com>
+Date: Thu, 10 Oct 2019 23:01:54 +0100
+Subject: [PATCH 2/3] Fixes failing tests on PHP 7.4
+
+From PHP 7.4 docs:
+
+ Calling get_object_vars() on an ArrayObject instance will now always return
+ the properties of the ArrayObject itself (or a subclass). Previously it
+ returned the values of the wrapped array/object unless the STD_PROP_LIST
+ flag was specified. Other affected operations are:
+
+ * ReflectionObject::getProperties()
+ * reset(), current(), etc. Use Iterator methods instead.
+ * Potentially others working on object properties as a list.
+---
+ .../application/views/scripts/partialLoopChildObject.phtml | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/test/Helper/_files/modules/application/views/scripts/partialLoopChildObject.phtml b/test/Helper/_files/modules/application/views/scripts/partialLoopChildObject.phtml
+index e5babd65..1463771b 100644
+--- a/test/Helper/_files/modules/application/views/scripts/partialLoopChildObject.phtml
++++ b/test/Helper/_files/modules/application/views/scripts/partialLoopChildObject.phtml
+@@ -1,12 +1,12 @@
+ <?php
+
+-$vars = $this->vars();
++$vars = (array) $this->vars();
+
+ if (empty($vars)) {
+ echo "No object model passed";
+ } elseif (isset($vars['message'])) {
+ echo $vars['message'];
+ } else {
+- $objKey = current($this->vars())->helper->getObjectKey();
++ $objKey = current($vars)->helper->getObjectKey();
+ echo 'This is an iteration with objectKey: ' . $objKey;
+ }
+
+From 81ed6ca3c83f295fabdb67f7d9e5e2c9de0a41be Mon Sep 17 00:00:00 2001
+From: webimpress <contact@webimpress.com>
+Date: Thu, 10 Oct 2019 23:08:36 +0100
+Subject: [PATCH 3/3] Correct the fix so the behaviour of the original code is
+ not changed
+
+Added tests to verify the change.
+---
+ src/Model/ViewModel.php | 9 +++++--
+ test/Model/ViewModelTest.php | 52 ++++++++++++++++++++++++++++++++++++
+ 2 files changed, 59 insertions(+), 2 deletions(-)
+
+diff --git a/src/Model/ViewModel.php b/src/Model/ViewModel.php
+index 6c330dab..5609a091 100644
+--- a/src/Model/ViewModel.php
++++ b/src/Model/ViewModel.php
+@@ -239,8 +239,13 @@ public function clearOptions()
+ public function getVariable($name, $default = null)
+ {
+ $name = (string) $name;
+- if (isset($this->variables[$name])) {
+- return $this->variables[$name];
++
++ if (is_array($this->variables)) {
++ if (array_key_exists($name, $this->variables)) {
++ return $this->variables[$name];
++ }
++ } elseif ($this->variables->offsetExists($name)) {
++ return $this->variables->offsetGet($name);
+ }
+
+ return $default;
+diff --git a/test/Model/ViewModelTest.php b/test/Model/ViewModelTest.php
+index 318825f8..e922a0e8 100644
+--- a/test/Model/ViewModelTest.php
++++ b/test/Model/ViewModelTest.php
+@@ -361,4 +361,56 @@ public function testCloneWithArray()
+ $this->assertEquals('foo', $model1->getVariable('a'));
+ $this->assertEquals('bar', $model2->getVariable('a'));
+ }
++
++ public function variableValue()
++ {
++ return [
++ // variables default expected
++
++ // if it is set always get the value
++ [['foo' => 'bar'], 'baz', 'bar'],
++ [['foo' => 'bar'], null, 'bar'],
++ [new ArrayObject(['foo' => 'bar']), 'baz', 'bar'],
++ [new ArrayObject(['foo' => 'bar']), null, 'bar'],
++
++ // if it is null always get null value
++ [['foo' => null], null, null],
++ [['foo' => null], 'baz', null],
++ [new ArrayObject(['foo' => null]), null, null],
++ [new ArrayObject(['foo' => null]), 'baz', null],
++
++ // when it is not set always get default value
++ [[], 'baz', 'baz'],
++ [new ArrayObject(), 'baz', 'baz'],
++ ];
++ }
++
++ /**
++ * @dataProvider variableValue
++ *
++ * @param array|ArrayObject $variables
++ * @param string|null $default
++ * @param string|null $expected
++ */
++ public function testGetVariableSetByConstruct($variables, $default, $expected)
++ {
++ $model = new ViewModel($variables);
++
++ self::assertSame($expected, $model->getVariable('foo', $default));
++ }
++
++ /**
++ * @dataProvider variableValue
++ *
++ * @param array|ArrayObject $variables
++ * @param string|null $default
++ * @param string|null $expected
++ */
++ public function testGetVariableSetBySetter($variables, $default, $expected)
++ {
++ $model = new ViewModel();
++ $model->setVariables($variables);
++
++ self::assertSame($expected, $model->getVariable('foo', $default));
++ }
+ }
diff --git a/php-zendframework-zend-view.spec b/php-zendframework-zend-view.spec
index 47617b1..9eab1aa 100644
--- a/php-zendframework-zend-view.spec
+++ b/php-zendframework-zend-view.spec
@@ -21,7 +21,7 @@
Name: php-%{gh_owner}-%{gh_project}
Version: 2.11.2
-Release: 1%{?dist}
+Release: 3%{?dist}
Summary: Zend Framework %{library} component
License: BSD
@@ -29,6 +29,9 @@ URL: https://zendframework.github.io/%{gh_project}/
Source0: %{gh_commit}/%{name}-%{version}-%{gh_short}.tgz
Source1: makesrc.sh
+Patch0: https://patch-diff.githubusercontent.com/raw/zendframework/zend-view/pull/195.patch
+Patch1: https://patch-diff.githubusercontent.com/raw/zendframework/zend-view/pull/192.patch
+
BuildArch: noarch
# Tests
%if %{with_tests}
@@ -213,6 +216,8 @@ Documentation: https://zendframework.github.io/%{gh_project}/
%prep
%setup -q -n %{gh_project}-%{gh_commit}
+%patch0 -p1
+%patch1 -p1
mv LICENSE.md LICENSE
@@ -283,7 +288,7 @@ require_once '%{buildroot}%{php_home}/Zend/%{library}/autoload.php';
EOF
ret=0
-for cmd in php php70 php71 php72 php73; do
+for cmd in php php72 php73 php74; do
if which $cmd; then
$cmd %{_bindir}/phpunit6 --verbose || ret=1
fi
@@ -304,6 +309,11 @@ exit $ret
%changelog
+* Fri Oct 11 2019 Remi Collet <remi@remirepo.net> - 2.11.2-3
+- add patches for PHP 7.4 from
+ https://github.com/zendframework/zend-view/pull/192
+ https://github.com/zendframework/zend-view/pull/195
+
* Wed Feb 20 2019 Remi Collet <remi@remirepo.net> - 2.11.2-1
- update to 2.11.2