Skip to content

Commit 7e46010

Browse files
authored
strict_types=1 (#10)
* strict_types=1 * Finalize classes * Fixes doc types
1 parent 4f2ff50 commit 7e46010

24 files changed

+105
-37
lines changed

.gitattributes

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,14 @@
1111
# @link https://github.com/JBZoo/Http-Client
1212
#
1313

14+
/.phan export-ignore
15+
/build export-ignore
16+
/tests export-ignore
17+
/.editorconfig export-ignore
18+
/.gitattributes export-ignore
19+
/.gitignore export-ignore
20+
/.travis.yml export-ignore
21+
/phpunit.xml.dist export-ignore
22+
/Makefile export-ignore
23+
1424
* text eol=lf

.phan/config.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* @link https://github.com/JBZoo/Http-Client
1414
*/
1515

16+
declare(strict_types=1);
17+
1618
$default = include __DIR__ . '/../vendor/jbzoo/codestyle/src/phan/default.php';
1719

1820
return array_merge($default, [

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ php:
1919
- 7.2
2020
- 7.3
2121
- 7.4
22+
- 8.0
23+
- nightly
24+
25+
jobs:
26+
fast_finish: true
27+
allow_failures:
28+
- php: 8.0
29+
- php: nightly
2230

2331
env:
2432
matrix:

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# JBZoo / Http-Client
22

3-
[![Build Status](https://travis-ci.org/JBZoo/Http-Client.svg)](https://travis-ci.org/JBZoo/Http-Client) [![Coverage Status](https://coveralls.io/repos/JBZoo/Http-Client/badge.svg)](https://coveralls.io/github/JBZoo/Http-Client) [![Psalm Coverage](https://shepherd.dev/github/JBZoo/Http-Client/coverage.svg)](https://shepherd.dev/github/JBZoo/Http-Client)
3+
[![Build Status](https://travis-ci.org/JBZoo/Http-Client.svg)](https://travis-ci.org/JBZoo/Http-Client) [![Coverage Status](https://coveralls.io/repos/JBZoo/Http-Client/badge.svg)](https://coveralls.io/github/JBZoo/Http-Client) [![Psalm Coverage](https://shepherd.dev/github/JBZoo/Http-Client/coverage.svg)](https://shepherd.dev/github/JBZoo/Http-Client) [![PHP Strict Types](https://img.shields.io/badge/strict__types-%3D1-brightgreen)](https://www.php.net/manual/en/language.types.declarations.php#language.types.declarations.strict)
44
[![Stable Version](https://poser.pugx.org/jbzoo/http-client/version)](https://packagist.org/packages/jbzoo/http-client) [![Latest Unstable Version](https://poser.pugx.org/jbzoo/http-client/v/unstable)](https://packagist.org/packages/jbzoo/http-client) [![Dependents](https://poser.pugx.org/jbzoo/http-client/dependents)](https://packagist.org/packages/jbzoo/http-client/dependents?order_by=downloads) [![GitHub Issues](https://img.shields.io/github/issues/jbzoo/http-client)](https://github.com/JBZoo/Http-Client/issues) [![Total Downloads](https://poser.pugx.org/jbzoo/http-client/downloads)](https://packagist.org/packages/jbzoo/http-client/stats) [![GitHub License](https://img.shields.io/github/license/jbzoo/http-client)](https://github.com/JBZoo/Http-Client/blob/master/LICENSE)
55

66

@@ -10,7 +10,7 @@ Just make HTTP requests in one line and don't care about terrible syntax of Guzz
1010

1111
## Install
1212
```sh
13-
composer require guzzlehttp/guzzle --no-update # Recomended, but not required
13+
composer require guzzlehttp/guzzle --no-update # Recommended, but not required
1414
composer require jbzoo/http-client
1515
```
1616

@@ -32,7 +32,7 @@ $httpClient = new HttpClient([
3232
'verify' => false, // Check cert for SSL
3333
'exceptions' => false, // Show exceptions for statuses 4xx and 5xx
3434
'allow_redirects' => true, // Show real 3xx-header or result?
35-
'max_redirects' => 10, // How much to reirect?
35+
'max_redirects' => 10, // How much to redirect?
3636
'user_agent' => "It's me", // Custom UserAgent
3737
]);
3838

@@ -70,7 +70,10 @@ $value = $json->find('key.nested', 'default', 'trim');
7070

7171

7272
## Asynchronous requests (curl_multi_* for parallels)
73+
7374
```php
75+
use JBZoo\HttpClient\HttpClient;
76+
7477
$httpClient = new HttpClient();
7578

7679
$results = $httpClient->multiRequest(array(

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
"php" : ">=7.2",
1818
"ext-json" : "*",
1919

20-
"jbzoo/data" : "^4.1.3",
21-
"jbzoo/utils" : "^4.2.3",
20+
"jbzoo/data" : "^4.2.0",
21+
"jbzoo/utils" : "^4.3.0",
2222
"guzzlehttp/promises" : ">=1.4.0"
2323
},
2424

2525
"require-dev" : {
26-
"jbzoo/toolbox-dev" : "^2.6.2",
27-
"jbzoo/event" : "^3.0.3",
26+
"jbzoo/toolbox-dev" : "^2.10.0",
27+
"jbzoo/event" : "^3.1.0",
2828
"rmccue/requests" : "^1.7.0",
2929
"guzzlehttp/guzzle" : ">=6.5.5"
3030
},

src/Driver/AbstractDriver.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* @link https://github.com/JBZoo/Http-Client
1414
*/
1515

16+
declare(strict_types=1);
17+
1618
namespace JBZoo\HttpClient\Driver;
1719

1820
use JBZoo\HttpClient\Request;

src/Driver/Auto.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* @link https://github.com/JBZoo/Http-Client
1414
*/
1515

16+
declare(strict_types=1);
17+
1618
namespace JBZoo\HttpClient\Driver;
1719

1820
use GuzzleHttp\Client;
@@ -23,7 +25,7 @@
2325
* Class Auto
2426
* @package JBZoo\HttpClient\Driver
2527
*/
26-
class Auto extends AbstractDriver
28+
final class Auto extends AbstractDriver
2729
{
2830
/**
2931
* @inheritDoc

src/Driver/Guzzle.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* @link https://github.com/JBZoo/Http-Client
1414
*/
1515

16+
declare(strict_types=1);
17+
1618
namespace JBZoo\HttpClient\Driver;
1719

1820
use GuzzleHttp\Client;
@@ -25,7 +27,7 @@
2527
* Class Guzzle
2628
* @package JBZoo\HttpClient\Driver
2729
*/
28-
class Guzzle extends AbstractDriver
30+
final class Guzzle extends AbstractDriver
2931
{
3032
/**
3133
* @inheritDoc
@@ -97,7 +99,7 @@ public function multiRequest(array $requestList): array
9799
* @param string|array|null $args
98100
* @return array
99101
*/
100-
protected static function getDriverOptions(Options $options, array $headers, string $method, $args): array
102+
private static function getDriverOptions(Options $options, array $headers, string $method, $args): array
101103
{
102104
$headers['User-Agent'] = $options->getUserAgent('Guzzle');
103105

@@ -127,11 +129,11 @@ protected static function getDriverOptions(Options $options, array $headers, str
127129

128130
/**
129131
* @param Options $options
130-
* @return array|bool
132+
* @return array|null
131133
*/
132-
protected static function getAllowRedirects(Options $options)
134+
private static function getAllowRedirects(Options $options): ?array
133135
{
134-
$allowRedirects = false;
136+
$allowRedirects = null;
135137

136138
if ($options->isAllowRedirects()) {
137139
$allowRedirects = [

src/Driver/Rmccue.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* @link https://github.com/JBZoo/Http-Client
1414
*/
1515

16+
declare(strict_types=1);
17+
1618
namespace JBZoo\HttpClient\Driver;
1719

1820
use JBZoo\HttpClient\Exception;
@@ -26,7 +28,7 @@
2628
* Class Rmccue
2729
* @package JBZoo\HttpClient\Driver
2830
*/
29-
class Rmccue extends AbstractDriver
31+
final class Rmccue extends AbstractDriver
3032
{
3133
private const INVALID_CODE_LINE = HttpCodes::BAD_REQUEST;
3234

@@ -39,7 +41,7 @@ public function request(Request $request): Response
3941

4042
/**
4143
* @psalm-suppress PossiblyInvalidArgument
42-
* @phan-suppress PhanPartialTypeMismatchArgument
44+
* @phan-suppress PhanPartialTypeMismatchArgument
4345
*/
4446
$httpResult = Requests::request(
4547
$request->getUri(),
@@ -95,7 +97,7 @@ public function multiRequest(array $requestList): array
9597
* @param Options $options
9698
* @return array
9799
*/
98-
protected static function getDriverOptions(Options $options): array
100+
private static function getDriverOptions(Options $options): array
99101
{
100102
return [
101103
'timeout' => $options->getTimeout(),

src/Exception.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* @link https://github.com/JBZoo/Http-Client
1414
*/
1515

16+
declare(strict_types=1);
17+
1618
namespace JBZoo\HttpClient;
1719

1820
use JBZoo\Event\EventManager;
@@ -21,7 +23,7 @@
2123
* Class Exception
2224
* @package JBZoo\HttpClient
2325
*/
24-
class Exception extends \RuntimeException
26+
final class Exception extends \RuntimeException
2527
{
2628
/**
2729
* Exception constructor.

0 commit comments

Comments
 (0)