Skip to content

Commit

Permalink
Merge pull request #274 from gregurco/drop_old_php_and_sf
Browse files Browse the repository at this point in the history
Drop support of old version of PHP and Symfony
  • Loading branch information
gregurco authored Oct 16, 2019
2 parents b5080c9 + 877b65b commit f94abd7
Show file tree
Hide file tree
Showing 21 changed files with 105 additions and 190 deletions.
13 changes: 0 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@ language: php
sudo: false

php:
- 7.0
- 7.1
- 7.2
- 7.3
- nightly

env:
- SYMFONY_VERSION=2.7.* # LTS (until 05/2019)
- SYMFONY_VERSION=2.8.* # LTS (until 11/2019)
- SYMFONY_VERSION=3.4.* # LTS (until 11/2021)
- SYMFONY_VERSION=4.1.* # (until 07/2019)
- SYMFONY_VERSION=4.2.* # (until 01/2020)
- SYMFONY_VERSION=4.3.* # (until 07/2020)
Expand All @@ -37,15 +33,6 @@ notifications:
- "florian.preusner@8points.de"

matrix:
exclude:
- php: 7
env: SYMFONY_VERSION=4.1.* # requires PHP ^7.1.3
- php: 7
env: SYMFONY_VERSION=4.2.* # requires PHP ^7.1.3
- php: 7
env: SYMFONY_VERSION=4.3.* # requires PHP ^7.1.3
- php: 7
env: DEPENDENCIES=dev # requires PHP ^7.1.3
allow_failures:
- env: DEPENDENCIES=dev
- php: nightly
35 changes: 6 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ GuzzleBundle follows semantic versioning. Read more on [semver.org][2].
----

## Requirements
- PHP 7.0 or above
- Symfony 2.7 or above
- PHP 7.1 or above
- Symfony 4.0 or above
- [Guzzle PHP Framework][1] (included by composer)

----
Expand Down Expand Up @@ -57,14 +57,6 @@ _Note: we created [Symfony Flex Recipe][14] to speed up the installation of pack

## Usage

##### Load bundle in AppKernel.php:

*Skip it for Symfony >= 4.0*

``` php
new EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundle()
```

##### Configuration in config.yml:
``` yaml
eight_points_guzzle:
Expand Down Expand Up @@ -117,11 +109,7 @@ Open [Configuration Reference](src/Resources/doc/configuration-reference.md) pag

##### Install assets _(if it's not performed automatically)_:
``` bash
# for symfony >= 3.0
bin/console assets:install

# for symfony < 3.0
app/console assets:install
```

Using services in controller (eight_points_guzzle.client.**api_crm** represents the client name of the yaml config and is an instance of GuzzleHttp\Client):
Expand All @@ -138,19 +126,8 @@ $response = $client->get('/users');
This bundle allows to register and integrate plugins to extend functionality of guzzle and this bundle.

### Usage

#### Symfony 2.x and 3.x
All plugins will be activated/connected through bundle constructor in AppKernel, like this:

``` php
new EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundle([
new Gregurco\Bundle\GuzzleBundleOAuth2Plugin\GuzzleBundleOAuth2Plugin(),
])
```

#### Symfony 4
The registration of bundles was changed in Symfony 4 and now you have to change `src/Kernel.php` to achieve the same functionality.
Find next lines:

Find next lines in `src/Kernel.php`:

```php
foreach ($contents as $class => $envs) {
Expand Down Expand Up @@ -246,11 +223,11 @@ eight_points_guzzle:
----
## Contributing
👍 If you would like to contribute to the project, please read the [CONTRIBUTING.md](CONTRIBUTING.md).
👍If you would like to contribute to the project, please read the [CONTRIBUTING.md](CONTRIBUTING.md).
<img src="/src/Resources/doc/img/icon_slack.png" alt="Slack" title="Slack" style="width: 23px; margin-right: -4px;" /> Join our Slack channel on [Symfony Devs][9] for discussions, questions and more: [#8p-guzzlebundle][10].
🎉 Thanks to the [contributors][11] who participated in this project.
🎉Thanks to the [contributors][11] who participated in this project.
----
Expand Down
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@
}
],
"require": {
"php": ">=7.0",
"php": ">=7.1",
"guzzlehttp/guzzle": "~6.0",
"symfony/framework-bundle": "~2.7|~3.0|~4.0",
"symfony/expression-language": "~2.7|~3.0|~4.0",
"symfony/stopwatch": "~2.7|~3.0|~4.0",
"symfony/framework-bundle": "~4.0",
"symfony/expression-language": "~4.0",
"symfony/stopwatch": "~4.0",
"psr/log": "~1.0"
},
"require-dev": {
"symfony/phpunit-bridge": "~2.7|~3.0|~4.0",
"symfony/twig-bundle": "~2.7|~3.0|~4.0",
"symfony/var-dumper": "~2.7|~3.0|~4.0",
"symfony/yaml": "~2.7|~3.0|~4.0",
"symfony/phpunit-bridge": "~4.0",
"symfony/twig-bundle": "~4.0",
"symfony/var-dumper": "~4.0",
"symfony/yaml": "~4.0",
"namshi/cuzzle": "^2.0"
},
"suggest": {
Expand Down
20 changes: 4 additions & 16 deletions src/DataCollector/HttpDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Kernel;

/**
* Collecting http data for Symfony profiler
Expand Down Expand Up @@ -81,7 +80,7 @@ public function getName() : string
*
* @return void
*/
public function reset()
public function reset() : void
{
$this->data = [
'logs' => [],
Expand Down Expand Up @@ -134,7 +133,7 @@ public function getCallCount() : int
*
* @return integer
*/
public function getErrorCount(): int
public function getErrorCount() : int
{
return count($this->getErrorsByType(LogLevel::ERROR));
}
Expand All @@ -144,7 +143,7 @@ public function getErrorCount(): int
*
* @return array
*/
public function getErrorsByType(string $type): array
public function getErrorsByType(string $type) : array
{
return array_filter(
$this->getMessages(),
Expand Down Expand Up @@ -179,7 +178,7 @@ public function hasSlowResponses() : bool
*
* @return void
*/
public function addTotalTime(float $time)
public function addTotalTime(float $time) : void
{
$this->data['totalTime'] += $time;
}
Expand All @@ -199,15 +198,4 @@ protected function getLogGroup(string $id) : LogGroup

return $this->data['logs'][$id];
}

/**
* Return the color used version
*
* @return string
*/
public final function getIconColor() : string
{
$iconColor = version_compare(Kernel::VERSION, '2.8.0', '>=') ? '#AAAAAA' : '#3F3F3F';
return $this->data['iconColor'] = $iconColor;
}
}
21 changes: 10 additions & 11 deletions src/DependencyInjection/EightPointsGuzzleExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace EightPoints\Bundle\GuzzleBundle\DependencyInjection;

use EightPoints\Bundle\GuzzleBundle\Twig\Extension\DebugExtension;
use RuntimeException;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Reference;
Expand Down Expand Up @@ -166,7 +165,7 @@ protected function createHandler(ContainerBuilder $container, string $clientName
*
* @return void
*/
protected function defineTwigDebugExtension(ContainerBuilder $container)
protected function defineTwigDebugExtension(ContainerBuilder $container) : void
{
$twigDebugExtensionDefinition = new Definition(DebugExtension::class);
$twigDebugExtensionDefinition->addTag('twig.extension');
Expand All @@ -183,7 +182,7 @@ protected function defineTwigDebugExtension(ContainerBuilder $container)
*
* @return void
*/
protected function defineLogger(ContainerBuilder $container)
protected function defineLogger(ContainerBuilder $container) : void
{
$loggerDefinition = new Definition('%eight_points_guzzle.logger.class%');
$loggerDefinition->setPublic(true);
Expand All @@ -200,7 +199,7 @@ protected function defineLogger(ContainerBuilder $container)
*
* @return void
*/
protected function defineDataCollector(ContainerBuilder $container, float $slowResponseTime)
protected function defineDataCollector(ContainerBuilder $container, float $slowResponseTime) : void
{
$dataCollectorDefinition = new Definition('%eight_points_guzzle.data_collector.class%');
$dataCollectorDefinition->addArgument(new Reference('eight_points_guzzle.logger'));
Expand All @@ -222,7 +221,7 @@ protected function defineDataCollector(ContainerBuilder $container, float $slowR
*
* @return void
*/
protected function defineFormatter(ContainerBuilder $container)
protected function defineFormatter(ContainerBuilder $container) : void
{
$formatterDefinition = new Definition('%eight_points_guzzle.formatter.class%');
$formatterDefinition->setPublic(true);
Expand All @@ -238,7 +237,7 @@ protected function defineFormatter(ContainerBuilder $container)
*
* @return void
*/
protected function defineRequestTimeMiddleware(ContainerBuilder $container, Definition $handler, string $clientName)
protected function defineRequestTimeMiddleware(ContainerBuilder $container, Definition $handler, string $clientName) : void
{
$requestTimeMiddlewareDefinitionName = sprintf('eight_points_guzzle.middleware.request_time.%s', $clientName);
$requestTimeMiddlewareDefinition = new Definition('%eight_points_guzzle.middleware.request_time.class%');
Expand All @@ -260,7 +259,7 @@ protected function defineRequestTimeMiddleware(ContainerBuilder $container, Defi
*
* @return void
*/
protected function defineLogMiddleware(ContainerBuilder $container, Definition $handler, string $clientName)
protected function defineLogMiddleware(ContainerBuilder $container, Definition $handler, string $clientName) : void
{
$logMiddlewareDefinitionName = sprintf('eight_points_guzzle.middleware.log.%s', $clientName);
$logMiddlewareDefinition = new Definition('%eight_points_guzzle.middleware.log.class%');
Expand All @@ -282,7 +281,7 @@ protected function defineLogMiddleware(ContainerBuilder $container, Definition $
*
* @return void
*/
protected function defineProfileMiddleware(ContainerBuilder $container, Definition $handler, string $clientName)
protected function defineProfileMiddleware(ContainerBuilder $container, Definition $handler, string $clientName) : void
{
$profileMiddlewareDefinitionName = sprintf('eight_points_guzzle.middleware.profile.%s', $clientName);
$profileMiddlewareDefinition = new Definition('%eight_points_guzzle.middleware.profile.class%');
Expand All @@ -299,7 +298,7 @@ protected function defineProfileMiddleware(ContainerBuilder $container, Definiti
*
* @return void
*/
protected function attachSymfonyLogMiddlewareToHandler(Definition $handler)
protected function attachSymfonyLogMiddlewareToHandler(Definition $handler) : void
{
$logExpression = new Expression(sprintf("service('%s')", 'eight_points_guzzle.middleware.symfony_log'));
$handler->addMethodCall('push', [$logExpression, 'symfony_log']);
Expand Down Expand Up @@ -327,7 +326,7 @@ protected function createEventMiddleware(string $name) : Definition
*
* @return void
*/
protected function defineSymfonyLogFormatter(ContainerBuilder $container)
protected function defineSymfonyLogFormatter(ContainerBuilder $container) : void
{
$formatterDefinition = new Definition('%eight_points_guzzle.symfony_log_formatter.class%');
$formatterDefinition->setArguments(['%eight_points_guzzle.symfony_log_formatter.pattern%']);
Expand All @@ -340,7 +339,7 @@ protected function defineSymfonyLogFormatter(ContainerBuilder $container)
*
* @return void
*/
protected function defineSymfonyLogMiddleware(ContainerBuilder $container)
protected function defineSymfonyLogMiddleware(ContainerBuilder $container) : void
{
$logMiddlewareDefinition = new Definition('%eight_points_guzzle.middleware.symfony_log.class%');
$logMiddlewareDefinition->addArgument(new Reference('logger'));
Expand Down
6 changes: 3 additions & 3 deletions src/EightPointsGuzzleBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ public function boot()
/**
* @param \EightPoints\Bundle\GuzzleBundle\PluginInterface $plugin
*
* @return void
*@throws \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
* @throws \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
*
* @return void
*/
protected function registerPlugin(PluginInterface $plugin)
protected function registerPlugin(PluginInterface $plugin) : void
{
// Check plugins name duplication
foreach ($this->plugins as $registeredPlugin) {
Expand Down
6 changes: 3 additions & 3 deletions src/Events/PostTransactionEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class PostTransactionEvent extends Event
* @param \Psr\Http\Message\ResponseInterface|null $response
* @param string $serviceName
*/
public function __construct(ResponseInterface $response = null, string $serviceName)
public function __construct(?ResponseInterface $response, string $serviceName)
{
$this->response = $response;
$this->serviceName = $serviceName;
Expand All @@ -29,7 +29,7 @@ public function __construct(ResponseInterface $response = null, string $serviceN
*
* @return \Psr\Http\Message\ResponseInterface|null
*/
public function getTransaction()
public function getTransaction() : ?ResponseInterface
{
return $this->response;
}
Expand All @@ -41,7 +41,7 @@ public function getTransaction()
*
* @return void
*/
public function setTransaction(ResponseInterface $response = null)
public function setTransaction(?ResponseInterface $response) : void
{
$this->response = $response;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Events/PreTransactionEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function getTransaction() : RequestInterface
*
* @return void
*/
public function setTransaction(RequestInterface $requestTransaction)
public function setTransaction(RequestInterface $requestTransaction) : void
{
$this->requestTransaction = $requestTransaction;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Log/DevNullLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function log($level, $message, array $context = [])
*
* @return void
*/
public function clear()
public function clear() : void
{
// do nothing!!
}
Expand Down
8 changes: 4 additions & 4 deletions src/Log/LogGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class LogGroup
*
* @return void
*/
public function setRequestName(string $value)
public function setRequestName(string $value) : void
{
$this->requestName = $value;
}
Expand All @@ -27,7 +27,7 @@ public function setRequestName(string $value)
*
* @return string
*/
public function getRequestName()
public function getRequestName() : ?string
{
return $this->requestName;
}
Expand All @@ -39,7 +39,7 @@ public function getRequestName()
*
* @return void
*/
public function setMessages(array $value)
public function setMessages(array $value) : void
{
$this->messages = $value;
}
Expand All @@ -51,7 +51,7 @@ public function setMessages(array $value)
*
* @return void
*/
public function addMessages(array $value)
public function addMessages(array $value) : void
{
$this->messages = array_merge($this->messages, $value);
}
Expand Down
Loading

0 comments on commit f94abd7

Please sign in to comment.