From 79dd656635c8a4321efb86ed540bbaba2f3f5117 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Thu, 7 Dec 2017 12:50:39 +0100
Subject: switch from zend-loader to fedora/autoloader

---
 php-zendframework-zend-validator.spec | 52 +++++++++++++++++++++++++----------
 1 file changed, 37 insertions(+), 15 deletions(-)

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

diff --git a/php-zendframework-zend-validator.spec b/php-zendframework-zend-validator.spec
index d5173ce..a3e98aa 100644
--- a/php-zendframework-zend-validator.spec
+++ b/php-zendframework-zend-validator.spec
@@ -19,9 +19,11 @@
 %global with_tests   0%{!?_without_tests:1}
 %endif
 
+# TODO switch BR to fedora-autoloader + tests
+
 Name:           php-%{gh_owner}-%{gh_project}
 Version:        2.10.1
-Release:        2%{?dist}
+Release:        3%{?dist}
 Summary:        Zend Framework %{library} component
 
 Group:          Development/Libraries
@@ -43,7 +45,7 @@ BuildRequires:  php-hash
 BuildRequires:  php-intl
 BuildRequires:  php-pcre
 BuildRequires:  php-spl
-BuildRequires:  php-composer(%{gh_owner}/zend-stdlib)             >= 2.7.6
+BuildRequires:  php-autoloader(%{gh_owner}/zend-stdlib)           >= 2.7.6
 BuildRequires:  php-composer(container-interop/container-interop) >= 1.1
 # From composer, "require-dev": {
 #        "zendframework/zend-cache": "^2.6.1",
@@ -77,6 +79,7 @@ BuildRequires:  %{phpunit}
 # Autoloader
 BuildRequires:  php-composer(%{gh_owner}/zend-loader)           >= 2.5
 %endif
+BuildRequires:  php-fedora-autoloader-devel
 
 # From composer, "require": {
 #        "php": "^5.6 || ^7.0",
@@ -84,8 +87,8 @@ BuildRequires:  php-composer(%{gh_owner}/zend-loader)           >= 2.5
 #        "container-interop/container-interop": "^1.1"
 Requires:       php(language) >= 5.5
 %if ! %{bootstrap}
-Requires:       php-composer(%{gh_owner}/zend-stdlib)             >= 2.7.6
-Requires:       php-composer(%{gh_owner}/zend-stdlib)             <  4
+Requires:       php-autoloader(%{gh_owner}/zend-stdlib)           >= 2.7.6
+Requires:       php-autoloader(%{gh_owner}/zend-stdlib)           <  4
 Requires:       php-composer(container-interop/container-interop) >= 1.1
 Requires:       php-composer(container-interop/container-interop) <  2
 # From composer, "suggest": {
@@ -108,6 +111,8 @@ Suggests:       php-composer(%{gh_owner}/zend-session)
 Suggests:       php-composer(%{gh_owner}/zend-uri)
 %endif
 %endif
+# Autoloader
+Requires:       php-composer(fedora/autoloader)
 # From phpcompatinfo report for version 2.10.1
 Requires:       php-ctype
 Requires:       php-date
@@ -120,6 +125,7 @@ Requires:       php-spl
 Obsoletes:      php-ZendFramework2-%{library} < 2.5
 Provides:       php-ZendFramework2-%{library} = %{version}
 Provides:       php-composer(%{gh_owner}/%{gh_project}) = %{version}
+Provides:       php-autoloader(%{gh_owner}/%{gh_project}) = %{version}
 
 
 %description
@@ -138,12 +144,27 @@ 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/Stdlib/autoload.php',
+]);
+\Fedora\Autoloader\Dependencies::optional([
+    '%{php_home}/Zend/Db/autoload.php',
+    '%{php_home}/Zend/Filter/autoload.php',
+    '%{php_home}/Zend/I18n/autoload.php',
+    '%{php_home}/Zend/I18n/Translator/autoload.php',
+    '%{php_home}/Zend/Math/autoload.php',
+    '%{php_home}/Zend/ServiceManager/autoload.php',
+    '%{php_home}/Zend/Validator/autoload.php',
+    '%{php_home}/Zend/Session/autoload.php',
+    '%{php_home}/Zend/Uri/Translator/Resources.php',
+]);
+EOF
 
 
 %install
-rm -rf %{buildroot}
-
 mkdir -p   %{buildroot}%{php_home}/Zend/
 cp -pr src %{buildroot}%{php_home}/Zend/%{library}
 
@@ -153,14 +174,12 @@ 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';
+# For BR without new autoloader
+\Fedora\Autoloader\Dependencies::required([
+    '%{php_home}/Zend/autoload.php',
+]);
+\Fedora\Autoloader\Autoload::addPsr4('ZendTest\\%{library}\\', dirname(__DIR__) . '/test');
 EOF
 
 # PHP 7.2 https://github.com/zendframework/zend-validator/issues/196
@@ -186,6 +205,9 @@ exit $ret
 
 
 %changelog
+* Thu Dec  7 2017 Remi Collet <remi@remirepo.net> - 2.10-1-3
+- switch from zend-loader to fedora/autoloader
+
 * Tue Oct 31 2017 Remi Collet <remi@remirepo.net> - 2.10.1-2
 - fix FTBFS from Koschei, add patch for test with 7.2 from
   https://github.com/zendframework/zend-validator/pull/205
-- 
cgit