From c30e855c44d8e0dfaa01d900c87930ded72762b9 Mon Sep 17 00:00:00 2001 From: webimpress Date: Thu, 3 May 2018 14:38:08 +0100 Subject: [PATCH 1/9] Updated Travis CI configuration - added PHP 7.2 support - use PSR-4 autoloading - updated PHPUnit - dropped PHP < 5.6 and HHVM support --- .travis.yml | 14 ++- README.md | 8 +- composer.json | 25 +++-- phpunit.xml.dist | 17 ++++ .../Apns/Client/AbstractClient.php | 0 .../Apple => src}/Apns/Client/Feedback.php | 0 .../Apple => src}/Apns/Client/Message.php | 0 .../Apple => src}/Apns/Message.php | 0 .../Apple => src}/Apns/Message/Alert.php | 0 .../Apple => src}/Apns/Response/Feedback.php | 0 .../Apple => src}/Apns/Response/Message.php | 0 .../Exception/InvalidArgumentException.php | 0 .../Exception/RuntimeException.php | 0 .../Exception/StreamSocketClientException.php | 0 .../Apns/FeedbackClientTest.php | 3 +- .../Apple => test}/Apns/MessageClientTest.php | 13 +-- .../Apple => test}/Apns/MessageTest.php | 40 ++++---- .../Apns/TestAsset/FeedbackClient.php | 0 .../Apns/TestAsset/MessageClient.php | 0 .../Apns/TestAsset/certificate.pem | 0 tests/.gitignore | 2 - tests/Bootstrap.php | 93 ------------------- tests/TestConfiguration.php.dist | 45 --------- tests/TestConfiguration.php.travis | 20 ---- tests/_autoload.php | 29 ------ tests/phpunit.xml.dist | 13 --- 26 files changed, 66 insertions(+), 256 deletions(-) create mode 100755 phpunit.xml.dist rename {library/ZendService/Apple => src}/Apns/Client/AbstractClient.php (100%) rename {library/ZendService/Apple => src}/Apns/Client/Feedback.php (100%) rename {library/ZendService/Apple => src}/Apns/Client/Message.php (100%) rename {library/ZendService/Apple => src}/Apns/Message.php (100%) rename {library/ZendService/Apple => src}/Apns/Message/Alert.php (100%) rename {library/ZendService/Apple => src}/Apns/Response/Feedback.php (100%) rename {library/ZendService/Apple => src}/Apns/Response/Message.php (100%) rename {library/ZendService/Apple => src}/Exception/InvalidArgumentException.php (100%) rename {library/ZendService/Apple => src}/Exception/RuntimeException.php (100%) rename {library/ZendService/Apple => src}/Exception/StreamSocketClientException.php (100%) rename {tests/ZendService/Apple => test}/Apns/FeedbackClientTest.php (94%) rename {tests/ZendService/Apple => test}/Apns/MessageClientTest.php (94%) rename {tests/ZendService/Apple => test}/Apns/MessageTest.php (88%) rename {tests/ZendService/Apple => test}/Apns/TestAsset/FeedbackClient.php (100%) rename {tests/ZendService/Apple => test}/Apns/TestAsset/MessageClient.php (100%) rename {tests/ZendService/Apple => test}/Apns/TestAsset/certificate.pem (100%) delete mode 100755 tests/.gitignore delete mode 100755 tests/Bootstrap.php delete mode 100755 tests/TestConfiguration.php.dist delete mode 100755 tests/TestConfiguration.php.travis delete mode 100755 tests/_autoload.php delete mode 100755 tests/phpunit.xml.dist diff --git a/.travis.yml b/.travis.yml index 1806edf..4763b4d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,16 @@ language: php php: - - 5.3 - - 5.4 - - 5.5 - 5.6 - - hhvm + - 7.0 + - 7.1 + - 7.2 before_install: - - cp tests/TestConfiguration.php.travis tests/TestConfiguration.php - - composer install --dev + - composer install script: - - phpunit -c tests/phpunit.xml.dist + - ./vendor/bin/phpunit notifications: - #irc: "irc.freenode.org#zftalk.2" \ No newline at end of file + email: false diff --git a/README.md b/README.md index 23d927d..184ac6a 100755 --- a/README.md +++ b/README.md @@ -4,11 +4,11 @@ ZendService\Apple\Apns [![Build Status](https://travis-ci.org/zendframework/Zend Provides support for Apple push notifications. -## Requirements ## +## Requirements -* PHP >= 5.3.3 +* PHP >= 5.6 -## Getting Started ## +## Getting Started Install this library using [Composer](http://getcomposer.org/): @@ -16,7 +16,7 @@ Install this library using [Composer](http://getcomposer.org/): $ composer require zendframework/zendservice-apple-apns ``` -## Documentation ## +## Documentation The documentation can be found at: http://framework.zend.com/manual/current/en/modules/zendservice.apple.apns.html diff --git a/composer.json b/composer.json index 9347c96..f55bd02 100755 --- a/composer.json +++ b/composer.json @@ -1,33 +1,30 @@ { "name": "zendframework/zendservice-apple-apns", "description": "OOP Zend Framework 2 wrapper for Apple Push Notification Service", - "type": "library", "keywords": [ - "zf2", + "zf", + "zendframework", "apns", "push", "notification", "apple" ], - "homepage": "https://packages.zendframework.com/", "license": "BSD-3-Clause", "autoload": { - "psr-0": { - "ZendService\\Apple\\Apns\\": "library/", - "ZendService\\Apple\\Exception\\": "library/" + "psr-4": { + "ZendService\\Apple\\": "src/" } }, - "repositories": [ - { - "type": "composer", - "url": "https://packages.zendframework.com/" + "autoload-dev": { + "psr-4": { + "ZendServiceTest\\Apple\\": "test/" } - ], + }, "require": { - "php": ">=5.3.3", - "zendframework/zend-json": "^2.0|^3.0" + "php": "^5.3.3 || ^7.0", + "zendframework/zend-json": "^2.0 || ^3.0" }, "require-dev": { - "phpunit/phpunit": "3.7.*" + "phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1.5" } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100755 index 0000000..36b2d67 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,17 @@ + + + + + ./test + + + + + + ./src + + + diff --git a/library/ZendService/Apple/Apns/Client/AbstractClient.php b/src/Apns/Client/AbstractClient.php similarity index 100% rename from library/ZendService/Apple/Apns/Client/AbstractClient.php rename to src/Apns/Client/AbstractClient.php diff --git a/library/ZendService/Apple/Apns/Client/Feedback.php b/src/Apns/Client/Feedback.php similarity index 100% rename from library/ZendService/Apple/Apns/Client/Feedback.php rename to src/Apns/Client/Feedback.php diff --git a/library/ZendService/Apple/Apns/Client/Message.php b/src/Apns/Client/Message.php similarity index 100% rename from library/ZendService/Apple/Apns/Client/Message.php rename to src/Apns/Client/Message.php diff --git a/library/ZendService/Apple/Apns/Message.php b/src/Apns/Message.php similarity index 100% rename from library/ZendService/Apple/Apns/Message.php rename to src/Apns/Message.php diff --git a/library/ZendService/Apple/Apns/Message/Alert.php b/src/Apns/Message/Alert.php similarity index 100% rename from library/ZendService/Apple/Apns/Message/Alert.php rename to src/Apns/Message/Alert.php diff --git a/library/ZendService/Apple/Apns/Response/Feedback.php b/src/Apns/Response/Feedback.php similarity index 100% rename from library/ZendService/Apple/Apns/Response/Feedback.php rename to src/Apns/Response/Feedback.php diff --git a/library/ZendService/Apple/Apns/Response/Message.php b/src/Apns/Response/Message.php similarity index 100% rename from library/ZendService/Apple/Apns/Response/Message.php rename to src/Apns/Response/Message.php diff --git a/library/ZendService/Apple/Exception/InvalidArgumentException.php b/src/Exception/InvalidArgumentException.php similarity index 100% rename from library/ZendService/Apple/Exception/InvalidArgumentException.php rename to src/Exception/InvalidArgumentException.php diff --git a/library/ZendService/Apple/Exception/RuntimeException.php b/src/Exception/RuntimeException.php similarity index 100% rename from library/ZendService/Apple/Exception/RuntimeException.php rename to src/Exception/RuntimeException.php diff --git a/library/ZendService/Apple/Exception/StreamSocketClientException.php b/src/Exception/StreamSocketClientException.php similarity index 100% rename from library/ZendService/Apple/Exception/StreamSocketClientException.php rename to src/Exception/StreamSocketClientException.php diff --git a/tests/ZendService/Apple/Apns/FeedbackClientTest.php b/test/Apns/FeedbackClientTest.php similarity index 94% rename from tests/ZendService/Apple/Apns/FeedbackClientTest.php rename to test/Apns/FeedbackClientTest.php index 1435437..205fabd 100644 --- a/tests/ZendService/Apple/Apns/FeedbackClientTest.php +++ b/test/Apns/FeedbackClientTest.php @@ -10,6 +10,7 @@ namespace ZendServiceTest\Apple\Apns; +use PHPUnit\Framework\TestCase; use ZendServiceTest\Apple\Apns\TestAsset\FeedbackClient; /** @@ -20,7 +21,7 @@ * @group ZendService_Apple * @group ZendService_Apple_Apns */ -class FeedbackClientTest extends \PHPUnit_Framework_TestCase +class FeedbackClientTest extends TestCase { public function setUp() { diff --git a/tests/ZendService/Apple/Apns/MessageClientTest.php b/test/Apns/MessageClientTest.php similarity index 94% rename from tests/ZendService/Apple/Apns/MessageClientTest.php rename to test/Apns/MessageClientTest.php index dd6bf03..9c470a9 100644 --- a/tests/ZendService/Apple/Apns/MessageClientTest.php +++ b/test/Apns/MessageClientTest.php @@ -12,6 +12,7 @@ namespace ZendServiceTest\Apple\Apns; +use PHPUnit\Framework\TestCase; use ZendServiceTest\Apple\Apns\TestAsset\MessageClient; use ZendService\Apple\Apns\Message; use ZendService\Apple\Apns\Response\Message as MessageResponse; @@ -24,7 +25,7 @@ * @group ZendService_Apple * @group ZendService_Apple_Apns */ -class MessageClientTest extends \PHPUnit_Framework_TestCase +class MessageClientTest extends TestCase { public function setUp() { @@ -42,25 +43,25 @@ protected function setupValidBase() public function testConnectThrowsExceptionOnInvalidEnvironment() { - $this->setExpectedException('InvalidArgumentException'); + $this->expectException('InvalidArgumentException'); $this->apns->open(5, __DIR__ . '/TestAsset/certificate.pem'); } public function testSetCertificateThrowsExceptionOnNonString() { - $this->setExpectedException('InvalidArgumentException'); + $this->expectException('InvalidArgumentException'); $this->apns->open(MessageClient::PRODUCTION_URI, array('foo')); } public function testSetCertificateThrowsExceptionOnMissingFile() { - $this->setExpectedException('InvalidArgumentException'); + $this->expectException('InvalidArgumentException'); $this->apns->open(MessageClient::PRODUCTION_URI, 'foo'); } public function testSetCertificatePassphraseThrowsExceptionOnNonString() { - $this->setExpectedException('InvalidArgumentException'); + $this->expectException('InvalidArgumentException'); $this->apns->open(MessageClient::PRODUCTION_URI, __DIR__ . '/TestAsset/certificate.pem', array('foo')); } @@ -80,7 +81,7 @@ public function testClose() public function testOpenWhenAlreadyOpenThrowsException() { - $this->setExpectedException('RuntimeException'); + $this->expectException('RuntimeException'); $this->apns->open(MessageClient::SANDBOX_URI, __DIR__ . '/TestAsset/certificate.pem'); $this->apns->open(MessageClient::SANDBOX_URI, __DIR__ . '/TestAsset/certificate.pem'); } diff --git a/tests/ZendService/Apple/Apns/MessageTest.php b/test/Apns/MessageTest.php similarity index 88% rename from tests/ZendService/Apple/Apns/MessageTest.php rename to test/Apns/MessageTest.php index 3e829d8..d3af66f 100644 --- a/tests/ZendService/Apple/Apns/MessageTest.php +++ b/test/Apns/MessageTest.php @@ -1,15 +1,13 @@ setExpectedException('InvalidArgumentException'); + $this->expectException('InvalidArgumentException'); $this->message->setAlert(array()); } public function testSetAlertThrowsExceptionOnActionLocKeyNonString() { - $this->setExpectedException('InvalidArgumentException'); + $this->expectException('InvalidArgumentException'); $this->alert->setActionLocKey(array()); } public function testSetAlertThrowsExceptionOnLocKeyNonString() { - $this->setExpectedException('InvalidArgumentException'); + $this->expectException('InvalidArgumentException'); $this->alert->setLocKey(array()); } public function testSetAlertThrowsExceptionOnLaunchImageNonString() { - $this->setExpectedException('InvalidArgumentException'); + $this->expectException('InvalidArgumentException'); $this->alert->setLaunchImage(array()); } public function testSetAlertThrowsExceptionOnTitleNonString() { - $this->setExpectedException('InvalidArgumentException'); + $this->expectException('InvalidArgumentException'); $this->alert->setTitle(array()); } public function testSetAlertThrowsExceptionOnTitleLocKeyNonString() { - $this->setExpectedException('InvalidArgumentException'); + $this->expectException('InvalidArgumentException'); $this->alert->setTitleLocKey(array()); } @@ -86,7 +84,7 @@ public function testSetBadgeReturnsCorrectNumber() public function testSetBadgeNonNumericThrowsException() { - $this->setExpectedException('InvalidArgumentException'); + $this->expectException('InvalidArgumentException'); $this->message->setBadge('string!'); } @@ -105,7 +103,7 @@ public function testSetExpireReturnsInteger() public function testSetExpireNonNumericThrowsException() { - $this->setExpectedException('InvalidArgumentException'); + $this->expectException('InvalidArgumentException'); $this->message->setExpire('sting!'); } @@ -118,13 +116,13 @@ public function testSetSoundReturnsString() public function testSetSoundThrowsExceptionOnNonScalar() { - $this->setExpectedException('InvalidArgumentException'); + $this->expectException('InvalidArgumentException'); $this->message->setSound(array()); } public function testSetSoundThrowsExceptionOnNonString() { - $this->setExpectedException('InvalidArgumentException'); + $this->expectException('InvalidArgumentException'); $this->message->setSound(12345); } @@ -174,7 +172,7 @@ public function testSetMutableContentResultsInCorrectPayloadWithNullValue() public function testSetContentAvailableThrowsExceptionOnNonInteger() { - $this->setExpectedException('InvalidArgumentException'); + $this->expectException('InvalidArgumentException'); $this->message->setContentAvailable("string"); } @@ -202,13 +200,13 @@ public function testSetCategoryReturnsString() public function testSetCategoryThrowsExceptionOnNonScalar() { - $this->setExpectedException('InvalidArgumentException'); + $this->expectException('InvalidArgumentException'); $this->message->setCategory(array()); } public function testSetCategoryThrowsExceptionOnNonString() { - $this->setExpectedException('InvalidArgumentException'); + $this->expectException('InvalidArgumentException'); $this->message->setCategory(12345); } diff --git a/tests/ZendService/Apple/Apns/TestAsset/FeedbackClient.php b/test/Apns/TestAsset/FeedbackClient.php similarity index 100% rename from tests/ZendService/Apple/Apns/TestAsset/FeedbackClient.php rename to test/Apns/TestAsset/FeedbackClient.php diff --git a/tests/ZendService/Apple/Apns/TestAsset/MessageClient.php b/test/Apns/TestAsset/MessageClient.php similarity index 100% rename from tests/ZendService/Apple/Apns/TestAsset/MessageClient.php rename to test/Apns/TestAsset/MessageClient.php diff --git a/tests/ZendService/Apple/Apns/TestAsset/certificate.pem b/test/Apns/TestAsset/certificate.pem similarity index 100% rename from tests/ZendService/Apple/Apns/TestAsset/certificate.pem rename to test/Apns/TestAsset/certificate.pem diff --git a/tests/.gitignore b/tests/.gitignore deleted file mode 100755 index 902db60..0000000 --- a/tests/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -phpunit.xml -TestConfiguration.php diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php deleted file mode 100755 index 2bebec0..0000000 --- a/tests/Bootstrap.php +++ /dev/null @@ -1,93 +0,0 @@ -addDirectoryToWhitelist($zfCoreLibrary . '/' . $lastArg); - } elseif (is_file($zfCoreTests . '/' . $lastArg)) { - $codeCoverageFilter->addDirectoryToWhitelist(dirname($zfCoreLibrary . '/' . $lastArg)); - } else { - $codeCoverageFilter->addDirectoryToWhitelist($zfCoreLibrary); - } - - /* - * Omit from code coverage reports the contents of the tests directory - */ - $codeCoverageFilter->addDirectoryToBlacklist($zfCoreTests, ''); - $codeCoverageFilter->addDirectoryToBlacklist(PEAR_INSTALL_DIR, ''); - $codeCoverageFilter->addDirectoryToBlacklist(PHP_LIBDIR, ''); - - unset($codeCoverageFilter); -} - -/** - * Start output buffering, if enabled - */ -if (defined('TESTS_ZEND_OB_ENABLED') && constant('TESTS_ZEND_OB_ENABLED')) { - ob_start(); -} - -/* - * Unset global variables that are no longer needed. - */ -unset($zfRoot, $zfCoreLibrary, $zfCoreTests, $path); diff --git a/tests/TestConfiguration.php.dist b/tests/TestConfiguration.php.dist deleted file mode 100755 index 536498f..0000000 --- a/tests/TestConfiguration.php.dist +++ /dev/null @@ -1,45 +0,0 @@ - - - - ./ZendService - - - - - - disable - - - From c58201ce40aaf75316ac45a1b7a9f8613ed022af Mon Sep 17 00:00:00 2001 From: webimpress Date: Thu, 3 May 2018 14:41:29 +0100 Subject: [PATCH 2/9] Updated LICENSE - converted to MD file --- LICENSE.txt => LICENSE.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) rename LICENSE.txt => LICENSE.md (59%) diff --git a/LICENSE.txt b/LICENSE.md similarity index 59% rename from LICENSE.txt rename to LICENSE.md index 5ad81e9..d44ab5d 100755 --- a/LICENSE.txt +++ b/LICENSE.md @@ -1,19 +1,19 @@ -Copyright (c) 2005-2014, Zend Technologies USA, Inc. +Copyright (c) 2005-2018, Zend Technologies USA, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. +- Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. +- Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. - * Neither the name of Zend Technologies USA, Inc. nor the names of its - contributors may be used to endorse or promote products derived from this - software without specific prior written permission. +- Neither the name of Zend Technologies USA, Inc. nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED From 43445a8d9d6ca7016255cad0041569f181d5ad19 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 8 May 2018 13:29:55 -0500 Subject: [PATCH 3/9] Pin composer to 5.6 and 7.0 We no longer support 5.3 - 5.5. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f55bd02..65562ea 100755 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ } }, "require": { - "php": "^5.3.3 || ^7.0", + "php": "^5.6 || ^7.0", "zendframework/zend-json": "^2.0 || ^3.0" }, "require-dev": { From fdab2b2369b25c1fc389f396325d6a31f8ed0cc4 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 8 May 2018 13:30:19 -0500 Subject: [PATCH 4/9] Fixes unit test - use `expectException()` instead of `setExpectedException()` - import `InvalidArgumentException` and use `::class` notation --- test/Apns/MessageTest.php | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/test/Apns/MessageTest.php b/test/Apns/MessageTest.php index d3af66f..0611c2d 100644 --- a/test/Apns/MessageTest.php +++ b/test/Apns/MessageTest.php @@ -7,6 +7,7 @@ namespace ZendServiceTest\Apple\Apns; +use InvalidArgumentException; use PHPUnit\Framework\TestCase; use stdClass; use Zend\Json\Encoder as JsonEncoder; @@ -41,37 +42,37 @@ public function testSetAlertTextReturnsCorrectly() public function testSetAlertThrowsExceptionOnTextNonString() { - $this->expectException('InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->message->setAlert(array()); } public function testSetAlertThrowsExceptionOnActionLocKeyNonString() { - $this->expectException('InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->alert->setActionLocKey(array()); } public function testSetAlertThrowsExceptionOnLocKeyNonString() { - $this->expectException('InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->alert->setLocKey(array()); } public function testSetAlertThrowsExceptionOnLaunchImageNonString() { - $this->expectException('InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->alert->setLaunchImage(array()); } public function testSetAlertThrowsExceptionOnTitleNonString() { - $this->expectException('InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->alert->setTitle(array()); } public function testSetAlertThrowsExceptionOnTitleLocKeyNonString() { - $this->expectException('InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->alert->setTitleLocKey(array()); } @@ -84,7 +85,7 @@ public function testSetBadgeReturnsCorrectNumber() public function testSetBadgeNonNumericThrowsException() { - $this->expectException('InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->message->setBadge('string!'); } @@ -103,7 +104,7 @@ public function testSetExpireReturnsInteger() public function testSetExpireNonNumericThrowsException() { - $this->expectException('InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->message->setExpire('sting!'); } @@ -116,13 +117,13 @@ public function testSetSoundReturnsString() public function testSetSoundThrowsExceptionOnNonScalar() { - $this->expectException('InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->message->setSound(array()); } public function testSetSoundThrowsExceptionOnNonString() { - $this->expectException('InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->message->setSound(12345); } @@ -133,7 +134,7 @@ public function testSetSoundThrowsExceptionOnNonString() */ public function testSetMutableContentThrowsExceptionOnNonIntegerOneAndNull($value) { - $this->setExpectedException('InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->message->setMutableContent($value); } @@ -172,7 +173,7 @@ public function testSetMutableContentResultsInCorrectPayloadWithNullValue() public function testSetContentAvailableThrowsExceptionOnNonInteger() { - $this->expectException('InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->message->setContentAvailable("string"); } @@ -200,13 +201,13 @@ public function testSetCategoryReturnsString() public function testSetCategoryThrowsExceptionOnNonScalar() { - $this->expectException('InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->message->setCategory(array()); } public function testSetCategoryThrowsExceptionOnNonString() { - $this->expectException('InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->message->setCategory(12345); } From 6d5d0da25f409761408fa78043dd3ce502b21a93 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 8 May 2018 13:34:47 -0500 Subject: [PATCH 5/9] Use zend-coding-standard Adds zend-coding-standard as a dev requirement; code changes are result of running phpcbf and fixing items that required manual intervention. --- composer.json | 1 + phpcs.xml | 7 ++ src/Apns/Client/AbstractClient.php | 24 +++---- src/Apns/Client/Feedback.php | 8 +-- src/Apns/Client/Message.php | 6 +- src/Apns/Message.php | 52 +++++++-------- src/Apns/Message/Alert.php | 52 ++++++++------- src/Apns/Response/Feedback.php | 2 +- src/Apns/Response/Message.php | 4 +- test/Apns/MessageClientTest.php | 4 +- test/Apns/MessageTest.php | 88 +++++++++++++++----------- test/Apns/TestAsset/FeedbackClient.php | 4 +- test/Apns/TestAsset/MessageClient.php | 4 +- 13 files changed, 144 insertions(+), 112 deletions(-) create mode 100644 phpcs.xml diff --git a/composer.json b/composer.json index 65562ea..317de1c 100755 --- a/composer.json +++ b/composer.json @@ -22,6 +22,7 @@ }, "require": { "php": "^5.6 || ^7.0", + "zendframework/zend-coding-standard": "~1.0.0", "zendframework/zend-json": "^2.0 || ^3.0" }, "require-dev": { diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..4bfc5d0 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,7 @@ + + + + + src + test + diff --git a/src/Apns/Client/AbstractClient.php b/src/Apns/Client/AbstractClient.php index b50228e..c6fa72e 100644 --- a/src/Apns/Client/AbstractClient.php +++ b/src/Apns/Client/AbstractClient.php @@ -29,7 +29,7 @@ abstract class AbstractClient * APNS URIs * @var array */ - protected $uris = array(); + protected $uris = []; /** * Is Connected @@ -59,19 +59,19 @@ public function open($environment, $certificate, $passPhrase = null) throw new Exception\RuntimeException('Connection has already been opened and must be closed'); } - if (!array_key_exists($environment, $this->uris)) { + if (! array_key_exists($environment, $this->uris)) { throw new Exception\InvalidArgumentException('Environment must be one of PRODUCTION_URI or SANDBOX_URI'); } - if (!is_string($certificate) || !file_exists($certificate)) { + if (! is_string($certificate) || ! file_exists($certificate)) { throw new Exception\InvalidArgumentException('Certificate must be a valid path to a APNS certificate'); } - $sslOptions = array( + $sslOptions = [ 'local_cert' => $certificate, - ); + ]; if ($passPhrase !== null) { - if (!is_scalar($passPhrase)) { + if (! is_scalar($passPhrase)) { throw new Exception\InvalidArgumentException('SSL passphrase must be a scalar'); } $sslOptions['passphrase'] = $passPhrase; @@ -103,9 +103,9 @@ protected function connect($host, array $ssl) ini_get('default_socket_timeout'), STREAM_CLIENT_CONNECT, stream_context_create( - array( + [ 'ssl' => $ssl, - ) + ] ) ); } catch (StreamSocketClientException $e) { @@ -120,7 +120,7 @@ protected function connect($host, array $ssl) restore_error_handler(); - if (!$this->socket) { + if (! $this->socket) { throw new Exception\RuntimeException(sprintf( 'Unable to connect: %s: %d (%s)', $host, @@ -167,11 +167,11 @@ public function isConnected() */ protected function read($length = 6) { - if (!$this->isConnected()) { + if (! $this->isConnected()) { throw new Exception\RuntimeException('You must open the connection prior to reading data'); } $data = false; - $read = array($this->socket); + $read = [$this->socket]; $null = null; if (0 < @stream_select($read, $null, $null, 1, 0)) { @@ -189,7 +189,7 @@ protected function read($length = 6) */ protected function write($payload) { - if (!$this->isConnected()) { + if (! $this->isConnected()) { throw new Exception\RuntimeException('You must open the connection prior to writing data'); } diff --git a/src/Apns/Client/Feedback.php b/src/Apns/Client/Feedback.php index 3261415..209c53c 100644 --- a/src/Apns/Client/Feedback.php +++ b/src/Apns/Client/Feedback.php @@ -22,10 +22,10 @@ class Feedback extends AbstractClient * APNS URIs * @var array */ - protected $uris = array( + protected $uris = [ 'tls://feedback.sandbox.push.apple.com:2196', 'tls://feedback.push.apple.com:2196' - ); + ]; /** * Get Feedback @@ -34,11 +34,11 @@ class Feedback extends AbstractClient */ public function feedback() { - if (!$this->isConnected()) { + if (! $this->isConnected()) { throw new Exception\RuntimeException('You must first open the connection by calling open()'); } - $tokens = array(); + $tokens = []; while ($token = $this->read(38)) { $tokens[] = new FeedbackResponse($token); } diff --git a/src/Apns/Client/Message.php b/src/Apns/Client/Message.php index a18077b..3fdd59c 100644 --- a/src/Apns/Client/Message.php +++ b/src/Apns/Client/Message.php @@ -29,10 +29,10 @@ class Message extends AbstractClient * APNS URIs * @var array */ - protected $uris = array( + protected $uris = [ 'tls://gateway.sandbox.push.apple.com:2195', 'tls://gateway.push.apple.com:2195', - ); + ]; /** * Send Message @@ -42,7 +42,7 @@ class Message extends AbstractClient */ public function send(ApnsMessage $message) { - if (!$this->isConnected()) { + if (! $this->isConnected()) { throw new Exception\RuntimeException('You must first open the connection by calling open()'); } diff --git a/src/Apns/Message.php b/src/Apns/Message.php index e5fe0d4..bb1a546 100644 --- a/src/Apns/Message.php +++ b/src/Apns/Message.php @@ -102,7 +102,7 @@ public function getId() */ public function setId($id) { - if (!is_scalar($id)) { + if (! is_scalar($id)) { throw new Exception\InvalidArgumentException('Identifier must be a scalar value'); } $this->id = $id; @@ -128,25 +128,25 @@ public function getToken() */ public function setToken($token) { - if (!is_string($token)) { + if (! is_string($token)) { throw new Exception\InvalidArgumentException(sprintf( - 'Device token must be a string, "%s" given.', - gettype($token) + 'Device token must be a string, "%s" given.', + gettype($token) )); } if (preg_match('/[^0-9a-f]/i', $token)) { throw new Exception\InvalidArgumentException(sprintf( - 'Device token must be mask "%s". Token given: "%s"', - '/[^0-9a-f]/', - $token + 'Device token must be mask "%s". Token given: "%s"', + '/[^0-9a-f]/', + $token )); } if (strlen($token) != 64) { throw new Exception\InvalidArgumentException(sprintf( - 'Device token must be a 64 charsets, Token length given: %d.', - mb_strlen($token) + 'Device token must be a 64 charsets, Token length given: %d.', + mb_strlen($token) )); } @@ -175,7 +175,7 @@ public function setExpire($expire) { if ($expire instanceof \DateTime) { $expire = $expire->getTimestamp(); - } elseif (!is_numeric($expire) || $expire != (int) $expire) { + } elseif (! is_numeric($expire) || $expire != (int) $expire) { throw new Exception\InvalidArgumentException('Expiration must be a DateTime object or a unix timestamp'); } $this->expire = $expire; @@ -201,7 +201,7 @@ public function getAlert() */ public function setAlert($alert) { - if (!$alert instanceof Message\Alert && !is_null($alert)) { + if (! $alert instanceof Message\Alert && ! is_null($alert)) { $alert = new Message\Alert($alert); } $this->alert = $alert; @@ -227,7 +227,7 @@ public function getBadge() */ public function setBadge($badge) { - if ($badge !== null && !$badge == (int) $badge) { + if ($badge !== null && ! $badge == (int) $badge) { throw new Exception\InvalidArgumentException('Badge must be null or an integer'); } $this->badge = $badge; @@ -253,7 +253,7 @@ public function getSound() */ public function setSound($sound) { - if ($sound !== null && !is_string($sound)) { + if ($sound !== null && ! is_string($sound)) { throw new Exception\InvalidArgumentException('Sound must be null or a string'); } $this->sound = $sound; @@ -269,7 +269,7 @@ public function setSound($sound) */ public function setMutableContent($value) { - if ($value !== null && !is_int($value)) { + if ($value !== null && ! is_int($value)) { throw new Exception\InvalidArgumentException( 'Mutable Content must be null or an integer, received: ' . gettype($value) ); @@ -302,7 +302,7 @@ public function getContentAvailable() */ public function setContentAvailable($value) { - if ($value !== null && !is_int($value)) { + if ($value !== null && ! is_int($value)) { throw new Exception\InvalidArgumentException('Content Available must be null or an integer'); } $this->contentAvailable = $value; @@ -328,7 +328,7 @@ public function getCategory() */ public function setCategory($category) { - if ($category !== null && !is_string($category)) { + if ($category !== null && ! is_string($category)) { throw new Exception\InvalidArgumentException('Category must be null or a string'); } $this->category = $category; @@ -395,34 +395,34 @@ public function setCustom(array $custom) */ public function getPayload() { - $message = array(); - $aps = array(); + $message = []; + $aps = []; if ($this->alert && ($alert = $this->alert->getPayload())) { $aps['alert'] = $alert; } - if (!is_null($this->badge)) { + if (! is_null($this->badge)) { $aps['badge'] = $this->badge; } - if (!is_null($this->sound)) { + if (! is_null($this->sound)) { $aps['sound'] = $this->sound; } - if (!is_null($this->mutableContent)) { + if (! is_null($this->mutableContent)) { $aps['mutable-content'] = $this->mutableContent; } - if (!is_null($this->contentAvailable)) { + if (! is_null($this->contentAvailable)) { $aps['content-available'] = $this->contentAvailable; } - if (!is_null($this->category)) { + if (! is_null($this->category)) { $aps['category'] = $this->category; } - if (!is_null($this->urlArgs)) { + if (! is_null($this->urlArgs)) { $aps['url-args'] = $this->urlArgs; } - if (!empty($this->custom)) { + if (! empty($this->custom)) { $message = array_merge($this->custom, $message); } - $message['aps'] = empty($aps) ? (object) array() : $aps; + $message['aps'] = empty($aps) ? (object) [] : $aps; return $message; } diff --git a/src/Apns/Message/Alert.php b/src/Apns/Message/Alert.php index a34634f..cc85345 100644 --- a/src/Apns/Message/Alert.php +++ b/src/Apns/Message/Alert.php @@ -22,7 +22,7 @@ class Alert * @var string|null */ protected $body; - + /** * Action * @var string|null @@ -52,19 +52,19 @@ class Alert * @var string|null */ protected $launchImage; - + /** * Message Title * @var string|null */ protected $title; - + /** * Title Locale Key * @var string|null */ protected $titleLocKey; - + /** * Title Locale Arguments * @var array|null @@ -81,8 +81,16 @@ class Alert * @param string $launchImage * @return Alert */ - public function __construct($body = null, $actionLocKey = null, $locKey = null, $locArgs = null, $launchImage = null, $title = null, $titleLocKey = null, $titleLocArgs = null) - { + public function __construct( + $body = null, + $actionLocKey = null, + $locKey = null, + $locArgs = null, + $launchImage = null, + $title = null, + $titleLocKey = null, + $titleLocArgs = null + ) { if ($body !== null) { $this->setBody($body); } @@ -127,14 +135,14 @@ public function getBody() */ public function setBody($body) { - if (!is_null($body) && !is_scalar($body)) { + if (! is_null($body) && ! is_scalar($body)) { throw new Exception\InvalidArgumentException('Body must be null OR a scalar value'); } $this->body = $body; return $this; } - + /** * Get Action * @@ -153,14 +161,14 @@ public function getAction() */ public function setAction($key) { - if (!is_null($key) && !is_scalar($key)) { + if (! is_null($key) && ! is_scalar($key)) { throw new Exception\InvalidArgumentException('Action must be null OR a scalar value'); } $this->action = $key; return $this; } - + /** * Get Action Locale Key * @@ -179,7 +187,7 @@ public function getActionLocKey() */ public function setActionLocKey($key) { - if (!is_null($key) && !is_scalar($key)) { + if (! is_null($key) && ! is_scalar($key)) { throw new Exception\InvalidArgumentException('ActionLocKey must be null OR a scalar value'); } $this->actionLocKey = $key; @@ -205,7 +213,7 @@ public function getLocKey() */ public function setLocKey($key) { - if (!is_null($key) && !is_scalar($key)) { + if (! is_null($key) && ! is_scalar($key)) { throw new Exception\InvalidArgumentException('LocKey must be null OR a scalar value'); } $this->locKey = $key; @@ -232,7 +240,7 @@ public function getLocArgs() public function setLocArgs(array $args) { foreach ($args as $a) { - if (!is_scalar($a)) { + if (! is_scalar($a)) { throw new Exception\InvalidArgumentException('Arguments must only contain scalar values'); } } @@ -259,10 +267,10 @@ public function getLaunchImage() */ public function setLaunchImage($image) { - if (!is_null($image) && !is_scalar($image)) { + if (! is_null($image) && ! is_scalar($image)) { throw new Exception\InvalidArgumentException('Launch image must be null OR a scalar value'); } - $this->launchImage = $image; + $this->launchImage = $image; return $this; } @@ -285,14 +293,14 @@ public function getTitle() */ public function setTitle($title) { - if (!is_null($title) && !is_scalar($title)) { + if (! is_null($title) && ! is_scalar($title)) { throw new Exception\InvalidArgumentException('Title must be null OR a scalar value'); } $this->title = $title; return $this; } - + /** * Get Title Locale Key * @@ -311,14 +319,14 @@ public function getTitleLocKey() */ public function setTitleLocKey($key) { - if (!is_null($key) && !is_scalar($key)) { + if (! is_null($key) && ! is_scalar($key)) { throw new Exception\InvalidArgumentException('TitleLocKey must be null OR a scalar value'); } $this->titleLocKey = $key; return $this; } - + /** * Get Title Locale Arguments * @@ -338,7 +346,7 @@ public function getTitleLocArgs() public function setTitleLocArgs(array $args) { foreach ($args as $a) { - if (!is_scalar($a)) { + if (! is_scalar($a)) { throw new Exception\InvalidArgumentException('Title Arguments must only contain scalar values'); } } @@ -360,9 +368,9 @@ public function getPayload() return null; } - $alert = array(); + $alert = []; foreach ($vars as $key => $value) { - if (!is_null($value)) { + if (! is_null($value)) { $key = strtolower(preg_replace('/([a-z])([A-Z])/', '$1-$2', $key)); $alert[$key] = $value; } diff --git a/src/Apns/Response/Feedback.php b/src/Apns/Response/Feedback.php index ce8d2a3..b94eeb3 100644 --- a/src/Apns/Response/Feedback.php +++ b/src/Apns/Response/Feedback.php @@ -59,7 +59,7 @@ public function getToken() */ public function setToken($token) { - if (!is_scalar($token)) { + if (! is_scalar($token)) { throw new Exception\InvalidArgumentException('Token must be a scalar value'); } $this->token = $token; diff --git a/src/Apns/Response/Message.php b/src/Apns/Response/Message.php index 5e328bd..837ab69 100644 --- a/src/Apns/Response/Message.php +++ b/src/Apns/Response/Message.php @@ -107,7 +107,7 @@ public function getId() */ public function setId($id) { - if (!is_scalar($id)) { + if (! is_scalar($id)) { throw new Exception\InvalidArgumentException('Identifier must be a scalar value'); } $this->id = $id; @@ -123,7 +123,7 @@ public function setId($id) */ public function parseRawResponse($rawResponse) { - if (!is_scalar($rawResponse)) { + if (! is_scalar($rawResponse)) { throw new Exception\InvalidArgumentException('Response must be a scalar value'); } diff --git a/test/Apns/MessageClientTest.php b/test/Apns/MessageClientTest.php index 9c470a9..99f294a 100644 --- a/test/Apns/MessageClientTest.php +++ b/test/Apns/MessageClientTest.php @@ -50,7 +50,7 @@ public function testConnectThrowsExceptionOnInvalidEnvironment() public function testSetCertificateThrowsExceptionOnNonString() { $this->expectException('InvalidArgumentException'); - $this->apns->open(MessageClient::PRODUCTION_URI, array('foo')); + $this->apns->open(MessageClient::PRODUCTION_URI, ['foo']); } public function testSetCertificateThrowsExceptionOnMissingFile() @@ -62,7 +62,7 @@ public function testSetCertificateThrowsExceptionOnMissingFile() public function testSetCertificatePassphraseThrowsExceptionOnNonString() { $this->expectException('InvalidArgumentException'); - $this->apns->open(MessageClient::PRODUCTION_URI, __DIR__ . '/TestAsset/certificate.pem', array('foo')); + $this->apns->open(MessageClient::PRODUCTION_URI, __DIR__ . '/TestAsset/certificate.pem', ['foo']); } public function testOpen() diff --git a/test/Apns/MessageTest.php b/test/Apns/MessageTest.php index 0611c2d..278a078 100644 --- a/test/Apns/MessageTest.php +++ b/test/Apns/MessageTest.php @@ -43,37 +43,37 @@ public function testSetAlertTextReturnsCorrectly() public function testSetAlertThrowsExceptionOnTextNonString() { $this->expectException(InvalidArgumentException::class); - $this->message->setAlert(array()); + $this->message->setAlert([]); } public function testSetAlertThrowsExceptionOnActionLocKeyNonString() { $this->expectException(InvalidArgumentException::class); - $this->alert->setActionLocKey(array()); + $this->alert->setActionLocKey([]); } public function testSetAlertThrowsExceptionOnLocKeyNonString() { $this->expectException(InvalidArgumentException::class); - $this->alert->setLocKey(array()); + $this->alert->setLocKey([]); } public function testSetAlertThrowsExceptionOnLaunchImageNonString() { $this->expectException(InvalidArgumentException::class); - $this->alert->setLaunchImage(array()); + $this->alert->setLaunchImage([]); } public function testSetAlertThrowsExceptionOnTitleNonString() { $this->expectException(InvalidArgumentException::class); - $this->alert->setTitle(array()); + $this->alert->setTitle([]); } public function testSetAlertThrowsExceptionOnTitleLocKeyNonString() { $this->expectException(InvalidArgumentException::class); - $this->alert->setTitleLocKey(array()); + $this->alert->setTitleLocKey([]); } public function testSetBadgeReturnsCorrectNumber() @@ -118,7 +118,7 @@ public function testSetSoundReturnsString() public function testSetSoundThrowsExceptionOnNonScalar() { $this->expectException(InvalidArgumentException::class); - $this->message->setSound(array()); + $this->message->setSound([]); } public function testSetSoundThrowsExceptionOnNonString() @@ -143,16 +143,16 @@ public function testSetMutableContentThrowsExceptionOnNonIntegerOneAndNull($valu */ public function provideSetMutableContentThrowsExceptionOnNonIntegerOneOrNullData() { - return array( - 'unsupported positive integer' => array('value' => 2), - 'zero integer' => array('value' => 0), - 'negative integer' => array('value' => -1), - 'boolean' => array('value' => true), - 'string' => array('value' => 'any string'), - 'float' => array('value' => 123.12), - 'array' => array('value' => array()), - 'object' => array('value' => new stdClass()), - ); + return [ + 'unsupported positive integer' => ['value' => 2], + 'zero integer' => ['value' => 0], + 'negative integer' => ['value' => -1], + 'boolean' => ['value' => true], + 'string' => ['value' => 'any string'], + 'float' => ['value' => 123.12], + 'array' => ['value' => []], + 'object' => ['value' => new stdClass()], + ]; } public function testSetMutableContentResultsInCorrectPayloadWithIntegerValue() @@ -202,7 +202,7 @@ public function testSetCategoryReturnsString() public function testSetCategoryThrowsExceptionOnNonScalar() { $this->expectException(InvalidArgumentException::class); - $this->message->setCategory(array()); + $this->message->setCategory([]); } public function testSetCategoryThrowsExceptionOnNonString() @@ -213,14 +213,14 @@ public function testSetCategoryThrowsExceptionOnNonString() public function testSetUrlArgsReturnsString() { - $urlArgs = array('path/to/somewhere'); + $urlArgs = ['path/to/somewhere']; $this->message->setUrlArgs($urlArgs); $this->assertEquals($urlArgs, $this->message->getUrlArgs()); } public function testSetCustomData() { - $data = array('key' => 'val', 'key2' => array(1, 2, 3, 4, 5)); + $data = ['key' => 'val', 'key2' => [1, 2, 3, 4, 5]]; $this->message->setCustom($data); $this->assertEquals($data, $this->message->getCustom()); } @@ -231,21 +231,21 @@ public function testAlertConstructor() 'Foo wants to play Bar!', 'PLAY', 'GAME_PLAY_REQUEST_FORMAT', - array('Foo', 'Baz'), + ['Foo', 'Baz'], 'Default.png', 'Alert', 'ALERT', - array('Foo', 'Baz') + ['Foo', 'Baz'] ); $this->assertEquals('Foo wants to play Bar!', $alert->getBody()); $this->assertEquals('PLAY', $alert->getActionLocKey()); $this->assertEquals('GAME_PLAY_REQUEST_FORMAT', $alert->getLocKey()); - $this->assertEquals(array('Foo', 'Baz'), $alert->getLocArgs()); + $this->assertEquals(['Foo', 'Baz'], $alert->getLocArgs()); $this->assertEquals('Default.png', $alert->getLaunchImage()); $this->assertEquals('Alert', $alert->getTitle()); $this->assertEquals('ALERT', $alert->getTitleLocKey()); - $this->assertEquals(array('Foo', 'Baz'), $alert->getTitleLocArgs()); + $this->assertEquals(['Foo', 'Baz'], $alert->getTitleLocArgs()); } public function testAlertJsonPayload() @@ -254,11 +254,11 @@ public function testAlertJsonPayload() 'Foo wants to play Bar!', 'PLAY', 'GAME_PLAY_REQUEST_FORMAT', - array('Foo', 'Baz'), + ['Foo', 'Baz'], 'Default.png', 'Alert', 'ALERT', - array('Foo', 'Baz') + ['Foo', 'Baz'] ); $payload = $alert->getPayload(); @@ -288,30 +288,46 @@ public function testPayloadJsonFormedCorrectly() $this->message->setExpire(100); $this->message->setToken('0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef'); $payload = $this->message->getPayload(); - $this->assertEquals($payload, array('aps' => array('alert' => 'hi=привет'))); + $this->assertEquals($payload, ['aps' => ['alert' => 'hi=привет']]); if (defined('JSON_UNESCAPED_UNICODE')) { $payloadJson = json_encode($payload, JSON_UNESCAPED_UNICODE); $this->assertEquals($payloadJson, '{"aps":{"alert":"hi=привет"}}'); $length = 35; // 23 + (2 * 6) because UTF-8 (Russian) "привет" contains 2 bytes per letter - $result = pack('CNNnH*', 1, $this->message->getId(), $this->message->getExpire(), 32, $this->message->getToken()) - . pack('n', $length) - . $payloadJson; + $result = + pack( + 'CNNnH*', + 1, + $this->message->getId(), + $this->message->getExpire(), + 32, + $this->message->getToken() + ) + . pack('n', $length) + . $payloadJson; $this->assertEquals($this->message->getPayloadJson(), $result); } else { $payloadJson = JsonEncoder::encode($payload); $this->assertEquals($payloadJson, '{"aps":{"alert":"hi=\u043f\u0440\u0438\u0432\u0435\u0442"}}'); - $length = 59; // (23 + (6 * 6) because UTF-8 (Russian) "привет" converts into 6 bytes per letter constructions - $result = pack('CNNnH*', 1, $this->message->getId(), $this->message->getExpire(), 32, $this->message->getToken()) - . pack('n', $length) - . $payloadJson; + $length = 59; // (23 + (6 * 6) because UTF-8 (Russian) "привет" converts into 6 bytes/letter + $result = + pack( + 'CNNnH*', + 1, + $this->message->getId(), + $this->message->getExpire(), + 32, + $this->message->getToken() + ) + . pack('n', $length) + . $payloadJson; $this->assertEquals($this->message->getPayloadJson(), $result); } } public function testCustomDataPayloadIncludesEmptyApsObject() { - $data = array('custom' => 'data'); - $expected = array_merge($data, array('aps' => (object) array())); + $data = ['custom' => 'data']; + $expected = array_merge($data, ['aps' => (object) []]); $this->message->setCustom($data); $payload = $this->message->getPayload(); diff --git a/test/Apns/TestAsset/FeedbackClient.php b/test/Apns/TestAsset/FeedbackClient.php index 8242cc5..8952db2 100644 --- a/test/Apns/TestAsset/FeedbackClient.php +++ b/test/Apns/TestAsset/FeedbackClient.php @@ -81,7 +81,7 @@ protected function connect($host, array $ssl) */ protected function read($length = 1024) { - if (!$this->isConnected()) { + if (! $this->isConnected()) { throw new Exception\RuntimeException('You must open the connection prior to reading data'); } $ret = substr($this->readResponse, 0, $length); @@ -98,7 +98,7 @@ protected function read($length = 1024) */ protected function write($payload) { - if (!$this->isConnected()) { + if (! $this->isConnected()) { throw new Exception\RuntimeException('You must open the connection prior to writing data'); } $ret = $this->writeResponse; diff --git a/test/Apns/TestAsset/MessageClient.php b/test/Apns/TestAsset/MessageClient.php index d6317c0..31cd361 100644 --- a/test/Apns/TestAsset/MessageClient.php +++ b/test/Apns/TestAsset/MessageClient.php @@ -81,7 +81,7 @@ protected function connect($host, array $ssl) */ protected function read($length = 1024) { - if (!$this->isConnected()) { + if (! $this->isConnected()) { throw new Exception\RuntimeException('You must open the connection prior to reading data'); } $ret = substr($this->readResponse, 0, $length); @@ -98,7 +98,7 @@ protected function read($length = 1024) */ protected function write($payload) { - if (!$this->isConnected()) { + if (! $this->isConnected()) { throw new Exception\RuntimeException('You must open the connection prior to writing data'); } $ret = $this->writeResponse; From 1e9d550860ecba66f946f5f95fa7bafff9bf898c Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 8 May 2018 13:39:01 -0500 Subject: [PATCH 6/9] Adds CS checks into test matrix Adds a test matrix, providing a CS_CHECK env variable in 7.1. Adds a script that checks if that value is present, and, if so, runs CS checks. --- .travis.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4763b4d..7f38c26 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,22 @@ +sudo: false + language: php -php: - - 5.6 - - 7.0 - - 7.1 - - 7.2 +matrix: + include: + - php: 5.6 + - php: 7.0 + - php: 7.1 + env: + - CS_CHECK=true + - php: 7.2 before_install: - - composer install + - composer install --no-interaction script: - ./vendor/bin/phpunit + - if [[ $CS_CHECK == 'true' ]]; then ./vendor/bin/phpcs ; fi notifications: email: false From 04f0031c6caf6fecce2b94fe0a21a626044b00a8 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 8 May 2018 13:42:11 -0500 Subject: [PATCH 7/9] Adds CHANGELOG entry for #63 --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66901f0..1092505 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ All notable changes to this project will be documented in this file, in reverse ### Added +- [#63](https://github.com/zendframework/ZendService_Apple_Apns/pull/63) adds support for PHP 7.1 and 7.2. + - [#53](https://github.com/zendframework/ZendService_Apple_Apns/pull/53) adds support for the mutable-content Notification field within the `Message` implementation. - [#48](https://github.com/zendframework/ZendService_Apple_Apns/pull/48) adds two new methods to `ZendService\Apple\Apns\Message\Alert`: `setAction($key)` and `getAction()`. @@ -21,7 +23,9 @@ All notable changes to this project will be documented in this file, in reverse ### Removed -- Nothing. +- [#63](https://github.com/zendframework/ZendService_Apple_Apns/pull/63) removes support for PHP 5.3, 5.4, and 5.5. + +- [#63](https://github.com/zendframework/ZendService_Apple_Apns/pull/63) removes support for HHVM. ### Fixed From a3a18c36f638efff48abf7e9f08de4289531baab Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 8 May 2018 13:44:32 -0500 Subject: [PATCH 8/9] Adds support and branch alias configuration to composer.json --- composer.json | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 317de1c..cd3240d 100755 --- a/composer.json +++ b/composer.json @@ -1,6 +1,7 @@ { "name": "zendframework/zendservice-apple-apns", - "description": "OOP Zend Framework 2 wrapper for Apple Push Notification Service", + "description": "OOP Zend Framework wrapper for Apple Push Notification Service", + "license": "BSD-3-Clause", "keywords": [ "zf", "zendframework", @@ -9,7 +10,21 @@ "notification", "apple" ], - "license": "BSD-3-Clause", + "support": { + "issues": "https://github.com/zendframework/ZendService_Apple_Apns/issues", + "source": "https://github.com/zendframework/ZendService_Apple_Apns", + "rss": "https://github.com/zendframework/ZendService_Apple_Apns/releases.atom", + "chat": "https://zendframework-slack.herokuapp.com", + "forum": "https://discourse.zendframework.com/c/questions/components" + }, + "require": { + "php": "^5.6 || ^7.0", + "zendframework/zend-json": "^2.0 || ^3.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1.5", + "zendframework/zend-coding-standard": "~1.0.0" + }, "autoload": { "psr-4": { "ZendService\\Apple\\": "src/" @@ -20,12 +35,13 @@ "ZendServiceTest\\Apple\\": "test/" } }, - "require": { - "php": "^5.6 || ^7.0", - "zendframework/zend-coding-standard": "~1.0.0", - "zendframework/zend-json": "^2.0 || ^3.0" + "config": { + "sort-packages": true }, - "require-dev": { - "phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1.5" + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev", + "dev-develop": "1.4.x-dev" + } } } From c54bba8d133dedde18fec9de779d4e7b00c19cb9 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 8 May 2018 13:45:00 -0500 Subject: [PATCH 9/9] Adds date for 1.3.0 release to CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1092505..840aa38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to this project will be documented in this file, in reverse chronological order by release. -## 1.3.0 - TBD +## 1.3.0 - 2018-05-08 ### Added