From b01bf551684ea4a04734192aa77df30370a63145 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Tue, 28 Nov 2017 09:23:27 +0100
Subject: switch from zend-loader to fedora/autoloader

---
 php-zendframework-zend-code.spec | 66 ++++++++++++++++++----------------------
 1 file changed, 30 insertions(+), 36 deletions(-)

(limited to 'php-zendframework-zend-code.spec')

diff --git a/php-zendframework-zend-code.spec b/php-zendframework-zend-code.spec
index 33c6814..61d9621 100644
--- a/php-zendframework-zend-code.spec
+++ b/php-zendframework-zend-code.spec
@@ -21,7 +21,7 @@
 
 Name:           php-%{gh_owner}-%{gh_project}
 Version:        3.1.0
-Release:        1%{?dist}
+Release:        2%{?dist}
 Summary:        Zend Framework %{library} component
 
 Group:          Development/Libraries
@@ -30,7 +30,6 @@ URL:            https://zendframework.github.io/%{gh_project}/
 Source0:        %{gh_commit}/%{name}-%{version}-%{gh_short}.tgz
 Source1:        makesrc.sh
 
-BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root
 BuildArch:      noarch
 # Tests
 %if %{with_tests}
@@ -39,7 +38,7 @@ BuildRequires:  php-pcre
 BuildRequires:  php-reflection
 BuildRequires:  php-spl
 BuildRequires:  php-tokenizer
-BuildRequires:  php-composer(%{gh_owner}/zend-eventmanager)     >= 2.6
+BuildRequires:  php-autoloader(%{gh_owner}/zend-eventmanager)   >= 2.6
 # From composer, "require-dev": {
 #        "ext-phar": "*",
 #        "doctrine/annotations": "~1.0",
@@ -48,19 +47,21 @@ BuildRequires:  php-composer(%{gh_owner}/zend-eventmanager)     >= 2.6
 #        "squizlabs/php_codesniffer": "^2.5",
 #        "phpunit/PHPUnit": "^4.8.21"
 BuildRequires:  php-composer(doctrine/annotations)              >= 1.0
-BuildRequires:  php-composer(%{gh_owner}/zend-stdlib)           >= 2.7
+BuildRequires:  php-autoloader(%{gh_owner}/zend-stdlib)         >= 2.7
 BuildRequires:  php-composer(phpunit/phpunit)                   >= 4.8.21
 # Autoloader
 BuildRequires:  php-composer(%{gh_owner}/zend-loader)           >= 2.5
 %endif
+# Autoloader
+BuildRequires:  php-fedora-autoloader-devel
 
 # From composer, "require": {
 #        "php": "^5.6 || 7.0.0 - 7.0.4 || ^7.0.6",
 #        "zendframework/zend-eventmanager": "^2.6 || ^3.0""
 Requires:       php(language) >= 5.6
 %if ! %{bootstrap}
-Requires:       php-composer(%{gh_owner}/zend-eventmanager)     >= 2.6
-Requires:       php-composer(%{gh_owner}/zend-eventmanager)     <  4
+Requires:       php-autoloader(%{gh_owner}/zend-eventmanager)   >= 2.6
+Requires:       php-autoloader(%{gh_owner}/zend-eventmanager)   <  4
 # From composer, "suggest": {
 #         "doctrine/annotations": "Doctrine\\Common\\Annotations >=1.0 for annotation features",
 #         "zendframework/zend-stdlib": "Zend\\Stdlib component"
@@ -68,6 +69,8 @@ Requires:       php-composer(%{gh_owner}/zend-eventmanager)     <  4
 Suggests:       php-composer(doctrine/annotations)
 Suggests:       php-composer(%{gh_owner}/zend-stdlib)
 %endif
+# Autoloader
+Requires:       php-composer(fedora/autoloader)
 %endif
 # From phpcompatinfo report for version 2.6.2
 Requires:       php-pcre
@@ -98,12 +101,20 @@ mv LICENSE.md LICENSE
 
 
 %build
-# Empty build section, nothing required
+: Create autoloader
+phpab --template fedora --output src/autoload.php src
+cat << 'EOF' | tee -a src/autoload.php
+\Fedora\Autoloader\Dependencies::required([
+    '%{php_home}/Zend/EventManager/autoload.php',
+]);
+\Fedora\Autoloader\Dependencies::optional([
+    '%{php_home}/Doctrine/Common/Annotations/autoload.php',
+    '%{php_home}/Zend/Stdlib/autoload.php',
+]);
+EOF
 
 
 %install
-rm -rf %{buildroot}
-
 mkdir -p   %{buildroot}%{php_home}/Zend/
 cp -pr src %{buildroot}%{php_home}/Zend/%{library}
 
@@ -113,43 +124,23 @@ cp -pr src %{buildroot}%{php_home}/Zend/%{library}
 mkdir vendor
 cat << 'EOF' | tee vendor/autoload.php
 <?php
-require_once '%{php_home}/Zend/Loader/AutoloaderFactory.php';
-Zend\Loader\AutoloaderFactory::factory(array(
-    'Zend\Loader\StandardAutoloader' => array(
-        'namespaces' => array(
-           'ZendTest\\%{library}' => dirname(__DIR__).'/test/',
-           'Zend\\%{library}'     => '%{buildroot}%{php_home}/Zend/%{library}'
-))));
-require_once '%{php_home}/Zend/autoload.php';
+require_once '%{buildroot}%{php_home}/Zend/%{library}/autoload.php';
+\Fedora\Autoloader\Autoload::addPsr4('ZendTest\\%{library}\\', dirname(__DIR__) . '/test');
 EOF
 
-# remirepo:11
-run=0
 ret=0
-if which php56; then
-   php56 %{_bindir}/phpunit --include-path=%{buildroot}%{php_home} || ret=1
-   run=1
-fi
-if which php71; then
-   php70 %{_bindir}/phpunit --include-path=%{buildroot}%{php_home} || ret=1
-   run=1
-fi
-if [ $run -eq 0 ]; then
-%{_bindir}/phpunit --include-path=%{buildroot}%{php_home} --verbose
-# remirepo:2
-fi
+for cmd in php php70 php71 php72; do
+  if which $cmd; then
+    $cmd %{_bindir}/phpunit --verbose || ret=1
+  fi
+done
 exit $ret
 %else
 : Test suite disabled
 %endif
 
 
-%clean
-rm -rf %{buildroot}
-
-
 %files
-%defattr(-,root,root,-)
 %{!?_licensedir:%global license %%doc}
 %license LICENSE
 %doc *.md
@@ -158,6 +149,9 @@ rm -rf %{buildroot}
 
 
 %changelog
+* Tue Nov 28 2017 Remi Collet <remi@remirepo.net> - 3.1.0-2
+- switch from zend-loader to fedora/autoloader
+
 * Tue Oct 25 2016 Remi Collet <remi@fedoraproject.org> - 3.1.0-1
 - update to 3.1.0
 - raise dependency on PHP 5.6
-- 
cgit