From bcc35e0d0bf613d92b4b3e6332c5a7f6de52252a Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Fri, 26 Jun 2015 11:32:05 +0200 Subject: php-bartlett-PHP-CompatInfo: rewrite autoloader --- php-bartlett-PHP-CompatInfo-4.3.0-rpm.patch | 123 ++++++++++------------------ php-bartlett-PHP-CompatInfo-autoload.php | 25 ++++++ php-bartlett-PHP-CompatInfo.spec | 39 ++++----- 3 files changed, 90 insertions(+), 97 deletions(-) create mode 100644 php-bartlett-PHP-CompatInfo-autoload.php diff --git a/php-bartlett-PHP-CompatInfo-4.3.0-rpm.patch b/php-bartlett-PHP-CompatInfo-4.3.0-rpm.patch index c64a75e..b1bbb9e 100644 --- a/php-bartlett-PHP-CompatInfo-4.3.0-rpm.patch +++ b/php-bartlett-PHP-CompatInfo-4.3.0-rpm.patch @@ -1,6 +1,6 @@ diff -up ./bin/phpcompatinfo.json.dist.rpm ./bin/phpcompatinfo.json.dist ---- ./bin/phpcompatinfo.json.dist.rpm 2015-04-04 15:32:17.536201524 +0200 -+++ ./bin/phpcompatinfo.json.dist 2015-04-04 15:32:37.776282296 +0200 +--- ./bin/phpcompatinfo.json.dist.rpm 2015-06-16 10:56:41.000000000 +0200 ++++ ./bin/phpcompatinfo.json.dist 2015-06-26 11:15:13.028747350 +0200 @@ -6,6 +6,19 @@ } ], @@ -22,89 +22,76 @@ diff -up ./bin/phpcompatinfo.json.dist.rpm ./bin/phpcompatinfo.json.dist "analysers" : [ ], diff -up ./bin/phpcompatinfo.rpm ./bin/phpcompatinfo ---- ./bin/phpcompatinfo.rpm 2015-04-04 08:52:23.000000000 +0200 -+++ ./bin/phpcompatinfo 2015-04-04 15:33:59.668609143 +0200 -@@ -16,8 +16,30 @@ if (\Phar::running()) { - putenv("BARTLETTRC=" . strtolower($appName) . '.json'); - } +--- ./bin/phpcompatinfo.rpm 2015-06-16 10:56:41.000000000 +0200 ++++ ./bin/phpcompatinfo 2015-06-26 11:15:13.033747371 +0200 +@@ -1,23 +1,13 @@ + #!/usr/bin/env php + setUseIncludePath(true); -+ -+putenv('BARTLETT_COMPATINFO_DB=/usr/share/php-bartlett-PHP-CompatInfo/compatinfo.sqlite'); -+ -+$vendorDir = '/usr/share/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, -+ 'Psr\\Log' => $vendorDir, -+ 'Monolog' => $vendorDir, -+ 'Bartlett' => $vendorDir, -+)); -+$loader->register(); if (PHP_SAPI !== 'cli') { return; -@@ -28,5 +50,5 @@ use Bartlett\CompatInfo\Console\Applicat +@@ -28,5 +18,5 @@ use Bartlett\CompatInfo\Console\Applicat Environment::setScanDir(); -$application = new Application($appName, '4.3'); -+$application = new Application($appName, '@package_version@'); ++$application = new Application($appName, '4.3.0'); $application->run(); diff -up ./data/handleDB.php.rpm ./data/handleDB.php ---- ./data/handleDB.php.rpm 2015-04-04 08:52:23.000000000 +0200 -+++ ./data/handleDB.php 2015-04-04 15:31:55.188112331 +0200 -@@ -11,7 +11,18 @@ +--- ./data/handleDB.php.rpm 2015-06-16 10:56:41.000000000 +0200 ++++ ./data/handleDB.php 2015-06-26 11:15:13.028747350 +0200 +@@ -11,7 +11,8 @@ * @since Release 4.0.0alpha3 */ -require_once dirname(__DIR__) . '/vendor/autoload.php'; -+$baseDir = dirname(__DIR__); -+$vendorDir = '/usr/share/php'; -+require_once $vendorDir . '/Symfony/Component/ClassLoader/UniversalClassLoader.php'; -+use Symfony\Component\ClassLoader\UniversalClassLoader; -+ -+$loader = new UniversalClassLoader(); -+$loader->registerNamespaces(array( -+ 'Symfony\\Component' => $vendorDir, -+ )); -+ -+$loader->register(); ++require_once __DIR__ . '/../src/Bartlett/CompatInfo/autoload.php'; + require_once __DIR__ . '/ReferenceCollection.php'; use Bartlett\CompatInfo\Reference\ExtensionFactory; diff -up ./src/Bartlett/CompatInfo/Environment.php.rpm ./src/Bartlett/CompatInfo/Environment.php ---- ./src/Bartlett/CompatInfo/Environment.php.rpm 2015-04-04 08:52:23.000000000 +0200 -+++ ./src/Bartlett/CompatInfo/Environment.php 2015-04-04 15:31:55.188112331 +0200 -@@ -34,6 +34,10 @@ class Environment +--- ./src/Bartlett/CompatInfo/Environment.php.rpm 2015-06-26 11:20:20.075019885 +0200 ++++ ./src/Bartlett/CompatInfo/Environment.php 2015-06-26 11:23:06.329708917 +0200 +@@ -34,6 +34,11 @@ class Environment */ public static function initRefDb() { -+ if ($database = getenv('BARTLETT_COMPATINFO_DB')) { ++ if (($database = getenv('BARTLETT_COMPATINFO_DB')) && file_exists($database)) { ++ return new \PDO('sqlite:' . $database); ++ } else if (file_exists($database = '/usr/share/php-bartlett-PHP-CompatInfo/compatinfo.sqlite')) { + return new \PDO('sqlite:' . $database); + } -+ $database = 'compatinfo.sqlite'; $tempDir = sys_get_temp_dir() . '/bartlett'; diff -up ./tests/bootstrap.php.rpm ./tests/bootstrap.php ---- ./tests/bootstrap.php.rpm 2015-04-04 08:52:23.000000000 +0200 -+++ ./tests/bootstrap.php 2015-04-04 15:31:55.188112331 +0200 -@@ -1,8 +1,31 @@ +--- ./tests/bootstrap.php.rpm 2015-06-16 10:56:41.000000000 +0200 ++++ ./tests/bootstrap.php 2015-06-26 11:17:16.429258776 +0200 +@@ -1,8 +1,11 @@ addPrefix('Bartlett\\Tests\\CompatInfo', $baseDir . '/tests'); -+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( -+ 'Doctrine\\Common' => $vendorDir, -+ 'phpDocumentor\\Reflection' => $vendorDir, -+ 'Symfony\\Component' => $vendorDir, -+ 'Seld\\JsonLint' => $vendorDir, -+ 'JsonSchema' => $vendorDir, -+ 'Bartlett\\Reflect' => $vendorDir, -+ 'Bartlett\\UmlWriter' => $vendorDir, -+ 'Bartlett\\Tests\\CompatInfo' => $baseDir . '/tests', -+ 'Bartlett' => $baseDir . '/src', -+ )); -+ -+$loader->register(); -+ ++putenv('BARTLETT_COMPATINFO_DB='.dirname(__DIR__).'/data/compatinfo.sqlite'); +# Class not catched by autoloader -+require $vendorDir . '/Bartlett/Reflect.php'; require __DIR__ . '/Reference/GenericTest.php'; diff --git a/php-bartlett-PHP-CompatInfo-autoload.php b/php-bartlett-PHP-CompatInfo-autoload.php new file mode 100644 index 0000000..d40d05c --- /dev/null +++ b/php-bartlett-PHP-CompatInfo-autoload.php @@ -0,0 +1,25 @@ +register(); +} +$fedoraClassLoader->addPrefixes(array( + 'Bartlett\\CompatInfo' => 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 . '/Bartlett/Reflect/autoload.php'; diff --git a/php-bartlett-PHP-CompatInfo.spec b/php-bartlett-PHP-CompatInfo.spec index 5c04fdf..5bc28db 100644 --- a/php-bartlett-PHP-CompatInfo.spec +++ b/php-bartlett-PHP-CompatInfo.spec @@ -16,7 +16,7 @@ Name: php-bartlett-PHP-CompatInfo Version: 4.3.0 -%global specrel 2 +%global specrel 3 Release: %{?gh_date:0.%{specrel}.%{?prever}%{!?prever:%{gh_date}git%{gh_short}}}%{!?gh_date:%{specrel}}%{?dist} Summary: Find out version and the extensions required for a piece of code to run @@ -24,20 +24,25 @@ Group: Development/Libraries License: BSD URL: http://php5.laurent-laville.org/compatinfo/ Source0: https://github.com/%{gh_owner}/%{gh_project}/archive/%{gh_commit}/%{gh_project}-%{version}%{?prever}-%{gh_short}.tar.gz + # Script for fedora-review Source1: fedora-review-check # Autoloader for RPM - die composer ! -# and sqlite database path +Source2: %{name}-autoload.php + +# Autoload and sqlite database path Patch0: %{name}-4.3.0-rpm.patch BuildArch: noarch BuildRequires: php(language) >= 5.3.2 -BuildRequires: php-pdo_sqlite -BuildRequires: php-composer(bartlett/php-reflect) >= 3.1 %if %{with_tests} # to run test suite BuildRequires: %{_bindir}/phpunit +BuildRequires: php-pdo_sqlite +# For our patch / autoloader +BuildRequires: php-composer(symfony/class-loader) +BuildRequires: php-bartlett-PHP-Reflect >= 3.1.1-3 %endif # From composer.json, "require" @@ -78,20 +83,9 @@ Requires: php-composer(symfony/console) < 3 # "bartlett/umlwriter": "Allow writing UML class diagrams (Graphviz or PlantUML)" # "doctrine/cache": "Allow caching results, since bartlett/php-reflect 2.2" # "bartlett/umlwriter": "Allow writing UML class diagrams (Graphviz or PlantUML)" -Requires: php-composer(doctrine/cache) -Requires: php-composer(bartlett/umlwriter) # Required by autoloader -Requires: php-composer(nikic/php-parser) -Requires: php-composer(doctrine/collections) Requires: php-composer(symfony/class-loader) -Requires: php-composer(symfony/event-dispatcher) -Requires: php-composer(symfony/finder) -Requires: php-composer(symfony/stopwatch) -Requires: php-composer(symfony/dependency-injection) -Requires: php-composer(phpdocumentor/reflection-docblock) -Requires: php-composer(seld/jsonlint) -Requires: php-composer(sebastian/version) -Requires: php-composer(justinrainbow/json-schema) +Requires: php-bartlett-PHP-Reflect >= 3.1.1-3 Provides: phpcompatinfo = %{version} Provides: php-composer(bartlett/php-compatinfo) = %{version} @@ -111,6 +105,7 @@ Documentation: http://php5.laurent-laville.org/compatinfo/manual/current/en/ #setup -q -n %{gh_project}-%{version} %patch0 -p1 -b .rpm +cp %{SOURCE2} src/Bartlett/CompatInfo/autoload.php # Cleanup patched files find src -name \*rpm -delete -print @@ -139,10 +134,13 @@ install -D -p -m 755 %{SOURCE1} %{buildroot}%{_datadir}/%{name} %if %{with_tests} %check +# drop some test because of RC version +rm tests/Reference/Extension/AmqpExtensionTest.php +rm tests/Reference/Extension/SphinxExtensionTest.php + %{_bindir}/phpunit \ - --include-path src \ - -d memory_limit=-1 \ - --verbose \ + --include-path %{buildroot}%{_datadir}/php \ + -d memory_limit=1G %if 0%{?fedora} < 21 || exit 0 %endif @@ -168,6 +166,9 @@ fi %changelog +* Fri Jun 26 2015 Remi Collet - 4.3.0-3 +- rewrite autoloader + * Sun Jun 21 2015 Remi Collet - 4.3.0-2 - fix autoloader -- cgit