Skip to content

Commit

Permalink
Update dependencies and types for php 7
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwdan committed Mar 21, 2017
1 parent ecbc3df commit 7eb306b
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ install:
- composer install

script:
- phpunit
- vendor/bin/phpunit
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Install dependencies using [composer](https://getcomposer.org/doc/00-intro.md#do

$source = \Rx\React\Http::get('https://www.example.com/');

$source->subscribeCallback(
$source->subscribe(
function ($data) {
echo $data, PHP_EOL;
},
Expand All @@ -41,7 +41,7 @@ $headers = ['Content-Type' => 'application/json'];

$source = \Rx\React\Http::post('https://www.example.com/', $postData, $headers);

$source->subscribeCallback(
$source->subscribe(
function ($data) {
echo $data, PHP_EOL;
},
Expand All @@ -68,7 +68,7 @@ $images = \Rx\Observable::fromArray($imageTypes)
});
});

$images->subscribeCallback(
$images->subscribe(
function ($data) {
echo "Got Image: ", array_keys($data)[0], PHP_EOL;
},
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
},
"require": {
"PHP": "^7.0",
"voryx/event-loop": "^2.0.0",
"reactivex/rxphp": "2.x-dev",
"voryx/event-loop": "^2.0",
"reactivex/rxphp": "^2.0",
"react/http-client": "^0.4.8"
},
"require-dev": {
Expand Down
14 changes: 7 additions & 7 deletions src/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Http
{
public static function request(RequestInterface $request)
public static function request(RequestInterface $request): HttpObservable
{
$method = $request->getMethod();
$url = $request->getUri();
Expand All @@ -17,32 +17,32 @@ public static function request(RequestInterface $request)
return new HttpObservable($method, $url, $body, $headers, $protocolVersion);
}

public static function get($url, array $headers = [], $protocolVersion = '1.0')
public static function get(string $url, array $headers = [], string $protocolVersion = '1.1'): HttpObservable
{
return new HttpObservable('GET', $url, null, $headers, $protocolVersion);
}

public static function post($url, $body = null, array $headers = [], $protocolVersion = '1.0')
public static function post(string $url, string $body = null, array $headers = [], string $protocolVersion = '1.1'): HttpObservable
{
return new HttpObservable('POST', $url, $body, $headers, $protocolVersion);
}

public static function put($url, $body = null, array $headers = [], $protocolVersion = '1.0')
public static function put(string $url, string $body = null, array $headers = [], string $protocolVersion = '1.1'): HttpObservable
{
return new HttpObservable('PUT', $url, $body, $headers, $protocolVersion);
}

public static function delete($url, array $headers = [], $protocolVersion = '1.0')
public static function delete(string $url, array $headers = [], string $protocolVersion = '1.1'): HttpObservable
{
return new HttpObservable('DELETE', $url, null, $headers, $protocolVersion);
}

public static function patch($url, $body = null, array $headers = [], $protocolVersion = '1.0')
public static function patch(string $url, string $body = null, array $headers = [], string $protocolVersion = '1.1'): HttpObservable
{
return new HttpObservable('PATCH', $url, $body, $headers, $protocolVersion);
}

public static function head($url, array $headers = [], $protocolVersion = '1.0')
public static function head(string $url, array $headers = [], string $protocolVersion = '1.1'): HttpObservable
{
return new HttpObservable('HEAD', $url, null, $headers, $protocolVersion);
}
Expand Down
2 changes: 1 addition & 1 deletion src/HttpObservable.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(
string $url,
string $body = null,
array $headers = [],
string $protocolVersion = '1.0',
string $protocolVersion = '1.1',
bool $bufferResults = true,
bool $includeResponse = false,
SchedulerInterface $scheduler = null
Expand Down
8 changes: 4 additions & 4 deletions tests/Functional/Observable/HttpObservableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ function () use (&$complete) {
$response->emit("end");

$this->assertEquals($result[0], $testData);
$this->assertInstanceOf('React\HttpClient\Response', $result[1]);
$this->assertInstanceOf('React\HttpClient\Request', $result[2]);
$this->assertInstanceOf(Response::class, $result[1]);
$this->assertInstanceOf(Request::class, $result[2]);
$this->assertTrue($complete);
$this->assertFalse($error);

Expand Down Expand Up @@ -336,8 +336,8 @@ function () use (&$complete) {
$response->emit("end");

$this->assertEquals($result[0], $testData1 . $testData2 . $testData3);
$this->assertInstanceOf('React\HttpClient\Response', $result[1]);
$this->assertInstanceOf('React\HttpClient\Request', $result[2]);
$this->assertInstanceOf(Response::class, $result[1]);
$this->assertInstanceOf(Request::class, $result[2]);
$this->assertTrue($complete);
$this->assertFalse($error);

Expand Down

0 comments on commit 7eb306b

Please sign in to comment.