From 11604d336a148909bef0f5b4f77dcec86afca1dc Mon Sep 17 00:00:00 2001 From: mtak3 Date: Fri, 14 Feb 2020 08:45:58 +0000 Subject: [PATCH 1/5] update for cake-4.x --- .gitignore | 1 + composer.json | 12 +-- .../Component/ApiPaginationComponent.php | 10 ++- .../Component/ApiPaginationComponentTest.php | 89 +++++++++++-------- .../TestApp/Controller/ArticlesController.php | 2 +- 5 files changed, 68 insertions(+), 46 deletions(-) diff --git a/.gitignore b/.gitignore index 073e37a..b6bd0e7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ build composer.lock vendor +.phpunit.result.cache diff --git a/composer.json b/composer.json index a40ea6c..6eeaa50 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "bcrowe/cakephp-api-pagination", - "description": "CakePHP 3 plugin that injects pagination information into API responses.", + "description": "CakePHP 4 plugin that injects pagination information into API responses.", "type": "cakephp-plugin", "keywords": [ "cakephp", "api", "pagination", "cakephp3" @@ -16,13 +16,13 @@ } ], "require": { - "php": ">=5.6", - "cakephp/cakephp": "~3.6" + "php": ">=7.2", + "cakephp/cakephp": "^4.0" }, "require-dev": { - "phpunit/phpunit" : "~5.0", - "scrutinizer/ocular": "1.1", - "squizlabs/php_codesniffer": "~2.3.0" + "phpunit/phpunit" : "^8.5", + "scrutinizer/ocular": "1.7", + "cakephp/cakephp-codesniffer": "~4.0.0" }, "autoload": { "psr-4": { diff --git a/src/Controller/Component/ApiPaginationComponent.php b/src/Controller/Component/ApiPaginationComponent.php index b5944ea..0391c9e 100644 --- a/src/Controller/Component/ApiPaginationComponent.php +++ b/src/Controller/Component/ApiPaginationComponent.php @@ -43,7 +43,7 @@ public function beforeRender(Event $event) } $subject = $event->getSubject(); - $this->pagingInfo = $this->request->getParam('paging')[$subject->getName()]; + $this->pagingInfo = $this->getController()->getRequest()->getAttribute('paging')[$subject->getName()]; $config = $this->getConfig(); if (!empty($config['aliases'])) { @@ -55,7 +55,9 @@ public function beforeRender(Event $event) } $subject->set($config['key'], $this->pagingInfo); - $subject->viewVars['_serialize'][] = $config['key']; + $data = $subject->viewBuilder()->getVar('_serialize') ?? []; + $data[] = $config['key']; + $subject->set('_serialize', $data); } /** @@ -96,8 +98,8 @@ protected function setVisibility() */ protected function isPaginatedApiRequest() { - if ($this->request->getParam('paging') && - $this->request->is(['json', 'xml']) + if ($this->getController()->getRequest()->getAttribute('paging') && + $this->getController()->getRequest()->is(['json', 'xml']) ) { return true; } diff --git a/tests/TestCase/Controller/Component/ApiPaginationComponentTest.php b/tests/TestCase/Controller/Component/ApiPaginationComponentTest.php index be75d76..0bdd546 100644 --- a/tests/TestCase/Controller/Component/ApiPaginationComponentTest.php +++ b/tests/TestCase/Controller/Component/ApiPaginationComponentTest.php @@ -23,9 +23,9 @@ class ApiPaginationComponentTest extends TestCase * * @return void */ - public function setUp() + public function setUp(): void { - $this->request = new Request('/articles'); + $this->request = new Request(['url' => '/articles']); $this->response = $this->createMock('Cake\Http\Response'); $this->controller = new ArticlesController($this->request, $this->response); $this->Articles = TableRegistry::get('BryanCrowe/ApiPagination.Articles', ['table' => 'bryancrowe_articles']); @@ -37,7 +37,7 @@ public function setUp() * * @return void */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); } @@ -63,29 +63,34 @@ public function testNonApiPaginatedRequest() */ public function testDefaultPaginationSettings() { - $this->controller->request = $this->controller->request->withEnv('HTTP_ACCEPT', 'application/json'); + $this->controller->setRequest( + $this->controller->getRequest()->withEnv('HTTP_ACCEPT', 'application/json') + ); $this->controller->set('data', $this->controller->paginate($this->Articles)); $apiPaginationComponent = new ApiPaginationComponent($this->controller->components()); $event = new Event('Controller.beforeRender', $this->controller); $apiPaginationComponent->beforeRender($event); - $result = $apiPaginationComponent->_registry->getController()->viewVars['pagination']; + $result = $apiPaginationComponent->getController()->viewBuilder()->getVar('pagination'); $expected = [ - 'finder' => 'all', - 'page' => 1, - 'current' => 20, 'count' => 23, + 'current' => 20, 'perPage' => 20, + 'page' => 1, + 'requestedPage' => 1, + 'pageCount' => 2, + 'start' => 1, + 'end' => 20, 'prevPage' => false, 'nextPage' => true, - 'pageCount' => 2, 'sort' => null, - 'direction' => false, - 'limit' => null, + 'direction' => null, 'sortDefault' => false, 'directionDefault' => false, + 'completeSort' => [], + 'limit' => null, 'scope' => null, - 'completeSort' => [] + 'finder' => 'all', ]; $this->assertSame($expected, $result); @@ -98,7 +103,9 @@ public function testDefaultPaginationSettings() */ public function testVisibilitySettings() { - $this->controller->request = $this->controller->request->withEnv('HTTP_ACCEPT', 'application/json'); + $this->controller->setRequest( + $this->controller->getRequest()->withEnv('HTTP_ACCEPT', 'application/json') + ); $this->controller->set('data', $this->controller->paginate($this->Articles)); $apiPaginationComponent = new ApiPaginationComponent($this->controller->components(), [ 'visible' => [ @@ -113,14 +120,14 @@ public function testVisibilitySettings() $event = new Event('Controller.beforeRender', $this->controller); $apiPaginationComponent->beforeRender($event); - $result = $apiPaginationComponent->_registry->getController()->viewVars['pagination']; + $result = $apiPaginationComponent->getController()->viewBuilder()->getVar('pagination'); $expected = [ - 'page' => 1, - 'current' => 20, 'count' => 23, + 'current' => 20, + 'page' => 1, + 'pageCount' => 2, 'prevPage' => false, 'nextPage' => true, - 'pageCount' => 2 ]; $this->assertSame($expected, $result); @@ -133,7 +140,9 @@ public function testVisibilitySettings() */ public function testAliasSettings() { - $this->controller->request = $this->controller->request->withEnv('HTTP_ACCEPT', 'application/json'); + $this->controller->setRequest( + $this->controller->getRequest()->withEnv('HTTP_ACCEPT', 'application/json') + ); $this->controller->set('data', $this->controller->paginate($this->Articles)); $apiPaginationComponent = new ApiPaginationComponent($this->controller->components(), [ 'aliases' => [ @@ -145,20 +154,23 @@ public function testAliasSettings() $event = new Event('Controller.beforeRender', $this->controller); $apiPaginationComponent->beforeRender($event); - $result = $apiPaginationComponent->_registry->getController()->viewVars['pagination']; + $result = $apiPaginationComponent->getController()->viewBuilder()->getVar('pagination'); $expected = [ - 'finder' => 'all', 'perPage' => 20, + 'requestedPage' => 1, + 'pageCount' => 2, + 'start' => 1, + 'end' => 20, 'prevPage' => false, 'nextPage' => true, - 'pageCount' => 2, 'sort' => null, - 'direction' => false, - 'limit' => null, + 'direction' => null, 'sortDefault' => false, 'directionDefault' => false, - 'scope' => null, 'completeSort' => [], + 'limit' => null, + 'scope' => null, + 'finder' => 'all', 'curPage' => 1, 'currentCount' => 20, 'totalCount' => 23, @@ -174,7 +186,9 @@ public function testAliasSettings() */ public function testKeySetting() { - $this->controller->request = $this->controller->request->withEnv('HTTP_ACCEPT', 'application/json'); + $this->controller->setRequest( + $this->controller->getRequest()->withEnv('HTTP_ACCEPT', 'application/json') + ); $this->controller->set('data', $this->controller->paginate($this->Articles)); $apiPaginationComponent = new ApiPaginationComponent($this->controller->components(), [ 'key' => 'paging' @@ -182,23 +196,26 @@ public function testKeySetting() $event = new Event('Controller.beforeRender', $this->controller); $apiPaginationComponent->beforeRender($event); - $result = $apiPaginationComponent->_registry->getController()->viewVars['paging']; + $result = $apiPaginationComponent->getController()->viewBuilder()->getVar('paging'); $expected = [ - 'finder' => 'all', - 'page' => 1, - 'current' => 20, 'count' => 23, + 'current' => 20, 'perPage' => 20, + 'page' => 1, + 'requestedPage' => 1, + 'pageCount' => 2, + 'start' => 1, + 'end' => 20, 'prevPage' => false, 'nextPage' => true, - 'pageCount' => 2, 'sort' => null, - 'direction' => false, - 'limit' => null, + 'direction' => null, 'sortDefault' => false, 'directionDefault' => false, + 'completeSort' => [], + 'limit' => null, 'scope' => null, - 'completeSort' => [] + 'finder' => 'all', ]; $this->assertSame($expected, $result); @@ -211,7 +228,9 @@ public function testKeySetting() */ public function testAllSettings() { - $this->controller->request = $this->controller->request->withEnv('HTTP_ACCEPT', 'application/json'); + $this->controller->setRequest( + $this->controller->getRequest()->withEnv('HTTP_ACCEPT', 'application/json') + ); $this->controller->set('data', $this->controller->paginate($this->Articles)); $apiPaginationComponent = new ApiPaginationComponent($this->controller->components(), [ 'key' => 'fun', @@ -231,7 +250,7 @@ public function testAllSettings() $event = new Event('Controller.beforeRender', $this->controller); $apiPaginationComponent->beforeRender($event); - $result = $apiPaginationComponent->_registry->getController()->viewVars['fun']; + $result = $apiPaginationComponent->getController()->viewBuilder()->getVar('fun'); $expected = [ 'prevPage' => false, 'nextPage' => true, diff --git a/tests/test_app/TestApp/Controller/ArticlesController.php b/tests/test_app/TestApp/Controller/ArticlesController.php index f6a6155..d10655d 100644 --- a/tests/test_app/TestApp/Controller/ArticlesController.php +++ b/tests/test_app/TestApp/Controller/ArticlesController.php @@ -5,7 +5,7 @@ class ArticlesController extends Controller { - public function initialize() + public function initialize(): void { parent::initialize(); $this->loadComponent('Paginator'); From 88f2991825511fe8b0abcec30558cc4fd6e5e7bc Mon Sep 17 00:00:00 2001 From: mtak3 Date: Fri, 14 Feb 2020 08:46:56 +0000 Subject: [PATCH 2/5] phpcbf src/ tests/ $ ./vendor/bin/phpcbf src/ tests/ PHPCBF RESULT SUMMARY ----------------------------------------------------------------------------------------------------------------------------------- FILE FIXED REMAINING ----------------------------------------------------------------------------------------------------------------------------------- cakephp-api-pagination/src/Controller/Component/ApiPaginationComponent.php 2 9 cakephp-api-pagination/tests/TestCase/Controller/Component/ApiPaginationComponentTest.php 8 21 cakephp-api-pagination/tests/bootstrap.php 1 2 ----------------------------------------------------------------------------------------------------------------------------------- A TOTAL OF 11 ERRORS WERE FIXED IN 3 FILES ----------------------------------------------------------------------------------------------------------------------------------- Time: 372ms; Memory: 10MB --- .../Component/ApiPaginationComponent.php | 6 ++--- .../Component/ApiPaginationComponentTest.php | 24 ++++++++++++------- tests/bootstrap.php | 2 +- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/Controller/Component/ApiPaginationComponent.php b/src/Controller/Component/ApiPaginationComponent.php index 0391c9e..5a43399 100644 --- a/src/Controller/Component/ApiPaginationComponent.php +++ b/src/Controller/Component/ApiPaginationComponent.php @@ -33,7 +33,7 @@ class ApiPaginationComponent extends Component * Injects the pagination info into the response if the current request is a * JSON or XML request with pagination. * - * @param \Cake\Event\Event $event The Controller.beforeRender event. + * @param \Cake\Event\Event $event The Controller.beforeRender event. * @return void */ public function beforeRender(Event $event) @@ -98,8 +98,8 @@ protected function setVisibility() */ protected function isPaginatedApiRequest() { - if ($this->getController()->getRequest()->getAttribute('paging') && - $this->getController()->getRequest()->is(['json', 'xml']) + if ($this->getController()->getRequest()->getAttribute('paging') + && $this->getController()->getRequest()->is(['json', 'xml']) ) { return true; } diff --git a/tests/TestCase/Controller/Component/ApiPaginationComponentTest.php b/tests/TestCase/Controller/Component/ApiPaginationComponentTest.php index 0bdd546..5d02b83 100644 --- a/tests/TestCase/Controller/Component/ApiPaginationComponentTest.php +++ b/tests/TestCase/Controller/Component/ApiPaginationComponentTest.php @@ -107,7 +107,8 @@ public function testVisibilitySettings() $this->controller->getRequest()->withEnv('HTTP_ACCEPT', 'application/json') ); $this->controller->set('data', $this->controller->paginate($this->Articles)); - $apiPaginationComponent = new ApiPaginationComponent($this->controller->components(), [ + $apiPaginationComponent = new ApiPaginationComponent( + $this->controller->components(), [ 'visible' => [ 'page', 'current', @@ -116,7 +117,8 @@ public function testVisibilitySettings() 'nextPage', 'pageCount' ] - ]); + ] + ); $event = new Event('Controller.beforeRender', $this->controller); $apiPaginationComponent->beforeRender($event); @@ -144,13 +146,15 @@ public function testAliasSettings() $this->controller->getRequest()->withEnv('HTTP_ACCEPT', 'application/json') ); $this->controller->set('data', $this->controller->paginate($this->Articles)); - $apiPaginationComponent = new ApiPaginationComponent($this->controller->components(), [ + $apiPaginationComponent = new ApiPaginationComponent( + $this->controller->components(), [ 'aliases' => [ 'page' => 'curPage', 'current' => 'currentCount', 'count' => 'totalCount', ] - ]); + ] + ); $event = new Event('Controller.beforeRender', $this->controller); $apiPaginationComponent->beforeRender($event); @@ -190,9 +194,11 @@ public function testKeySetting() $this->controller->getRequest()->withEnv('HTTP_ACCEPT', 'application/json') ); $this->controller->set('data', $this->controller->paginate($this->Articles)); - $apiPaginationComponent = new ApiPaginationComponent($this->controller->components(), [ + $apiPaginationComponent = new ApiPaginationComponent( + $this->controller->components(), [ 'key' => 'paging' - ]); + ] + ); $event = new Event('Controller.beforeRender', $this->controller); $apiPaginationComponent->beforeRender($event); @@ -232,7 +238,8 @@ public function testAllSettings() $this->controller->getRequest()->withEnv('HTTP_ACCEPT', 'application/json') ); $this->controller->set('data', $this->controller->paginate($this->Articles)); - $apiPaginationComponent = new ApiPaginationComponent($this->controller->components(), [ + $apiPaginationComponent = new ApiPaginationComponent( + $this->controller->components(), [ 'key' => 'fun', 'aliases' => [ 'page' => 'currentPage', @@ -246,7 +253,8 @@ public function testAllSettings() 'prevPage', 'nextPage' ] - ]); + ] + ); $event = new Event('Controller.beforeRender', $this->controller); $apiPaginationComponent->beforeRender($event); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index d4ec98c..8a05bcc 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -13,7 +13,7 @@ unset($findRoot); chdir($root); if (file_exists($root . '/config/bootstrap.php')) { - require $root . '/config/bootstrap.php'; + include $root . '/config/bootstrap.php'; return; } require $root . '/vendor/cakephp/cakephp/tests/bootstrap.php'; From 7d64fd5ae716441a839432b853098b780a4a3df0 Mon Sep 17 00:00:00 2001 From: mtak3 Date: Fri, 14 Feb 2020 08:49:29 +0000 Subject: [PATCH 3/5] update phpunit.xml.dist I do not know how to solve. --- $ composer test > phpunit PHPUnit 8.5.2 by Sebastian Bergmann and contributors. Runtime: PHP 7.4.2 with Xdebug 2.9.2 Configuration: /path/to/cakephp-api-pagination/phpunit.xml.dist Warning - The configuration file did not pass validation! The following problems have been detected: Line 34: - Element 'log', attribute 'charset': The attribute 'charset' is not allowed. - Element 'log', attribute 'yui': The attribute 'yui' is not allowed. - Element 'log', attribute 'highlight': The attribute 'highlight' is not allowed. Test results may not be as expected. ...... 6 / 6 (100%) Time: 250 ms, Memory: 12.00 MB OK (6 tests, 6 assertions) Generating code coverage report in Clover XML format ... done [6 ms] Generating code coverage report in HTML format ... done [10 ms] --- --- phpunit.xml.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index c6c4b9c..1136eba 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -31,7 +31,7 @@ - + From e45806892a2d818f4f6cab79c0d2019784af78ff Mon Sep 17 00:00:00 2001 From: mtak3 Date: Fri, 14 Feb 2020 09:03:16 +0000 Subject: [PATCH 4/5] add phpcs.xml.dist --- composer.json | 4 ++- phpcs.xml.dist | 11 +++++++ .../Component/ApiPaginationComponent.php | 7 +++-- tests/Fixture/ArticlesFixture.php | 4 +-- .../Component/ApiPaginationComponentTest.php | 29 +++++++++++-------- tests/bootstrap.php | 2 +- .../TestApp/Controller/ArticlesController.php | 2 ++ 7 files changed, 41 insertions(+), 18 deletions(-) create mode 100644 phpcs.xml.dist diff --git a/composer.json b/composer.json index 6eeaa50..4b0cf5c 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,9 @@ } }, "scripts": { - "test": "phpunit" + "test": "phpunit", + "cs-check": "phpcs src/ tests/", + "cs-fix": "phpcbf src/ tests/" }, "extra": { "branch-alias": { diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 0000000..10c5a08 --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,11 @@ + + + + tests/bootstrap.php + + + + + + + diff --git a/src/Controller/Component/ApiPaginationComponent.php b/src/Controller/Component/ApiPaginationComponent.php index 5a43399..3f12012 100644 --- a/src/Controller/Component/ApiPaginationComponent.php +++ b/src/Controller/Component/ApiPaginationComponent.php @@ -1,4 +1,6 @@ 'pagination', 'aliases' => [], - 'visible' => [] + 'visible' => [], ]; /** @@ -98,7 +100,8 @@ protected function setVisibility() */ protected function isPaginatedApiRequest() { - if ($this->getController()->getRequest()->getAttribute('paging') + if ( + $this->getController()->getRequest()->getAttribute('paging') && $this->getController()->getRequest()->is(['json', 'xml']) ) { return true; diff --git a/tests/Fixture/ArticlesFixture.php b/tests/Fixture/ArticlesFixture.php index 44dbc8c..d241bc2 100644 --- a/tests/Fixture/ArticlesFixture.php +++ b/tests/Fixture/ArticlesFixture.php @@ -11,7 +11,7 @@ class ArticlesFixture extends TestFixture 'id' => ['type' => 'integer'], 'title' => ['type' => 'string', 'null' => false], 'body' => 'text', - '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]] + '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]], ]; public $records = [ @@ -37,6 +37,6 @@ class ArticlesFixture extends TestFixture ['title' => 'Post #20', 'body' => 'This is the article body.'], ['title' => 'Post #21', 'body' => 'This is the article body.'], ['title' => 'Post #22', 'body' => 'This is the article body.'], - ['title' => 'Post #23', 'body' => 'This is the article body.'] + ['title' => 'Post #23', 'body' => 'This is the article body.'], ]; } diff --git a/tests/TestCase/Controller/Component/ApiPaginationComponentTest.php b/tests/TestCase/Controller/Component/ApiPaginationComponentTest.php index 5d02b83..ddb7f95 100644 --- a/tests/TestCase/Controller/Component/ApiPaginationComponentTest.php +++ b/tests/TestCase/Controller/Component/ApiPaginationComponentTest.php @@ -1,11 +1,12 @@ controller->set('data', $this->controller->paginate($this->Articles)); $apiPaginationComponent = new ApiPaginationComponent( - $this->controller->components(), [ + $this->controller->components(), + [ 'visible' => [ 'page', 'current', 'count', 'prevPage', 'nextPage', - 'pageCount' - ] + 'pageCount', + ], ] ); $event = new Event('Controller.beforeRender', $this->controller); @@ -147,12 +149,13 @@ public function testAliasSettings() ); $this->controller->set('data', $this->controller->paginate($this->Articles)); $apiPaginationComponent = new ApiPaginationComponent( - $this->controller->components(), [ + $this->controller->components(), + [ 'aliases' => [ 'page' => 'curPage', 'current' => 'currentCount', 'count' => 'totalCount', - ] + ], ] ); $event = new Event('Controller.beforeRender', $this->controller); @@ -195,8 +198,9 @@ public function testKeySetting() ); $this->controller->set('data', $this->controller->paginate($this->Articles)); $apiPaginationComponent = new ApiPaginationComponent( - $this->controller->components(), [ - 'key' => 'paging' + $this->controller->components(), + [ + 'key' => 'paging', ] ); $event = new Event('Controller.beforeRender', $this->controller); @@ -239,20 +243,21 @@ public function testAllSettings() ); $this->controller->set('data', $this->controller->paginate($this->Articles)); $apiPaginationComponent = new ApiPaginationComponent( - $this->controller->components(), [ + $this->controller->components(), + [ 'key' => 'fun', 'aliases' => [ 'page' => 'currentPage', 'count' => 'totalCount', - 'limit' => 'unusedAlias' + 'limit' => 'unusedAlias', ], 'visible' => [ 'currentPage', 'totalCount', 'limit', 'prevPage', - 'nextPage' - ] + 'nextPage', + ], ] ); $event = new Event('Controller.beforeRender', $this->controller); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 8a05bcc..d4ec98c 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -13,7 +13,7 @@ unset($findRoot); chdir($root); if (file_exists($root . '/config/bootstrap.php')) { - include $root . '/config/bootstrap.php'; + require $root . '/config/bootstrap.php'; return; } require $root . '/vendor/cakephp/cakephp/tests/bootstrap.php'; diff --git a/tests/test_app/TestApp/Controller/ArticlesController.php b/tests/test_app/TestApp/Controller/ArticlesController.php index d10655d..428e94c 100644 --- a/tests/test_app/TestApp/Controller/ArticlesController.php +++ b/tests/test_app/TestApp/Controller/ArticlesController.php @@ -1,4 +1,6 @@ Date: Fri, 14 Feb 2020 09:08:22 +0000 Subject: [PATCH 5/5] update .travis.yml --- .travis.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 905a3eb..b4c3966 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,15 +6,13 @@ env: - RUN_TESTS=1 php: - - 5.6 - - 7.0 - - hhvm + - 7.3 sudo: false matrix: include: - - php: 5.6 + - php: 7.2 env: PHPCS=1 RUN_TESTS=0 before_script: @@ -23,7 +21,7 @@ before_script: script: - sh -c "if [ '$RUN_TESTS' = '1' ]; then vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover; fi" - - sh -c "if [ '$PHPCS' = '1' ]; then vendor/bin/phpcs -p -n --extensions=php --standard=psr2 ./src ./tests; fi" + - sh -c "if [ '$PHPCS' = '1' ]; then vendor/bin/phpcs -p ./src ./tests; fi" after_script: - if [[ $TRAVIS_PHP_VERSION != 'hhvm' && $TRAVIS_PHP_VERSION != '7.0' ]]; then php vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover; fi