summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--php-bartlett-umlwriter-autoload.php28
-rw-r--r--php-bartlett-umlwriter-rpm.patch68
-rw-r--r--php-bartlett-umlwriter.spec21
3 files changed, 50 insertions, 67 deletions
diff --git a/php-bartlett-umlwriter-autoload.php b/php-bartlett-umlwriter-autoload.php
new file mode 100644
index 0000000..7f70544
--- /dev/null
+++ b/php-bartlett-umlwriter-autoload.php
@@ -0,0 +1,28 @@
+<?php
+/**
+ * Autoloader for bartlett/umlwriter and its dependencies
+ */
+
+$vendorDir = '/usr/share/php';
+
+// Use Symfony autoloader
+if (!isset($fedoraClassLoader) || !($fedoraClassLoader instanceof \Symfony\Component\ClassLoader\ClassLoader)) {
+ if (!class_exists('Symfony\\Component\\ClassLoader\\ClassLoader', false)) {
+ require_once $vendorDir . '/Symfony/Component/ClassLoader/ClassLoader.php';
+ }
+
+ $fedoraClassLoader = new \Symfony\Component\ClassLoader\ClassLoader();
+ $fedoraClassLoader->register();
+}
+$fedoraClassLoader->addPrefixes(array(
+ 'Symfony\\Component' => $vendorDir,
+ 'TokenReflection' => $vendorDir,
+ 'Bartlett\\Umlwiter' => dirname(dirname(__DIR__)),
+));
+if (is_file('/usr/share/php-bartlett-PHP-CompatInfo/compatinfo.sqlite')) {
+ putenv('BARTLETT_COMPATINFO_DB=/usr/share/php-bartlett-PHP-CompatInfo/compatinfo.sqlite');
+}
+
+// Dependencies
+require_once $vendorDir . '/SebastianBergmann/Version/autoload.php';
+require_once $vendorDir . '/Bartlett/Reflect/autoload.php';
diff --git a/php-bartlett-umlwriter-rpm.patch b/php-bartlett-umlwriter-rpm.patch
index 994f79c..458af29 100644
--- a/php-bartlett-umlwriter-rpm.patch
+++ b/php-bartlett-umlwriter-rpm.patch
@@ -1,9 +1,7 @@
diff -up ./bin/umlwriter.rpm ./bin/umlwriter
---- ./bin/umlwriter.rpm 2015-03-31 11:24:18.000000000 +0200
-+++ ./bin/umlwriter 2015-03-31 11:29:43.000000000 +0200
-@@ -1,24 +1,36 @@
--#!/usr/bin/env php
-+#!/usr/bin/env php
+--- ./bin/umlwriter.rpm 2015-04-02 13:07:20.000000000 +0200
++++ ./bin/umlwriter 2015-06-26 10:34:32.782633902 +0200
+@@ -2,23 +2,14 @@
<?php
$appName = 'umlWriter';
@@ -18,72 +16,16 @@ diff -up ./bin/umlwriter.rpm ./bin/umlwriter
- }
-}
-require_once $vendorDir . '/autoload.php';
-+putenv('BARTLETT_COMPATINFO_DB=/usr/share/php-bartlett-PHP-CompatInfo/compatinfo.sqlite');
-
+-
if (PHP_SAPI !== 'cli') {
return;
}
+$vendorDir = '/usr/share/php';
-+require_once $vendorDir . '/PhpParser/Autoloader.php';
-+PhpParser\Autoloader::register();
-+
-+require_once $vendorDir . '/Symfony/Component/ClassLoader/UniversalClassLoader.php';
-+require_once $vendorDir . '/SebastianBergmann/Version/autoload.php';
-+
-+use Symfony\Component\ClassLoader\UniversalClassLoader;
-+
-+$loader = new UniversalClassLoader();
-+$loader->registerNamespaces(array(
-+ 'Symfony\\Component' => $vendorDir,
-+ 'Doctrine\\Common' => $vendorDir,
-+ 'phpDocumentor\\Reflection' => $vendorDir,
-+ 'Seld\\JsonLint' => $vendorDir,
-+ 'JsonSchema' => $vendorDir,
-+ 'Bartlett' => $vendorDir,
-+ 'TokenReflection' => $vendorDir,
-+));
-+$loader->useIncludePath(true);
-+$loader->register();
++require_once $vendorDir . '/Bartlett/UmlWriter/autoload.php';
+
use Bartlett\UmlWriter\Console\Application;
-$application = new Application($appName, '1.0');
+$application = new Application($appName, '@package_version@');
$application->run();
-diff -up ./tests/bootstrap.php.rpm ./tests/bootstrap.php
---- ./tests/bootstrap.php.rpm 2015-03-31 09:46:46.000000000 +0200
-+++ ./tests/bootstrap.php 2015-03-31 11:30:51.000000000 +0200
-@@ -1,6 +1,30 @@
- <?php
-
- $baseDir = dirname(__DIR__);
--$vendorDir = $baseDir . '/vendor';
-+$vendorDir = '/usr/share/php';
-+putenv('BARTLETT_COMPATINFO_DB=/usr/share/php-bartlett-PHP-CompatInfo/compatinfo.sqlite');
-
--require_once $vendorDir . '/autoload.php';
-+require_once $vendorDir . '/PhpParser/Autoloader.php';
-+PhpParser\Autoloader::register();
-+require_once $vendorDir . '/SebastianBergmann/Version/autoload.php';
-+require_once $vendorDir . '/Symfony/Component/ClassLoader/UniversalClassLoader.php';
-+
-+use Symfony\Component\ClassLoader\UniversalClassLoader;
-+
-+$loader = new UniversalClassLoader();
-+$loader->registerNamespaces(array(
-+ 'Symfony\\Component' => $vendorDir,
-+ 'Doctrine\\Common' => $vendorDir,
-+ 'phpDocumentor\\Reflection' => $vendorDir,
-+ 'Seld\\JsonLint' => $vendorDir,
-+ 'JsonSchema' => $vendorDir,
-+ 'Bartlett\\UmlWriter' => $baseDir . '/src',
-+ 'Bartlett\\Tests\\UmlWriter' => $baseDir . '/tests',
-+ 'Bartlett' => $vendorDir,
-+ 'TokenReflection' => $vendorDir,
-+));
-+
-+$loader->register();
-+
-+# Class not catched by autoloader
-+require $vendorDir . '/Bartlett/Reflect.php';
diff --git a/php-bartlett-umlwriter.spec b/php-bartlett-umlwriter.spec
index eda1d5c..2801ece 100644
--- a/php-bartlett-umlwriter.spec
+++ b/php-bartlett-umlwriter.spec
@@ -1,4 +1,4 @@
-# spec file for php-bartlett-umlwriter
+# remirepo/fedora spec file for php-bartlett-umlwriter
#
# Copyright (c) 2015 Remi Collet
# License: CC-BY-SA
@@ -21,7 +21,7 @@
Name: php-bartlett-umlwriter
Version: 1.0.0
-%global specrel 4
+%global specrel 5
Release: %{?gh_date:0.%{specrel}.%{?prever}%{!?prever:%{gh_date}git%{gh_short}}}%{!?gh_date:%{specrel}}%{?dist}
Summary: Create UML class diagrams from your PHP source
@@ -31,6 +31,9 @@ URL: http://php5.laurent-laville.org/umlwriter/
Source0: https://github.com/%{gh_owner}/%{gh_project}/archive/%{gh_commit}/%{gh_project}-%{version}%{?prever}-%{gh_short}.tar.gz
# Autoloader for RPM - die composer !
+Source1: %{name}-autoload.php
+
+# Use out autoloader
Patch0: %{name}-rpm.patch
BuildArch: noarch
@@ -41,6 +44,9 @@ BuildRequires: php-composer(symfony/console) >= 2.5
BuildRequires: php-composer(sebastian/version) >= 1.0
BuildRequires: php-composer(bartlett/php-reflect) >= 3.0
BuildRequires: php-composer(andrewsville/php-token-reflection) >= 1.4
+# For our patch / autoloader
+BuildRequires: php-composer(symfony/class-loader)
+BuildRequires: php-bartlett-PHP-Reflect >= 3.1.1-3
%endif
# From composer.json
@@ -66,8 +72,9 @@ Requires: php-composer(bartlett/php-reflect) < 4
%endif
Requires: php-composer(andrewsville/php-token-reflection) >= 1.4
Requires: php-composer(andrewsville/php-token-reflection) < 2
-# For our patch
+# For our patch / autoloader
Requires: php-composer(symfony/class-loader)
+Requires: php-bartlett-PHP-Reflect >= 3.1.1-3
Provides: php-composer(bartlett/umlwriter) = %{version}
@@ -89,6 +96,7 @@ interface and trait definitions in your PHP project.
%setup -q -n %{gh_project}-%{gh_commit}
%patch0 -p1 -b .rpm
+cp %{SOURCE1} src/Bartlett/UmlWriter/autoload.php
sed -e 's/@package_version@/%{version}%{?prever}/' \
-i $(find src -name \*.php) bin/umlwriter
@@ -107,7 +115,9 @@ install -D -p -m 755 bin/umlwriter %{buildroot}%{_bindir}/umlwriter
%check
%if %{with_tests}
-%{_bindir}/phpunit -v
+%{_bindir}/phpunit \
+ --bootstrap src/Bartlett/UmlWriter/autoload.php \
+ --verbose
%else
: Test suite disabled
%endif
@@ -123,6 +133,9 @@ install -D -p -m 755 bin/umlwriter %{buildroot}%{_bindir}/umlwriter
%changelog
+* Fri Jun 26 2015 Remi Collet <remi@fedoraproject.org> - 1.0.0-5
+- rewrite autoloader
+
* Mon Jun 22 2015 Remi Collet <remi@fedoraproject.org> - 1.0.0-4
- fix Autoload