Skip to content

Enforce the usage of the short array syntax. #140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/available-phone-numbers-view.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
$MessageBird = new \MessageBird\Client('MESSAGEBIRD_API_KEY');

try {
$phoneNumbers = $MessageBird->availablePhoneNumbers->getList("nl", array());
$phoneNumbers = $MessageBird->availablePhoneNumbers->getList("nl", []);
var_dump($phoneNumbers);

} catch (\MessageBird\Exceptions\AuthenticateException $e) {
Expand Down
4 changes: 2 additions & 2 deletions examples/chatchannels-create.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
// are required when creating a channel for this platform.

$ChatChannel->channelDetails =
array(
[
'botName' => 'testBot',
'token' => '1234566778:A34JT44Yr4amk234352et5hvRnHeAEHA'
);
];

try {
$ChatChannelResult = $MessageBird->chatChannels->create($ChatChannel);
Expand Down
2 changes: 1 addition & 1 deletion examples/contact-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
$MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here.

try {
$ContactList = $MessageBird->contacts->getList(array ());
$ContactList = $MessageBird->contacts->getList( []);
var_dump($ContactList);

} catch (\MessageBird\Exceptions\AuthenticateException $e) {
Expand Down
2 changes: 1 addition & 1 deletion examples/conversations/create-hsm.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
$hsm = new \MessageBird\Objects\Conversation\HSM\Message();
$hsm->templateName = 'YOUR TEMPLATE NAME';
$hsm->namespace = 'YOUR NAMESPACE';
$hsm->params = array($hsmParam1, $hsmParam2);
$hsm->params = [$hsmParam1, $hsmParam2];
$hsm->language = $hsmLanguage;

$content = new \MessageBird\Objects\Conversation\Content();
Expand Down
4 changes: 2 additions & 2 deletions examples/conversations/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
$messageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here.

// Take 10 objects, but skip the first 5.
$optionalParameters = array(
$optionalParameters = [
'limit' => '10',
'offset' => '5',
);
];

try {
$conversations = $messageBird->conversations->getList($optionalParameters);
Expand Down
4 changes: 2 additions & 2 deletions examples/conversations/messages-create-location.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
$messageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here.

$content = new \MessageBird\Objects\Conversation\Content();
$content->location = array(
$content->location = [
'latitude' => 52.379112,
'longitude' => 4.900384,
);
];

$message = new \MessageBird\Objects\Conversation\Message();
$message->channelId = 'CHANNEL_ID';
Expand Down
4 changes: 2 additions & 2 deletions examples/conversations/messages-create-media.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
$messageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here.

$content = new \MessageBird\Objects\Conversation\Content();
$content->image = array(
$content->image = [
'url' => 'https://cdn-gc.messagebird.com/assets/images/logo.png'
);
];

$message = new \MessageBird\Objects\Conversation\Message();
$message->channelId = 'CHANNEL_ID';
Expand Down
4 changes: 2 additions & 2 deletions examples/conversations/read.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

// Setting the optional 'include' parameter to 'content' requests the API to
// include the expanded Contact object in its response. Excluded by default.
$optionalParameters = array(
$optionalParameters = [
'include' => 'content',
);
];

try {
$conversation = $messageBird->conversations->read(
Expand Down
4 changes: 2 additions & 2 deletions examples/conversations/webhooks-create.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
$webhook = new \MessageBird\Objects\Conversation\Webhook();
$webhook->channelId = 'CHANNEL_ID';
$webhook->url = 'https://example.com/webhook';
$webhook->events = array(
$webhook->events = [
\MessageBird\Objects\Conversation\Webhook::EVENT_CONVERSATION_CREATED,
\MessageBird\Objects\Conversation\Webhook::EVENT_MESSAGE_CREATED,

// Other options:
// \MessageBird\Objects\Conversation\Webhook::EVENT_CONVERSATION_UPDATED,
// \MessageBird\Objects\Conversation\Webhook::EVENT_MESSAGE_UPDATED,
);
];

$messageBird->conversationWebhooks->create($webhook);
} catch (\Exception $e) {
Expand Down
4 changes: 2 additions & 2 deletions examples/group-add-contact-to-group.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
$MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here.

try {
$contacts['ids'] = array(
$contacts['ids'] = [
'contact_id_1',
'contact_id_2',
);
];
$group_id = 'group_id';
$GroupAddContact = $MessageBird->groups->addContacts($contacts, $group_id);
var_dump($GroupAddContact);
Expand Down
2 changes: 1 addition & 1 deletion examples/group-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
$MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here.

try {
$GroupsList = $MessageBird->groups->getList(array ());
$GroupsList = $MessageBird->groups->getList( []);
var_dump($GroupsList);

} catch (\MessageBird\Exceptions\AuthenticateException $e) {
Expand Down
2 changes: 1 addition & 1 deletion examples/hlr-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
$MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here.

try {
$HlrList = $MessageBird->hlr->getList(array ('offset' => 100, 'limit' => 30));
$HlrList = $MessageBird->hlr->getList( ['offset' => 100, 'limit' => 30]);
var_dump($HlrList);

} catch (\MessageBird\Exceptions\AuthenticateException $e) {
Expand Down
2 changes: 1 addition & 1 deletion examples/message-create-unicode.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

$Message = new \MessageBird\Objects\Message();
$Message->originator = 'MessageBird';
$Message->recipients = array(31612345678);
$Message->recipients = [31612345678];
$Message->body = 'This is a test message with a smiling emoji 😀.';
$Message->datacoding = 'unicode';

Expand Down
2 changes: 1 addition & 1 deletion examples/message-create.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

$Message = new \MessageBird\Objects\Message();
$Message->originator = 'MessageBird';
$Message->recipients = array(31612345678);
$Message->recipients = [31612345678];
$Message->body = 'This is a test message.';

try {
Expand Down
2 changes: 1 addition & 1 deletion examples/message-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
$MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here.

try {
$MessageList = $MessageBird->messages->getList(array ('offset' => 100, 'limit' => 30));
$MessageList = $MessageBird->messages->getList( ['offset' => 100, 'limit' => 30]);
var_dump($MessageList);

} catch (\MessageBird\Exceptions\AuthenticateException $e) {
Expand Down
4 changes: 2 additions & 2 deletions examples/mms-create.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

$MmsMessage = new \MessageBird\Objects\MmsMessage();
$MmsMessage->originator = 'MessageBird';
$MmsMessage->recipients = array(31612345678);
$MmsMessage->recipients = [31612345678];
$MmsMessage->subject = "Check out this cool MMS";
$MmsMessage->body = 'Have you seen this logo?';
$MmsMessage->mediaUrls = array('https://www.messagebird.com/assets/images/og/messagebird.gif');
$MmsMessage->mediaUrls = ['https://www.messagebird.com/assets/images/og/messagebird.gif'];

try {
$MmsMessageResult = $MessageBird->mmsMessages->create($MmsMessage);
Expand Down
2 changes: 1 addition & 1 deletion examples/mms-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
$MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here.

try {
$MmsList = $MessageBird->mmsMessages->getList(array('offset' => 0, 'limit' => 30));
$MmsList = $MessageBird->mmsMessages->getList(['offset' => 0, 'limit' => 30]);
var_dump($MmsList);
} catch (\MessageBird\Exceptions\AuthenticateException $e) {
// That means that your accessKey is unknown
Expand Down
2 changes: 1 addition & 1 deletion examples/phone-numbers-update.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

$MessageBird = new \MessageBird\Client('MESSAGEBIRD_API_KEY'); // Set your own API access key here.
$Number = new \MessageBird\Objects\Number();
$Number->tags = array('tag1');
$Number->tags = ['tag1'];

try {
$NumberResult = $MessageBird->phoneNumbers->update($Number, '31612345678');
Expand Down
4 changes: 2 additions & 2 deletions examples/verify-create.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
$Verify = new \MessageBird\Objects\Verify();
$Verify->recipient = 31612345678;

$extraOptions = array(
$extraOptions = [
'originator' => 'MessageBird',
'timeout' => 60,
);
];

try {
$VerifyResult = $MessageBird->verify->create($Verify, $extraOptions);
Expand Down
6 changes: 3 additions & 3 deletions examples/voice-call-flows-create.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
$callFlow->title = 'Foobar';
$step = new \MessageBird\Objects\Voice\Step();
$step->action = 'say';
$step->options = array(
$step->options = [
'payload' => 'This is a journey into sound.',
'language' => 'en-GB',
'voice' => 'male',
);
$callFlow->steps = array($step);
];
$callFlow->steps = [$step];

try {
$result = $messageBird->voiceCallFlows->create($callFlow);
Expand Down
2 changes: 1 addition & 1 deletion examples/voice-call-flows-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
$messageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here.

try {
$result = $messageBird->voiceCallFlows->getList(array('offset' => 100, 'limit' => 30));
$result = $messageBird->voiceCallFlows->getList(['offset' => 100, 'limit' => 30]);
var_dump($result);
} catch (\Exception $e) {
echo sprintf("%s: %s", get_class($e), $e->getMessage());
Expand Down
6 changes: 3 additions & 3 deletions examples/voice-calls-create.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
$callFlow->title = 'Say message';
$step = new \MessageBird\Objects\Voice\Step();
$step->action = 'say';
$step->options = array(
$step->options = [
'payload' => 'This is a journey into sound.',
'language' => 'en-GB',
'voice' => 'male',
);
$callFlow->steps = array($step);
];
$callFlow->steps = [$step];
$call->callFlow = $callFlow;

try {
Expand Down
2 changes: 1 addition & 1 deletion examples/voice-calls-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
$messageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here.

try {
$result = $messageBird->voiceCalls->getList(array('offset' => 100, 'limit' => 30));
$result = $messageBird->voiceCalls->getList(['offset' => 100, 'limit' => 30]);
var_dump($result);
} catch (\Exception $e) {
echo sprintf("%s: %s", get_class($e), $e->getMessage());
Expand Down
2 changes: 1 addition & 1 deletion examples/voice-legs-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
$messageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here.

try {
$result = $messageBird->voiceLegs->getList('dbf1373c-6781-43c7-bfe4-6538583c444b', array('offset' => 100, 'limit' => 30)); // Set a call id here
$result = $messageBird->voiceLegs->getList('dbf1373c-6781-43c7-bfe4-6538583c444b', ['offset' => 100, 'limit' => 30]); // Set a call id here
var_dump($result);
} catch (\Exception $e) {
echo sprintf("%s: %s", get_class($e), $e->getMessage());
Expand Down
2 changes: 1 addition & 1 deletion examples/voice-recordings-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
$messageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here.

try {
$result = $messageBird->voiceRecordings->getList('c226420d-f107-4db1-b2f9-4646656a90bc', '4f5ab5f4-c4b6-4586-9255-980bb3fd7336', array('offset' => 100, 'limit' => 30)); // Set a call and leg id here
$result = $messageBird->voiceRecordings->getList('c226420d-f107-4db1-b2f9-4646656a90bc', '4f5ab5f4-c4b6-4586-9255-980bb3fd7336', ['offset' => 100, 'limit' => 30]); // Set a call and leg id here
var_dump($result);
} catch (\Exception $e) {
echo sprintf("%s: %s", get_class($e), $e->getMessage());
Expand Down
2 changes: 1 addition & 1 deletion examples/voice-transcriptions-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
$messageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here.

try {
$result = $messageBird->voiceTranscriptions->getList('c226420d-f107-4db1-b2f9-4646656a90bc', '4f5ab5f4-c4b6-4586-9255-980bb3fd7336', 'a94f7d51-19b5-4eb8-9e8e-90fce490a577', array('offset' => 100, 'limit' => 30)); // Set a call and leg id here
$result = $messageBird->voiceTranscriptions->getList('c226420d-f107-4db1-b2f9-4646656a90bc', '4f5ab5f4-c4b6-4586-9255-980bb3fd7336', 'a94f7d51-19b5-4eb8-9e8e-90fce490a577', ['offset' => 100, 'limit' => 30]); // Set a call and leg id here
var_dump($result);
} catch (\Exception $e) {
echo sprintf("%s: %s", get_class($e), $e->getMessage());
Expand Down
2 changes: 1 addition & 1 deletion examples/voice-webhooks-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
$messageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here.

try {
$result = $messageBird->voiceWebhooks->getList(array('offset' => 100, 'limit' => 30));
$result = $messageBird->voiceWebhooks->getList(['offset' => 100, 'limit' => 30]);
var_dump($result);
} catch (\Exception $e) {
echo sprintf("%s: %s", get_class($e), $e->getMessage());
Expand Down
2 changes: 1 addition & 1 deletion examples/voicemessages-create.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
$MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here.

$VoiceMessage = new \MessageBird\Objects\VoiceMessage();
$VoiceMessage->recipients = array (31654286496);
$VoiceMessage->recipients = [31654286496];
$VoiceMessage->body = 'This is a test message. The message is converted to speech and the recipient is called on his mobile.';
$VoiceMessage->language = 'en-gb';
$VoiceMessage->voice = 'female';
Expand Down
2 changes: 1 addition & 1 deletion examples/voicemessages-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
$MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here.

try {
$VoiceMessageList = $MessageBird->voicemessages->getList(array ('offset' => 100, 'limit' => 30));
$VoiceMessageList = $MessageBird->voicemessages->getList( ['offset' => 100, 'limit' => 30]);
var_dump($VoiceMessageList);

} catch (\MessageBird\Exceptions\AuthenticateException $e) {
Expand Down
4 changes: 2 additions & 2 deletions src/MessageBird/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ public function __construct($accessKey = null, Common\HttpClient $httpClient = n
$this->ChatAPIHttpClient = new Common\HttpClient(self::CHATAPI_ENDPOINT);
$this->ConversationsAPIHttpClient = new Common\HttpClient(in_array(self::ENABLE_CONVERSATIONSAPI_WHATSAPP_SANDBOX, $config) ? self::CONVERSATIONSAPI_WHATSAPP_SANDBOX_ENDPOINT : self::CONVERSATIONSAPI_ENDPOINT);
$this->HttpClient = new Common\HttpClient(self::ENDPOINT);
$this->VoiceAPIHttpClient = new Common\HttpClient(self::VOICEAPI_ENDPOINT, 10, 2, array(
$this->VoiceAPIHttpClient = new Common\HttpClient(self::VOICEAPI_ENDPOINT, 10, 2, [
'X-MessageBird-Version' => '20170314',
));
]);
$this->partnerAccountClient = new Common\HttpClient(self::PARTNER_ACCOUNT_ENDPOINT);
$this->numbersAPIClient = new Common\HttpClient(self::NUMBERSAPI_ENDPOINT);
} else {
Expand Down
16 changes: 8 additions & 8 deletions src/MessageBird/Common/HttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class HttpClient
/**
* @var array
*/
protected $userAgent = array();
protected $userAgent = [];

/**
* @var Common\Authentication
Expand All @@ -48,20 +48,20 @@ class HttpClient
/**
* @var array
*/
private $headers = array();
private $headers = [];

/**
* @var array
*/
private $httpOptions = array();
private $httpOptions = [];

/**
* @param string $endpoint
* @param int $timeout > 0
* @param int $connectionTimeout >= 0
* @param array $headers
*/
public function __construct($endpoint, $timeout = 10, $connectionTimeout = 2, $headers = array())
public function __construct($endpoint, $timeout = 10, $connectionTimeout = 2, $headers = [])
{
$this->endpoint = $endpoint;

Expand Down Expand Up @@ -165,13 +165,13 @@ public function performHttpRequest($method, $resourceName, $query = null, $body
throw new Exceptions\AuthenticateException('Can not perform API Request without Authentication');
}

$headers = array (
$headers = [
'User-agent: ' . implode(' ', $this->userAgent),
'Accept: application/json',
'Content-Type: application/json',
'Accept-Charset: utf-8',
sprintf('Authorization: AccessKey %s', $this->Authentication->accessKey)
);
];

$headers = array_merge($headers, $this->headers);

Expand Down Expand Up @@ -220,11 +220,11 @@ public function performHttpRequest($method, $resourceName, $query = null, $body
// Split the header and body
$parts = explode("\r\n\r\n", $response, 3);
$isThreePartResponse = (strpos($parts[0], "\n") === false && strpos($parts[0], 'HTTP/1.') === 0);
list($responseHeader, $responseBody) = $isThreePartResponse ? array ($parts[1], $parts[2]) : array ($parts[0], $parts[1]);
list($responseHeader, $responseBody) = $isThreePartResponse ? [$parts[1], $parts[2]] : [$parts[0], $parts[1]];

curl_close($curl);

return array ($responseStatus, $responseHeader, $responseBody);
return [$responseStatus, $responseHeader, $responseBody];
}

/**
Expand Down
Loading