siwinski pushed to php-react-promise (f22). "Added autoloader"

notifications at fedoraproject.org notifications at fedoraproject.org
Mon Jun 1 18:49:02 UTC 2015


From cdf19cfc2238371e6e0870b32c251559f2338bb4 Mon Sep 17 00:00:00 2001
From: Shawn Iwinski <shawn.iwinski at gmail.com>
Date: Mon, 1 Jun 2015 14:47:45 -0400
Subject: Added autoloader


diff --git a/php-react-promise.spec b/php-react-promise.spec
index 897445c..eef4f36 100644
--- a/php-react-promise.spec
+++ b/php-react-promise.spec
@@ -23,12 +23,11 @@
 # Build using "--without tests" to disable tests
 %global with_tests %{?_without_tests:0}%{!?_without_tests:1}
 
-%{!?phpdir:     %global phpdir     %{_datadir}/php}
-%{!?__phpunit:  %global __phpunit  %{_bindir}/phpunit}
+%{!?phpdir:  %global phpdir  %{_datadir}/php}
 
 Name:          php-%{composer_vendor}-%{composer_project}
 Version:       %{github_version}
-Release:       1%{?github_release}%{?dist}
+Release:       2%{?github_release}%{?dist}
 Summary:       A lightweight implementation of CommonJS Promises/A for PHP
 
 Group:         Development/Libraries
@@ -37,14 +36,17 @@ URL:           https://github.com/%{github_owner}/%{github_name}
 Source0:       %{url}/archive/%{github_commit}/%{name}-%{github_version}-%{github_commit}.tar.gz
 
 BuildArch:     noarch
+# Tests
 %if %{with_tests}
-BuildRequires: %{__phpunit}
-# composer.json
+BuildRequires: %{_bindir}/phpunit
+## composer.json
 BuildRequires: php(language) >= %{php_min_ver}
-# phpcompatinfo (computed from version 2.2.0)
+## phpcompatinfo (computed from version 2.2.0)
 BuildRequires: php-json
 BuildRequires: php-reflection
 BuildRequires: php-spl
+## Autoloader
+BuildRequires: php-composer(symfony/class-loader) >= 2.5
 %endif
 
 # composer.json
@@ -53,6 +55,8 @@ Requires:      php(language) >= %{php_min_ver}
 Requires:      php-json
 Requires:      php-reflection
 Requires:      php-spl
+# Autoloader
+Requires:      php-composer(symfony/class-loader) >= 2.5
 
 # Composer
 Provides:      php-composer(%{composer_vendor}/%{composer_project}) = %{version}
@@ -66,39 +70,45 @@ A lightweight implementation of CommonJS Promises/A [1] for PHP.
 %prep
 %setup -qn %{github_name}-%{github_commit}
 
+: Create autoloader
+(cat <<'AUTOLOAD'
+<?php
+
+if (!class_exists('Symfony\\Component\\ClassLoader\\Psr4ClassLoader', false)) {
+    require_once '%{phpdir}/Symfony/Component/ClassLoader/Psr4ClassLoader.php';
+}
+
+$loader = new \Symfony\Component\ClassLoader\Psr4ClassLoader();
+$loader->addPrefix('React\\Promise', __DIR__);
+$loader->register();
+
+require_once __DIR__ . '/functions_include.php';
+AUTOLOAD
+) | tee src/autoload.php
+
 
 %build
 # Empty build section, nothing required
 
 
 %install
-mkdir -pm 0755 %{buildroot}%{phpdir}/React/Promise
+mkdir -p %{buildroot}%{phpdir}/React/Promise
 cp -rp src/* %{buildroot}%{phpdir}/React/Promise/
 
 
 %check
 %if %{with_tests}
-# Create bootstrap
-cat > bootstrap.php <<'BOOTSTRAP'
+: Create tests bootstrap
+(cat <<'BOOTSTRAP'
 <?php
 
-spl_autoload_register(function ($class) {
-    $src = str_replace('\\', '/', $class).'.php';
-
-    if (!@include_once $src) {
-        $psr4_class = str_replace('React\\Promise\\', '', $class);
-        $psr4_src = str_replace('\\', '/', $psr4_class).'.php';
+require_once '%{buildroot}%{phpdir}/React/Promise/autoload.php';
 
-        @include_once $psr4_src;
-    }
-});
-
-require_once '%{buildroot}%{phpdir}/React/Promise/functions.php';
+$loader->addPrefix('React\\Promise', __DIR__ . '/tests');
 BOOTSTRAP
+) | tee bootstrap.php
 
-%{__phpunit} \
-    --bootstrap ./bootstrap.php \
-    --include-path %{buildroot}%{phpdir}:./tests
+%{_bindir}/phpunit --bootstrap ./bootstrap.php -v
 %else
 : Tests skipped
 %endif
@@ -107,12 +117,16 @@ BOOTSTRAP
 %files
 %{!?_licensedir:%global license %%doc}
 %license LICENSE
-%doc *.md composer.json
+%doc *.md
+%doc composer.json
 %dir %{phpdir}/React
      %{phpdir}/React/Promise
 
 
 %changelog
+* Mon Jun 01 2015 Shawn Iwinski <shawn.iwinski at gmail.com> - 2.2.0-2
+- Added autoloader
+
 * Sun Jan 04 2015 Shawn Iwinski <shawn.iwinski at gmail.com> - 2.2.0-1
 - Updated to 2.2.0 (BZ #1178411)
 
-- 
cgit v0.10.2


	http://pkgs.fedoraproject.org/cgit/php-react-promise.git/commit/?h=f22&id=cdf19cfc2238371e6e0870b32c251559f2338bb4


More information about the scm-commits mailing list