Skip to content

Commit

Permalink
Update code & supports only maintained verisons of sf
Browse files Browse the repository at this point in the history
  • Loading branch information
odolbeau committed Jun 11, 2024
1 parent 321d479 commit 8ec2788
Show file tree
Hide file tree
Showing 31 changed files with 2,784 additions and 240 deletions.
88 changes: 0 additions & 88 deletions .github/workflows/ci.yml

This file was deleted.

43 changes: 43 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
on: [pull_request]
name: Static analysis
jobs:
php-cs-fixer:
name: 🧽 PHP-CS-Fixer
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3

- name: Install php-cs-fixer
uses: ramsey/composer-install@v2
with:
composer-options: "--working-dir=tools/php-cs-fixer"

- name: PHP-CS-Fixer
run: tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --dry-run --diff --config=.php-cs-fixer.dist.php

audit:
name: 🔍 Audit vendors
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3

- name: Download dependencies
uses: ramsey/composer-install@v2

- name: Check whether a PHP dependency is compromised
shell: bash
run: composer audit
52 changes: 52 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
on: [pull_request]
name: PHPUnit

jobs:
tests:
name: Tests
runs-on: Ubuntu-20.04

strategy:
matrix:
include:
# Lowest Deps
- php: 8.2
symfony-require: 5.4.*
composer-flags: '--prefer-stable --prefer-lowest'
# LTS with latest stable PHP
- php: 8.2
symfony-require: 6.4.*
composer-flags: '--prefer-stable'
# Active release
- php: 8.3
symfony-require: 7.1.*
composer-flags: '--prefer-stable --ignore-platform-req=php+'
# Development release
- php: nightly
symfony-require: 7.1.*@dev
composer-flags: '--ignore-platform-req=php+'
stability: dev
can-fail: true
fail-fast: false

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none

- name: Configure Composer minimum stability
if: matrix.stability
run: composer config minimum-stability ${{ matrix.stability }}

- name: Install dependencies
env:
SYMFONY_REQUIRE: ${{ matrix.symfony-require }}
run: composer update ${{ matrix.composer-flags }} --no-interaction --no-progress --optimize-autoloader

- name: Run PHPUnit
run: vendor/bin/simple-phpunit
8 changes: 3 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.php_cs.cache
build
phpunit.xml
coverage
composer.lock
vendor
/composer.lock
/vendor
/tools/**/vendor
1 change: 1 addition & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
EOF;

return (new PhpCsFixer\Config())
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
Expand Down
10 changes: 5 additions & 5 deletions Command/NotifyDeploymentCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
switch ($response['status']) {
case 200:
case 201:
$output->writeLn(sprintf("Recorded deployment to '%s' (%s)", $appName, ($input->getOption('description') ?: date('r'))));
$output->writeLn(sprintf("Recorded deployment to '%s' (%s)", $appName, $input->getOption('description') ?: date('r')));
break;
case 403:
$output->writeLn(sprintf("<error>Deployment not recorded to '%s': API key invalid</error>", $appName));
Expand Down Expand Up @@ -153,19 +153,19 @@ private function createPayload(string $appName, InputInterface $input): string
'deployment[app_name]' => $appName,
];

if (($user = $input->getOption('user'))) {
if ($user = $input->getOption('user')) {
$content_array['deployment[user]'] = $user;
}

if (($revision = $input->getOption('revision'))) {
if ($revision = $input->getOption('revision')) {
$content_array['deployment[revision]'] = $revision;
}

if (($changelog = $input->getOption('changelog'))) {
if ($changelog = $input->getOption('changelog')) {
$content_array['deployment[changelog]'] = $changelog;
}

if (($description = $input->getOption('description'))) {
if ($description = $input->getOption('description')) {
$content_array['deployment[description]'] = $description;
}

Expand Down
7 changes: 5 additions & 2 deletions DependencyInjection/Compiler/MonologHandlerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,18 @@ public function process(ContainerBuilder $container): void
}
}

private function getChannels(ContainerBuilder $container)
/**
* @return string[]
*/
private function getChannels(ContainerBuilder $container): array
{
$channels = [];
foreach ($container->getDefinitions() as $id => $definition) {
if ('monolog.logger' === $id) {
$channels[] = 'app';
continue;
}
if (0 === strpos($id, 'monolog.logger.')) {
if (str_starts_with($id, 'monolog.logger.')) {
$channels[] = substr($id, 15);
}
}
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function getConfigTreeBuilder(): TreeBuilder

$elements = [];
foreach ($v['elements'] as $element) {
if (0 === strpos($element, '!')) {
if (str_starts_with($element, '!')) {
if (false === $isExclusive) {
throw new InvalidConfigurationException('Cannot combine exclusive/inclusive definitions in channels list.');
}
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/EkinoNewRelicExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

/**
* This is the class that loads and manages your bundle configuration.
Expand Down
6 changes: 3 additions & 3 deletions EkinoNewRelicBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@

class EkinoNewRelicBundle extends Bundle
{
public function build(ContainerBuilder $container)
public function build(ContainerBuilder $container): void
{
parent::build($container);

$container->addCompilerPass(new MonologHandlerPass());
}

public function boot()
public function boot(): void
{
parent::boot();

Expand All @@ -36,7 +36,7 @@ public function boot()
}
}

public function shutdown()
public function shutdown(): void
{
if ($this->container->has(DeprecationListener::class)) {
$this->container->get(DeprecationListener::class)->unregister();
Expand Down
10 changes: 5 additions & 5 deletions Listener/RequestListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public static function getSubscribedEvents(): array
{
return [
KernelEvents::REQUEST => [
['setApplicationName', 255],
['setIgnoreTransaction', 31],
['setTransactionName', -10],
['setApplicationName', 255],
['setIgnoreTransaction', 31],
['setTransactionName', -10],
],
];
}
Expand All @@ -75,7 +75,7 @@ public function setApplicationName(KernelRequestEvent $event): void
}

// Set application name if different from ini configuration
if ($appName !== ini_get('newrelic.appname')) {
if ($appName !== \ini_get('newrelic.appname')) {
$this->interactor->setApplicationName($appName, $this->config->getLicenseKey(), $this->config->getXmit());
}
}
Expand Down Expand Up @@ -112,7 +112,7 @@ public function setIgnoreTransaction(KernelRequestEvent $event): void
*/
private function isEventValid(KernelRequestEvent $event): bool
{
return HttpKernelInterface::MASTER_REQUEST === $event->getRequestType();
return HttpKernelInterface::MAIN_REQUEST === $event->getRequestType();
}
}

Expand Down
2 changes: 1 addition & 1 deletion Listener/ResponseListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(
NewRelicInteractorInterface $interactor,
bool $instrument = false,
bool $symfonyCache = false,
NewRelicExtension $newRelicTwigExtension = null
?NewRelicExtension $newRelicTwigExtension = null
) {
$this->newRelic = $newRelic;
$this->interactor = $interactor;
Expand Down
7 changes: 4 additions & 3 deletions Logging/AdaptiveHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,22 @@
namespace Ekino\NewRelicBundle\Logging;

use Monolog\Handler\NewRelicHandler;
use Monolog\LogRecord;
use Psr\Log\LogLevel;

class AdaptiveHandler extends NewRelicHandler
{
public function __construct(
string $level = LogLevel::ERROR,
bool $bubble = true,
string $appName = null,
?string $appName = null,
bool $explodeArrays = false,
string $transactionName = null
?string $transactionName = null
) {
parent::__construct($level, $bubble, $appName, $explodeArrays, $transactionName);
}

protected function write(array $record): void
protected function write(LogRecord $record): void
{
if (!$this->isNewRelicEnabled()) {
return;
Expand Down
Loading

0 comments on commit 8ec2788

Please sign in to comment.