diff options
| -rw-r--r-- | 352.patch | 54 | ||||
| -rw-r--r-- | php-ramsey-uuid.spec | 33 | 
2 files changed, 80 insertions, 7 deletions
diff --git a/352.patch b/352.patch new file mode 100644 index 0000000..b7ba70d --- /dev/null +++ b/352.patch @@ -0,0 +1,54 @@ +From 2a39b0a67413e902274b09f640c6b68ffbd199fa Mon Sep 17 00:00:00 2001 +From: Remi Collet <remi@remirepo.net> +Date: Thu, 29 Oct 2020 16:34:55 +0100 +Subject: [PATCH 1/2] catch ValueError raised by PHP 8 + +--- + src/Generator/DefaultNameGenerator.php | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/src/Generator/DefaultNameGenerator.php b/src/Generator/DefaultNameGenerator.php +index 270e8fbe..be552b91 100644 +--- a/src/Generator/DefaultNameGenerator.php ++++ b/src/Generator/DefaultNameGenerator.php +@@ -29,7 +29,11 @@ class DefaultNameGenerator implements NameGeneratorInterface +     public function generate(UuidInterface $ns, string $name, string $hashAlgorithm): string +     { +         /** @var string|bool $bytes */ +-        $bytes = @hash($hashAlgorithm, $ns->getBytes() . $name, true); ++        try { ++            $bytes = @hash($hashAlgorithm, $ns->getBytes() . $name, true); ++        } catch (\ValueError $e) { ++            $bytes = false; // keep same behavior than PHP 7 */ ++        } +  +         if ($bytes === false) { +             throw new NameException(sprintf( + +From 3a488f24e05e711809f61626aeb8740d53e56feb Mon Sep 17 00:00:00 2001 +From: Remi Collet <remi@remirepo.net> +Date: Thu, 29 Oct 2020 16:40:08 +0100 +Subject: [PATCH 2/2] CS + +--- + src/Generator/DefaultNameGenerator.php | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/Generator/DefaultNameGenerator.php b/src/Generator/DefaultNameGenerator.php +index be552b91..1c0b0048 100644 +--- a/src/Generator/DefaultNameGenerator.php ++++ b/src/Generator/DefaultNameGenerator.php +@@ -28,11 +28,11 @@ class DefaultNameGenerator implements NameGeneratorInterface +     /** @psalm-pure */ +     public function generate(UuidInterface $ns, string $name, string $hashAlgorithm): string +     { +-        /** @var string|bool $bytes */ +         try { ++            /** @var string|bool $bytes */ +             $bytes = @hash($hashAlgorithm, $ns->getBytes() . $name, true); +         } catch (\ValueError $e) { +-            $bytes = false; // keep same behavior than PHP 7 */ ++            $bytes = false; // keep same behavior than PHP 7 +         } +  +         if ($bytes === false) { diff --git a/php-ramsey-uuid.spec b/php-ramsey-uuid.spec index c34c107..f9317b9 100644 --- a/php-ramsey-uuid.spec +++ b/php-ramsey-uuid.spec @@ -23,7 +23,7 @@  Name:           php-%{pk_vendor}-%{pk_name}  Version:        4.1.1 -Release:        1%{?dist} +Release:        2%{?dist}  Summary:        Library for generating and working with UUIDs  License:        MIT @@ -34,6 +34,7 @@ Source1:        makesrc.sh  # don't use codeception/aspect-mock  Patch0:         %{name}-tests.patch +Patch1:         https://patch-diff.githubusercontent.com/raw/ramsey/uuid/pull/352.patch  BuildArch:      noarch @@ -77,7 +78,14 @@ BuildRequires:  php-brick-math                      >= 0.8  BuildRequires:  php-ramsey-collection               >= 1.0  BuildRequires:  php-mockery                         >= 1.3  %endif +%if 0%{?fedora} >= 32 || 0%{?rhel} >= 9 +# https://github.com/ramsey/uuid/pull/350 +BuildRequires:  phpunit9 +%global phpunit %{_bindir}/phpunit9 +%else  BuildRequires:  phpunit8 >= 8.5 +%global phpunit %{_bindir}/phpunit8 +%endif  %endif  # Autoloader  BuildRequires:  php-fedora-autoloader-devel @@ -122,6 +130,7 @@ Autoloader: %{_datadir}/php/%{ns_vendor}/%{ns_project}/autoload.php  %prep  %setup -q -n %{gh_project}-%{gh_commit}  %patch0 -p1 -b .rpm +%patch1 -p1 -b .pr352  %build @@ -161,14 +170,17 @@ EOF  : Ignore tests using missing mocking libraries  find tests -type f -exec grep -Eq '(PHPMockery|Aspec|Moontoast)' {} \; -delete -print +: Ignore test with erratic result on Koji +FILTER="--filter '^((?!(testSerializationOfNodeProviderCollection)).)*$'" +  : Run upstream test suite  ret=0 -# TODO php 8: phpunit and mockery not compatible -for cmd in php php73 php74; do -  if which $cmd; then -   $cmd %{_bindir}/phpunit8 \ -     --no-coverage \ -     --verbose || ret=1 +for cmdarg in "php %{?phpunit}" php73 php74 php80; do +  if which $cmdarg; then +    set $cmdarg +    $1 ${2:-%{_bindir}/phpunit9} \ +      --no-coverage \ +      --verbose $FILTER || ret=1    fi  done  exit $ret @@ -186,5 +198,12 @@ exit $ret  %changelog +* Fri Nov  6 2020 Remi Collet <remi@remirepo.net> - 4.1.1-2 +- add patch for PHP 8 from merged PR +  https://github.com/ramsey/uuid/pull/352 +- switch to phpunit9 +  https://github.com/ramsey/uuid/pull/350 +- ignore 1 test with erratic result from review #1884542 +  * Fri Oct  2 2020 Remi Collet <remi@remirepo.net> - 4.1.1-1  - initial package  | 
