From b0878e46fc9c311d509a66cd2d8c5baa281dbd34 Mon Sep 17 00:00:00 2001 From: Gregurco Vlad Date: Tue, 12 Mar 2024 23:11:55 +0200 Subject: [PATCH] Update dependencies, switch to github actions --- .github/workflows/phpunit.yml | 54 ++++++ .travis.yml | 49 ----- README.md | 2 +- composer.json | 16 +- phpunit.xml.dist | 2 +- .../GuzzleCacheExtension.php | 6 +- src/Event/InvalidateRequestEvent.php | 171 ++++++------------ .../InvalidateRequestSubscriber.php | 1 - 8 files changed, 116 insertions(+), 185 deletions(-) create mode 100644 .github/workflows/phpunit.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml new file mode 100644 index 0000000..7cc23e9 --- /dev/null +++ b/.github/workflows/phpunit.yml @@ -0,0 +1,54 @@ +name: PHPUnit + +on: + pull_request: + push: + branches: [ master ] + +jobs: + build: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + php: + - '7.2' + - '8.3' + symfony: + - '5.0.*' + - '5.4.*' # LTS + - '6.0.*' + - '7.0.*' + exclude: + - php: '7.2' + symfony: '6.0.*' # requires PHP >=8.1 + - php: '7.2' + symfony: '7.0.*' # requires PHP >=8.2 + + runs-on: ${{ matrix.os }} + + env: + SYMFONY: ${{ matrix.symfony }} + + steps: + - uses: actions/checkout@v4 + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + ini-values: date.timezone='UTC' + tools: composer:v2 + + - name: Require symfony + run: composer --no-update require symfony/symfony:"${SYMFONY}" + + - name: Install dependencies + run: | + composer update + vendor/bin/simple-phpunit install + + - name: Test + run: | + composer validate --strict --no-check-lock + vendor/bin/simple-phpunit --coverage-text --verbose diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 220c859..0000000 --- a/.travis.yml +++ /dev/null @@ -1,49 +0,0 @@ -language: php - -sudo: false - -php: - - 7.1 - - 7.2 - - 7.3 - - 7.4 - -env: - - SYMFONY_VERSION=4.4.* # LTS (until 11/2023) - - SYMFONY_VERSION=5.0.* # (until 07/2020) - - SYMFONY_VERSION=5.1.* # (until 01/2021) - -cache: - directories: - - $HOME/.composer/cache/files - -before_install: - - composer self-update - - if [ "$DEPENDENCIES" == "dev" ]; then perl -pi -e 's/^}$/,"minimum-stability":"dev"}/' composer.json; fi; - - if [ "$SYMFONY_VERSION" != "" ]; then composer --no-update require symfony/symfony:${SYMFONY_VERSION}; fi; - -install: - - composer update - - vendor/bin/simple-phpunit install - -script: - - mkdir -p build/logs - - composer validate --strict --no-check-lock - - vendor/bin/simple-phpunit --coverage-text --verbose - -after_success: - - travis_retry php vendor/bin/php-coveralls - -matrix: - exclude: - - php: 7.1 - env: SYMFONY_VERSION=5.0.* # requires PHP ^7.2.5 - - php: 7.1 - env: SYMFONY_VERSION=5.1.* # requires PHP ^7.2.5 - allow_failures: - - php: nightly - - env: SYMFONY_VERSION=dev-master - -notifications: - email: - - "gregurco.vlad@gmail.com" diff --git a/README.md b/README.md index 420b50c..76b69bc 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ This plugin integrates cache functionality into Guzzle Bundle, a bundle for building RESTful web service clients. ## Requirements - - PHP 7.0 or above + - PHP 7.2 or above - [Guzzle Bundle][1] - [Guzzle Cache middleware][2] diff --git a/composer.json b/composer.json index cdc95b2..8d7a36c 100644 --- a/composer.json +++ b/composer.json @@ -19,18 +19,18 @@ ], "require": { - "php": "^7.0 || ^8.0", - "guzzlehttp/guzzle": "~6.0 || ^7.5.0", + "php": ">=7.2", + "guzzlehttp/guzzle": "^6.5.8|^7.4.5", "eightpoints/guzzle-bundle": "~8.0", - "symfony/http-kernel": "~4.0 || ~5.0|| ~6.0", - "symfony/config": "~4.0 || ~5.0|| ~6.0", - "symfony/dependency-injection": "~4.0 || ~5.0|| ~6.0", - "symfony/expression-language": "~4.0 || ~5.0|| ~6.0", - "kevinrob/guzzle-cache-middleware": "~4.0" + "symfony/http-kernel": "~5.0|~6.0|~7.0", + "symfony/config": "~5.0|~6.0|~7.0", + "symfony/dependency-injection": "~5.0|~6.0|~7.0", + "symfony/expression-language": "~5.0|~6.0|~7.0", + "kevinrob/guzzle-cache-middleware": "~4.0|~5.0" }, "require-dev": { - "symfony/phpunit-bridge": "~4.0|~5.0", + "symfony/phpunit-bridge": "~5.0|~6.0|~7.0", "php-coveralls/php-coveralls": "~2.2" }, diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 275b4e4..3275052 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -6,7 +6,7 @@ xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.1/phpunit.xsd" > - + diff --git a/src/DependencyInjection/GuzzleCacheExtension.php b/src/DependencyInjection/GuzzleCacheExtension.php index be8c714..b01b24d 100644 --- a/src/DependencyInjection/GuzzleCacheExtension.php +++ b/src/DependencyInjection/GuzzleCacheExtension.php @@ -9,11 +9,7 @@ class GuzzleCacheExtension extends Extension { - /** - * @param array $configs - * @param ContainerBuilder $container - */ - public function load(array $configs, ContainerBuilder $container) + public function load(array $configs, ContainerBuilder $container): void { $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); diff --git a/src/Event/InvalidateRequestEvent.php b/src/Event/InvalidateRequestEvent.php index 1231903..31fc6e9 100644 --- a/src/Event/InvalidateRequestEvent.php +++ b/src/Event/InvalidateRequestEvent.php @@ -3,140 +3,71 @@ namespace Gregurco\Bundle\GuzzleBundleCachePlugin\Event; use Psr\Http\Message\UriInterface; -use Symfony\Component\EventDispatcher\Event as BaseEvent; -use Symfony\Component\EventDispatcher\EventDispatcher; -use Symfony\Contracts\EventDispatcher\Event as ContractsBaseEvent; -use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +use Symfony\Contracts\EventDispatcher\Event; use GuzzleHttp\Client; use GuzzleHttp\Psr7; use GuzzleHttp\Psr7\Request; -if (is_subclass_of(EventDispatcher::class, EventDispatcherInterface::class)) { - class InvalidateRequestEvent extends ContractsBaseEvent - { - /** @var Client */ - protected $client; - - /** @var string */ - protected $method; - - /** @var string */ - protected $uri; - - /** - * @param Client $client - * @param string $method - * @param string $uri - */ - public function __construct(Client $client, string $method, string $uri) - { - $this->client = $client; - $this->method = $method; - $this->uri = $uri; - } - - /** - * @return Client - */ - public function getClient(): Client - { - return $this->client; - } +class InvalidateRequestEvent extends Event +{ + /** @var Client */ + protected $client; - /** - * @return string - */ - public function getMethod(): string - { - return $this->method; - } - - /** - * @return string - */ - public function getUri(): string - { - return $this->uri; - } - - /** - * @return Request - */ - public function getRequest(): Request - { - $baseUri = $this->client->getConfig('base_uri'); + /** @var string */ + protected $method; - if ($baseUri instanceof UriInterface) { - $uri = Psr7\UriResolver::resolve($baseUri, Psr7\Utils::uriFor($this->uri)); - } else { - $uri = $this->uri; - } + /** @var string */ + protected $uri; - return new Request($this->method, $uri); - } - } -} else { - class InvalidateRequestEvent extends BaseEvent + /** + * @param Client $client + * @param string $method + * @param string $uri + */ + public function __construct(Client $client, string $method, string $uri) { - /** @var Client */ - protected $client; - - /** @var string */ - protected $method; + $this->client = $client; + $this->method = $method; + $this->uri = $uri; + } - /** @var string */ - protected $uri; + /** + * @return Client + */ + public function getClient(): Client + { + return $this->client; + } - /** - * @param Client $client - * @param string $method - * @param string $uri - */ - public function __construct(Client $client, string $method, string $uri) - { - $this->client = $client; - $this->method = $method; - $this->uri = $uri; - } + /** + * @return string + */ + public function getMethod(): string + { + return $this->method; + } - /** - * @return Client - */ - public function getClient(): Client - { - return $this->client; - } + /** + * @return string + */ + public function getUri(): string + { + return $this->uri; + } - /** - * @return string - */ - public function getMethod(): string - { - return $this->method; - } + /** + * @return Request + */ + public function getRequest(): Request + { + $baseUri = $this->client->getConfig('base_uri'); - /** - * @return string - */ - public function getUri(): string - { - return $this->uri; + if ($baseUri instanceof UriInterface) { + $uri = Psr7\UriResolver::resolve($baseUri, Psr7\Utils::uriFor($this->uri)); + } else { + $uri = $this->uri; } - /** - * @return Request - */ - public function getRequest(): Request - { - $baseUri = $this->client->getConfig('base_uri'); - - if ($baseUri instanceof UriInterface) { - $uri = Psr7\UriResolver::resolve($baseUri, Psr7\Utils::uriFor($this->uri)); - } else { - $uri = $this->uri; - } - - return new Request($this->method, $uri); - } + return new Request($this->method, $uri); } } diff --git a/src/EventListener/InvalidateRequestSubscriber.php b/src/EventListener/InvalidateRequestSubscriber.php index d25271b..c024c79 100644 --- a/src/EventListener/InvalidateRequestSubscriber.php +++ b/src/EventListener/InvalidateRequestSubscriber.php @@ -61,5 +61,4 @@ protected function getClientIdentifier(Client $client): string { return spl_object_hash($client); } - }