Skip to content

Commit

Permalink
Merge pull request #14 from okvpn/feat/symfony-7
Browse files Browse the repository at this point in the history
Symfony 7.0 support
  • Loading branch information
vtsykun authored Oct 8, 2023
2 parents e6f93ec + 491f897 commit 632245d
Show file tree
Hide file tree
Showing 23 changed files with 385 additions and 103 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.github export-ignore
.travis.yml export-ignore
phpunit.xml.dist export-ignore
symfony.lock export-ignore
49 changes: 49 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: "Tests"

on:
push:
paths:
- 'src/**'
- 'tests/**'
- 'composer.json'
branches:
- master
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
tests:
strategy:
fail-fast: false
matrix:
include:
- php: '7.4'
symfony: 4.4.*
- php: '8.1'
symfony: 6.4.*
- php: '8.3'
symfony: 7.0.*
name: PHP ${{ matrix.php }} SYMFONY ${{ matrix.symfony }}
runs-on: ubuntu-20.04

steps:
- name: "Checkout"
uses: "actions/checkout@v3"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
extensions: curl, mbstring, pdo, pdo_sqlite, sqlite
php-version: ${{ matrix.php }}
tools: composer

- name: "Install dependencies"
run: composer update --ansi --no-interaction
env:
SYMFONY_REQUIRE: ${{ matrix.symfony }}
- name: "Run tests"
run: "php vendor/bin/phpunit"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/composer.lock
/vendor/*
/var/*
.phpunit.result.cache
31 changes: 0 additions & 31 deletions .travis.yml

This file was deleted.

25 changes: 0 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,31 +35,6 @@ return [
]
```

For Symfony 3.4

```php
<?php

use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ....
new Okvpn\Bundle\DatadogBundle\OkvpnDatadogBundle(), //Should loaded after framework bundle
);
}

public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
}
}
```

3. Base configuration to enable the datadog client in your `config.yml`

```
Expand Down
42 changes: 29 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,37 @@
"psr-4": { "Okvpn\\Bundle\\DatadogBundle\\Tests\\": "tests/" }
},
"require": {
"php":">=7.2",
"symfony/framework-bundle": "^3.4 || ^4.0 || ^5.0 || ^6.0",
"symfony/yaml": "^3.4 || ^4.0 || ^5.0 || ^6.0",
"php":">=7.4",
"symfony/framework-bundle": "^4.4 || ^5.4 || ^6.0 || ^7.0",
"graze/dog-statsd": "^0.4 || ^1.0"
},
"require-dev": {
"ext-pdo_sqlite": "*",
"doctrine/doctrine-bundle": "^1.6.10 || ^2.0.6",
"doctrine/orm": "2.5.11 || 2.6.x-dev as 2.6.3 || ^2.7.0",
"phpunit/phpunit": "^6.2 || ^8.5",
"symfony/browser-kit": "^3.4 || ^4.0 || ^5.0 || ^6.0",
"symfony/console": "^3.4 || ^4.0 || ^5.0 || ^6.0",
"symfony/security-bundle": "^3.4 || ^4.0 || ^5.0 || ^6.0",
"symfony/phpunit-bridge": "^3.4 || ^4.0 || ^5.0 || ^6.0",
"symfony/var-dumper": "^3.4 || ^4.0 || ^5.0 || ^6.0",
"symfony/monolog-bundle": "^3.2.0"
}
"doctrine/doctrine-bundle": "^2.6",
"doctrine/orm": "^2.7",
"phpunit/phpunit": "^8.5 || ^9.0 || ^10.0",
"symfony/browser-kit": "^4.4 || ^5.4 || ^6.0 || ^7.0",
"symfony/console": "^4.4 || ^5.4 || ^6.0 || ^7.0",
"symfony/security-bundle": "^4.4 || ^5.4 || ^6.0 || ^7.0",
"symfony/phpunit-bridge": "^4.4 || ^5.4 || ^6.0 || ^7.0",
"symfony/var-dumper": "^4.4 || ^5.4 || ^6.0 || ^7.0",
"symfony/yaml": "^4.4 || ^5.4 || ^6.0 || ^7.0",
"symfony/flex": "^1.10 || ^2.0",
"symfony/monolog-bundle": "^3.2"
},
"config": {
"allow-plugins": {
"symfony/flex": true
}
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
},
"symfony": {
"allow-contrib": false
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
2 changes: 1 addition & 1 deletion src/Client/ClientWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function event($title, $text, array $metadata = [], array $tags = [])
*/
public function getOption(string $option, $default = null)
{
return isset($this->options[$option]) ? $this->options[$option] : $default;
return $this->options[$option] ?? $default;
}

/**
Expand Down
13 changes: 13 additions & 0 deletions src/Client/DatadogDns.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

namespace Okvpn\Bundle\DatadogBundle\Client;

class DatadogDns
{
public static function parser(string $dsn): array
{

}
}
15 changes: 15 additions & 0 deletions src/Client/DatadogFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

namespace Okvpn\Bundle\DatadogBundle\Client;

class DatadogFactory implements DatadogFactoryInterface
{
/**
* {@inheritdoc}
*/
public function createClient(array $options): DogStatsInterface
{
}
}
10 changes: 10 additions & 0 deletions src/Client/DatadogFactoryInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

namespace Okvpn\Bundle\DatadogBundle\Client;

interface DatadogFactoryInterface
{
public function createClient(array $options): DogStatsInterface;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class PushDatadogHandlerPass implements CompilerPassInterface
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if ('all' !== $container->getParameter('okvpn_datadog.logging') || false === $container->getParameter('okvpn_datadog.profiling')) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/CompilerPass/SqlLoggerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(array $connections)
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if (false === $container->hasDefinition('okvpn_datadog.logger.sql')) {
return;
Expand Down
6 changes: 2 additions & 4 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ class Configuration implements ConfigurationInterface
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('okvpn_datadog');
$rootNode = \method_exists($treeBuilder, 'getRootNode') ?
$treeBuilder->getRootNode() :
$treeBuilder->root('okvpn_datadog');
$rootNode = $treeBuilder->getRootNode();

$rootNode->children()
->arrayNode('handle_exceptions')
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/OkvpnDatadogExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class OkvpnDatadogExtension extends Extension
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container): void
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
Expand Down
2 changes: 1 addition & 1 deletion src/Logging/ErrorBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function flush(): void

public function rootError(): ?array
{
return isset($this->errors[0]) ? $this->errors[0] : null;
return $this->errors[0] ?? null;
}

public function getErrors(): array
Expand Down
2 changes: 1 addition & 1 deletion src/Logging/Watcher/DefaultWatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function watch(): array
$context = [];
if ($this->tokenStorage instanceof TokenStorageInterface) {
$token = $this->tokenStorage->getToken();
if (null !== $token) {
if (null !== $token) {
$context['token'] = method_exists($token, '__toString') ? $token->__toString() : $token->serialize();
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/Services/ExceptionHashService.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public function hash(\Throwable $exception): string
}
}

$hash = sha1($hash);
return $hash;
return sha1($hash);
}
}
Loading

0 comments on commit 632245d

Please sign in to comment.