diff options
-rw-r--r-- | .gitignore | 8 | ||||
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | composer.json | 63 | ||||
-rwxr-xr-x | makesrc.sh | 28 | ||||
-rw-r--r-- | php-laminas-zendframework-bridge-rpm.patch | 76 | ||||
-rw-r--r-- | php-laminas-zendframework-bridge.spec | 131 |
6 files changed, 309 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fc9aa8c --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +clog +package-*.xml +*.tgz +*.tar.gz +*.tar.xz +*.tar.xz.asc +*.src.rpm +*/*rpm diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a2cd659 --- /dev/null +++ b/Makefile @@ -0,0 +1,3 @@ +SRCDIR := $(shell pwd) +NAME := $(shell basename $(SRCDIR)) +include ../../../common/Makefile diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..c43db4b --- /dev/null +++ b/composer.json @@ -0,0 +1,63 @@ +{ + "name": "laminas/laminas-zendframework-bridge", + "description": "Alias legacy ZF class names to Laminas Project equivalents.", + "license": "BSD-3-Clause", + "keywords": [ + "autoloading", + "laminas", + "zf", + "zendframework" + ], + "support": { + "docs": "https://docs.laminas.dev/laminas-zendframework-bridge/", + "issues": "https://github.com/laminas/laminas-zendframework-bridge/issues", + "source": "https://github.com/laminas/laminas-zendframework-bridge", + "rss": "https://github.com/laminas/laminas-zendframework-bridge/releases.atom", + "forum": "https://discourse.laminas.dev/" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7 || ^6.5 || ^7.5 || ^8.1", + "squizlabs/php_codesniffer": "^3.5" + }, + "autoload": { + "files": [ + "src/autoload.php" + ], + "psr-4": { + "Laminas\\ZendFrameworkBridge\\": "src//" + } + }, + "autoload-dev": { + "files": [ + "test/classes.php" + ], + "psr-4": { + "LaminasTest\\ZendFrameworkBridge\\": "test/", + "LaminasTest\\ZendFrameworkBridge\\TestAsset\\": "test/TestAsset/classes/", + "Laminas\\ApiTools\\": "test/TestAsset/LaminasApiTools/", + "Mezzio\\": "test/TestAsset/Mezzio/", + "Laminas\\": "test/TestAsset/Laminas/" + } + }, + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev", + "dev-develop": "1.1.x-dev" + }, + "laminas": { + "module": "Laminas\\ZendFrameworkBridge" + } + }, + "config": { + "sort-packages": true + }, + "scripts": { + "cs-check": "phpcs", + "cs-fix": "phpcbf", + "test": "phpunit --colors=always", + "test-coverage": "phpunit --colors=always --coverage-clover clover.xml" + } +} diff --git a/makesrc.sh b/makesrc.sh new file mode 100755 index 0000000..87d223d --- /dev/null +++ b/makesrc.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +NAME=$(basename $PWD) +OWNER=$(sed -n '/^%global gh_owner/{s/.* //;p}' $NAME.spec) +PROJECT=$(sed -n '/^%global gh_project/{s/.* //;p}' $NAME.spec) +VERSION=$(sed -n '/^Version:/{s/.* //;p}' $NAME.spec) +COMMIT=$(sed -n '/^%global gh_commit/{s/.* //;p}' $NAME.spec) +SHORT=${COMMIT:0:7} + +echo -e "\nCreate git snapshot\nName=$NAME, Owner=$OWNER, Project=$PROJECT, Version=$VERSION\n" + +echo "Cloning..." +rm -rf $PROJECT-$COMMIT +git clone https://github.com/$OWNER/$PROJECT.git $PROJECT-$COMMIT + +echo "Getting commit..." +pushd $PROJECT-$COMMIT +git checkout $COMMIT +cp composer.json ../composer.json +popd + +echo "Archiving..." +tar czf $NAME-$VERSION-$SHORT.tgz --exclude .git $PROJECT-$COMMIT + +echo "Cleaning..." +rm -rf $PROJECT-$COMMIT + +echo "Done." diff --git a/php-laminas-zendframework-bridge-rpm.patch b/php-laminas-zendframework-bridge-rpm.patch new file mode 100644 index 0000000..0bd5dd1 --- /dev/null +++ b/php-laminas-zendframework-bridge-rpm.patch @@ -0,0 +1,76 @@ +diff -up src/Autoloader.php.rpm src/Autoloader.php +--- src/Autoloader.php.rpm 2020-01-06 11:58:27.000000000 +0100 ++++ src/Autoloader.php 2020-01-06 13:35:58.942532257 +0100 +@@ -9,7 +9,6 @@ + namespace Laminas\ZendFrameworkBridge; + + use ArrayObject; +-use Composer\Autoload\ClassLoader; + use RuntimeException; + + /** +@@ -38,7 +37,6 @@ class Autoloader + + spl_autoload_register(self::createPrependAutoloader( + RewriteRules::namespaceReverse(), +- self::getClassLoader(), + $loaded + ), true, true); + +@@ -49,32 +47,15 @@ class Autoloader + } + + /** +- * @return ClassLoader +- * @throws RuntimeException +- */ +- private static function getClassLoader() +- { +- if (file_exists(__DIR__ . '/../../../autoload.php')) { +- return include __DIR__ . '/../../../autoload.php'; +- } +- +- if (file_exists(__DIR__ . '/../vendor/autoload.php')) { +- return include __DIR__ . '/../vendor/autoload.php'; +- } +- +- throw new RuntimeException('Cannot detect composer autoload. Please run composer install'); +- } +- +- /** + * @return callable + */ +- private static function createPrependAutoloader(array $namespaces, ClassLoader $classLoader, ArrayObject $loaded) ++ private static function createPrependAutoloader(array $namespaces, ArrayObject $loaded) + { + /** + * @param string $class Class name to autoload + * @return void + */ +- return static function ($class) use ($namespaces, $classLoader, $loaded) { ++ return static function ($class) use ($namespaces, $loaded) { + if (isset($loaded[$class])) { + return; + } +@@ -93,7 +74,8 @@ class Autoloader + return; + } + +- if ($classLoader->loadClass($class)) { ++ if ($file = \Fedora\Autoloader\Autoload::findFileForClass($class)) { ++ \Fedora\Autoloader\includeFile($file); + $legacy = $namespaces[$check] + . strtr(substr($class, strlen($check)), [ + 'ApiTools' => 'Apigility', +diff -up src/Replacements.php.rpm src/Replacements.php +--- src/Replacements.php.rpm 2020-01-06 11:58:27.000000000 +0100 ++++ src/Replacements.php 2020-01-06 13:32:48.361356190 +0100 +@@ -16,7 +16,7 @@ class Replacements + public function __construct(array $additionalReplacements = []) + { + $this->replacements = array_merge( +- require __DIR__ . '/../config/replacements.php', ++ require __DIR__ . '/config/replacements.php', + $additionalReplacements + ); + } diff --git a/php-laminas-zendframework-bridge.spec b/php-laminas-zendframework-bridge.spec new file mode 100644 index 0000000..d7aa563 --- /dev/null +++ b/php-laminas-zendframework-bridge.spec @@ -0,0 +1,131 @@ +# remirepo/Fedora spec file for php-laminas-zendframework-bridge +# +# Copyright (c) 2020 Remi Collet +# License: CC-BY-SA +# http://creativecommons.org/licenses/by-sa/4.0/ +# +# Please, preserve the changelog entries +# +%global bootstrap 0 +%global gh_commit 32d7095e436a31b8d98e485a5c63d70df74915a8 +%global gh_short %(c=%{gh_commit}; echo ${c:0:7}) +%global gh_owner laminas +%global gh_project laminas-zendframework-bridge +%global php_home %{_datadir}/php +%global namespace Laminas +%global library ZendFrameworkBridge +%if %{bootstrap} +%global with_tests 0%{?_with_tests:1} +%else +%global with_tests 0%{!?_without_tests:1} +%endif + +Name: php-%{gh_project} +Version: 1.0.0 +Release: 1%{?dist} +Summary: Alias legacy ZF class names to Laminas Project equivalents + +License: BSD +URL: https://github.com/%{gh_owner}/%{gh_project} +Source0: %{gh_commit}/%{name}-%{version}-%{gh_short}.tgz +Source1: makesrc.sh + +# Adapt for Fedora autoloader and RPM layout +Patch0: %{name}-rpm.patch + +BuildArch: noarch +# Tests +%if %{with_tests} +BuildRequires: php(language) >= 5.6 +BuildRequires: php-spl +# From composer, "require-dev": { +# "phpunit/phpunit": "^5.7 || ^6.5 || ^7.5 || ^8.1", +# "squizlabs/php_codesniffer": "^3.5" +# remirepo:1 +%global phpunit %{_bindir}/phpunit8 +BuildRequires: phpunit8 >= 8.1 +# Autoloader +BuildRequires: php-fedora-autoloader-devel +%endif + +# From composer, "require": { +# "php": "^5.6 || ^7.0" +Requires: php(language) >= 5.6 +# From phpcompatinfo report for version 1.0.0 +Requires: php-spl +# Autoloader +Requires: php-composer(fedora/autoloader) + +Provides: php-composer(%{gh_owner}/%{gh_project}) = %{version} +Provides: php-autoloader(%{gh_owner}/%{gh_project}) = %{version} + + +%description +This library provides a custom autoloader that aliases legacy +Zend Framework, Apigility, and Expressive classes to their +replacements under the Laminas Project. + +Documentation: https://docs.laminas.dev/%{gh_project}/ + + +%prep +%setup -q -n %{gh_project}-%{gh_commit} +%patch0 -p0 -b .rpm +#find . -name \*.rpm -delete + +mv LICENSE.md LICENSE + + +%build +mv src/autoload.php upstream.php +phpab --template fedora --output src/autoload.php src +grep -v '^<?php' upstream.php | tee -a src/autoload.php + + +%install +mkdir -p %{buildroot}%{php_home}/%{namespace}/ +cp -pr src %{buildroot}%{php_home}/%{namespace}//%{library} +cp -pr config %{buildroot}%{php_home}/%{namespace}//%{library}/config + + +%check +%if %{with_tests} +mkdir vendor +cat << 'EOF' | tee vendor/autoload.php +<?php +require_once '%{buildroot}%{php_home}/%{namespace}/%{library}/autoload.php'; +\Fedora\Autoloader\Autoload::addPsr4('%{namespace}Test\\%{library}\\', dirname(__DIR__) . '/test'); +\Fedora\Autoloader\Autoload::addPsr4('%{namespace}Test\\%{library}\\TestAsset\\', dirname(__DIR__) . '/test/TestAsset/classes'); +\Fedora\Autoloader\Autoload::addPsr4('%{namespace}\\ApiTools\\', dirname(__DIR__) . '/test/TestAsset/LaminasApiTools'); +\Fedora\Autoloader\Autoload::addPsr4('Mezzio\\', dirname(__DIR__) . '/test/TestAsset/Mezzio'); +\Fedora\Autoloader\Autoload::addPsr4('%{namespace}\\', dirname(__DIR__) . '/test/TestAsset/Laminas'); +\Fedora\Autoloader\Dependencies::required([ + dirname(__DIR__) . '/test/classes.php', +]); +EOF + +ret=0 +for cmdarg in "php %{phpunit}" php72 php73 php74; do + if which $cmdarg; then + set $cmdarg + $1 ${2:-%{_bindir}/phpunit8} --verbose || ret=1 + fi +done +exit $ret +%else +: Test suite disabled +%endif + + +%files +%{!?_licensedir:%global license %%doc} +%license LICENSE +%doc *.md +%doc composer.json +%dir %{php_home}/%{namespace} + %{php_home}/%{namespace}/%{library} + + +%changelog +* Mon Jan 6 2020 Remi Collet <remi@remirepo.net> - 1.0.0-1 +- initial package |