Skip to content

Commit

Permalink
Merge pull request solariumphp#479 from remicollet/issue-php53
Browse files Browse the repository at this point in the history
fix for PHP 5.3
  • Loading branch information
basdenooijer authored Feb 2, 2017
2 parents 8d25cfb + 188b80f commit e30bf0d
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 56 deletions.
2 changes: 1 addition & 1 deletion library/Solarium/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Client extends CoreClient
*
* @var string
*/
const VERSION = '3.7.0';
const VERSION = '3.8.0';

/**
* Check for an exact version.
Expand Down
8 changes: 4 additions & 4 deletions library/Solarium/Core/Client/Adapter/Guzzle3.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ public function execute($request, $endpoint)
$endpoint->getBaseUri() . $request->getUri(),
$this->getRequestHeaders($request),
$this->getRequestBody($request),
[
array(
'timeout' => $endpoint->getTimeout(),
'connecttimeout' => $endpoint->getTimeout(),
]
)
);

// Try endpoint authentication first, fallback to request for backwards compatibility
Expand All @@ -96,7 +96,7 @@ public function execute($request, $endpoint)
$guzzleResponse = $guzzleRequest->getResponse();

$responseHeaders = array_merge(
["HTTP/1.1 {$guzzleResponse->getStatusCode()} {$guzzleResponse->getReasonPhrase()}"],
array("HTTP/1.1 {$guzzleResponse->getStatusCode()} {$guzzleResponse->getReasonPhrase()}"),
$guzzleResponse->getHeaderLines()
);

Expand Down Expand Up @@ -155,7 +155,7 @@ private function getRequestBody(Request $request)
*/
private function getRequestHeaders(Request $request)
{
$headers = [];
$headers = array();
foreach ($request->getHeaders() as $headerLine) {
list($header, $value) = explode(':', $headerLine);
if ($header = trim($header)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function parse($query, $grouping, $data)
$matches = (isset($result['matches'])) ? $result['matches'] : null;
$groupCount = (isset($result['ngroups'])) ? $result['ngroups'] : null;
if ($grouping->getFormat() === GroupingComponent::FORMAT_SIMPLE) {
$valueGroups = [$this->extractValueGroup($valueResultClass, $documentClass, $result, $query)];
$valueGroups = array($this->extractValueGroup($valueResultClass, $documentClass, $result, $query));
$groups[$field] = new FieldGroup($matches, $groupCount, $valueGroups);
continue;
}
Expand Down
38 changes: 19 additions & 19 deletions tests/Solarium/Tests/Core/Client/Adapter/Guzzle3Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ public function executeGet()
$this->assertSame('OK', $response->getStatusMessage());
$this->assertSame('200', $response->getStatusCode());
$this->assertSame(
[
array(
'HTTP/1.1 200 OK',
'Content-Type: application/json',
'X-PHPUnit: response value',
],
),
$response->getHeaders()
);
$this->assertSame($guzzleResponse->getBody(true), $response->getBody());
Expand Down Expand Up @@ -138,11 +138,11 @@ public function executePostWithFile()
$this->assertSame('OK', $response->getStatusMessage());
$this->assertSame('200', $response->getStatusCode());
$this->assertSame(
[
array(
'HTTP/1.1 200 OK',
'Content-Type: application/json',
'X-PHPUnit: response value',
],
),
$response->getHeaders()
);
$this->assertSame($guzzleResponse->getBody(true), $response->getBody());
Expand Down Expand Up @@ -187,11 +187,11 @@ public function executePostWithRawBody()
$this->assertSame('OK', $response->getStatusMessage());
$this->assertSame('200', $response->getStatusCode());
$this->assertSame(
[
array(
'HTTP/1.1 200 OK',
'Content-Type: application/json',
'X-PHPUnit: response value',
],
),
$response->getHeaders()
);
$this->assertSame($guzzleResponse->getBody(true), $response->getBody());
Expand Down Expand Up @@ -239,11 +239,11 @@ public function executeGetWithAuthentication()
$this->assertSame('OK', $response->getStatusMessage());
$this->assertSame('200', $response->getStatusCode());
$this->assertSame(
[
array(
'HTTP/1.1 200 OK',
'Content-Type: application/json',
'X-PHPUnit: response value',
],
),
$response->getHeaders()
);
$this->assertSame($guzzleResponse->getBody(true), $response->getBody());
Expand Down Expand Up @@ -280,9 +280,9 @@ public function executeRequestException()
$request->setMethod(Request::METHOD_GET);

$endpoint = new Endpoint(
[
array(
'scheme' => 'silly', //invalid protocol
]
)
);

$this->adapter->execute($request, $endpoint);
Expand All @@ -296,26 +296,26 @@ public function executeRequestException()
private function getValidResponse()
{
$body = json_encode(
[
'response' => [
array(
'response' => array(
'numFound' => 10,
'start' => 0,
'docs' => [
[
'docs' => array(
array(
'id' => '58339e95d5200',
'author' => 'Gambardella, Matthew',
'title' => "XML Developer's Guide",
'genre' => 'Computer',
'price' => 44.95,
'published' => 970372800,
'description' => 'An in-depth look at creating applications with XML.',
],
],
],
]
),
),
),
)
);

$headers = ['Content-Type' => 'application/json', 'X-PHPUnit' => 'response value'];
$headers = array('Content-Type' => 'application/json', 'X-PHPUnit' => 'response value');
return new Response(200, $headers, $body);
}
}
62 changes: 31 additions & 31 deletions tests/Solarium/Tests/Core/Client/Adapter/GuzzleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ public function setUp()
public function executeGet()
{
$guzzleResponse = $this->getValidResponse();
$mockHandler = new MockHandler([$guzzleResponse]);
$mockHandler = new MockHandler(array($guzzleResponse));

$container = [];
$container = array();
$history = Middleware::history($container);

$stack = HandlerStack::create($mockHandler);
$stack->push($history);

$adapter = new GuzzleAdapter(['handler' => $stack]);
$adapter = new GuzzleAdapter(array('handler' => $stack));

$request = new Request();
$request->setMethod(Request::METHOD_GET);
Expand All @@ -96,11 +96,11 @@ public function executeGet()
$this->assertSame('OK', $response->getStatusMessage());
$this->assertSame('200', $response->getStatusCode());
$this->assertSame(
[
array(
'HTTP/1.1 200 OK',
'Content-Type: application/json',
'X-PHPUnit: response value',
],
),
$response->getHeaders()
);
$this->assertSame((string)$guzzleResponse->getBody(), $response->getBody());
Expand All @@ -121,15 +121,15 @@ public function executeGet()
public function executePostWithFile()
{
$guzzleResponse = $this->getValidResponse();
$mockHandler = new MockHandler([$guzzleResponse]);
$mockHandler = new MockHandler(array($guzzleResponse));

$container = [];
$container = array();
$history = Middleware::history($container);

$stack = HandlerStack::create($mockHandler);
$stack->push($history);

$adapter = new GuzzleAdapter(['handler' => $stack]);
$adapter = new GuzzleAdapter(array('handler' => $stack));

$request = new Request();
$request->setMethod(Request::METHOD_POST);
Expand All @@ -143,11 +143,11 @@ public function executePostWithFile()
$this->assertSame('OK', $response->getStatusMessage());
$this->assertSame('200', $response->getStatusCode());
$this->assertSame(
[
array(
'HTTP/1.1 200 OK',
'Content-Type: application/json',
'X-PHPUnit: response value',
],
),
$response->getHeaders()
);
$this->assertSame((string)$guzzleResponse->getBody(), $response->getBody());
Expand All @@ -169,15 +169,15 @@ public function executePostWithFile()
public function executePostWithRawBody()
{
$guzzleResponse = $this->getValidResponse();
$mockHandler = new MockHandler([$guzzleResponse]);
$mockHandler = new MockHandler(array($guzzleResponse));

$container = [];
$container = array();
$history = Middleware::history($container);

$stack = HandlerStack::create($mockHandler);
$stack->push($history);

$adapter = new GuzzleAdapter(['handler' => $stack]);
$adapter = new GuzzleAdapter(array('handler' => $stack));

$request = new Request();
$request->setMethod(Request::METHOD_POST);
Expand All @@ -192,11 +192,11 @@ public function executePostWithRawBody()
$this->assertSame('OK', $response->getStatusMessage());
$this->assertSame('200', $response->getStatusCode());
$this->assertSame(
[
array(
'HTTP/1.1 200 OK',
'Content-Type: application/json',
'X-PHPUnit: response value',
],
),
$response->getHeaders()
);
$this->assertSame((string)$guzzleResponse->getBody(), $response->getBody());
Expand All @@ -219,15 +219,15 @@ public function executePostWithRawBody()
public function executeGetWithAuthentication()
{
$guzzleResponse = $this->getValidResponse();
$mockHandler = new MockHandler([$guzzleResponse]);
$mockHandler = new MockHandler(array($guzzleResponse));

$container = [];
$container = array();
$history = Middleware::history($container);

$stack = HandlerStack::create($mockHandler);
$stack->push($history);

$adapter = new GuzzleAdapter(['handler' => $stack]);
$adapter = new GuzzleAdapter(array('handler' => $stack));

$request = new Request();
$request->setMethod(Request::METHOD_GET);
Expand All @@ -241,11 +241,11 @@ public function executeGetWithAuthentication()
$this->assertSame('OK', $response->getStatusMessage());
$this->assertSame('200', $response->getStatusCode());
$this->assertSame(
[
array(
'HTTP/1.1 200 OK',
'Content-Type: application/json',
'X-PHPUnit: response value',
],
),
$response->getHeaders()
);
$this->assertSame((string)$guzzleResponse->getBody(), $response->getBody());
Expand Down Expand Up @@ -277,9 +277,9 @@ public function executeRequestException()
$request->setMethod(Request::METHOD_GET);

$endpoint = new Endpoint(
[
array(
'scheme' => 'silly', //invalid protocol
]
)
);
$endpoint->setTimeout(10);

Expand All @@ -294,26 +294,26 @@ public function executeRequestException()
private function getValidResponse()
{
$body = json_encode(
[
'response' => [
array(
'response' => array(
'numFound' => 10,
'start' => 0,
'docs' => [
[
'docs' => array(
array(
'id' => '58339e95d5200',
'author' => 'Gambardella, Matthew',
'title' => "XML Developer's Guide",
'genre' => 'Computer',
'price' => 44.95,
'published' => 970372800,
'description' => 'An in-depth look at creating applications with XML.',
],
],
],
]
),
),
),
)
);

$headers = ['Content-Type' => 'application/json', 'X-PHPUnit' => 'response value'];
$headers = array('Content-Type' => 'application/json', 'X-PHPUnit' => 'response value');
return new Response(200, $headers, $body);
}
}

0 comments on commit e30bf0d

Please sign in to comment.