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

feat!: update all dependencies to latest supported versions #88

Merged
merged 2 commits into from
Oct 26, 2023
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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ jobs:
- run: composer install --prefer-dist --no-interaction
- run: bin/php-cs-fixer fix --ansi --dry-run --using-cache=no --verbose

tests:
name: Tests
atoum-tests:
name: Atoum tests
Comment on lines +16 to +17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

much discrimination, such sadness

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm planing to add a bit of rector & phpstan, that's why 😁

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

=> #89

runs-on: ubuntu-20.04
strategy:
matrix:
version: [ '7.4', '8.0', '8.1' ]
version: [ 8.1, 8.2 ]
flags: [ '', '--prefer-lowest' ]
fail-fast: false
steps:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ try {
'second' => $client->getAsync('http://domain.tld/path/to/other/resource')
];

$result = \GuzzleHttp\Promise\unwrap($promises);
$result = \GuzzleHttp\Promise\Utils::unwrap($promises);
} catch(\GuzzleHttp\Exception\ConnectException $e) {
// connection problem like timeout
}
Expand Down
24 changes: 12 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "m6web/guzzle-http-bundle",
"type" : "symfony-bundle",
"description": "Symfony2 bundle on top of guzzle 6",
"description": "Symfony bundle on top of Guzzle",
"keywords": ["bundle", "http", "client", "HTTP client"],
"license" : "MIT",
"authors": [
Expand All @@ -12,21 +12,21 @@
}
],
"require": {
"php": ">=7.4",
"php": ">=8.1",
"ext-curl": "*",
"guzzlehttp/guzzle": "^6.3||^7.0",
"symfony/config" : "^4.4||^5.0||^6.0",
"symfony/dependency-injection": "^4.4||^5.0||^6.0",
"symfony/event-dispatcher": "^4.4||^5.0||^6.0",
"symfony/http-kernel": "^4.4||^5.0||^6.0",
"symfony/yaml" : "^4.4||^5.0||^6.0"
"guzzlehttp/guzzle": "^7",
"symfony/config" : "^5.4||^6.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Symfony 4.4 is still supported by Symfony ("security fixes only") until November... but it should be fine to release this before November 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As PHP8.0... but I guessed it was the time to make some cleanup. 🤷‍♂️

"symfony/dependency-injection": "^5.4||^6.0",
"symfony/event-dispatcher": "^5.4||^6.0",
"symfony/http-kernel": "^5.4||^6.0",
"symfony/yaml" : "^5.4||^6.0"
},
"require-dev": {
"atoum/atoum": "4.0.3",
"atoum/atoum": "4.2.0",
"atoum/stubs": "*",
"m6web/php-cs-fixer-config": "2.0.0",
"friendsofphp/php-cs-fixer": "3.34.1",
"guzzlehttp/promises": "^1"
"m6web/php-cs-fixer-config": "3.2.0",
"friendsofphp/php-cs-fixer": "3.35.1",
"guzzlehttp/promises": "^2"
},
"autoload": {
"psr-4": {"M6Web\\Bundle\\GuzzleHttpBundle\\": "src/"}
Expand Down
2 changes: 2 additions & 0 deletions src/Cache/CacheInterface.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace M6Web\Bundle\GuzzleHttpBundle\Cache;

/**
Expand Down
10 changes: 6 additions & 4 deletions src/Cache/InMemory.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace M6Web\Bundle\GuzzleHttpBundle\Cache;

/**
Expand All @@ -12,8 +14,8 @@ class InMemory implements CacheInterface

public function has($key)
{
if (array_key_exists($key, $this->cache)) {
if (is_null($this->ttl[$key]) || $this->ttl[$key] > microtime(true)) {
if (\array_key_exists($key, $this->cache)) {
if (\is_null($this->ttl[$key]) || $this->ttl[$key] > microtime(true)) {
return true;
}
$this->remove($key);
Expand All @@ -34,7 +36,7 @@ public function get($key)
public function set($key, $value, $ttl = null)
{
$this->cache[$key] = $value;
$this->ttl[$key] = is_null($ttl) ? null : microtime(true) + $ttl;
$this->ttl[$key] = \is_null($ttl) ? null : microtime(true) + $ttl;
}

public function remove($key)
Expand All @@ -48,7 +50,7 @@ public function remove($key)
public function ttl($key)
{
if ($this->has($key)) {
if (!is_null($this->ttl[$key])) {
if (!\is_null($this->ttl[$key])) {
return (int) round($this->ttl[$key] - microtime(true));
}

Expand Down
2 changes: 2 additions & 0 deletions src/DataCollector/GuzzleHttpDataCollector.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace M6Web\Bundle\GuzzleHttpBundle\DataCollector;

use GuzzleHttp\ClientInterface as GuzzleHttpClient;
Expand Down
18 changes: 10 additions & 8 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace M6Web\Bundle\GuzzleHttpBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
Expand Down Expand Up @@ -51,23 +53,23 @@ public function getConfigTreeBuilder(): TreeBuilder
->variableNode('cert')
->validate()
->ifTrue(function ($v) {
return !is_string($v) && (!is_array($v) || count($v) != 2);
return !\is_string($v) && (!\is_array($v) || \count($v) != 2);
})
->theninvalid('Requires a string or a two entries array')
->end()
->end()
->variableNode('debug')
->validate()
->ifTrue(function ($v) {
return !is_string($v) && !is_bool($v);
return !\is_string($v) && !\is_bool($v);
})
->theninvalid('Requires an invokable service id or a bolean value')
->end()
->end()
->variableNode('decode_content')
->validate()
->ifTrue(function ($v) {
return !is_string($v) && !is_bool($v);
return !\is_string($v) && !\is_bool($v);
})
->theninvalid('Requires a string or a boolean')
->end()
Expand All @@ -76,7 +78,7 @@ public function getConfigTreeBuilder(): TreeBuilder
->variableNode('expect')
->validate()
->ifTrue(function ($v) {
return !is_int($v) && !is_bool($v);
return !\is_int($v) && !\is_bool($v);
})
->theninvalid('Requires an integer or a boolean')
->end()
Expand All @@ -90,7 +92,7 @@ public function getConfigTreeBuilder(): TreeBuilder
->variableNode('cookies')
->validate()
->ifTrue(function ($v) {
return !is_array($v) && !is_bool($v);
return !\is_array($v) && !\is_bool($v);
})
->theninvalid('Requires an array or a boolean')
->end()
Expand All @@ -113,7 +115,7 @@ public function getConfigTreeBuilder(): TreeBuilder
->variableNode('proxy')
->validate()
->ifTrue(function ($v) {
return !is_array($v) && !is_string($v);
return !\is_array($v) && !\is_string($v);
})
->theninvalid('Requires an array or a string')
->end()
Expand All @@ -126,7 +128,7 @@ public function getConfigTreeBuilder(): TreeBuilder
->variableNode('ssl_key')
->validate()
->ifTrue(function ($v) {
return !is_string($v) && (!is_array($v) || count($v) != 2);
return !\is_string($v) && (!\is_array($v) || \count($v) != 2);
})
->theninvalid('Requires a string or a two entries array')
->end()
Expand All @@ -136,7 +138,7 @@ public function getConfigTreeBuilder(): TreeBuilder
->variableNode('verify')
->validate()
->ifTrue(function ($v) {
return !is_string($v) && !is_bool($v);
return !\is_string($v) && !\is_bool($v);
})
->theninvalid('Requires a string or a boolean')
->end()
Expand Down
2 changes: 2 additions & 0 deletions src/DependencyInjection/GuzzleHttpPass.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace M6Web\Bundle\GuzzleHttpBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
Expand Down
14 changes: 8 additions & 6 deletions src/DependencyInjection/M6WebGuzzleHttpExtension.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace M6Web\Bundle\GuzzleHttpBundle\DependencyInjection;

use Symfony\Component\Config\FileLocator;
Expand Down Expand Up @@ -50,7 +52,7 @@ protected function loadClient(ContainerBuilder $container, string $clientId, arr
{
// clear empty arrays
foreach ($config as $key => $item) {
if (is_array($item) && count($item) == 0) {
if (\is_array($item) && \count($item) == 0) {
unset($config[$key]);
}
}
Expand Down Expand Up @@ -110,7 +112,7 @@ protected function loadClient(ContainerBuilder $container, string $clientId, arr
}
}
// Create cookies jar if required
if (!empty($config['cookies']) && is_array($config['cookies'])) {
if (!empty($config['cookies']) && \is_array($config['cookies'])) {
$config['cookies'] = $this->getCookiesJarServiceReference($container, $config['cookies'], $clientId);
}

Expand All @@ -126,7 +128,7 @@ protected function loadClient(ContainerBuilder $container, string $clientId, arr
// Services entries
foreach (['on_headers', 'on_stats'] as $key) {
if (!empty($config[$key])) {
if (is_null($serviceReference = $this->getServiceReference($config[$key]))) {
if (\is_null($serviceReference = $this->getServiceReference($config[$key]))) {
throw new \InvalidArgumentException(sprintf('"%s" configuration entry requires a valid service reference, "%s" given', $key, $config[$key]));
}
$config[$key] = $serviceReference;
Expand Down Expand Up @@ -171,7 +173,7 @@ protected function setGuzzleProxyHandler(ContainerBuilder $container, ?string $c
if (isset($config['guzzlehttp_cache'])) {
if (
!isset($config['guzzlehttp_cache']['service'])
|| is_null($cacheService = $this->getServiceReference($config['guzzlehttp_cache']['service']))
|| \is_null($cacheService = $this->getServiceReference($config['guzzlehttp_cache']['service']))
) {
throw new \InvalidArgumentException(sprintf('"guzzlehttp_cache.service" requires a valid service reference, "%s" given', $config['guzzlehttp_cache']['service']));
}
Expand Down Expand Up @@ -218,11 +220,11 @@ protected function getCurlConfig(array $config)

$protocols = array_map('strtolower', $config['allow_redirects']['protocols']);

if (in_array('http', $protocols)) {
if (\in_array('http', $protocols)) {
$redirProtocols |= CURLPROTO_HTTP;
}

if (in_array('https', $protocols)) {
if (\in_array('https', $protocols)) {
$redirProtocols |= CURLPROTO_HTTPS;
}

Expand Down
2 changes: 2 additions & 0 deletions src/DependencyInjection/MiddlewarePass.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace M6Web\Bundle\GuzzleHttpBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
Expand Down
2 changes: 2 additions & 0 deletions src/EventDispatcher/AbstractGuzzleCacheEvent.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace M6Web\Bundle\GuzzleHttpBundle\EventDispatcher;

use Psr\Http\Message\RequestInterface;
Expand Down
2 changes: 2 additions & 0 deletions src/EventDispatcher/AbstractGuzzleHttpEvent.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace M6Web\Bundle\GuzzleHttpBundle\EventDispatcher;

use GuzzleHttp\Psr7\Request;
Expand Down
16 changes: 9 additions & 7 deletions src/Handler/CacheTrait.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace M6Web\Bundle\GuzzleHttpBundle\Handler;

use GuzzleHttp\Promise\FulfilledPromise;
Expand Down Expand Up @@ -75,7 +77,7 @@ protected static function getKey(RequestInterface $request)
array_keys($request->getHeaders()),
function ($header) use ($vary) {
return 0 !== stripos($header, 'x-')
|| array_key_exists($header, $vary)
|| \array_key_exists($header, $vary)
;
}
)
Expand All @@ -95,7 +97,7 @@ protected function getCacheTtl(Response $response)
$cacheControl = $response->getHeader('Cache-Control')[0];

if (preg_match('`max-age=(\d+)`', $cacheControl, $match)) {
return intval($match[1]);
return \intval($match[1]);
}
}

Expand Down Expand Up @@ -159,13 +161,13 @@ protected function getCached(RequestInterface $request)
}

$cacheKey = self::getKey($request);
if (is_null($cachedContent = $this->cache->get($cacheKey))) {
if (\is_null($cachedContent = $this->cache->get($cacheKey))) {
return null;
}

$cached = unserialize($cachedContent);
foreach ($cached as $value) {
if (is_null($value)) {
if (\is_null($value)) {
return null;
}
}
Expand All @@ -191,13 +193,13 @@ protected function getCached(RequestInterface $request)
*/
public function __invoke(RequestInterface $request, array $options): PromiseInterface
{
if (is_null($this->cache)) {
if (\is_null($this->cache)) {
return parent::__invoke($request, $options);
}

// user want to force cache reload
// so we remove existing cache
if (array_key_exists('cache_force', $options)) {
if (\array_key_exists('cache_force', $options)) {
$this->cache->remove(self::getKey($request));
}

Expand Down Expand Up @@ -236,7 +238,7 @@ public function __invoke(RequestInterface $request, array $options): PromiseInte
*/
protected function isSupportedMethod(RequestInterface $request)
{
return in_array(strtoupper($request->getMethod()), self::$methods);
return \in_array(strtoupper($request->getMethod()), self::$methods);
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/Handler/CurlFactory.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace M6Web\Bundle\GuzzleHttpBundle\Handler;

use GuzzleHttp\Handler\CurlFactory as GuzzleCurlFactory;
Expand All @@ -16,7 +18,7 @@ class CurlFactory extends GuzzleCurlFactory
{
public function release(EasyHandle $easy): void
{
if (!is_null($easy->response)) {
if (!\is_null($easy->response)) {
$easy->response->curlInfo = curl_getinfo($easy->handle);
}

Expand Down
2 changes: 2 additions & 0 deletions src/Handler/CurlHandler.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace M6Web\Bundle\GuzzleHttpBundle\Handler;

use GuzzleHttp\Handler\CurlHandler as GuzzleCurlHandler;
Expand Down
2 changes: 2 additions & 0 deletions src/Handler/CurlMultiHandler.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace M6Web\Bundle\GuzzleHttpBundle\Handler;

use GuzzleHttp\Handler\CurlMultiHandler as GuzzleCurlMultiHandler;
Expand Down
2 changes: 2 additions & 0 deletions src/M6WebGuzzleHttpBundle.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace M6Web\Bundle\GuzzleHttpBundle;

use M6Web\Bundle\GuzzleHttpBundle\DependencyInjection\GuzzleHttpPass;
Expand Down
Loading