Skip to content

Commit 0cc53d2

Browse files
authored
Fix PHP 8.2 deprecated issues (#182)
* fix deprecated creation of dynamic properties * use short syntax arrays
1 parent 6d0c928 commit 0cc53d2

11 files changed

+49
-51
lines changed

get_attachment_example.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php
22
require_once __DIR__ . '/autoload.php';
33

44
use \ATWS;
@@ -7,13 +7,13 @@
77
$username = 'INSERT USERNAME HERE';
88
$password = 'INSERT PASSWORD HERE';
99

10-
$postAuthOpts = array(
11-
'login' => $username,
10+
$postAuthOpts = [
11+
'login' => $username,
1212
'password' => $password,
13-
'trace' => 1, // Allows us to debug by getting the XML requests sent
14-
);
13+
'trace' => 1, // Allows us to debug by getting the XML requests sent
14+
];
1515

16-
$opts = array('trace' => 1);
16+
$opts = ['trace' => 1];
1717
$authWsdl = 'https://webservices.autotask.net/atservices/1.5/atws.wsdl';
1818
$client = new ATWS\Client($authWsdl, $opts);
1919
$zoneInfo = $client->getZoneInfo($username);

src/AutotaskObjects/CreateParam.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ class CreateParam
66
public $Entities;
77

88
public function __construct($param) {
9-
$this->Entities = array($param);
9+
$this->Entities = [$param];
1010
}
1111
}

src/AutotaskObjects/DeleteParam.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ class DeleteParam
66
public $Entities;
77

88
public function __construct($param) {
9-
$this->Entities = array($param);
9+
$this->Entities = [$param];
1010
}
1111
}

src/AutotaskObjects/Query.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
class Query
55
{
6+
public $entity;
67
public $clauses;
78
public $query;
89
public $queryField;
@@ -11,7 +12,7 @@ class Query
1112
public function __construct($entity)
1213
{
1314
$this->entity = $entity;
14-
$this->clauses = array();
15+
$this->clauses = [];
1516
}
1617

1718
public function addField(QueryField $field)

src/AutotaskObjects/QueryCondition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class QueryCondition
88

99
public function __construct($operator = null)
1010
{
11-
$this->clauses = array();
11+
$this->clauses = [];
1212

1313
$this->operator = $operator;
1414

src/AutotaskObjects/QueryField.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33

44
class QueryField
55
{
6+
public $isUDF;
67
public $name;
78
public $expressions;
89

910
public function __construct($name, $isUDF = false)
1011
{
1112
$this->name = $name;
1213
$this->isUDF = $isUDF;
13-
$this->expressions = array();
14+
$this->expressions = [];
1415
}
1516

1617
public function addExpression($op, $value)

src/AutotaskObjects/QueryFieldExpression.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class QueryFieldExpression
77
public $op;
88
public $value;
99

10-
public static $validOperators = array(
10+
public static $validOperators = [
1111
'equals',
1212
'notequal',
1313
'greaterthan',
@@ -23,7 +23,7 @@ class QueryFieldExpression
2323
'like',
2424
'notlike',
2525
'soundslike',
26-
);
26+
];
2727

2828
public function __construct($op, $value)
2929
{

src/AutotaskObjects/UpdateParam.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ class UpdateParam
66
public $Entities;
77

88
public function __construct($param) {
9-
$this->Entities = array($param);
9+
$this->Entities = [$param];
1010
}
1111
}

src/Client.php

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Client extends \SoapClient
88
protected $version;
99
protected $integrationCode;
1010

11-
public static $classMap = array(
11+
public static $classMap = [
1212
'Account' => 'ATWS\AutotaskObjects\Account',
1313
'AccountAlert' => 'ATWS\AutotaskObjects\AccountAlert',
1414
'AccountLocation' => 'ATWS\AutotaskObjects\AccountLocation',
@@ -169,10 +169,10 @@ class Client extends \SoapClient
169169
'UserDefinedFieldDefinition' => 'ATWS\AutotaskObjects\UserDefinedFieldDefinition',
170170
'UserDefinedFieldListItem' => 'ATWS\AutotaskObjects\UserDefinedFieldListItem',
171171
'WorkTypeModifier' => 'ATWS\AutotaskObjects\WorkTypeModifier',
172-
);
172+
];
173173

174174
// @codeCoverageIgnoreStart
175-
public function __construct($wsdl, $soapOpts = array(), $integrationCode = null)
175+
public function __construct($wsdl, $soapOpts = [], $integrationCode = null)
176176
{
177177
foreach (static::$classMap as $external => $internal) {
178178
if (!isset($soapOpts['classmap'][$external])) {
@@ -196,9 +196,7 @@ public function setIntegrationCode($code)
196196
$header = new \SOAPHeader(
197197
'http://autotask.net/ATWS/v' . str_replace('.', '_', $this->version) .'/',
198198
'AutotaskIntegrations',
199-
array(
200-
'IntegrationCode' => $code,
201-
)
199+
['IntegrationCode' => $code]
202200
);
203201

204202
$this->__setSoapHeaders($header);
@@ -212,10 +210,7 @@ public function setResourceImpersonation($resourceId)
212210
$header = new \SOAPHeader(
213211
'http://autotask.net/ATWS/v' . str_replace('.', '_', $this->version) .'/',
214212
'AutotaskIntegrations',
215-
array(
216-
'IntegrationCode' => $this->integrationCode,
217-
'ImpersonateAsResourceID' => $resourceId
218-
)
213+
['IntegrationCode' => $this->integrationCode, 'ImpersonateAsResourceID' => $resourceId]
219214
);
220215
$this->__setSoapHeaders($header);
221216
return $this;
@@ -224,13 +219,13 @@ public function setResourceImpersonation($resourceId)
224219
public function getZoneInfo($username)
225220
{
226221
$zoneInfoObject = new AutotaskObjects\ZoneInfo($username);
227-
return $this->_call('getZoneInfo', array($zoneInfoObject));
222+
return $this->_call('getZoneInfo', [$zoneInfoObject]);
228223
}
229224

230225
public function create(AutotaskObjects\Entity $obj)
231226
{
232227
$params = new AutotaskObjects\CreateParam($obj);
233-
return $this->_call('create', array($params));
228+
return $this->_call('create', [$params]);
234229
}
235230

236231
public function bulkCreate(array $objs)
@@ -246,13 +241,13 @@ public function bulkCreate(array $objs)
246241
$createObjs->Entities[] = $obj;
247242
}
248243
}
249-
return $this->_call('create', array($createObjs));
244+
return $this->_call('create', [$createObjs]);
250245
}
251246

252247
public function update(AutotaskObjects\Entity $obj)
253248
{
254249
$params = new AutotaskObjects\UpdateParam($obj);
255-
return $this->_call('update', array($params));
250+
return $this->_call('update', [$params]);
256251
}
257252

258253
public function bulkUpdate(array $objs)
@@ -261,21 +256,21 @@ public function bulkUpdate(array $objs)
261256
throw new \Exception('You can only execute a bulk update on a max of 200 objects per request');
262257
}
263258
$updateObjs = null;
264-
$calls = array();
259+
$calls = [];
265260
foreach ($objs as $obj) {
266261
if (!$updateObjs) {
267262
$updateObjs = new AutotaskObjects\UpdateParam($obj);
268263
} else {
269264
$updateObjs->Entities[] = $obj;
270265
}
271266
}
272-
return $this->_call('update', array($updateObjs));
267+
return $this->_call('update', [$updateObjs]);
273268
}
274269

275270
public function delete(AutotaskObjects\Entity $obj)
276271
{
277272
$params = new AutotaskObjects\DeleteParam($obj);
278-
return $this->_call('delete', array($params));
273+
return $this->_call('delete', [$params]);
279274
}
280275

281276
public function bulkDelete(array $objs)
@@ -284,45 +279,45 @@ public function bulkDelete(array $objs)
284279
throw new \Exception('You can only execute a bulk delete on a max of 200 objects per request');
285280
}
286281
$deleteObjs = null;
287-
$calls = array();
282+
$calls = [];
288283
foreach ($objs as $obj) {
289284
if (!$deleteObjs) {
290285
$deleteObjs = new AutotaskObjects\DeleteParam($obj);
291286
} else {
292287
$deleteObjs->Entities[] = $obj;
293288
}
294289
}
295-
return $this->_call('delete', array($deleteObjs));
290+
return $this->_call('delete', [$deleteObjs]);
296291
}
297292

298293
public function GetAttachment(AutotaskObjects\Entity $obj)
299294
{
300295
$params = new AutotaskObjects\GetAttachment($obj);
301-
return $this->_call('GetAttachment', array($params));
296+
return $this->_call('GetAttachment', [$params]);
302297
}
303298

304299
public function CreateAttachment(AutotaskObjects\Entity $obj)
305300
{
306301
$params = new AutotaskObjects\CreateAttachment($obj);
307-
return $this->_call('CreateAttachment', array($params));
302+
return $this->_call('CreateAttachment', [$params]);
308303
}
309304

310305
public function query(AutotaskObjects\Query $obj)
311306
{
312307
$obj->asXml();
313-
return $this->_call('query', array($obj));
308+
return $this->_call('query', [$obj]);
314309
}
315310

316311
public function getUDFInfo($type)
317312
{
318313
$param = new AutotaskObjects\UDFParam($type);
319-
return $this->_call('getUDFInfo', array($param));
314+
return $this->_call('getUDFInfo', [$param]);
320315
}
321316

322317
public function getFieldInfo($type)
323318
{
324319
$fieldInfo = new AutotaskObjects\FieldInfo($type);
325-
return $this->_call('getFieldInfo', array($fieldInfo));
320+
return $this->_call('getFieldInfo', [$fieldInfo]);
326321
}
327322

328323
public function getEntityInfo()
@@ -340,7 +335,7 @@ public function getInvoiceMarkup($invoiceId, $type)
340335
$invoiceMarkup = new AutotaskObjects\InvoiceMarkup();
341336
$invoiceMarkup->InvoiceId = (int)$invoiceId;
342337
$invoiceMarkup->Format = $type;
343-
return $this->_call('GetInvoiceMarkup', array($invoiceMarkup));
338+
return $this->_call('GetInvoiceMarkup', [$invoiceMarkup]);
344339
}
345340

346341
public function __doRequest($request, $location, $action, $version, $oneWay = 0): ?string
@@ -355,7 +350,7 @@ public function __doRequest($request, $location, $action, $version, $oneWay = 0)
355350
return parent::__doRequest($request, $location, $action, $version, $oneWay);
356351
}
357352

358-
private function _call($method, $params = array())
353+
private function _call($method, $params = [])
359354
{
360355
return $this->__soapCall($method, $params);
361356
}

ticket_create_example.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
require_once __DIR__ . '/src/autoload.php';
66

77
// Edit these variables to get this example to work for you
8+
$accountId = '<YOUR ACCOUNT ID>';
89
$username = '<YOUR USERNAME>';
910
$password = '<YOUR PASSWORD>';
1011

@@ -15,7 +16,7 @@
1516
$ticket = new ATWS\AutotaskObjects\Ticket();
1617
// Set required fields
1718
$ticket->id= 0; // Set to 0 for create, or a ticket id for update
18-
$ticket->AccountID = ;
19+
$ticket->AccountID = $accountId;
1920
$ticket->DueDateTime = '2018-12-17';
2021
$ticket->Title = 'Test Ticket';
2122
$ticket->Status = 1;
@@ -31,15 +32,15 @@
3132
// End Edit Region
3233

3334
$authWsdl = 'https://webservices.autotask.net/atservices/1.5/atws.wsdl';
34-
$opts = array('trace' => 1);
35+
$opts = ['trace' => 1];
3536
$client = new ATWS\Client($authWsdl, $opts);
3637
$zoneInfo = $client->getZoneInfo($username);
3738

38-
$authOpts = array(
39-
'login' => $username,
39+
$authOpts = [
40+
'login' => $username,
4041
'password' => $password,
41-
'trace' => 1, // Allows us to debug by getting the XML requests sent
42-
);
42+
'trace' => 1, // Allows us to debug by getting the XML requests sent
43+
];
4344
$wsdl = str_replace('.asmx', '.wsdl', $zoneInfo->getZoneInfoResult->URL);
4445
$client = new ATWS\Client($wsdl, $authOpts);
4546
$client->setIntegrationCode($integrationCode);

udf_query_example.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@
1313
// End Edit Region
1414

1515
$authWsdl = 'https://webservices.autotask.net/atservices/1.5/atws.wsdl';
16-
$opts = array('trace' => 1);
16+
$opts = ['trace' => 1];
1717
$client = new ATWS\Client($authWsdl, $opts);
1818
$zoneInfo = $client->getZoneInfo($username);
1919

2020
print_r($zoneInfo);
2121

22-
$authOpts = array(
23-
'login' => $username,
22+
$authOpts = [
23+
'login' => $username,
2424
'password' => $password,
25-
'trace' => 1, // Allows us to debug by getting the XML requests sent
26-
);
25+
'trace' => 1, // Allows us to debug by getting the XML requests sent
26+
];
2727
$wsdl = str_replace('.asmx', '.wsdl', $zoneInfo->getZoneInfoResult->URL);
2828
$client = new ATWS\Client($wsdl, $authOpts);
2929

0 commit comments

Comments
 (0)