Skip to content

Commit 6a542a4

Browse files
committed
Fix CR issues
1 parent bcab5d9 commit 6a542a4

15 files changed

+172
-57
lines changed

.github/workflows/static-analysis.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ jobs:
1717

1818
- name: Setup PHP
1919
uses: shivammathur/setup-php@v2
20-
with:
21-
php-version: '7.4'
2220

2321
- name: Install dependencies
2422
run: composer update --no-progress --no-interaction --prefer-dist

.github/workflows/tests.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,59 @@ jobs:
6565
with:
6666
file: './coverage.xml'
6767
fail_ci_if_error: true
68+
69+
missing-optional-packages-tests:
70+
name: Tests with missing optional packages
71+
runs-on: ubuntu-latest
72+
strategy:
73+
fail-fast: false
74+
matrix:
75+
php:
76+
- '7.2'
77+
- '8.0'
78+
dependencies:
79+
- lowest
80+
- highest
81+
82+
steps:
83+
- name: Checkout
84+
uses: actions/checkout@v2
85+
86+
- name: Setup PHP
87+
uses: shivammathur/setup-php@v2
88+
with:
89+
php-version: ${{ matrix.php }}
90+
coverage: xdebug
91+
92+
- name: Setup Problem Matchers for PHPUnit
93+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
94+
95+
- name: Determine Composer cache directory
96+
id: composer-cache
97+
run: echo "::set-output name=directory::$(composer config cache-dir)"
98+
99+
- name: Cache Composer dependencies
100+
uses: actions/cache@v2
101+
with:
102+
path: ${{ steps.composer-cache.outputs.directory }}
103+
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock') }}
104+
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer-${{ matrix.dependencies }}-
105+
106+
- name: Remove optional packages
107+
run: composer remove doctrine/dbal doctrine/doctrine-bundle --dev --no-update
108+
109+
- name: Install highest dependencies
110+
run: composer update --no-progress --no-interaction --prefer-dist
111+
if: ${{ matrix.dependencies == 'highest' }}
112+
113+
- name: Install lowest dependencies
114+
run: composer update --no-progress --no-interaction --prefer-dist --prefer-lowest
115+
if: ${{ matrix.dependencies == 'lowest' }}
116+
117+
- name: Run tests
118+
run: vendor/bin/phpunit --coverage-clover=build/coverage-report.xml
119+
120+
- name: Upload code coverage
121+
uses: codecov/codecov-action@v1
122+
with:
123+
file: build/coverage-report.xml

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
},
5555
"suggest": {
5656
"monolog/monolog": "Allow sending log messages to Sentry by using the included Monolog handler.",
57-
"doctrine/dbal": "Allow distributed tracing of SQL queries using Sentry."
57+
"doctrine/doctrine-bundle": "Allow distributed tracing of database queries using Sentry."
5858
},
5959
"autoload": {
6060
"files": [

phpstan-baseline.neon

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,17 @@ parameters:
3636
path: src/Tracing/Doctrine/DBAL/TracingDriver.php
3737

3838
-
39-
message: "#^Method Doctrine\\\\DBAL\\\\Driver\\:\\:connect\\(\\) invoked with 4 parameters, 1 required\\.$#"
39+
message: "#^Call to an undefined method Doctrine\\\\DBAL\\\\Driver\\|Sentry\\\\SentryBundle\\\\Tracing\\\\Doctrine\\\\DBAL\\\\Compatibility\\\\ExceptionConverterDriverInterface\\:\\:connect\\(\\)\\.$#"
40+
count: 1
41+
path: src/Tracing/Doctrine/DBAL/TracingDriver.php
42+
43+
-
44+
message: "#^Call to an undefined method Doctrine\\\\DBAL\\\\Driver\\|Sentry\\\\SentryBundle\\\\Tracing\\\\Doctrine\\\\DBAL\\\\Compatibility\\\\ExceptionConverterDriverInterface\\:\\:getDatabasePlatform\\(\\)\\.$#"
45+
count: 2
46+
path: src/Tracing/Doctrine/DBAL/TracingDriver.php
47+
48+
-
49+
message: "#^Call to an undefined method Doctrine\\\\DBAL\\\\Driver\\|Sentry\\\\SentryBundle\\\\Tracing\\\\Doctrine\\\\DBAL\\\\Compatibility\\\\ExceptionConverterDriverInterface\\:\\:getSchemaManager\\(\\)\\.$#"
4050
count: 1
4151
path: src/Tracing/Doctrine/DBAL/TracingDriver.php
4252

@@ -206,7 +216,7 @@ parameters:
206216
path: tests/Tracing/Doctrine/DBAL/TracingDriverTest.php
207217

208218
-
209-
message: "#^Trying to mock an undefined method convertException\\(\\) on class Sentry\\\\SentryBundle\\\\Tests\\\\Tracing\\\\Doctrine\\\\DBAL\\\\ExceptionConverterDriverInterface\\.$#"
219+
message: "#^Trying to mock an undefined method convertException\\(\\) on class Sentry\\\\SentryBundle\\\\Tests\\\\Tracing\\\\Doctrine\\\\DBAL\\\\StubExceptionConverterDriverInterface\\.$#"
210220
count: 1
211221
path: tests/Tracing/Doctrine/DBAL/TracingDriverTest.php
212222

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Sentry\SentryBundle\Tracing\Doctrine\DBAL\Compatibility;
6+
7+
/**
8+
* @internal
9+
*/
10+
interface DriverInterface
11+
{
12+
}

src/Tracing/Doctrine/DBAL/Compatibility/ExceptionConverterDriverInterface.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44

55
namespace Sentry\SentryBundle\Tracing\Doctrine\DBAL\Compatibility;
66

7-
use Doctrine\DBAL\Driver as DriverInterface;
8-
97
/**
108
* @internal
119
*/
12-
interface ExceptionConverterDriverInterface extends DriverInterface
10+
interface ExceptionConverterDriverInterface
1311
{
1412
}

src/Tracing/Doctrine/DBAL/TracingDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* This is a simple implementation of the {@see DriverInterface} interface that
2020
* decorates an existing driver to support distributed tracing capabilities.
2121
* This implementation IS and MUST be compatible with all versions of Doctrine
22-
* DBAL >= 2.11.
22+
* DBAL >= 2.10.
2323
*
2424
* @internal
2525
*/

src/Tracing/Doctrine/DBAL/TracingDriverConnection.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313

1414
/**
1515
* This implementation wraps a driver connection and adds distributed tracing
16-
* capabilities to Doctrine DBAL.
16+
* capabilities to Doctrine DBAL. This implementation IS and MUST be compatible
17+
* with all versions of Doctrine DBAL >= 2.10.
1718
*/
1819
final class TracingDriverConnection implements DriverConnectionInterface
1920
{
@@ -45,7 +46,7 @@ final class TracingDriverConnection implements DriverConnectionInterface
4546
/**
4647
* @internal
4748
*/
48-
public const SPAN_OP_TRANSACTION_ROLLBACK = 'sql.transaciton.rollback';
49+
public const SPAN_OP_TRANSACTION_ROLLBACK = 'sql.transaction.rollback';
4950

5051
/**
5152
* @var HubInterface The current hub

src/aliases.php

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Sentry\SentryBundle;
66

7-
use Doctrine\DBAL\Connection;
7+
use Doctrine\DBAL\Driver as DoctrineDriverInterface;
88
use Doctrine\DBAL\Driver\DriverException as LegacyDriverExceptionInterface;
99
use Doctrine\DBAL\Driver\Exception as DriverExceptionInterface;
1010
use Doctrine\DBAL\Driver\ExceptionConverterDriver as LegacyExceptionConverterDriverInterface;
@@ -15,6 +15,7 @@
1515
use Sentry\SentryBundle\EventListener\RequestListenerControllerEvent;
1616
use Sentry\SentryBundle\EventListener\RequestListenerRequestEvent;
1717
use Sentry\SentryBundle\EventListener\SubRequestListenerRequestEvent;
18+
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\Compatibility\DriverInterface;
1819
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\Compatibility\ExceptionConverterDriverInterface;
1920
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\Compatibility\MiddlewareInterface;
2021
use Symfony\Component\HttpKernel\Event\ControllerEvent;
@@ -67,24 +68,27 @@ class_alias(GetResponseEvent::class, SubRequestListenerRequestEvent::class);
6768
}
6869
}
6970

70-
if (class_exists(Connection::class)) {
71-
if (!interface_exists(Result::class)) {
72-
/** @psalm-suppress UndefinedClass */
73-
class_alias(Statement::class, Result::class);
74-
}
71+
if (interface_exists(Statement::class) && !interface_exists(Result::class)) {
72+
/** @psalm-suppress UndefinedClass */
73+
class_alias(Statement::class, Result::class);
74+
}
7575

76-
if (!interface_exists(DoctrineMiddlewareInterface::class)) {
77-
/** @psalm-suppress UndefinedClass */
78-
class_alias(MiddlewareInterface::class, DoctrineMiddlewareInterface::class);
79-
}
76+
if (interface_exists(DriverExceptionInterface::class) && !interface_exists(LegacyDriverExceptionInterface::class)) {
77+
/** @psalm-suppress UndefinedClass */
78+
class_alias(DriverExceptionInterface::class, LegacyDriverExceptionInterface::class);
79+
}
8080

81-
if (!interface_exists(LegacyExceptionConverterDriverInterface::class)) {
82-
/** @psalm-suppress UndefinedClass */
83-
class_alias(ExceptionConverterDriverInterface::class, LegacyExceptionConverterDriverInterface::class);
84-
}
81+
if (!interface_exists(DoctrineMiddlewareInterface::class)) {
82+
/** @psalm-suppress UndefinedClass */
83+
class_alias(MiddlewareInterface::class, DoctrineMiddlewareInterface::class);
84+
}
8585

86-
if (!interface_exists(LegacyDriverExceptionInterface::class)) {
87-
/** @psalm-suppress UndefinedClass */
88-
class_alias(DriverExceptionInterface::class, LegacyDriverExceptionInterface::class);
89-
}
86+
if (!interface_exists(DoctrineDriverInterface::class)) {
87+
/** @psalm-suppress UndefinedClass */
88+
class_alias(DriverInterface::class, DoctrineDriverInterface::class);
89+
}
90+
91+
if (!interface_exists(LegacyExceptionConverterDriverInterface::class)) {
92+
/** @psalm-suppress UndefinedClass */
93+
class_alias(ExceptionConverterDriverInterface::class, LegacyExceptionConverterDriverInterface::class);
9094
}

tests/DependencyInjection/Compiler/DbalTracingPassTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ final class DbalTracingPassTest extends DoctrineTestCase
1818
{
1919
public function testProcessWithDoctrineDBALVersionAtLeast30(): void
2020
{
21-
if (!$this->isDoctrineDBALVersion3Installed()) {
21+
if (!self::isDoctrineDBALVersion3Installed()) {
2222
$this->markTestSkipped('This test requires the version of the "doctrine/dbal" Composer package to be >= 3.0.');
2323
}
2424

@@ -84,7 +84,7 @@ public function testProcessWithDoctrineDBALVersionAtLeast30(): void
8484

8585
public function testProcessWithDoctrineDBALVersionLowerThan30(): void
8686
{
87-
if ($this->isDoctrineDBALVersion3Installed()) {
87+
if (self::isDoctrineDBALVersion3Installed()) {
8888
$this->markTestSkipped('This test requires the version of the "doctrine/dbal" Composer package to be < 3.0.');
8989
}
9090

0 commit comments

Comments
 (0)