Skip to content
Draft
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
20 changes: 20 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
- 5.*
- 6.*
- 7.*
- 8.0.*@beta
dependencies:
- highest
exclude:
Expand All @@ -54,6 +55,20 @@ jobs:
symfony-version: 7.*
- php: '8.4'
symfony-version: 4.4.*
- php: '7.2'
symfony-version: 8.0.*@beta
- php: '7.3'
symfony-version: 8.0.*@beta
- php: '7.4'
symfony-version: 8.0.*@beta
- php: '8.0'
symfony-version: 8.0.*@beta
- php: '8.1'
symfony-version: 8.0.*@beta
- php: '8.2'
symfony-version: 8.0.*@beta
- php: '8.3'
symfony-version: 8.0.*@beta
include:
- php: '7.2'
symfony-version: 4.4.*
Expand Down Expand Up @@ -122,6 +137,7 @@ jobs:
symfony-version: 4.4.*
- php: '8.4'
dependencies: highest
symfony-version: 8.0.*@beta

steps:
- name: Checkout
Expand All @@ -137,6 +153,10 @@ jobs:
- name: Setup Problem Matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

# These dependencies are not used running the tests but can cause deprecation warnings so we remove them before running the tests
- name: Remove unused dependencies
run: composer remove vimeo/psalm phpstan/phpstan friendsofphp/php-cs-fixer --dev --no-interaction --no-update

- name: Remove optional packages
run: composer remove doctrine/dbal doctrine/doctrine-bundle symfony/messenger symfony/twig-bundle symfony/cache symfony/http-client --dev --no-update

Expand Down
44 changes: 23 additions & 21 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"description": "Symfony integration for Sentry (http://getsentry.com)",
"keywords": ["logging", "errors", "symfony", "sentry"],
"homepage": "http://getsentry.com",
"minimum-stability": "dev",
"prefer-stable": false,
"license": "MIT",
"authors": [
{
Expand All @@ -15,39 +17,39 @@
"php": "^7.2||^8.0",
"guzzlehttp/psr7": "^2.1.1",
"jean85/pretty-package-versions": "^1.5||^2.0",
"sentry/sentry": "^4.16.0",
"sentry/sentry": "^4.18",
"symfony/cache-contracts": "^1.1||^2.4||^3.0",
"symfony/config": "^4.4.20||^5.0.11||^6.0||^7.0",
"symfony/console": "^4.4.20||^5.0.11||^6.0||^7.0",
"symfony/dependency-injection": "^4.4.20||^5.0.11||^6.0||^7.0",
"symfony/event-dispatcher": "^4.4.20||^5.0.11||^6.0||^7.0",
"symfony/http-kernel": "^4.4.20||^5.0.11||^6.0||^7.0",
"symfony/config": "^4.4.20||^5.0.11||^6.0||^7.0||^8.0",
"symfony/console": "^4.4.20||^5.0.11||^6.0||^7.0||^8.0",
"symfony/dependency-injection": "^4.4.20||^5.0.11||^6.0||^7.0||^8.0",
"symfony/event-dispatcher": "^4.4.20||^5.0.11||^6.0||^7.0||^8.0",
"symfony/http-kernel": "^4.4.20||^5.0.11||^6.0||^7.0||^8.0",
"symfony/polyfill-php80": "^1.22",
"symfony/psr-http-message-bridge": "^1.2||^2.0||^6.4||^7.0"
"symfony/psr-http-message-bridge": "^1.2||^2.0||^6.4||^7.0||^8.0"
},
"require-dev": {
"doctrine/dbal": "^2.13||^3.3||^4.0",
"doctrine/doctrine-bundle": "^2.6",
"doctrine/doctrine-bundle": "^2.6||^3.0",
"friendsofphp/php-cs-fixer": "^2.19||^3.40",
"masterminds/html5": "^2.8",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "1.12.5",
"phpstan/phpstan-phpunit": "1.4.0",
"phpstan/phpstan-symfony": "1.4.10",
"phpunit/phpunit": "^8.5.40||^9.6.21",
"symfony/browser-kit": "^4.4.20||^5.0.11||^6.0||^7.0",
"symfony/cache": "^4.4.20||^5.0.11||^6.0||^7.0",
"symfony/dom-crawler": "^4.4.20||^5.0.11||^6.0||^7.0",
"symfony/framework-bundle": "^4.4.20||^5.0.11||^6.0||^7.0",
"symfony/http-client": "^4.4.20||^5.0.11||^6.0||^7.0",
"symfony/messenger": "^4.4.20||^5.0.11||^6.0||^7.0",
"symfony/monolog-bundle": "^3.4",
"symfony/phpunit-bridge": "^5.2.6||^6.0||^7.0",
"symfony/process": "^4.4.20||^5.0.11||^6.0||^7.0",
"symfony/security-core": "^4.4.20||^5.0.11||^6.0||^7.0",
"symfony/security-http": "^4.4.20||^5.0.11||^6.0||^7.0",
"symfony/twig-bundle": "^4.4.20||^5.0.11||^6.0||^7.0",
"symfony/yaml": "^4.4.20||^5.0.11||^6.0||^7.0",
"symfony/browser-kit": "^4.4.20||^5.0.11||^6.0||^7.0||^8.0",
"symfony/cache": "^4.4.20||^5.0.11||^6.0||^7.0||^8.0",
"symfony/dom-crawler": "^4.4.20||^5.0.11||^6.0||^7.0||^8.0",
"symfony/framework-bundle": "^4.4.20||^5.0.11||^6.0||^7.0||^8.0",
"symfony/http-client": "^4.4.20||^5.0.11||^6.0||^7.0||^8.0",
"symfony/messenger": "^4.4.20||^5.0.11||^6.0||^7.0||^8.0",
"symfony/monolog-bundle": "^3.4||^4.0",
"symfony/phpunit-bridge": "^5.2.6||^6.0||^7.0||^8.0",
"symfony/process": "^4.4.20||^5.0.11||^6.0||^7.0||^8.0",
"symfony/security-core": "^4.4.20||^5.0.11||^6.0||^7.0||^8.0",
"symfony/security-http": "^4.4.20||^5.0.11||^6.0||^7.0||^8.0",
"symfony/twig-bundle": "^4.4.20||^5.0.11||^6.0||^7.0||^8.0",
"symfony/yaml": "^4.4.20||^5.0.11||^6.0||^7.0||^8.0",
"vimeo/psalm": "^4.3||^5.16.0"
},
"suggest": {
Expand Down
14 changes: 13 additions & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Symfony\Bundle\TwigBundle\TwigBundle;
use Symfony\Component\Cache\CacheItem;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\NodeParentInterface;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\HttpClient\HttpClient;
Expand All @@ -19,12 +20,14 @@ final class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
*
* @phpstan-return TreeBuilder<'array'>
*/
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('sentry');

/** @var ArrayNodeDefinition $rootNode */
/** @phpstan-var ArrayNodeDefinition<NodeParentInterface|null> $rootNode */
$rootNode = method_exists(TreeBuilder::class, 'getRootNode')
? $treeBuilder->getRootNode()
: $treeBuilder->root('sentry');
Expand All @@ -38,6 +41,7 @@ public function getConfigTreeBuilder(): TreeBuilder
$inAppExcludes[] = '%kernel.build_dir%';
}

// @phpstan-ignore-next-line
$rootNode
->children()
->scalarNode('dsn')
Expand Down Expand Up @@ -176,8 +180,12 @@ public function getConfigTreeBuilder(): TreeBuilder
return $treeBuilder;
}

/**
* @phpstan-param ArrayNodeDefinition<NodeParentInterface|null> $rootNode
*/
private function addMessengerSection(ArrayNodeDefinition $rootNode): void
{
// @phpstan-ignore-next-line
$rootNode
->children()
->arrayNode('messenger')
Expand All @@ -190,8 +198,12 @@ private function addMessengerSection(ArrayNodeDefinition $rootNode): void
->end();
}

/**
* @phpstan-param ArrayNodeDefinition<NodeParentInterface|null> $rootNode
*/
private function addDistributedTracingSection(ArrayNodeDefinition $rootNode): void
{
// @phpstan-ignore-next-line
$rootNode
->children()
->arrayNode('tracing')
Expand Down
22 changes: 20 additions & 2 deletions src/DependencyInjection/SentryExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,18 @@ public function getNamespace(): string
*/
protected function loadInternal(array $mergedConfig, ContainerBuilder $container): void
{
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.xml');
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.yaml');

if (!$container->hasParameter('env(SENTRY_RELEASE)')) {
$container->setParameter('env(SENTRY_RELEASE)', PrettyVersions::getRootPackageVersion()->getPrettyVersion());
}

// Remove Twig extension service if Twig is not installed to avoid autoloading failures on Symfony 8
if (!class_exists(\Twig\Extension\AbstractExtension::class)) {
$container->removeDefinition(\Sentry\SentryBundle\Twig\SentryExtension::class);
}

$this->registerConfiguration($container, $mergedConfig);
$this->registerErrorListenerConfiguration($container, $mergedConfig);
$this->registerMessengerListenerConfiguration($container, $mergedConfig['messenger']);
Expand Down Expand Up @@ -244,6 +249,19 @@ private function registerDbalTracingConfiguration(ContainerBuilder $container, a
$container->setParameter('sentry.tracing.dbal.enabled', $isConfigEnabled);
$container->setParameter('sentry.tracing.dbal.connections', $isConfigEnabled ? $config['dbal']['connections'] : []);

$factoryServiceId = 'sentry.tracing.dbal.connection_factory';
if ($container->hasDefinition($factoryServiceId)) {
$factoryClass = \Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriverConnectionFactoryForV2V3::class;

// On Symfony 8+, the container validates FQCN-like service IDs at compile time. Classes provided
// via aliases.php aren’t considered during this check, so FQCN IDs without loadable classes fail
if (class_exists(\Doctrine\DBAL\Result::class) && !interface_exists(\Doctrine\DBAL\VersionAwarePlatformDriver::class)) {
$factoryClass = \Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriverConnectionFactoryForV4::class;
}

$container->getDefinition($factoryServiceId)->setClass($factoryClass);
}

if (!$isConfigEnabled) {
$container->removeDefinition(ConnectionConfigurator::class);
$container->removeDefinition(TracingDriverMiddleware::class);
Expand Down
144 changes: 0 additions & 144 deletions src/Resources/config/services.xml

This file was deleted.

Loading
Loading