From 7bec5c35cdf98593793d0998a260226f081bb146 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Mon, 3 Feb 2020 13:10:24 -0600 Subject: [PATCH] feat: migrate to Laminas Runs the Laminas migration tooling over the project. --- README.md | 2 +- bin/phly-simple-page | 4 ++-- composer.json | 21 ++++++++++---------- phpcs.xml | 2 +- src/CacheController.php | 12 +++++------ src/CacheControllerService.php | 6 +++--- src/ClearCacheCommand.php | 4 ++-- src/Module.php | 10 +++++----- src/PageCacheListener.php | 14 ++++++------- src/PageCacheListenerService.php | 4 ++-- src/PageCacheService.php | 10 +++++----- src/PageController.php | 34 ++++++++++++++++---------------- test/ModuleTest.php | 16 +++++++-------- test/PageControllerTest.php | 20 +++++++++---------- test/RouteMatchCreationTrait.php | 4 ++-- test/TestAsset/Application.php | 10 +++++----- 16 files changed, 87 insertions(+), 86 deletions(-) diff --git a/README.md b/README.md index 0e9b594..01738be 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ You can enable a write-through cache for all pages served by the To create cache configuration, create a `phly-simple-page` configuration key in your configuration, with a `cache` subkey, and configuration suitable for -`Zend\Cache\StorageFactory::factory`. As an example, the following would setup +`Laminas\Cache\StorageFactory::factory`. As an example, the following would setup filesystem caching: ```php diff --git a/bin/phly-simple-page b/bin/phly-simple-page index 7dd8f90..d18a53e 100755 --- a/bin/phly-simple-page +++ b/bin/phly-simple-page @@ -12,8 +12,8 @@ use PackageVersions\Versions; use RuntimeException; use Symfony\Component\Console\Application as ConsoleApplication; use Symfony\Component\Console\CommandLoader\ContainerCommandLoader; -use Zend\Mvc\Application as MvcApplication; -use Zend\Stdlib\ArrayUtils; +use Laminas\Mvc\Application as MvcApplication; +use Laminas\Stdlib\ArrayUtils; // Setup/verify autoloading $cwd = getcwd(); diff --git a/composer.json b/composer.json index 78b5950..2cfac53 100644 --- a/composer.json +++ b/composer.json @@ -23,20 +23,21 @@ }, "require": { "php": "^5.6 || ^7.0", - "zendframework/zend-cache": "^2.9", - "zendframework/zend-console": "^2.8", - "zendframework/zend-eventmanager": "^2.6.4 || ^3.2.1", - "zendframework/zend-http": "^2.9.1", - "zendframework/zend-mvc": "^2.7.9 || ^3.1.1", - "zendframework/zend-stdlib": "^2.7.7 || ^3.2.1", - "zendframework/zend-view": "^2.9.1", + "laminas/laminas-cache": "^2.9", + "laminas/laminas-console": "^2.8", + "laminas/laminas-eventmanager": "^2.6.4 || ^3.2.1", + "laminas/laminas-http": "^2.9.1", + "laminas/laminas-mvc": "^2.7.9 || ^3.1.1", + "laminas/laminas-stdlib": "^2.7.7 || ^3.2.1", + "laminas/laminas-view": "^2.9.1", "symfony/console": "^3.4 || ^4.0 || ^5.0", - "ocramius/package-versions": "^1.4" + "ocramius/package-versions": "^1.4", + "laminas/laminas-dependency-plugin": "^1.0" }, "require-dev": { - "zendframework/zend-coding-standard": "~1.0.0", + "laminas/laminas-coding-standard": "~1.0.0", "phpunit/phpunit": "^5.7.25 || ^6.4.4", - "zendframework/zend-servicemanager": "^2.7.11 || ^3.4.0" + "laminas/laminas-servicemanager": "^2.7.11 || ^3.4.0" }, "extra": { "zf": { diff --git a/phpcs.xml b/phpcs.xml index 9e6a751..efc33fc 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,6 +1,6 @@  - + src diff --git a/src/CacheController.php b/src/CacheController.php index 87d5124..7047b85 100644 --- a/src/CacheController.php +++ b/src/CacheController.php @@ -8,12 +8,12 @@ namespace PhlySimplePage; use RuntimeException; -use Zend\Cache\Storage\Adapter\AbstractAdapter as CacheAdapter; -use Zend\Cache\Storage\FlushableInterface; -use Zend\Console\Adapter\AdapterInterface as Console; -use Zend\Console\ColorInterface as Color; -use Zend\Console\Request as ConsoleRequest; -use Zend\Mvc\Controller\AbstractActionController; +use Laminas\Cache\Storage\Adapter\AbstractAdapter as CacheAdapter; +use Laminas\Cache\Storage\FlushableInterface; +use Laminas\Console\Adapter\AdapterInterface as Console; +use Laminas\Console\ColorInterface as Color; +use Laminas\Console\Request as ConsoleRequest; +use Laminas\Mvc\Controller\AbstractActionController; /** * @deprecated Since 1.1.0. To be removed in 2.0.0. diff --git a/src/CacheControllerService.php b/src/CacheControllerService.php index 76ebf0a..1ad88fc 100644 --- a/src/CacheControllerService.php +++ b/src/CacheControllerService.php @@ -7,9 +7,9 @@ namespace PhlySimplePage; -use Zend\ServiceManager\Exception; -use Zend\ServiceManager\FactoryInterface; -use Zend\ServiceManager\ServiceLocatorInterface; +use Laminas\ServiceManager\Exception; +use Laminas\ServiceManager\FactoryInterface; +use Laminas\ServiceManager\ServiceLocatorInterface; /** * Service factory for CacheController diff --git a/src/ClearCacheCommand.php b/src/ClearCacheCommand.php index e4c27e5..1aeec34 100644 --- a/src/ClearCacheCommand.php +++ b/src/ClearCacheCommand.php @@ -11,8 +11,8 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Zend\Cache\Storage\Adapter\AbstractAdapter; -use Zend\Cache\Storage\FlushableInterface; +use Laminas\Cache\Storage\Adapter\AbstractAdapter; +use Laminas\Cache\Storage\FlushableInterface; class ClearCacheCommand extends Command { diff --git a/src/Module.php b/src/Module.php index d68cfb9..1665a8f 100644 --- a/src/Module.php +++ b/src/Module.php @@ -7,8 +7,8 @@ namespace PhlySimplePage; -use Zend\Mvc\Application; -use Zend\Stdlib\ResponseInterface; +use Laminas\Mvc\Application; +use Laminas\Stdlib\ResponseInterface; /** * Module class for use with ZF2 @@ -48,7 +48,7 @@ public function getConsoleUsage() * "PhlySimplePage\PageCacheListener" service and attach it to the * event manager. * - * @param \Zend\Mvc\MvcEvent $e + * @param \Laminas\Mvc\MvcEvent $e */ public function onBootstrap($e) { @@ -69,7 +69,7 @@ public function onBootstrap($e) * Registers a post-dispatch listener on the controller if the matched * controller is the PageController from this module. * - * @param \Zend\Mvc\MvcEvent $e + * @param \Laminas\Mvc\MvcEvent $e */ public function onRoutePost($e) { @@ -95,7 +95,7 @@ public function onRoutePost($e) * If the controller result is a 404 status, triggers the application * dispatch.error event. * - * @param \Zend\Mvc\MvcEvent $e + * @param \Laminas\Mvc\MvcEvent $e */ public function onDispatchPost($e) { diff --git a/src/PageCacheListener.php b/src/PageCacheListener.php index fd800f0..b1f04e4 100644 --- a/src/PageCacheListener.php +++ b/src/PageCacheListener.php @@ -7,9 +7,9 @@ namespace PhlySimplePage; -use Zend\Cache\Storage\Adapter\AbstractAdapter; -use Zend\EventManager\EventManagerInterface; -use Zend\EventManager\ListenerAggregateInterface; +use Laminas\Cache\Storage\Adapter\AbstractAdapter; +use Laminas\EventManager\EventManagerInterface; +use Laminas\EventManager\ListenerAggregateInterface; /** * Event listener implementing page level caching for pages provided by the @@ -23,7 +23,7 @@ class PageCacheListener implements ListenerAggregateInterface protected $cache; /** - * @var \Zend\Stdlib\CallbackHandler[] + * @var \Laminas\Stdlib\CallbackHandler[] */ protected $listeners = []; @@ -90,8 +90,8 @@ public function detach(EventManagerInterface $events) * response; if not, we continue, but indicate that we should cache the * response on completion. * - * @param \Zend\Mvc\MvcEvent $e - * @return null|\Zend\Stdlib\ResponseInterface + * @param \Laminas\Mvc\MvcEvent $e + * @return null|\Laminas\Stdlib\ResponseInterface */ public function onRoutePost($e) { @@ -137,7 +137,7 @@ public function onRoutePost($e) * * Checks to see if we should cache the current request; if so, it does. * - * @param \Zend\Mvc\MvcEvent $e + * @param \Laminas\Mvc\MvcEvent $e */ public function onFinishPost($e) { diff --git a/src/PageCacheListenerService.php b/src/PageCacheListenerService.php index 3fcf492..c5b29f7 100644 --- a/src/PageCacheListenerService.php +++ b/src/PageCacheListenerService.php @@ -7,8 +7,8 @@ namespace PhlySimplePage; -use Zend\ServiceManager\FactoryInterface; -use Zend\ServiceManager\ServiceLocatorInterface; +use Laminas\ServiceManager\FactoryInterface; +use Laminas\ServiceManager\ServiceLocatorInterface; /** * Service factory for page cache service diff --git a/src/PageCacheService.php b/src/PageCacheService.php index d6cdf30..b979b27 100644 --- a/src/PageCacheService.php +++ b/src/PageCacheService.php @@ -7,10 +7,10 @@ namespace PhlySimplePage; -use Zend\Cache\StorageFactory; -use Zend\ServiceManager\Exception; -use Zend\ServiceManager\FactoryInterface; -use Zend\ServiceManager\ServiceLocatorInterface; +use Laminas\Cache\StorageFactory; +use Laminas\ServiceManager\Exception; +use Laminas\ServiceManager\FactoryInterface; +use Laminas\ServiceManager\ServiceLocatorInterface; /** * Service factory for cache adapter used for page caching @@ -21,7 +21,7 @@ class PageCacheService implements FactoryInterface * Create and return cache storage adapter * * @param ServiceLocatorInterface $services - * @return \Zend\Cache\Storage\Adapter\AbstractAdapter + * @return \Laminas\Cache\Storage\Adapter\AbstractAdapter * @throws Exception\ServiceNotCreatedException */ public function createService(ServiceLocatorInterface $services) diff --git a/src/PageController.php b/src/PageController.php index 981bdc7..ed30e4e 100644 --- a/src/PageController.php +++ b/src/PageController.php @@ -7,21 +7,21 @@ namespace PhlySimplePage; -use Zend\EventManager\EventInterface; -use Zend\EventManager\EventManager; -use Zend\EventManager\EventManagerAwareInterface; -use Zend\EventManager\EventManagerInterface; -use Zend\Http\Response as HttpResponse; -use Zend\Mvc\Application; -use Zend\Mvc\Exception; -use Zend\Mvc\InjectApplicationEventInterface; -use Zend\Mvc\MvcEvent; -use Zend\Mvc\Router\RouteMatch as LegacyRouteMatch; -use Zend\Router\RouteMatch; -use Zend\Stdlib\DispatchableInterface; -use Zend\Stdlib\RequestInterface; -use Zend\Stdlib\ResponseInterface; -use Zend\View\Model\ViewModel; +use Laminas\EventManager\EventInterface; +use Laminas\EventManager\EventManager; +use Laminas\EventManager\EventManagerAwareInterface; +use Laminas\EventManager\EventManagerInterface; +use Laminas\Http\Response as HttpResponse; +use Laminas\Mvc\Application; +use Laminas\Mvc\Exception; +use Laminas\Mvc\InjectApplicationEventInterface; +use Laminas\Mvc\MvcEvent; +use Laminas\Mvc\Router\RouteMatch as LegacyRouteMatch; +use Laminas\Router\RouteMatch; +use Laminas\Stdlib\DispatchableInterface; +use Laminas\Stdlib\RequestInterface; +use Laminas\Stdlib\ResponseInterface; +use Laminas\View\Model\ViewModel; /** * Page controller @@ -51,7 +51,7 @@ class PageController implements * * - PhlySimplePage\PageController * - current class name - * - Zend\Stdlib\DispatchableInterface + * - Laminas\Stdlib\DispatchableInterface * * It also registers the onDispatch method as the default handler for the * dispatch event. @@ -64,7 +64,7 @@ public function setEventManager(EventManagerInterface $events) $events->setIdentifiers([ __CLASS__, get_class($this), - 'Zend\Stdlib\DispatchableInterface', + 'Laminas\Stdlib\DispatchableInterface', ]); $events->attach('dispatch', [$this, 'onDispatch']); $this->events = $events; diff --git a/test/ModuleTest.php b/test/ModuleTest.php index 9007e63..0926c13 100644 --- a/test/ModuleTest.php +++ b/test/ModuleTest.php @@ -12,14 +12,14 @@ use PhlySimplePage\PageController; use PHPUnit\Framework\TestCase; use stdClass; -use Zend\Cache\Storage\Adapter\AbstractAdapter; -use Zend\EventManager\EventManager; -use Zend\EventManager\SharedEventManager; -use Zend\EventManager\StaticEventManager; -use Zend\EventManager\Test\EventListenerIntrospectionTrait; -use Zend\Mvc\Application; -use Zend\Mvc\MvcEvent; -use Zend\ServiceManager\ServiceLocatorInterface; +use Laminas\Cache\Storage\Adapter\AbstractAdapter; +use Laminas\EventManager\EventManager; +use Laminas\EventManager\SharedEventManager; +use Laminas\EventManager\StaticEventManager; +use Laminas\EventManager\Test\EventListenerIntrospectionTrait; +use Laminas\Mvc\Application; +use Laminas\Mvc\MvcEvent; +use Laminas\ServiceManager\ServiceLocatorInterface; /** * Unit tests for PhlySimplePage\Module diff --git a/test/PageControllerTest.php b/test/PageControllerTest.php index 3966efb..354ec45 100644 --- a/test/PageControllerTest.php +++ b/test/PageControllerTest.php @@ -9,11 +9,11 @@ use PhlySimplePage\PageController; use PHPUnit\Framework\TestCase; -use Zend\Http\Response as HttpResponse; -use Zend\Mvc\Application; -use Zend\Mvc\Exception\DomainException; -use Zend\Mvc\MvcEvent; -use Zend\Stdlib\Request; +use Laminas\Http\Response as HttpResponse; +use Laminas\Mvc\Application; +use Laminas\Mvc\Exception\DomainException; +use Laminas\Mvc\MvcEvent; +use Laminas\Stdlib\Request; /** * Unit tests for PhlySimplePage\PageController @@ -31,17 +31,17 @@ public function setUp() public function testIsEventManagerAware() { - $this->assertInstanceOf('Zend\EventManager\EventManagerAwareInterface', $this->controller); + $this->assertInstanceOf('Laminas\EventManager\EventManagerAwareInterface', $this->controller); } public function testIsDispatchable() { - $this->assertInstanceOf('Zend\Stdlib\DispatchableInterface', $this->controller); + $this->assertInstanceOf('Laminas\Stdlib\DispatchableInterface', $this->controller); } public function testIsEventInjectable() { - $this->assertInstanceOf('Zend\Mvc\InjectApplicationEventInterface', $this->controller); + $this->assertInstanceOf('Laminas\Mvc\InjectApplicationEventInterface', $this->controller); } public function testRaisesExceptionOnDispatchIfEventDoesNotContainRouteMatch() @@ -82,7 +82,7 @@ public function testReturnsViewModelWithTemplateFromRouteMatchOnSuccess() $request = new Request(); $this->controller->dispatch($request); $result = $this->event->getResult(); - $this->assertInstanceOf('Zend\View\Model\ModelInterface', $result); + $this->assertInstanceOf('Laminas\View\Model\ModelInterface', $result); $this->assertEquals('this/template', $result->getTemplate()); } @@ -93,7 +93,7 @@ public function testSetsLayoutTemplateIfLayoutFromRouteMatchIsSet() $request = new Request(); $this->controller->dispatch($request); $layoutViewModel = $this->event->getViewModel(); - $this->assertInstanceOf('Zend\View\Model\ModelInterface', $layoutViewModel); + $this->assertInstanceOf('Laminas\View\Model\ModelInterface', $layoutViewModel); $this->assertEquals('this/layout', $layoutViewModel->getTemplate()); } } diff --git a/test/RouteMatchCreationTrait.php b/test/RouteMatchCreationTrait.php index eca556b..30b1f26 100644 --- a/test/RouteMatchCreationTrait.php +++ b/test/RouteMatchCreationTrait.php @@ -7,8 +7,8 @@ namespace PhlySimplePageTest; -use Zend\Mvc\Router\RouteMatch as LegacyRouteMatch; -use Zend\Router\RouteMatch; +use Laminas\Mvc\Router\RouteMatch as LegacyRouteMatch; +use Laminas\Router\RouteMatch; trait RouteMatchCreationTrait { diff --git a/test/TestAsset/Application.php b/test/TestAsset/Application.php index af44161..e00bfb8 100644 --- a/test/TestAsset/Application.php +++ b/test/TestAsset/Application.php @@ -7,9 +7,9 @@ namespace PhlySimplePageTest\TestAsset; -use Zend\EventManager\EventManager; -use Zend\EventManager\EventManagerInterface; -use Zend\Mvc\ApplicationInterface; +use Laminas\EventManager\EventManager; +use Laminas\EventManager\EventManagerInterface; +use Laminas\Mvc\ApplicationInterface; /** * Application stub for testing purposes @@ -24,8 +24,8 @@ public function setEventManager(EventManagerInterface $events) $events->setIdentifiers([ __CLASS__, get_class($this), - 'Zend\Mvc\Application', - 'Zend\Mvc\ApplicationInterface', + 'Laminas\Mvc\Application', + 'Laminas\Mvc\ApplicationInterface', ]); $this->events = $events; return $this;