From ab600bb9710b8fa1438cbbb6920e18507590409e Mon Sep 17 00:00:00 2001 From: Sundeep Anand Date: Fri, 11 Oct 2019 13:59:22 +0530 Subject: [PATCH] fix for PHP 7.4 Signed-off-by: Sundeep Anand --- 230.patch | 93 ++++++++++++++++++++++++++++++++++++++++ php-gettext-gettext.spec | 36 ++++++++++++---- 2 files changed, 121 insertions(+), 8 deletions(-) create mode 100644 230.patch diff --git a/230.patch b/230.patch new file mode 100644 index 0000000..44ba408 --- /dev/null +++ b/230.patch @@ -0,0 +1,93 @@ +From 03a36641bd9b13b1084ffa9dc330d7ebd2700ed1 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Thu, 10 Oct 2019 16:25:20 +0200 +Subject: [PATCH 1/3] Fix TypeError with 7.4 + +TypeError: Argument 1 passed to Gettext\Translations::Gettext\{closure}() must be an instance of Gettext\Translation, array given + +From UPGRADINGS + . 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. +--- + src/Translations.php | 12 +++++++----- + 1 file changed, 7 insertions(+), 5 deletions(-) + +diff --git a/src/Translations.php b/src/Translations.php +index 083b4ad..05d6a3e 100644 +--- a/src/Translations.php ++++ b/src/Translations.php +@@ -435,11 +435,13 @@ public function find($context, $original = '') + */ + public function countTranslated() + { +- $callback = function (Translation $v) { +- return ($v->hasTranslation()) ? $v->getTranslation() : null; +- }; +- +- return count(array_filter(get_object_vars($this), $callback)); ++ $c = 0; ++ foreach($this as $v) { ++ if ($v->hasTranslation()) { ++ $c++; ++ } ++ } ++ return $c; + } + + /** + +From bfc9a85db55107ed58ce8e9ca84be077e03eec41 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Thu, 10 Oct 2019 16:28:19 +0200 +Subject: [PATCH 2/3] Fix Invalid characters passed for attempted conversion + (7.4) + +--- + src/Extractors/PhpCode.php | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/Extractors/PhpCode.php b/src/Extractors/PhpCode.php +index ef31449..34243b9 100644 +--- a/src/Extractors/PhpCode.php ++++ b/src/Extractors/PhpCode.php +@@ -122,11 +122,11 @@ function ($match) { + case '\\': + return '\\'; + case 'x': +- return chr(hexdec(substr($match[0], 1))); ++ return chr(hexdec(substr($match[1], 1))); + case 'u': +- return self::unicodeChar(hexdec(substr($match[0], 1))); ++ return self::unicodeChar(hexdec(substr($match[1], 1))); + default: +- return chr(octdec($match[0])); ++ return chr(octdec($match[1])); + } + }, + $value + +From 15dec68549d91fd9129fa3b09f212af1cd7807aa Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Thu, 10 Oct 2019 16:37:26 +0200 +Subject: [PATCH 3/3] CS + +--- + src/Translations.php | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/Translations.php b/src/Translations.php +index 05d6a3e..1fa38c8 100644 +--- a/src/Translations.php ++++ b/src/Translations.php +@@ -436,7 +436,7 @@ public function find($context, $original = '') + public function countTranslated() + { + $c = 0; +- foreach($this as $v) { ++ foreach ($this as $v) { + if ($v->hasTranslation()) { + $c++; + } + diff --git a/php-gettext-gettext.spec b/php-gettext-gettext.spec index 05c7b97..a800230 100644 --- a/php-gettext-gettext.spec +++ b/php-gettext-gettext.spec @@ -4,7 +4,7 @@ Name: php-gettext-gettext Version: 4.7.0 -Release: 1%{?dist} +Release: 2%{?dist} BuildArch: noarch License: MIT @@ -14,11 +14,14 @@ Source0: %{url}/archive/v%{version}.tar.gz # Upstream strips the tests from the tarball, so we have to generate it manually. # dltests.sh is used to do this, and is included in this repository. Source1: tests-v%{version}.tar.bz2 +Patch0: 230.patch BuildRequires: dos2unix -#BuildRequires: php-composer(gettext/languages) >= 2.3.0 -#BuildRequires: php-composer(gettext/languages) < 3.0.0 -BuildRequires: php-gettext-languages +%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8 +BuildRequires: (php-composer(gettext/languages) >= 2.3.0 with php-composer(gettext/languages) < 3) +%else +BuildRequires: php-gettext-languages >= 2.3.0 +%endif BuildRequires: phpunit Requires: php(language) >= 5.4.0 @@ -31,8 +34,11 @@ Requires: php-simplexml Requires: php-spl Requires: php-tokenizer -Requires: php-composer(gettext/languages) >= 2.3.0 -Requires: php-composer(gettext/languages) < 3.0.0 +%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8 +Requires: (php-composer(gettext/languages) >= 2.3.0 with php-composer(gettext/languages) < 3) +%else +Requires: php-gettext-languages >= 2.3.0 +%endif Provides: php-composer(gettext/gettext) = %{version} @@ -45,7 +51,8 @@ Autoloader: %{_datadir}/php/Gettext/autoload.php %prep -%autosetup -p1 -a1 -n Gettext-%{version} +%setup -a1 -n Gettext-%{version} +%patch0 -p1 # The documentation has the wrong newline codes dos2unix *.md @@ -84,8 +91,15 @@ sed -i "s:include_once.*:\ninclude_once '%{buildroot}/%{_datadir}/php/Gettext/au # if desired). Thus, we need to skip the tests on these integration points since they will fail # without the dependencies. There is an upstream issue about compatibility issues with Twig: # https://github.com/oscarotero/Gettext/issues/137 -phpunit --bootstrap tests/bootstrap.php --filter ^\(\(?!\(testBlade\|testTwig\)\).\)*$ tests +: run upstream test suite with all installed PHP versions +ret=0 +for cmd in php php71 php72 php73 php74; do + if which $cmd; then + $cmd %{_bindir}/phpunit --bootstrap tests/bootstrap.php --filter ^\(\(?!\(testBlade\|testTwig\)\).\)*$ tests + fi +done +exit $ret %files %license LICENSE @@ -97,6 +111,12 @@ phpunit --bootstrap tests/bootstrap.php --filter ^\(\(?!\(testBlade\|testTwig\)\ %changelog +* Thu Oct 10 2019 Remi Collet - 4.7.0-2 +- update to 4.7.0 +- use range dependencies +- add patch for PHP 7.4 from +- https://github.com/oscarotero/Gettext/pull/230 + * Thu Oct 10 2019 Sundeep Anand - 4.7.0-1 - Update to 4.7.0 (#1759099). - https://github.com/oscarotero/Gettext/blob/v4.7.0/CHANGELOG.md