From c678e4f72837886fc7e1e2958640b9761b8ba588 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 16 Jul 2016 10:49:30 +0700 Subject: [PATCH 1/4] preparation for 1.0.0 --- composer.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index b862ead..c71083b 100644 --- a/composer.json +++ b/composer.json @@ -14,20 +14,20 @@ } ], "require": { - "php": ">=5.3.23,<8", - "zendframework/zend-session": "~2.3", - "zendframework/zend-debug": "~2.3", - "zendframework/zend-json": "~2.3 || ~3.0" + "php": "^5.6 || ^7.0", + "zendframework/zend-session": "^2.5", + "zendframework/zend-debug": "^2.5", + "zendframework/zend-json": "^2.5 || ^3.0" }, "require-dev": { "container-interop/container-interop": "^1.1", "satooshi/php-coveralls": "^1.0", "phpunit/phpcov": "~2.0", - "zendframework/zend-test": "~2.3", - "zendframework/zend-serializer": "~2.3", - "zendframework/zend-log": "~2.3", - "zendframework/zend-i18n": "~2.3", - "zendframework/zend-view": "~2.3", + "zendframework/zend-test": "^2.5", + "zendframework/zend-serializer": "^2.5", + "zendframework/zend-log": "^2.5", + "zendframework/zend-i18n": "^2.5", + "zendframework/zend-view": "^2.5", "zendframework/zend-developer-tools": "^1.0.0 || ^1.1.0" }, "suggest": { From 039ebccf60207029dfacfc5580e6ae4ba445f3d8 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 16 Jul 2016 10:55:08 +0700 Subject: [PATCH 2/4] short array syntax and update readme --- .styleci.yml | 2 - README.md | 2 +- config/module.config.php | 80 +++++++++---------- src/Collector/SessionCollector.php | 2 +- src/Controller/SessionToolbarController.php | 30 +++---- src/Manager/SessionManager.php | 4 +- src/Manager/SessionManagerInterface.php | 2 +- src/Module.php | 6 +- test/Collector/SessionCollectorTest.php | 34 ++++---- .../SessionToolbarControllerTest.php | 48 +++++------ test/Manager/SessionMangerTest.php | 34 ++++---- test/ModuleTest.php | 12 +-- 12 files changed, 127 insertions(+), 129 deletions(-) diff --git a/.styleci.yml b/.styleci.yml index dc1455a..048d01f 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -3,13 +3,11 @@ preset: recommended linting: true enabled: - - long_array_syntax - strict - unalign_double_arrow disabled: - align_double_arrow - - short_array_syntax finder: exclude: diff --git a/README.md b/README.md index 58b2d60..4da6c1d 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Installation Installation of this module uses composer. ```sh -$ composer require san/san-session-toolbar 0.* +$ composer require san/san-session-toolbar ``` For composer documentation, please refer to [getcomposer.org](https://getcomposer.org/). diff --git a/config/module.config.php b/config/module.config.php index d7bd58b..4f79b83 100644 --- a/config/module.config.php +++ b/config/module.config.php @@ -17,62 +17,62 @@ * and is licensed under the MIT license. */ -return array( +return [ - 'controllers' => array( - 'factories' => array( + 'controllers' => [ + 'factories' => [ 'SanSessionToolbar\Controller\SessionToolbar' => 'SanSessionToolbar\Factory\Controller\SessionToolbarControllerFactory', - ), - ), + ], + ], - 'router' => array( - 'routes' => array( - 'san-session-toolbar' => array( + 'router' => [ + 'routes' => [ + 'san-session-toolbar' => [ 'type' => 'segment', - 'options' => array( + 'options' => [ 'route' => '/san-session-toolbar[/:action]', - 'constraints' => array( + 'constraints' => [ 'action' => '[a-zA-Z][a-zA-Z0-9_-]*', - ), - 'defaults' => array( + ], + 'defaults' => [ 'controller' => 'SanSessionToolbar\Controller\SessionToolbar', 'action' => 'removesession', - ), - ), - ), - ), - ), + ], + ], + ], + ], + ], - 'service_manager' => array( - 'invokables' => array( + 'service_manager' => [ + 'invokables' => [ 'SanSessionManager' => 'SanSessionToolbar\Manager\SessionManager', - ), - 'factories' => array( + ], + 'factories' => [ 'session.toolbar' => 'SanSessionToolbar\Factory\Collector\SessionCollectorFactory', - ), - ), + ], + ], - 'view_manager' => array( - 'template_map' => array( + 'view_manager' => [ + 'template_map' => [ 'zend-developer-tools/toolbar/session-data' => __DIR__.'/../view/zend-developer-tools/toolbar/session-data.phtml', 'zend-developer-tools/toolbar/session-data-list' => __DIR__.'/../view/zend-developer-tools/toolbar/session-data-list.phtml', - ), - 'strategies' => array( + ], + 'strategies' => [ 'ViewJsonStrategy', - ), - ), + ], + ], - 'zenddevelopertools' => array( - 'profiler' => array( - 'collectors' => array( + 'zenddevelopertools' => [ + 'profiler' => [ + 'collectors' => [ 'session.toolbar' => 'session.toolbar', - ), - ), - 'toolbar' => array( - 'entries' => array( + ], + ], + 'toolbar' => [ + 'entries' => [ 'session.toolbar' => 'zend-developer-tools/toolbar/session-data', - ), - ), - ), + ], + ], + ], -); +]; diff --git a/src/Collector/SessionCollector.php b/src/Collector/SessionCollector.php index 0bc6333..2510def 100644 --- a/src/Collector/SessionCollector.php +++ b/src/Collector/SessionCollector.php @@ -67,7 +67,7 @@ public function getPriority() public function collect(MvcEvent $mvcEvent) { if (!isset($this->data['san-session'])) { - $this->data['san-session'] = array(); + $this->data['san-session'] = []; } } diff --git a/src/Controller/SessionToolbarController.php b/src/Controller/SessionToolbarController.php index 9e2e811..6fa1a73 100644 --- a/src/Controller/SessionToolbarController.php +++ b/src/Controller/SessionToolbarController.php @@ -69,9 +69,9 @@ public function removesessionAction() ->sessionSetting($containerName, $keysession); } - return new JsonModel(array( + return new JsonModel([ 'success' => $success, - )); + ]); } /** @@ -82,11 +82,11 @@ public function reloadsessionAction() $sessionData = $this->sessionManager->getSessionData(false); $renderedContent = $this->viewRenderer - ->render('zend-developer-tools/toolbar/session-data-list', array('sessionData' => $sessionData)); + ->render('zend-developer-tools/toolbar/session-data-list', ['sessionData' => $sessionData]); - return new JsonModel(array( + return new JsonModel([ 'san_sessiontoolbar_data_renderedContent' => $renderedContent, - )); + ]); } /** @@ -101,11 +101,11 @@ public function clearsessionAction() $sessionData = $this->sessionManager->getSessionData(); $renderedContent = $this->viewRenderer - ->render('zend-developer-tools/toolbar/session-data-list', array('sessionData' => $sessionData)); + ->render('zend-developer-tools/toolbar/session-data-list', ['sessionData' => $sessionData]); - return new JsonModel(array( + return new JsonModel([ 'san_sessiontoolbar_data_renderedContent' => $renderedContent, - )); + ]); } /** @@ -113,7 +113,7 @@ public function clearsessionAction() */ public function savesessionAction() { - $processSetOrAddSessionData = array('success' => false, 'errorMessage' => ''); + $processSetOrAddSessionData = ['success' => false, 'errorMessage' => '']; $request = $this->getEvent()->getRequest(); if ($request instanceof Request && $request->isPost()) { @@ -122,13 +122,13 @@ public function savesessionAction() $sessionData = $this->sessionManager->getSessionData(); $renderedContent = $this->viewRenderer - ->render('zend-developer-tools/toolbar/session-data-list', array('sessionData' => $sessionData)); + ->render('zend-developer-tools/toolbar/session-data-list', ['sessionData' => $sessionData]); - return new JsonModel(array( + return new JsonModel([ 'success' => $processSetOrAddSessionData['success'], 'errorMessage' => $processSetOrAddSessionData['errorMessage'], 'san_sessiontoolbar_data_renderedContent' => $renderedContent, - )); + ]); } /** @@ -148,11 +148,11 @@ private function setOrAddSession(Request $request) $notEmptyValidator = new NotEmpty(); if ($notEmptyValidator->isValid($keysession) && $notEmptyValidator->isValid($sessionValue)) { $success = $this->sessionManager - ->sessionSetting($containerName, $keysession, $sessionValue, array('set' => true, 'new' => $new)); + ->sessionSetting($containerName, $keysession, $sessionValue, ['set' => true, 'new' => $new]); - return array('success' => $success, 'errorMessage' => ''); + return ['success' => $success, 'errorMessage' => '']; } - return array('success' => false, 'errorMessage' => 'Value is required and can\'t be empty'); + return ['success' => false, 'errorMessage' => 'Value is required and can\'t be empty']; } } diff --git a/src/Manager/SessionManager.php b/src/Manager/SessionManager.php index 4b3fad4..c91c578 100644 --- a/src/Manager/SessionManager.php +++ b/src/Manager/SessionManager.php @@ -53,7 +53,7 @@ public function getSessionData($checkExists = true) */ private function collectSessionData(array $arraysession) { - $data = array(); + $data = []; foreach ($arraysession as $key => $row) { if ($row instanceof ArrayObject) { @@ -71,7 +71,7 @@ private function collectSessionData(array $arraysession) /** * {@inheritdoc} */ - public function sessionSetting($containerName, $keysession, $value = null, $options = array()) + public function sessionSetting($containerName, $keysession, $value = null, $options = []) { $container = new Container($containerName); $set = (!empty($options['set'])) ? $options['set'] : false; diff --git a/src/Manager/SessionManagerInterface.php b/src/Manager/SessionManagerInterface.php index deac63e..757f7bb 100644 --- a/src/Manager/SessionManagerInterface.php +++ b/src/Manager/SessionManagerInterface.php @@ -44,7 +44,7 @@ public function getSessionData($checkExists = true); * * @return bool */ - public function sessionSetting($containerName, $keysession, $value = null, $options = array()); + public function sessionSetting($containerName, $keysession, $value = null, $options = []); /** * Clear Session. diff --git a/src/Module.php b/src/Module.php index 1dea674..91718fd 100644 --- a/src/Module.php +++ b/src/Module.php @@ -48,7 +48,7 @@ public function onBootstrap(MvcEvent $e) $sharedEvm->attach( 'Zend\Mvc\Controller\AbstractActionController', 'dispatch', - array($this, 'flashMessengerHandler'), + [$this, 'flashMessengerHandler'], 2 ); } @@ -67,7 +67,7 @@ public function flashMessengerHandler(EventInterface $e) foreach ($reCreateFlash as $key => $row) { if ($row instanceof SplQueue) { $flashPerNameSpace = $flash->setNamespace($key); - $valuesMessage = array(); + $valuesMessage = []; foreach ($row->toArray() as $keyArray => $rowArray) { $flashPerNameSpace->addMessage($rowArray); $valuesMessage[] = $rowArray; @@ -90,6 +90,6 @@ public function getConfig() */ public function getModuleDependencies() { - return array('ZendDeveloperTools'); + return ['ZendDeveloperTools']; } } diff --git a/test/Collector/SessionCollectorTest.php b/test/Collector/SessionCollectorTest.php index 7c86773..0f24529 100644 --- a/test/Collector/SessionCollectorTest.php +++ b/test/Collector/SessionCollectorTest.php @@ -90,32 +90,32 @@ public function testCallCollect() public function testGetSessionData() { $this->sessionContainer->word = 'zaf8go6i'; - $this->sessionContainer->a = array( + $this->sessionContainer->a = [ 'foo' => 'bar', 42 => 24, - 'multi' => array( - 'dimensional' => array( + 'multi' => [ + 'dimensional' => [ 'array' => 'foo', - ), - ), - ); + ], + ], + ]; $this->sessionContainer->bar = 'bar'; - $this->assertEquals(array( - 'Default' => array( + $this->assertEquals([ + 'Default' => [ 'word' => 'zaf8go6i', - 'a' => array( + 'a' => [ 'foo' => 'bar', 42 => 24, - 'multi' => array( - 'dimensional' => array( + 'multi' => [ + 'dimensional' => [ 'array' => 'foo', - ), - ), - ), + ], + ], + ], 'bar' => 'bar', - ), - ), $this->sessionCollector->getSessionData()); + ], + ], $this->sessionCollector->getSessionData()); } /** @@ -129,7 +129,7 @@ public function testGetSessionDataForEmpty() $this->sessionContainer->offsetUnset('bar'); $this->sessionCollector->collect(new MvcEvent()); - $this->assertEquals(array(), $this->sessionCollector->getSessionData()); + $this->assertEquals([], $this->sessionCollector->getSessionData()); } protected function tearDown() diff --git a/test/Controller/SessionToolbarControllerTest.php b/test/Controller/SessionToolbarControllerTest.php index 1c85022..9a52792 100644 --- a/test/Controller/SessionToolbarControllerTest.php +++ b/test/Controller/SessionToolbarControllerTest.php @@ -31,17 +31,17 @@ class SessionToolbarControllerTest extends AbstractHttpControllerTestCase { protected function setUp() { - $this->setApplicationConfig(array( - 'modules' => array( + $this->setApplicationConfig([ + 'modules' => [ 'ZendDeveloperTools', 'SanSessionToolbar', - ), - 'module_listener_options' => array( - 'module_paths' => array( + ], + 'module_listener_options' => [ + 'module_paths' => [ dirname(dirname(dirname(__DIR__))), - ), - ), - )); + ], + ], + ]); parent::setUp(); } @@ -56,10 +56,10 @@ public function testAccessRemoveSessionWithoutPostData() public function testPostDataWithSessionNotExists() { - $postData = array( + $postData = [ 'key' => 'Default', 'keysession' => 'foo', - ); + ]; $this->dispatch('/san-session-toolbar/removesession', 'POST', $postData); $this->assertResponseHeaderContains('Content-Type', 'application/json; charset=utf-8'); @@ -71,10 +71,10 @@ public function testPostDataWithSessionExists() $container = new Container('Default'); $container->foo = 'fooValue'; - $postData = array( + $postData = [ 'key' => 'Default', 'keysession' => 'foo', - ); + ]; $this->dispatch('/san-session-toolbar/removesession', 'POST', $postData); $this->assertResponseHeaderContains('Content-Type', 'application/json; charset=utf-8'); @@ -109,9 +109,9 @@ public function testClearSessionByContainerExecuteCurrentContainerWhenItMet() $container = new Container('OtherContainer'); $container->foo = 'fooValue'; - $postData = array( + $postData = [ 'byContainer' => 'Default', - ); + ]; $this->dispatch('/san-session-toolbar/clearsession', 'POST', $postData); $this->assertResponseHeaderContains('Content-Type', 'application/json; charset=utf-8'); @@ -143,11 +143,11 @@ public function testUpdateSessionData() $container = new Container('OtherContainer'); $container->foo = 'fux'; - $postData = array( + $postData = [ 'key' => 'Default', 'keysession' => 'foo', 'sessionvalue' => 'barbar', - ); + ]; $this->dispatch('/san-session-toolbar/savesession', 'POST', $postData); $this->assertResponseHeaderContains('Content-Type', 'application/json; charset=utf-8'); @@ -164,11 +164,11 @@ public function testUpdateSessionDataWithEmptyValue() $container = new Container('OtherContainer'); $container->foo = 'fux'; - $postData = array( + $postData = [ 'key' => 'Default', 'keysession' => 'foo', 'sessionvalue' => '', - ); + ]; $this->dispatch('/san-session-toolbar/savesession', 'POST', $postData); $this->assertResponseHeaderContains('Content-Type', 'application/json; charset=utf-8'); @@ -182,11 +182,11 @@ public function testUpdateSessionDataNotExists() $container = new Container('Default'); $container->foo = 'fooValue'; - $postData = array( + $postData = [ 'key' => 'Default', 'keysession' => 'bazbazbadabum', 'sessionvalue' => 'barbar', - ); + ]; $this->dispatch('/san-session-toolbar/savesession', 'POST', $postData); $this->assertResponseHeaderContains('Content-Type', 'application/json; charset=utf-8'); @@ -199,12 +199,12 @@ public function testNewSessionDataNotExists() $container = new Container('Default'); $container->foo = 'fooValue'; - $postData = array( + $postData = [ 'key' => 'Default', 'keysession' => 'bazbazbadabum', 'sessionvalue' => 'barbar', 'new' => 1, - ); + ]; $this->dispatch('/san-session-toolbar/savesession', 'POST', $postData); $this->assertResponseHeaderContains('Content-Type', 'application/json; charset=utf-8'); @@ -217,12 +217,12 @@ public function testNewSessionDataExists() $container = new Container('Default'); $container->foo = 'fooValue'; - $postData = array( + $postData = [ 'key' => 'Default', 'keysession' => 'foo', 'sessionvalue' => 'barbar', 'new' => 1, - ); + ]; $this->dispatch('/san-session-toolbar/savesession', 'POST', $postData); $this->assertResponseHeaderContains('Content-Type', 'application/json; charset=utf-8'); diff --git a/test/Manager/SessionMangerTest.php b/test/Manager/SessionMangerTest.php index 97a4363..7055753 100644 --- a/test/Manager/SessionMangerTest.php +++ b/test/Manager/SessionMangerTest.php @@ -60,14 +60,14 @@ public function testGetSessionData() $container = new Container(); $container->foo = 'fooValue'; - $sessionData = array( - 'Foo' => array( + $sessionData = [ + 'Foo' => [ 'foo' => 'fooValue', - ), - 'Default' => array( + ], + 'Default' => [ 'foo' => 'fooValue', - ), - ); + ], + ]; $this->assertEquals($sessionData, $this->manager->getSessionData()); } @@ -84,13 +84,13 @@ public function testSessionSetting($container, $keysession, $value, $options, $r public function provideSessionSettingData() { - return array( - array('Default', 'foo', null, array(), false), - array('Default', 'foo', 'fooValue', array('new' => true), true), - array('Foo', 'foo', 'fooValue', array('new' => true), false), - array('Foo', 'foo', 'NewFooValue', array('set' => true), true), - array('Foo', 'foo', 'NewFooValue', array('set' => false), true), - ); + return [ + ['Default', 'foo', null, [], false], + ['Default', 'foo', 'fooValue', ['new' => true], true], + ['Foo', 'foo', 'fooValue', ['new' => true], false], + ['Foo', 'foo', 'NewFooValue', ['set' => true], true], + ['Foo', 'foo', 'NewFooValue', ['set' => false], true], + ]; } /** @@ -107,9 +107,9 @@ public function testClearSession($byContainer, $result) public function provideClearSession() { - return array( - array('Default', array('Foo' => array('foo' => 'fooValue'))), - array(null, array()), - ); + return [ + ['Default', ['Foo' => ['foo' => 'fooValue']]], + [null, []], + ]; } } diff --git a/test/ModuleTest.php b/test/ModuleTest.php index b8c946f..68c7dd0 100644 --- a/test/ModuleTest.php +++ b/test/ModuleTest.php @@ -41,10 +41,10 @@ protected function setUp() public function provideHasMessages() { - return array( - array(false), - array(true), - ); + return [ + [false], + [true], + ]; } /** @@ -66,7 +66,7 @@ public function testOnBootstrap($hasMessages) $sharedEvmAttach = $sharedEvm->attach( 'Zend\Mvc\Controller\AbstractActionController', 'dispatch', - array($this->module, 'flashMessengerHandler'), + [$this->module, 'flashMessengerHandler'], 2 ); $module = $this->module; @@ -130,6 +130,6 @@ public function testGetConfig() */ public function testGetModuleDependencies() { - $this->assertEquals(array('ZendDeveloperTools'), $this->module->getModuleDependencies()); + $this->assertEquals(['ZendDeveloperTools'], $this->module->getModuleDependencies()); } } From 3375d209759d3f02636a40e7c24785d81e737924 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 16 Jul 2016 11:01:58 +0700 Subject: [PATCH 3/4] remove old php version --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5d7abe9..58ed421 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,9 +3,6 @@ sudo: false language: php php: - - 5.3 - - 5.4 - - 5.5 - 5.6 - 7 - hhvm From 408b1c1bacf4ae06b4cad59d07697ec4c662ec93 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 16 Jul 2016 11:08:52 +0700 Subject: [PATCH 4/4] changelog update --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7364a6b..5ac7cac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +### 1.0.0 - 2016-07-16 + +- support only php ^5.6 | ^7.0 +- bring short array syntax +- support only zf ^2.5 components + ### 0.6.3 - 2016-06-28 - zdt dependency in require-dev