From 41425143d87f2c03196d08ba8bd042c165b3a687 Mon Sep 17 00:00:00 2001 From: Cody Mann Date: Thu, 4 May 2017 19:52:35 -0500 Subject: [PATCH 1/2] added namespacing --- composer.json | 6 ++++-- lib/Shippo/Address.php | 31 +++++++++++++++-------------- lib/Shippo/ApiConnectionError.php | 2 ++ lib/Shippo/ApiError.php | 2 ++ lib/Shippo/ApiRequestor.php | 3 +++ lib/Shippo/ApiResource.php | 4 +++- lib/Shippo/AttachedObject.php | 2 ++ lib/Shippo/AuthenticationError.php | 2 ++ lib/Shippo/Batch.php | 15 +++++++------- lib/Shippo/CarrierAccount.php | 4 +++- lib/Shippo/CurlClient.php | 2 ++ lib/Shippo/CustomsDeclaration.php | 2 ++ lib/Shippo/CustomsItem.php | 2 ++ lib/Shippo/Error.php | 11 ++++++++++ lib/Shippo/InvalidRequestError.php | 4 ++++ lib/Shippo/List.php | 2 ++ lib/Shippo/Manifest.php | 2 ++ lib/Shippo/Object.php | 9 +++++++-- lib/Shippo/Parcel.php | 2 ++ lib/Shippo/Rate.php | 2 ++ lib/Shippo/RateLimitError.php | 2 ++ lib/Shippo/Refund.php | 2 ++ lib/Shippo/Shipment.php | 2 ++ lib/Shippo/Shippo.php | 2 ++ lib/Shippo/SingletonApiResource.php | 2 ++ lib/Shippo/Track.php | 2 ++ lib/Shippo/Transaction.php | 2 ++ lib/Shippo/Util.php | 6 ++++-- lib/Shippo/Util/Set.php | 2 ++ test/AddressTest.php | 2 ++ test/ApiRequestorTest.php | 5 ++++- test/AuthenticationErrorTest.php | 4 ++++ test/BatchTest.php | 2 ++ test/CarrierAccountTest.php | 2 ++ test/CurlClientTest.php | 2 ++ test/CustomsDeclarationTest.php | 2 ++ test/CustomsItemTest.php | 2 ++ test/ErrorTest.php | 2 ++ test/InvalidRequestErrorTest.php | 3 +++ test/ManifestTest.php | 2 ++ test/ObjectTest.php | 2 ++ test/ParcelTest.php | 2 ++ test/RateTest.php | 3 +++ test/RefundTest.php | 2 ++ test/ShipmentTest.php | 2 ++ test/ShippoBaseTest.php | 4 +++- test/TestCase.php | 10 ++++++++-- test/TrackTest.php | 2 ++ test/TransactionTest.php | 3 +++ test/UtilTest.php | 2 ++ 50 files changed, 156 insertions(+), 35 deletions(-) diff --git a/composer.json b/composer.json index ee5ce7f..1eb79c5 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ } ], "require": { - "php": ">=5.2", + "php": ">=5.6", "ext-curl": "*", "ext-json": "*", "ext-mbstring": "*" @@ -30,6 +30,8 @@ "phpunit/phpunit": "5.5.*" }, "autoload": { - "classmap": ["lib/Shippo/"] + "psr-4": { + "Shippo\\": "lib/" + } } } diff --git a/lib/Shippo/Address.php b/lib/Shippo/Address.php index f2e58e1..f3eec22 100644 --- a/lib/Shippo/Address.php +++ b/lib/Shippo/Address.php @@ -1,5 +1,7 @@ refresh(); return $instance; } - + /** * @returns Shippo_ApiResource The refreshed resource. */ diff --git a/lib/Shippo/AttachedObject.php b/lib/Shippo/AttachedObject.php index 2c4e083..04c21cc 100644 --- a/lib/Shippo/AttachedObject.php +++ b/lib/Shippo/AttachedObject.php @@ -1,5 +1,7 @@ ' . $k . ' = NULL to delete the property'); + throw new \InvalidArgumentException('You cannot set \'' . $k . '\'to an empty string. ' . 'We interpret empty strings as NULL in requests. ' . 'You may set obj->' . $k . ' = NULL to delete the property'); } if (self::$nestedUpdatableAttributes->includes($k) && isset($this->$k) && is_array($v)) { @@ -179,7 +184,7 @@ public function refreshFrom($values, $apiKey, $partial = false) continue; if (self::$nestedUpdatableAttributes->includes($k) && is_array($v)) { - $this->_values[$k] = Shippo_Object::scopedConstructFrom('Shippo_AttachedObject', $v, $apiKey); + $this->_values[$k] = Shippo_Object::scopedConstructFrom(Shippo_AttachedObject::class, $v, $apiKey); } else { $this->_values[$k] = Shippo_Util::convertToShippoObject($v, $apiKey); } diff --git a/lib/Shippo/Parcel.php b/lib/Shippo/Parcel.php index c5005b6..53015de 100644 --- a/lib/Shippo/Parcel.php +++ b/lib/Shippo/Parcel.php @@ -1,5 +1,7 @@ = // 5.3 if (version_compare(PHP_VERSION, '5.3.2', '>=')) { - $reflector = new ReflectionClass('Shippo_APIRequestor'); + $reflector = new ReflectionClass(Shippo_ApiRequestor::class); $method = $reflector->getMethod('_encodeObjects'); $method->setAccessible(true); diff --git a/test/AuthenticationErrorTest.php b/test/AuthenticationErrorTest.php index 8ca04c9..c5416bc 100644 --- a/test/AuthenticationErrorTest.php +++ b/test/AuthenticationErrorTest.php @@ -1,5 +1,9 @@ assertEquals(Shippo::getApiKey(), 'dW5pdHRlc3Q6dW5pdHRlc3Q='); } -} \ No newline at end of file +} diff --git a/test/TestCase.php b/test/TestCase.php index 34c3ade..235d748 100644 --- a/test/TestCase.php +++ b/test/TestCase.php @@ -1,6 +1,10 @@ mock) { - $this->mock = $this->createMock('CurlClient'); + $this->mock = $this->createMock(CurlClient::class); Shippo_ApiRequestor::setHttpClient($this->mock); } return $this->mock; diff --git a/test/TrackTest.php b/test/TrackTest.php index 6e28eaf..7541772 100644 --- a/test/TrackTest.php +++ b/test/TrackTest.php @@ -1,5 +1,7 @@ $pagesize, 'page' => '1' )); + var_dump($list); $this->assertEquals(count($list->results), $pagesize); } diff --git a/test/UtilTest.php b/test/UtilTest.php index 265b6fa..795c5ae 100644 --- a/test/UtilTest.php +++ b/test/UtilTest.php @@ -1,5 +1,7 @@ Date: Thu, 4 May 2017 20:09:32 -0500 Subject: [PATCH 2/2] fixed failing test --- test/TransactionTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/TransactionTest.php b/test/TransactionTest.php index 0473a72..f8c26f6 100644 --- a/test/TransactionTest.php +++ b/test/TransactionTest.php @@ -42,12 +42,11 @@ public function testListAll() public function testListPageSize() { - $pagesize = 1; + $pagesize = 0; $list = Shippo_Transaction::all(array( 'results' => $pagesize, 'page' => '1' )); - var_dump($list); $this->assertEquals(count($list->results), $pagesize); }