Skip to content
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

CS: align the array assignment operators in multi-line multi-item arrays #403

Merged
merged 1 commit into from
Oct 22, 2020
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
8 changes: 4 additions & 4 deletions examples/multiple.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
// Setup what we want to request
$requests = array(
array(
'url' => 'http://httpbin.org/get',
'url' => 'http://httpbin.org/get',
'headers' => array('Accept' => 'application/javascript'),
),
'post' => array(
'url' => 'http://httpbin.org/post',
'post' => array(
'url' => 'http://httpbin.org/post',
'data' => array('mydata' => 'something'),
),
'delayed' => array(
'url' => 'http://httpbin.org/delay/10',
'url' => 'http://httpbin.org/delay/10',
'options' => array(
'timeout' => 20,
),
Expand Down
34 changes: 17 additions & 17 deletions library/Requests.php
Original file line number Diff line number Diff line change
Expand Up @@ -503,25 +503,25 @@ public static function request_multiple($requests, $options = array()) {
*/
protected static function get_default_options($multirequest = false) {
$defaults = array(
'timeout' => 10,
'connect_timeout' => 10,
'useragent' => 'php-requests/' . self::VERSION,
'timeout' => 10,
'connect_timeout' => 10,
'useragent' => 'php-requests/' . self::VERSION,
'protocol_version' => 1.1,
'redirected' => 0,
'redirects' => 10,
'redirected' => 0,
'redirects' => 10,
'follow_redirects' => true,
'blocking' => true,
'type' => self::GET,
'filename' => false,
'auth' => false,
'proxy' => false,
'cookies' => false,
'max_bytes' => false,
'idn' => true,
'hooks' => null,
'transport' => null,
'verify' => Requests::get_certificate_path(),
'verifyname' => true,
'blocking' => true,
'type' => self::GET,
'filename' => false,
'auth' => false,
'proxy' => false,
'cookies' => false,
'max_bytes' => false,
'idn' => true,
'hooks' => null,
'transport' => null,
'verify' => Requests::get_certificate_path(),
'verifyname' => true,
);
if ($multirequest !== false) {
$defaults['complete'] = null;
Expand Down
6 changes: 3 additions & 3 deletions library/Requests/Cookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ public function __construct($name, $value, $attributes = array(), $flags = array
$this->value = $value;
$this->attributes = $attributes;
$default_flags = array(
'creation' => time(),
'creation' => time(),
'last-access' => time(),
'persistent' => false,
'host-only' => true,
'persistent' => false,
'host-only' => true,
);
$this->flags = array_merge($default_flags, $flags);

Expand Down
2 changes: 1 addition & 1 deletion library/Requests/Transport/fsockopen.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function request($url, $headers = array(), $data = array(), $options = ar
}

$context_options = array(
'verify_peer' => true,
'verify_peer' => true,
// 'CN_match' => $host,
'capture_peer_cert' => true
);
Expand Down
6 changes: 3 additions & 3 deletions tests/Auth/Basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function testUsingArray($transport) {
}

$options = array(
'auth' => array('user', 'passwd'),
'auth' => array('user', 'passwd'),
'transport' => $transport,
);
$request = Requests::get(httpbin('/basic-auth/user/passwd'), array(), $options);
Expand All @@ -40,7 +40,7 @@ public function testUsingInstantiation($transport) {
}

$options = array(
'auth' => new Requests_Auth_Basic(array('user', 'passwd')),
'auth' => new Requests_Auth_Basic(array('user', 'passwd')),
'transport' => $transport,
);
$request = Requests::get(httpbin('/basic-auth/user/passwd'), array(), $options);
Expand All @@ -61,7 +61,7 @@ public function testPOSTUsingInstantiation($transport) {
}

$options = array(
'auth' => new Requests_Auth_Basic(array('user', 'passwd')),
'auth' => new Requests_Auth_Basic(array('user', 'passwd')),
'transport' => $transport,
);
$data = 'test';
Expand Down
8 changes: 4 additions & 4 deletions tests/ChunkedEncoding.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ public function testChunked($body, $expected) {

public static function notChunkedProvider() {
return array(
'invalid chunk size' => array('Hello! This is a non-chunked response!'),
'invalid chunk extension' => array('1BNot chunked\r\nLooks chunked but it is not\r\n'),
'unquoted chunk-ext-val with space' => array("02;foo=unquoted with space\r\nab\r\n04\r\nra\nc\r\n06\r\nadabra\r\n0c\r\n\nall we got\n"),
'invalid chunk size' => array('Hello! This is a non-chunked response!'),
'invalid chunk extension' => array('1BNot chunked\r\nLooks chunked but it is not\r\n'),
'unquoted chunk-ext-val with space' => array("02;foo=unquoted with space\r\nab\r\n04\r\nra\nc\r\n06\r\nadabra\r\n0c\r\n\nall we got\n"),
'unquoted chunk-ext-val with forbidden character' => array("02;foo={unquoted}\r\nab\r\n04\r\nra\nc\r\n06\r\nadabra\r\n0c\r\n\nall we got\n"),
'invalid chunk-ext-name' => array("02;{foo}=bar\r\nab\r\n04\r\nra\nc\r\n06\r\nadabra\r\n0c\r\n\nall we got\n"),
'invalid chunk-ext-name' => array("02;{foo}=bar\r\nab\r\n04\r\nra\nc\r\n06\r\nadabra\r\n0c\r\n\nall we got\n"),
'incomplete quote for chunk-ext-value' => array("02;foo=\"no end quote\r\nab\r\n04\r\nra\nc\r\n06\r\nadabra\r\n0c\r\n\nall we got\n"),
);
}
Expand Down
12 changes: 6 additions & 6 deletions tests/Proxy/HTTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function testConnectWithString($transport) {
$this->checkProxyAvailable();

$options = array(
'proxy' => REQUESTS_HTTP_PROXY,
'proxy' => REQUESTS_HTTP_PROXY,
'transport' => $transport,
);
$response = Requests::get(httpbin('/get'), array(), $options);
Expand All @@ -48,7 +48,7 @@ public function testConnectWithArray($transport) {
$this->checkProxyAvailable();

$options = array(
'proxy' => array(REQUESTS_HTTP_PROXY),
'proxy' => array(REQUESTS_HTTP_PROXY),
'transport' => $transport,
);
$response = Requests::get(httpbin('/get'), array(), $options);
Expand All @@ -66,7 +66,7 @@ public function testConnectInvalidParameters($transport) {
$this->checkProxyAvailable();

$options = array(
'proxy' => array(REQUESTS_HTTP_PROXY, 'testuser', 'password', 'something'),
'proxy' => array(REQUESTS_HTTP_PROXY, 'testuser', 'password', 'something'),
'transport' => $transport,
);
$response = Requests::get(httpbin('/get'), array(), $options);
Expand All @@ -79,7 +79,7 @@ public function testConnectWithInstance($transport) {
$this->checkProxyAvailable();

$options = array(
'proxy' => new Requests_Proxy_HTTP(REQUESTS_HTTP_PROXY),
'proxy' => new Requests_Proxy_HTTP(REQUESTS_HTTP_PROXY),
'transport' => $transport,
);
$response = Requests::get(httpbin('/get'), array(), $options);
Expand All @@ -96,7 +96,7 @@ public function testConnectWithAuth($transport) {
$this->checkProxyAvailable('auth');

$options = array(
'proxy' => array(
'proxy' => array(
REQUESTS_HTTP_PROXY_AUTH,
REQUESTS_HTTP_PROXY_AUTH_USER,
REQUESTS_HTTP_PROXY_AUTH_PASS
Expand All @@ -118,7 +118,7 @@ public function testConnectWithInvalidAuth($transport) {
$this->checkProxyAvailable('auth');

$options = array(
'proxy' => array(
'proxy' => array(
REQUESTS_HTTP_PROXY_AUTH,
REQUESTS_HTTP_PROXY_AUTH_USER . '!',
REQUESTS_HTTP_PROXY_AUTH_PASS . '!'
Expand Down
8 changes: 4 additions & 4 deletions tests/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,20 @@ public function testMultiple() {

public function testPropertyUsage() {
$headers = array(
'X-TestHeader' => 'testing',
'X-TestHeader' => 'testing',
'X-TestHeader2' => 'requests-test'
);
$data = array(
'testdata' => 'value1',
'test2' => 'value2',
'test3' => array(
'test2' => 'value2',
'test3' => array(
'foo' => 'bar',
'abc' => 'xyz'
)
);
$options = array(
'testoption' => 'test',
'foo' => 'bar'
'foo' => 'bar'
);

$session = new Requests_Session('http://example.com/', $headers, $data, $options);
Expand Down
40 changes: 20 additions & 20 deletions tests/Transport/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function testResponseByteLimitWithFile() {
$limit = 300;
$options = array(
'max_bytes' => $limit,
'filename' => tempnam(sys_get_temp_dir(), 'RLT') // RequestsLibraryTest
'filename' => tempnam(sys_get_temp_dir(), 'RLT') // RequestsLibraryTest
);
$response = Requests::get(httpbin('/bytes/482'), array(), $this->getOptions($options));
$this->assertEmpty($response->body);
Expand Down Expand Up @@ -89,7 +89,7 @@ public function testGETWithArgs() {

public function testGETWithData() {
$data = array(
'test' => 'true',
'test' => 'true',
'test2' => 'test',
);
$request = Requests::request(httpbin('/get'), array(), $data, Requests::GET, $this->getOptions());
Expand All @@ -102,7 +102,7 @@ public function testGETWithData() {

public function testGETWithNestedData() {
$data = array(
'test' => 'true',
'test' => 'true',
'test2' => array(
'test3' => 'test',
'test4' => 'test-too',
Expand Down Expand Up @@ -179,7 +179,7 @@ public function testFormPost() {

public function testPOSTWithArray() {
$data = array(
'test' => 'true',
'test' => 'true',
'test2' => 'test',
);
$request = Requests::post(httpbin('/post'), array(), $data, $this->getOptions());
Expand All @@ -191,7 +191,7 @@ public function testPOSTWithArray() {

public function testPOSTWithNestedData() {
$data = array(
'test' => 'true',
'test' => 'true',
'test2' => array(
'test3' => 'test',
'test4' => 'test-too',
Expand Down Expand Up @@ -224,7 +224,7 @@ public function testFormPUT() {

public function testPUTWithArray() {
$data = array(
'test' => 'true',
'test' => 'true',
'test2' => 'test',
);
$request = Requests::put(httpbin('/put'), array(), $data, $this->getOptions());
Expand Down Expand Up @@ -254,7 +254,7 @@ public function testFormPATCH() {

public function testPATCHWithArray() {
$data = array(
'test' => 'true',
'test' => 'true',
'test2' => 'test',
);
$request = Requests::patch(httpbin('/patch'), array(), $data, $this->getOptions());
Expand All @@ -280,7 +280,7 @@ public function testDELETE() {

public function testDELETEWithData() {
$data = array(
'test' => 'true',
'test' => 'true',
'test2' => 'test',
);
$request = Requests::request(httpbin('/delete'), array(), $data, Requests::DELETE, $this->getOptions());
Expand All @@ -298,7 +298,7 @@ public function testLOCK() {

public function testLOCKWithData() {
$data = array(
'test' => 'true',
'test' => 'true',
'test2' => 'test',
);
$request = Requests::request(httpbin('/lock'), array(), $data, 'LOCK', $this->getOptions());
Expand Down Expand Up @@ -393,7 +393,7 @@ public function testStatusCode($code, $success) {

$options = array(
'follow_redirects' => false,
'transport' => $transport,
'transport' => $transport,
);
$request = Requests::get($url, array(), $options);
$this->assertEquals($code, $request->status_code);
Expand All @@ -410,7 +410,7 @@ public function testStatusCodeThrow($code, $success) {
$url = sprintf(httpbin('/status/%d'), $code);
$options = array(
'follow_redirects' => false,
'transport' => $transport,
'transport' => $transport,
);

if (!$success) {
Expand All @@ -435,7 +435,7 @@ public function testStatusCodeThrowAllowRedirects($code, $success) {
$url = sprintf(httpbin('/status/%d'), $code);
$options = array(
'follow_redirects' => false,
'transport' => $transport,
'transport' => $transport,
);

if (!$success) {
Expand Down Expand Up @@ -657,7 +657,7 @@ public function testMultipleWithDifferingMethods() {
'url' => httpbin('/get'),
),
'post' => array(
'url' => httpbin('/post'),
'url' => httpbin('/post'),
'type' => Requests::POST,
'data' => 'test',
),
Expand All @@ -682,7 +682,7 @@ public function testMultipleWithFailure() {
'url' => httpbin('/get'),
),
'timeout' => array(
'url' => httpbin('/delay/10'),
'url' => httpbin('/delay/10'),
'options' => array(
'timeout' => 1,
),
Expand All @@ -699,7 +699,7 @@ public function testMultipleUsingCallback() {
'url' => httpbin('/get'),
),
'post' => array(
'url' => httpbin('/post'),
'url' => httpbin('/post'),
'type' => Requests::POST,
'data' => 'test',
),
Expand All @@ -720,7 +720,7 @@ public function testMultipleUsingCallbackAndFailure() {
'url' => httpbin('/get'),
),
'timeout' => array(
'url' => httpbin('/delay/10'),
'url' => httpbin('/delay/10'),
'options' => array(
'timeout' => 1,
),
Expand All @@ -743,15 +743,15 @@ public function completeCallback($response, $key) {
public function testMultipleToFile() {
$requests = array(
'get' => array(
'url' => httpbin('/get'),
'url' => httpbin('/get'),
'options' => array(
'filename' => tempnam(sys_get_temp_dir(), 'RLT') // RequestsLibraryTest
),
),
'post' => array(
'url' => httpbin('/post'),
'type' => Requests::POST,
'data' => 'test',
'url' => httpbin('/post'),
'type' => Requests::POST,
'data' => 'test',
'options' => array(
'filename' => tempnam(sys_get_temp_dir(), 'RLT') // RequestsLibraryTest
),
Expand Down