diff options
-rw-r--r-- | .gitignore | 8 | ||||
-rw-r--r-- | d967c0d39c48a79c3c37ff84d8658240038f4d78.patch | 345 | ||||
-rw-r--r-- | php-zendframework-zend-cache.spec | 51 |
3 files changed, 381 insertions, 23 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/d967c0d39c48a79c3c37ff84d8658240038f4d78.patch b/d967c0d39c48a79c3c37ff84d8658240038f4d78.patch new file mode 100644 index 0000000..64a9d41 --- /dev/null +++ b/d967c0d39c48a79c3c37ff84d8658240038f4d78.patch @@ -0,0 +1,345 @@ +Adapted to be usable from EL-6 (patch doesn't support rename) + + + +From d967c0d39c48a79c3c37ff84d8658240038f4d78 Mon Sep 17 00:00:00 2001 +From: webimpress <contact@webimpress.com> +Date: Thu, 26 Oct 2017 12:51:36 +0100 +Subject: [PATCH] :fire: Polyfill PatternPluginManager - to allow work with + Zend SMv2 and v3 + +Fixes issue with PHP 7.2 signature compatibility. +--- + autoload/patternPluginManagerPolyfill.php | 17 +++++ + composer.json | 7 +- + composer.lock | 2 +- + .../PatternPluginManagerTrait.php | 75 +++++++++++++++++++ + .../PatternPluginManagerV2Polyfill.php} | 77 +++---------------- + .../PatternPluginManagerV3Polyfill.php | 87 ++++++++++++++++++++++ + 6 files changed, 197 insertions(+), 68 deletions(-) + create mode 100644 autoload/patternPluginManagerPolyfill.php + create mode 100644 src/PatternPluginManager/PatternPluginManagerTrait.php + rename src/{PatternPluginManager.php => PatternPluginManager/PatternPluginManagerV2Polyfill.php} (51%) + create mode 100644 src/PatternPluginManager/PatternPluginManagerV3Polyfill.php + +diff --git a/autoload/patternPluginManagerPolyfill.php b/autoload/patternPluginManagerPolyfill.php +new file mode 100644 +index 00000000..4d896fb8 +--- /dev/null ++++ b/autoload/patternPluginManagerPolyfill.php +@@ -0,0 +1,17 @@ ++<?php ++/** ++ * @see https://github.com/zendframework/zend-cache for the canonical source repository ++ * @copyright Copyright (c) 2017 Zend Technologies USA Inc. (http://www.zend.com) ++ * @license https://github.com/zendframework/zend-cache/blob/master/LICENSE.md New BSD License ++ */ ++ ++use Zend\Cache\PatternPluginManager; ++use Zend\ServiceManager\ServiceManager; ++ ++call_user_func(function () { ++ $target = method_exists(ServiceManager::class, 'configure') ++ ? PatternPluginManager\PatternPluginManagerV3Polyfill::class ++ : PatternPluginManager\PatternPluginManagerV2Polyfill::class; ++ ++ class_alias($target, PatternPluginManager::class); ++}); +diff --git a/src/PatternPluginManager/PatternPluginManagerTrait.php b/src/PatternPluginManager/PatternPluginManagerTrait.php +new file mode 100644 +index 00000000..8c6f2b27 +--- /dev/null ++++ b/src/PatternPluginManager/PatternPluginManagerTrait.php +@@ -0,0 +1,75 @@ ++<?php ++/** ++ * @see https://github.com/zendframework/zend-cache for the canonical source repository ++ * @copyright Copyright (c) 2005-2017 Zend Technologies USA Inc. (http://www.zend.com) ++ * @license https://github.com/zendframework/zend-cache/blob/master/LICENSE.md New BSD License ++ */ ++ ++namespace Zend\Cache\PatternPluginManager; ++ ++use Zend\Cache\Exception; ++use Zend\Cache\Pattern; ++use Zend\ServiceManager\Exception\InvalidServiceException; ++ ++/** ++ * Trait providing common logic between FormElementManager implementations. ++ * ++ * Trait does not define properties, as the properties common between the ++ * two versions are originally defined in their parent class, causing a ++ * resolution conflict. ++ */ ++trait PatternPluginManagerTrait ++{ ++ /** ++ * Override build to inject options as PatternOptions instance. ++ * ++ * {@inheritDoc} ++ */ ++ public function build($plugin, array $options = null) ++ { ++ if (empty($options)) { ++ return parent::build($plugin); ++ } ++ ++ $plugin = parent::build($plugin); ++ $plugin->setOptions(new Pattern\PatternOptions($options)); ++ return $plugin; ++ } ++ ++ /** ++ * Validate the plugin is of the expected type (v3). ++ * ++ * Validates against `$instanceOf`. ++ * ++ * @param mixed $instance ++ * @throws InvalidServiceException ++ */ ++ public function validate($instance) ++ { ++ if (! $instance instanceof $this->instanceOf) { ++ throw new InvalidServiceException(sprintf( ++ '%s can only create instances of %s; %s is invalid', ++ get_class($this), ++ $this->instanceOf, ++ (is_object($instance) ? get_class($instance) : gettype($instance)) ++ )); ++ } ++ } ++ ++ /** ++ * Validate the plugin is of the expected type (v2). ++ * ++ * Proxies to `validate()`. ++ * ++ * @param mixed $plugin ++ * @throws Exception\RuntimeException if invalid ++ */ ++ public function validatePlugin($plugin) ++ { ++ try { ++ $this->validate($plugin); ++ } catch (InvalidServiceException $e) { ++ throw new Exception\RuntimeException($e->getMessage(), $e->getCode(), $e); ++ } ++ } ++} +diff --git a/src/PatternPluginManager.php b/src/PatternPluginManager/PatternPluginManagerV2Polyfill.php +--- a/src/PatternPluginManager/PatternPluginManagerV2Polyfill.php ++++ b/src/PatternPluginManager/PatternPluginManagerV2Polyfill.php +@@ -1,27 +1,27 @@ + <?php + /** +- * Zend Framework (http://framework.zend.com/) +- * +- * @link http://github.com/zendframework/zf2 for the canonical source repository +- * @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com) +- * @license http://framework.zend.com/license/new-bsd New BSD License ++ * @see https://github.com/zendframework/zend-cache for the canonical source repository ++ * @copyright Copyright (c) 2017 Zend Technologies USA Inc. (http://www.zend.com) ++ * @license https://github.com/zendframework/zend-cache/blob/master/LICENSE.md New BSD License + */ + +-namespace Zend\Cache; ++namespace Zend\Cache\PatternPluginManager; + ++use Zend\Cache\Pattern; + use Zend\ServiceManager\AbstractPluginManager; + use Zend\ServiceManager\Factory\InvokableFactory; +-use Zend\ServiceManager\Exception\InvalidServiceException; + + /** +- * Plugin manager implementation for cache pattern adapters ++ * zend-servicemanager v2-compatible plugin manager implementation for cache pattern adapters. + * + * Enforces that retrieved adapters are instances of + * Pattern\PatternInterface. Additionally, it registers a number of default + * patterns available. + */ +-class PatternPluginManager extends AbstractPluginManager ++class PatternPluginManagerV2Polyfill extends AbstractPluginManager + { ++ use PatternPluginManagerTrait; ++ + protected $aliases = [ + 'callback' => Pattern\CallbackCache::class, + 'Callback' => Pattern\CallbackCache::class, +@@ -53,14 +53,14 @@ class PatternPluginManager extends AbstractPluginManager + /** + * Don't share by default + * +- * @var boolean ++ * @var bool + */ + protected $shareByDefault = false; + + /** + * Don't share by default + * +- * @var boolean ++ * @var bool + */ + protected $sharedByDefault = false; + +@@ -74,7 +74,7 @@ class PatternPluginManager extends AbstractPluginManager + * + * {@inheritDoc} + */ +- public function get($plugin, array $options = [], $usePeeringServiceManagers = true) ++ public function get($plugin, $options = [], $usePeeringServiceManagers = true) + { + if (empty($options)) { + return parent::get($plugin, [], $usePeeringServiceManagers); +@@ -84,57 +84,4 @@ public function get($plugin, array $options = [], $usePeeringServiceManagers = t + $plugin->setOptions(new Pattern\PatternOptions($options)); + return $plugin; + } +- +- /** +- * Override build to inject options as PatternOptions instance. +- * +- * {@inheritDoc} +- */ +- public function build($plugin, array $options = null) +- { +- if (empty($options)) { +- return parent::build($plugin); +- } +- +- $plugin = parent::build($plugin); +- $plugin->setOptions(new Pattern\PatternOptions($options)); +- return $plugin; +- } +- +- /** +- * Validate the plugin is of the expected type (v3). +- * +- * Validates against `$instanceOf`. +- * +- * @param mixed $instance +- * @throws InvalidServiceException +- */ +- public function validate($instance) +- { +- if (! $instance instanceof $this->instanceOf) { +- throw new InvalidServiceException(sprintf( +- '%s can only create instances of %s; %s is invalid', +- get_class($this), +- $this->instanceOf, +- (is_object($instance) ? get_class($instance) : gettype($instance)) +- )); +- } +- } +- +- /** +- * Validate the plugin is of the expected type (v2). +- * +- * Proxies to `validate()`. +- * +- * @param mixed $plugin +- * @throws Exception\RuntimeException if invalid +- */ +- public function validatePlugin($plugin) +- { +- try { +- $this->validate($plugin); +- } catch (InvalidServiceException $e) { +- throw new Exception\RuntimeException($e->getMessage(), $e->getCode(), $e); +- } +- } + } +diff --git a/src/PatternPluginManager/PatternPluginManagerV3Polyfill.php b/src/PatternPluginManager/PatternPluginManagerV3Polyfill.php +new file mode 100644 +index 00000000..c00ef1d5 +--- /dev/null ++++ b/src/PatternPluginManager/PatternPluginManagerV3Polyfill.php +@@ -0,0 +1,87 @@ ++<?php ++/** ++ * @see https://github.com/zendframework/zend-cache for the canonical source repository ++ * @copyright Copyright (c) 2017 Zend Technologies USA Inc. (http://www.zend.com) ++ * @license https://github.com/zendframework/zend-cache/blob/master/LICENSE.md New BSD License ++ */ ++ ++namespace Zend\Cache\PatternPluginManager; ++ ++use Zend\Cache\Pattern; ++use Zend\ServiceManager\AbstractPluginManager; ++use Zend\ServiceManager\Factory\InvokableFactory; ++ ++/** ++ * zend-servicemanager v3-compatible plugin manager implementation for cache pattern adapters. ++ * ++ * Enforces that retrieved adapters are instances of ++ * Pattern\PatternInterface. Additionally, it registers a number of default ++ * patterns available. ++ */ ++class PatternPluginManagerV3Polyfill extends AbstractPluginManager ++{ ++ use PatternPluginManagerTrait; ++ ++ protected $aliases = [ ++ 'callback' => Pattern\CallbackCache::class, ++ 'Callback' => Pattern\CallbackCache::class, ++ 'capture' => Pattern\CaptureCache::class, ++ 'Capture' => Pattern\CaptureCache::class, ++ 'class' => Pattern\ClassCache::class, ++ 'Class' => Pattern\ClassCache::class, ++ 'object' => Pattern\ObjectCache::class, ++ 'Object' => Pattern\ObjectCache::class, ++ 'output' => Pattern\OutputCache::class, ++ 'Output' => Pattern\OutputCache::class, ++ ]; ++ ++ protected $factories = [ ++ Pattern\CallbackCache::class => InvokableFactory::class, ++ Pattern\CaptureCache::class => InvokableFactory::class, ++ Pattern\ClassCache::class => InvokableFactory::class, ++ Pattern\ObjectCache::class => InvokableFactory::class, ++ Pattern\OutputCache::class => InvokableFactory::class, ++ ++ // v2 normalized FQCNs ++ 'zendcachepatterncallbackcache' => InvokableFactory::class, ++ 'zendcachepatterncapturecache' => InvokableFactory::class, ++ 'zendcachepatternclasscache' => InvokableFactory::class, ++ 'zendcachepatternobjectcache' => InvokableFactory::class, ++ 'zendcachepatternoutputcache' => InvokableFactory::class, ++ ]; ++ ++ /** ++ * Don't share by default ++ * ++ * @var bool ++ */ ++ protected $shareByDefault = false; ++ ++ /** ++ * Don't share by default ++ * ++ * @var bool ++ */ ++ protected $sharedByDefault = false; ++ ++ /** ++ * @var string ++ */ ++ protected $instanceOf = Pattern\PatternInterface::class; ++ ++ /** ++ * Override get to inject options as PatternOptions instance. ++ * ++ * {@inheritDoc} ++ */ ++ public function get($plugin, array $options = null, $usePeeringServiceManagers = true) ++ { ++ if (empty($options)) { ++ return parent::get($plugin, null, $usePeeringServiceManagers); ++ } ++ ++ $plugin = parent::get($plugin, null, $usePeeringServiceManagers); ++ $plugin->setOptions(new Pattern\PatternOptions($options)); ++ return $plugin; ++ } ++} diff --git a/php-zendframework-zend-cache.spec b/php-zendframework-zend-cache.spec index 1ceda54..80f9ff2 100644 --- a/php-zendframework-zend-cache.spec +++ b/php-zendframework-zend-cache.spec @@ -21,7 +21,7 @@ Name: php-%{gh_owner}-%{gh_project} Version: 2.7.2 -Release: 1%{?dist} +Release: 4%{?dist} Summary: Zend Framework %{library} component Group: Development/Libraries @@ -30,7 +30,8 @@ URL: https://zendframework.github.io/%{gh_project}/ Source0: %{gh_commit}/%{name}-%{version}-%{gh_short}.tgz Source1: makesrc.sh -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root +Patch0: https://github.com/zendframework/zend-cache/commit/d967c0d39c48a79c3c37ff84d8658240038f4d78.patch + BuildArch: noarch # Tests %if %{with_tests} @@ -121,26 +122,40 @@ Documentation: https://zendframework.github.io/%{gh_project}/ %prep %setup -q -n %{gh_project}-%{gh_commit} +# EL-6 patch don't allow rename +mkdir src/PatternPluginManager +mv src/PatternPluginManager.php src/PatternPluginManager/PatternPluginManagerV2Polyfill.php +%patch0 -p1 mv LICENSE.md LICENSE +: Create dependency autoloader +mv autoload/*.php src + +cat << 'EOF' | tee autoload.php +<?php +require_once __DIR__ . '/%{library}/patternPluginManagerPolyfill.php'; +EOF + %build # Empty build section, nothing required %install -rm -rf %{buildroot} - mkdir -p %{buildroot}%{php_home}/Zend/ cp -pr src %{buildroot}%{php_home}/Zend/%{library} +install -m644 autoload.php %{buildroot}%{php_home}/Zend/%{library}-autoload.php + %check %if %{with_tests} mkdir vendor cat << EOF | tee vendor/autoload.php <?php +define('RPM_BUILDROOT', '%{buildroot}%{php_home}/Zend'); + require_once '%{php_home}/Zend/Loader/AutoloaderFactory.php'; Zend\Loader\AutoloaderFactory::factory(array( 'Zend\Loader\StandardAutoloader' => array( @@ -151,41 +166,31 @@ Zend\Loader\AutoloaderFactory::factory(array( require_once '%{php_home}/Zend/autoload.php'; EOF -# remirepo:11 -run=0 ret=0 -if which php56; then - php56 %{_bindir}/phpunit || ret=1 - run=1 -fi -if which php71; then - php71 %{_bindir}/phpunit || ret=1 - run=1 -fi -if [ $run -eq 0 ]; then -%{_bindir}/phpunit --verbose -# remirepo:2 -fi +for cmd in php php56 php70 php71 php72; do + if which $cmd; then + $cmd %{_bindir}/phpunit || ret=1 + fi +done exit $ret %else : Test suite disabled %endif -%clean -rm -rf %{buildroot} - - %files -%defattr(-,root,root,-) %{!?_licensedir:%global license %%doc} %license LICENSE %doc *.md %doc composer.json %{php_home}/Zend/%{library} +%{php_home}/Zend/%{library}-autoload.php %changelog +* Tue Oct 31 2017 Remi Collet <remi@fedoraproject.org> - 2.7.2-4 +- fix FTBFS from Koschei, add upstream patch for PHP 7.2 + * Fri Dec 16 2016 Remi Collet <remi@fedoraproject.org> - 2.7.2-1 - update to 2.7.2 |