From 8b9a3424d30034e439c7977533aeaa1613a6211e Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 31 Mar 2021 11:28:43 +0200 Subject: add minimal fix for PHP 8 use range dependencies --- php-aura-di-php8.patch | 24 ++++++++++++++++++++++++ php-aura-di.spec | 37 ++++++++++++++++++++++++++++++------- 2 files changed, 54 insertions(+), 7 deletions(-) create mode 100644 php-aura-di-php8.patch diff --git a/php-aura-di-php8.patch b/php-aura-di-php8.patch new file mode 100644 index 0000000..889af96 --- /dev/null +++ b/php-aura-di-php8.patch @@ -0,0 +1,24 @@ +diff -up ./src/Resolver/AutoResolver.php.php8 ./src/Resolver/AutoResolver.php +--- ./src/Resolver/AutoResolver.php.php8 2021-03-31 11:23:21.738880158 +0200 ++++ ./src/Resolver/AutoResolver.php 2021-03-31 11:23:24.532869778 +0200 +@@ -54,7 +54,7 @@ class AutoResolver extends Resolver + } + + // use an explicit auto-resolution? +- $rtype = $rparam->getClass(); ++ $rtype = @$rparam->getClass(); + if ($rtype && isset($this->types[$rtype->name])) { + return $this->types[$rtype->name]; + } +diff -up ./src/Resolver/Resolver.php.php8 ./src/Resolver/Resolver.php +--- ./src/Resolver/Resolver.php.php8 2021-03-31 11:21:49.964221101 +0200 ++++ ./src/Resolver/Resolver.php 2021-03-31 11:22:01.635177740 +0200 +@@ -266,7 +266,7 @@ class Resolver + $spec = [[], []]; + + // fetch the values for parents so we can inherit them +- $parent = get_parent_class($class); ++ $parent = class_exists($class) ? get_parent_class($class) : null; + if ($parent) { + $spec = $this->getUnified($parent); + } diff --git a/php-aura-di.spec b/php-aura-di.spec index 636fe57..f7047e9 100644 --- a/php-aura-di.spec +++ b/php-aura-di.spec @@ -1,11 +1,14 @@ # remirepo/Fedora spec file for php-aura-di # -# Copyright (c) 2015-2017 Remi Collet +# Copyright (c) 2015-2021 Remi Collet # License: CC-BY-SA # http://creativecommons.org/licenses/by-sa/4.0/ # # Please, preserve the changelog entries # + +%bcond_without tests + %global bootstrap 0 %global gh_commit f676b38a0d1c3b0d7897b0a082f4811eb8b08faa %global gh_short %(c=%{gh_commit}; echo ${c:0:7}) @@ -16,11 +19,10 @@ %global ns_owner Aura %global ns_project Di %global php_home %{_datadir}/php -%global with_tests 0%{!?_without_tests:1} Name: php-%{pk_owner}-%{pk_project} Version: 3.4.0 -Release: 1%{?dist} +Release: 9%{?dist} Summary: A serializable dependency injection container Group: Development/Libraries @@ -28,12 +30,21 @@ License: MIT URL: https://github.com/%{gh_owner}/%{gh_project} Source0: https://github.com/%{gh_owner}/%{gh_project}/archive/%{gh_commit}/%{name}-%{version}-%{gh_short}.tar.gz +# Minimal patch for PHP 8 +Patch0: %{name}-php8.patch + BuildArch: noarch BuildRequires: php-composer(fedora/autoloader) # Tests -%if %{with_tests} +%if %{with tests} BuildRequires: php(language) >= 5.5.0 +%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8 +BuildRequires: (php-composer(container-interop/container-interop) >= 1.0 with php-composer(container-interop/container-interop) < 2) +# remirepo:4 +%else +BuildRequires: php-composer(container-interop/container-interop) < 2 BuildRequires: php-composer(container-interop/container-interop) >= 1.0 +%endif BuildRequires: php-reflection BuildRequires: php-spl BuildRequires: php-composer(phpunit/phpunit) @@ -47,8 +58,14 @@ BuildRequires: php-composer(phpunit/phpunit) # "php": ">=5.5.0" # "container-interop/container-interop": "~1.0" Requires: php(language) >= 5.5.0 -Requires: php-composer(container-interop/container-interop) >= 1.0 +# remirepo:1 +%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8 +Requires: (php-composer(container-interop/container-interop) >= 1.0 with php-composer(container-interop/container-interop) < 2) +# remirepo:4 +%else Requires: php-composer(container-interop/container-interop) < 2 +Requires: php-composer(container-interop/container-interop) >= 1.0 +%endif # From phpcompatinfo report for version 3.2.0 Requires: php-reflection Requires: php-spl @@ -69,6 +86,7 @@ Autoloader: %{php_home}/%{ns_owner}/%{ns_project}/autoload.php %prep %setup -q -n %{gh_project}-%{gh_commit} +%patch0 -p1 %build @@ -90,7 +108,7 @@ cp -pr src %{buildroot}%{php_home}/%{ns_owner}/%{ns_project} %check -%if %{with_tests} +%if %{with tests} : Ignore test using not available dependency rm tests/ContainerTest.php @@ -102,7 +120,7 @@ require '%{buildroot}/%{php_home}/%{ns_owner}/%{ns_project}/autoload.php'; EOF ret=0 -for cmd in php php56 php70 php71 php72; do +for cmd in php php73 php74 php80; do if which $cmd; then $cmd %{_bindir}/phpunit --verbose || ret=1 fi @@ -114,6 +132,7 @@ exit $ret %files +# remirepo:1 %{!?_licensedir:%global license %%doc} %license LICENSE %doc *.md @@ -123,6 +142,10 @@ exit $ret %changelog +* Wed Mar 31 2021 Remi Collet - 3.4.0-9 +- add minimal fix for PHP 8 +- use range dependencies + * Tue Aug 8 2017 Remi Collet - 3.4.0-1 - Update to 3.4.0 -- cgit