Skip to content

Commit 11f0edf

Browse files
committed
Add return type information
1 parent 6e02731 commit 11f0edf

20 files changed

+42
-43
lines changed

src/MessageBird/Objects/Number.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Number extends Base
4646
* Additional user-provided tags for this Number
4747
* @var array
4848
*/
49-
public $tags = array();
49+
public $tags = [];
5050

5151
/**
5252
* Number type (example: landline, mobile).

src/MessageBird/Resources/AvailablePhoneNumbers.php

+21-22
Original file line numberDiff line numberDiff line change
@@ -34,33 +34,32 @@ public function __construct(Common\HttpClient $HttpClient)
3434
* @throws \MessageBird\Exceptions\RequestException
3535
* @throws \MessageBird\Exceptions\ServerException
3636
*/
37-
public function getList($countryCode, $parameters = array())
37+
public function getList($countryCode, $parameters = []): Objects\BaseList
3838
{
3939
list($status, , $body) = $this->HttpClient->performHttpRequest(
4040
Common\HttpClient::REQUEST_GET,
4141
"available-phone-numbers/$countryCode",
4242
$parameters
4343
);
4444

45-
if ($status === 200) {
46-
$body = json_decode($body);
45+
if ($status !== 200) {
46+
return $this->processRequest($body);
47+
}
48+
$body = json_decode($body);
4749

48-
$items = $body->data;
49-
unset($body->data);
50+
$items = $body->data;
51+
unset($body->data);
5052

51-
$baseList = new Objects\BaseList();
52-
$baseList->loadFromArray($body);
53+
$baseList = new Objects\BaseList();
54+
$baseList->loadFromArray($body);
5355

54-
foreach ($items as $item) {
55-
$object = new Objects\Number($this->HttpClient);
56+
foreach ($items as $item) {
57+
$object = new Objects\Number($this->HttpClient);
5658

57-
$itemObject = $object->loadFromArray($item);
58-
$baseList->items[] = $itemObject;
59-
}
60-
return $baseList;
59+
$itemObject = $object->loadFromArray($item);
60+
$baseList->items[] = $itemObject;
6161
}
62-
63-
return $this->processRequest($body);
62+
return $baseList;
6463
}
6564

6665
/**
@@ -70,20 +69,20 @@ public function getList($countryCode, $parameters = array())
7069
* @throws \MessageBird\Exceptions\RequestException
7170
* @throws \MessageBird\Exceptions\ServerException
7271
*/
73-
private function processRequest($body)
72+
private function processRequest($body): Objects\Number
7473
{
75-
$body = @json_decode($body);
74+
$body = json_decode($body);
7675

77-
if ($body === null or $body === false) {
76+
if (json_last_error()) {
7877
throw new \MessageBird\Exceptions\ServerException('Got an invalid JSON response from the server.');
7978
}
8079

81-
if (empty($body->errors)) {
82-
return Objects\Number.loadFromArray($body->data[0]);
80+
if (!empty($body->errors)) {
81+
$ResponseError = new Common\ResponseError($body);
82+
throw new \MessageBird\Exceptions\RequestException($ResponseError->getErrorString());
8383
}
8484

85-
$ResponseError = new Common\ResponseError($body);
86-
throw new \MessageBird\Exceptions\RequestException($ResponseError->getErrorString());
85+
return Objects\Number.loadFromArray($body->data[0]);
8786
}
8887
}
8988
?>

src/MessageBird/Resources/PhoneNumbers.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ public function __construct(Common\HttpClient $HttpClient)
3232
* @param $object
3333
* @param $id
3434
*
35-
* @return $this ->Object
35+
* @return Objects\Number
3636
*
3737
* @internal param array $parameters
3838
*/
39-
public function update($object, $id)
39+
public function update($object, $id): Objects\Number
4040
{
4141
$objVars = get_object_vars($object);
42-
$body = array();
42+
$body = [];
4343
foreach ($objVars as $key => $value) {
4444
if (null !== $value) {
4545
$body[$key] = $value;

tests/integration/BaseTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class BaseTest extends TestCase
1010
/** @var PHPUnit_Framework_MockObject_MockObject */
1111
protected $mockClient;
1212

13-
protected function setUp(): void
13+
protected function setUp()
1414
{
1515
$this->mockClient = $this->getMockBuilder("\MessageBird\Common\HttpClient")->setConstructorArgs(array("fake.messagebird.dev"))->getMock();
1616
$this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient);

tests/integration/balance/BalanceTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
class BalanceTest extends BaseTest
33
{
4-
protected function setUp(): void
4+
protected function setUp()
55
{
66
parent::setUp();
77
$this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient);

tests/integration/chat/ChatTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
class ChatTest extends BaseTest
33
{
4-
protected function setUp(): void
4+
protected function setUp()
55
{
66
parent::setUp();
77
$this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient);

tests/integration/contacts/ContactTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
class ContactTest extends BaseTest
33
{
4-
protected function setUp(): void
4+
protected function setUp()
55
{
66
parent::setUp();
77
$this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient);

tests/integration/conversation/ConversationMessageTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ConversationMessageTest extends BaseTest
4646
"type": "video"
4747
}';
4848

49-
protected function setUp(): void
49+
protected function setUp()
5050
{
5151
parent::setUp();
5252

tests/integration/conversation/ConversationTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class ConversationTest extends BaseTest
9494
"lastUsedChannelId": "channel-id"
9595
}';
9696

97-
protected function setUp(): void
97+
protected function setUp()
9898
{
9999
parent::setUp();
100100

tests/integration/conversation/ConversationWebhookTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ConversationWebhookTest extends BaseTest
3737
"updatedDatetime": "2018-07-20T12:13:51+00:00"
3838
}';
3939

40-
protected function setUp(): void
40+
protected function setUp()
4141
{
4242
parent::setUp();
4343

tests/integration/groups/GroupTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
class GroupTest extends BaseTest
33
{
4-
protected function setUp(): void
4+
protected function setUp()
55
{
66
parent::setUp();
77
$this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient);

tests/integration/hlr/HlrTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
class HlrTest extends BaseTest
33
{
4-
protected function setUp(): void
4+
protected function setUp()
55
{
66
parent::setUp();
77
$this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient);

tests/integration/lookup/LookupTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
class LookupTest extends BaseTest
33
{
4-
protected function setUp(): void
4+
protected function setUp()
55
{
66
parent::setUp();
77
$this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient);

tests/integration/messages/MessagesTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
class MessageTest extends BaseTest
33
{
4-
protected function setUp(): void
4+
protected function setUp()
55
{
66
parent::setUp();
77
$this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient);

tests/integration/numbers/AvailablePhoneNumbersTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
class AvailablePhoneNumbersTest extends BaseTest
33
{
4-
protected function setUp(): void
4+
protected function setUp()
55
{
66
parent::setUp();
77
$this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient);

tests/integration/numbers/PhoneNumbersTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
class PhoneNumbersTest extends BaseTest
33
{
4-
protected function setUp(): void
4+
protected function setUp()
55
{
66
parent::setUp();
77
$this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient);

tests/integration/partneraccount/AccountTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class AccountTest extends BaseTest
44
{
5-
protected function setUp(): void
5+
protected function setUp()
66
{
77
parent::setUp();
88
$this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient);

tests/integration/verify/VerifyTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
class VerifyTest extends BaseTest
33
{
4-
protected function setUp(): void
4+
protected function setUp()
55
{
66
parent::setUp();
77
$this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient);

tests/integration/voice/VoiceTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class VoiceTest extends BaseTest
55
/** @var \MessageBird\Client client */
66
public $client;
77

8-
protected function setUp(): void
8+
protected function setUp()
99
{
1010
parent::setUp();
1111
$this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient);

tests/integration/voicemessages/VoiceMessagesTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
class VoiceMessagesTest extends BaseTest
33
{
4-
protected function setUp(): void
4+
protected function setUp()
55
{
66
parent::setUp();
77
$this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient);

0 commit comments

Comments
 (0)