Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- 8080:80
strategy:
matrix:
php-versions: [ '8.0', '8.1' ]
php-versions: [ '8.0', '8.1', '8.2', '8.3', '8.4' ]
composer-options: [ '--prefer-lowest', '']
runs-on: ubuntu-latest
steps:
Expand Down
4 changes: 3 additions & 1 deletion Curl/CurlErrorException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@

namespace evaisse\SimpleHttpBundle\Curl;

use Exception;

class CurlErrorException extends \RuntimeException
{
public function __construct($message="", $code=0, \Exception $previous=null) {
public function __construct($message="", $code=0, ?Exception $previous=null) {
parent::__construct($message,$code,$previous);
}
}
3 changes: 2 additions & 1 deletion Curl/MultiManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ class MultiManager implements CurlRequest
* @param boolean $blocking Whether the execution should block until finished or wait until
* the destructor is called to block
*/
public function __construct(EventDispatcherInterface $dispatcher=null,$blocking=true) {
public function __construct(?EventDispatcherInterface $dispatcher = null, $blocking = true)
{
$this->dispatcher = $dispatcher;
$this->handle = curl_multi_init();
$this->blocking = $blocking;
Expand Down
2 changes: 1 addition & 1 deletion Http/Exception/RequestException.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class RequestException extends Exception
* @param int $code error code
* @param Exception $previous optionnal previous exception
*/
public function __construct(Request $request, $message = "", $code = 0, Exception $previous = null)
public function __construct(Request $request, $message = "", $code = 0, ?Exception $previous = null)
{
parent::__construct($message, $code, $previous); // TODO: Change the autogenerated stub
$this->setRequest($request);
Expand Down
6 changes: 5 additions & 1 deletion Http/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,11 @@ public function onProgress(callable $callable)
*/
public function onFinish(callable $callable)
{
$this->getPromise()->always($callable);
if (method_exists(object_or_class: $this->getPromise(), method: 'finally')) {
$this->getPromise()->finally($callable);
} else {
$this->getPromise()->always($callable);
}
return $this;
}

Expand Down
2 changes: 1 addition & 1 deletion Service/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function createCookieJar(?SessionInterface $session = null): SessionCooki
* @param Kernel|null $client http client proxy to use
* @return Helper given service list
*/
public function execute(array $servicesList, ?SessionCookieJar $cookieJar = null, Kernel $client = null): static
public function execute(array $servicesList, ?SessionCookieJar $cookieJar = null, ?Kernel $client = null): static
{
$httpClient = $client ? $client : $this->httpKernel;

Expand Down
3 changes: 3 additions & 0 deletions Tests/Unit/AbstractTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public function __construct(?string $name = null, array $data = [], $dataName =
}


/**
* @return array{0: Helper, 1: Kernel}
*/
protected function createContext()
{
$eventDispatcher = new EventDispatcher();
Expand Down
8 changes: 6 additions & 2 deletions Tests/Unit/PromisesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace evaisse\SimpleHttpBundle\Tests\Unit;

use React\Promise\Promise;
use Symfony\Component\HttpKernel\Exception\HttpException;

class PromisesTest extends AbstractTests
Expand Down Expand Up @@ -37,11 +38,14 @@ public function testPromises($code, $expectedResults)

$events = new \ArrayObject();

$finallyMethod = method_exists(object_or_class: Promise::class, method: 'always') ? 'always' : 'finally';
$catchMethod = method_exists(object_or_class: Promise::class, method: 'catch') ? 'catch' : 'otherwise';

$stmt->getPromise()->then(function () use ($events) {
$events[] = 'success';
})->otherwise(function () use ($events) {
})->$catchMethod(function () use ($events) {
$events[] = 'error';
})->done(function () use ($events) {
})->$finallyMethod(function () use ($events) {
$events[] = 'done';
});

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"homepage": "https://github.com/evaisse/SimpleHttpBundle",
"require": {
"php": "^8.0",
"react/promise": "^2.2",
"react/promise": "^2.2 || ^3.0",
"symfony/http-foundation": "^5.4 || ^6.0",
"symfony/browser-kit": "^5.4 || ^6.0",
"symfony/event-dispatcher": "^5.4 || ^6.0",
Expand Down
21 changes: 11 additions & 10 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.