@@ -54,10 +54,10 @@ about *SSL* transport layers and options
54
54
55
55
``` php
56
56
// Set the configuration parameters
57
- $config = array(
57
+ $config = [
58
58
'adapter' => 'Zend\Http\Client\Adapter\Socket',
59
- 'ssltransport' => 'tls'
60
- ) ;
59
+ 'ssltransport' => 'tls',
60
+ ] ;
61
61
62
62
// Instantiate a client object
63
63
$client = new Zend\Http\Client('https://www.example.com', $config);
@@ -93,25 +93,25 @@ context options using regular *PHP* stream context functions.
93
93
94
94
``` php
95
95
// Array of options
96
- $options = array(
97
- 'socket' => array(
96
+ $options = [
97
+ 'socket' => [
98
98
// Bind local socket side to a specific interface
99
99
'bindto' => '10.1.2.3:50505'
100
- ) ,
101
- 'ssl' => array(
100
+ ] ,
101
+ 'ssl' => [
102
102
// Verify server side certificate,
103
103
// do not accept invalid or self-signed SSL certificates
104
- 'verify_peer' => true,
104
+ 'verify_peer' => true,
105
105
'allow_self_signed' => false,
106
106
107
107
// Capture the peer's certificate
108
108
'capture_peer_cert' => true
109
- )
110
- ) ;
109
+ ],
110
+ ] ;
111
111
112
112
// Create an adapter object and attach it to the HTTP client
113
113
$adapter = new Zend\Http\Client\Adapter\Socket();
114
- $client = new Zend\Http\Client();
114
+ $client = new Zend\Http\Client();
115
115
$client->setAdapter($adapter);
116
116
117
117
// Method 1: pass the options array to setStreamContext()
@@ -165,13 +165,13 @@ Currently, only basic authentication (`Zend\Http\Client::AUTH_BASIC`) is support
165
165
166
166
``` php
167
167
// Set the configuration parameters
168
- $config = array(
168
+ $config = [
169
169
'adapter' => 'Zend\Http\Client\Adapter\Proxy',
170
170
'proxy_host' => 'proxy.int.zend.com',
171
171
'proxy_port' => 8000,
172
172
'proxy_user' => 'shahar.e',
173
- 'proxy_pass' => 'bananashaped'
174
- ) ;
173
+ 'proxy_pass' => 'bananashaped',
174
+ ] ;
175
175
176
176
// Instantiate a client object
177
177
$client = new Zend\Http\Client('http://www.example.com', $config);
@@ -199,10 +199,10 @@ large files around between servers.
199
199
### Setting cURL options
200
200
201
201
``` php
202
- $config = array(
203
- 'adapter' => 'Zend\Http\Client\Adapter\Curl',
204
- 'curloptions' => array( CURLOPT_FOLLOWLOCATION => true) ,
205
- ) ;
202
+ $config = [
203
+ 'adapter' => 'Zend\Http\Client\Adapter\Curl',
204
+ 'curloptions' => [ CURLOPT_FOLLOWLOCATION => true] ,
205
+ ] ;
206
206
$client = new Zend\Http\Client($uri, $config);
207
207
```
208
208
@@ -224,12 +224,14 @@ $adapter = new Zend\Http\Client\Adapter\Curl();
224
224
$client = new Zend\Http\Client();
225
225
$client->setAdapter($adapter);
226
226
$client->setMethod('PUT');
227
- $adapter->setOptions(array(
228
- 'curloptions' => array(
229
- CURLOPT_INFILE => $putFileHandle,
230
- CURLOPT_INFILESIZE => $putFileSize
231
- )
232
- ));
227
+ $adapter->setOptions(
228
+ [
229
+ 'curloptions' => [
230
+ CURLOPT_INFILE => $putFileHandle,
231
+ CURLOPT_INFILESIZE => $putFileSize,
232
+ ],
233
+ ]
234
+ );
233
235
$client->send();
234
236
```
235
237
@@ -254,9 +256,12 @@ even performing an actual *HTTP* request.
254
256
``` php
255
257
// Instantiate a new adapter and client
256
258
$adapter = new Zend\Http\Client\Adapter\Test();
257
- $client = new Zend\Http\Client('http://www.example.com', array(
258
- 'adapter' => $adapter
259
- ));
259
+ $client = new Zend\Http\Client(
260
+ 'http://www.example.com',
261
+ [
262
+ 'adapter' => $adapter,
263
+ ]
264
+ );
260
265
261
266
// Set the expected response
262
267
$adapter->setResponse(
@@ -291,9 +296,12 @@ opportunity to set the next response(s) your program might need before returning
291
296
``` php
292
297
// Instantiate a new adapter and client
293
298
$adapter = new Zend\Http\Client\Adapter\Test();
294
- $client = new Zend\Http\Client('http://www.example.com', array(
295
- 'adapter' => $adapter
296
- ));
299
+ $client = new Zend\Http\Client(
300
+ 'http://www.example.com',
301
+ [
302
+ 'adapter' => $adapter,
303
+ ]
304
+ );
297
305
298
306
// Set the first expected response
299
307
$adapter->setResponse(
@@ -346,9 +354,12 @@ this feature.
346
354
``` php
347
355
// Instantiate a new adapter and client
348
356
$adapter = new Zend\Http\Client\Adapter\Test();
349
- $client = new Zend\Http\Client('http://www.example.com', array(
350
- 'adapter' => $adapter
351
- ));
357
+ $client = new Zend\Http\Client(
358
+ 'http://www.example.com',
359
+ [
360
+ 'adapter' => $adapter,
361
+ ]
362
+ );
352
363
353
364
// Force the next request to fail with an exception
354
365
$adapter->setNextRequestWillFail(true);
@@ -386,7 +397,7 @@ class MyApp\Http\Client\Adapter\BananaProtocol
386
397
*
387
398
* @param array $config
388
399
*/
389
- public function setOptions($config = array() )
400
+ public function setOptions($config = [] )
390
401
{
391
402
// This rarely changes - you should usually copy the
392
403
// implementation in Zend\Http\Client\Adapter\Socket.
@@ -417,7 +428,7 @@ class MyApp\Http\Client\Adapter\BananaProtocol
417
428
public function write($method,
418
429
$url,
419
430
$http_ver = '1.1',
420
- $headers = array() ,
431
+ $headers = [] ,
421
432
$body = '')
422
433
{
423
434
// Send request to the remote server.
@@ -446,7 +457,9 @@ class MyApp\Http\Client\Adapter\BananaProtocol
446
457
}
447
458
448
459
// Then, you could use this adapter:
449
- $client = new Zend\Http\Client(array(
450
- 'adapter' => 'MyApp\Http\Client\Adapter\BananaProtocol'
451
- ));
460
+ $client = new Zend\Http\Client(
461
+ [
462
+ 'adapter' => 'MyApp\Http\Client\Adapter\BananaProtocol',
463
+ ]
464
+ );
452
465
```
0 commit comments