Repository: code-tool/doctrine-dbal-jaeger
Pull request #8: Add support of doctrine/dbal 4.0
Author: login: drewblin
Created: 2025-03-27T12:42:15Z | Merged: 2025-03-28T15:08:35Z

* Add support of doctrine/dbal 4.0
* Support of PHP 7.4 and 8.0 was removed - dbal supports only ^8.1
* Remove phpunit from composer - no tests & too old version


Diff:
diff --git a/composer.json b/composer.json
index d4cc251..4f9f43a 100644
--- a/composer.json
+++ b/composer.json
@@ -2,12 +2,13 @@
   "name": "code-tool/doctrine-dbal-jaeger",
   "license": "MIT",
   "require": {
-    "php": "^7.4 || ^8",
-    "doctrine/dbal": "^3.0",
+    "php": "^8.1",
+    "doctrine/dbal": "^4.0",
     "code-tool/jaeger-client-php": "^3"
-  },
+  }
+  ,
   "require-dev": {
-    "phpunit/phpunit": "^7.2 || ^8"
+    "roave/security-advisories": "dev-latest"
   },
   "config": {
     "sort-packages": true
diff --git a/src/Wrapper/JaegerConnectionWrapper.php b/src/Wrapper/JaegerConnectionWrapper.php
index 8d067e8..1facaa1 100644
--- a/src/Wrapper/JaegerConnectionWrapper.php
+++ b/src/Wrapper/JaegerConnectionWrapper.php
@@ -14,16 +14,12 @@
 
 class JaegerConnectionWrapper extends AbstractConnectionMiddleware
 {
-    private TracerInterface $tracer;
-
-    private ?int $maxSqlLength;
-
-    public function __construct(Connection $wrappedConnection, TracerInterface $tracer, ?int $maxSqlLength = null)
-    {
+    public function __construct(
+        Connection $wrappedConnection,
+        private readonly TracerInterface $tracer,
+        private readonly ?int $maxSqlLength = null
+    ) {
         parent::__construct($wrappedConnection);
-
-        $this->tracer = $tracer;
-        $this->maxSqlLength = $maxSqlLength;
     }
 
     public function prepare(string $sql): Statement
@@ -89,13 +85,13 @@ public function exec(string $sql): int
         }
     }
 
-    public function beginTransaction(): bool
+    public function beginTransaction(): void
     {
         $span = $this->tracer
             ->start('dbal.transaction');
 
         try {
-            return parent::beginTransaction();
+            parent::beginTransaction();
         } catch (\Throwable $t) {
             $span
                 ->addTag(new DbalErrorCodeTag($t->getCode()))
@@ -107,13 +103,13 @@ public function beginTransaction(): bool
         }
     }
 
-    public function commit(): bool
+    public function commit(): void
     {
         $span = $this->tracer
             ->start('dbal.commit');
 
         try {
-            return parent::commit();
+            parent::commit();
         } catch (\Throwable $t) {
             $span
                 ->addTag(new DbalErrorCodeTag($t->getCode()))
@@ -125,13 +121,13 @@ public function commit(): bool
         }
     }
 
-    public function rollBack(): bool
+    public function rollBack(): void
     {
         $span = $this->tracer
             ->start('dbal.rollback');
 
         try {
-            return parent::rollBack();
+            parent::rollBack();
         } catch (\Throwable $t) {
             $span
                 ->addTag(new DbalErrorCodeTag($t->getCode()))
diff --git a/src/Wrapper/JaegerDriverWrapper.php b/src/Wrapper/JaegerDriverWrapper.php
index a56bbd1..f35cdf8 100644
--- a/src/Wrapper/JaegerDriverWrapper.php
+++ b/src/Wrapper/JaegerDriverWrapper.php
@@ -13,16 +13,12 @@
 
 class JaegerDriverWrapper extends AbstractDriverMiddleware
 {
-    private TracerInterface $tracer;
-
-    private ?int $maxSqlLength;
-
-    public function __construct(Driver $wrappedDriver, TracerInterface $tracer, ?int $maxSqlLength = null)
-    {
+    public function __construct(
+        private readonly Driver $wrappedDriver,
+        private readonly TracerInterface $tracer,
+        private readonly ?int $maxSqlLength = null
+    ) {
         parent::__construct($wrappedDriver);
-
-        $this->tracer = $tracer;
-        $this->maxSqlLength = $maxSqlLength;
     }
 
     public function connect(array $params): DriverConnection
@@ -42,7 +38,7 @@ public function connect(array $params): DriverConnection
 
             throw $t;
         } finally {
-            $span->addTag(new DbType(\get_class($this->getDatabasePlatform())));
+            $span->addTag(new DbType($this->wrappedDriver::class));
 
             $this->tracer->finish($span);
         }
diff --git a/src/Wrapper/JaegerMiddleware.php b/src/Wrapper/JaegerMiddleware.php
index c02771f..60a4577 100644
--- a/src/Wrapper/JaegerMiddleware.php
+++ b/src/Wrapper/JaegerMiddleware.php
@@ -9,14 +9,10 @@
 
 class JaegerMiddleware implements Middleware
 {
-    private TracerInterface $tracer;
-
-    private ?int $maxSqlLength;
-
-    public function __construct(TracerInterface $tracer, ?int $maxSqlLength = null)
-    {
-        $this->tracer = $tracer;
-        $this->maxSqlLength = $maxSqlLength;
+    public function __construct(
+        private readonly TracerInterface $tracer,
+        private readonly ?int $maxSqlLength = null
+    ) {
     }
 
     public function wrap(Driver $driver): Driver
diff --git a/src/Wrapper/JaegerStatementWrapper.php b/src/Wrapper/JaegerStatementWrapper.php
index 550c1d2..483aca4 100644
--- a/src/Wrapper/JaegerStatementWrapper.php
+++ b/src/Wrapper/JaegerStatementWrapper.php
@@ -13,26 +13,22 @@
 
 class JaegerStatementWrapper extends AbstractStatementMiddleware
 {
-    private TracerInterface $tracer;
-
-    private string $sql;
-
-    public function __construct(Statement $wrappedStatement, TracerInterface $tracer, string $sql)
-    {
+    public function __construct(
+        Statement $wrappedStatement,
+        private readonly TracerInterface $tracer,
+        private readonly string $sql
+    ) {
         parent::__construct($wrappedStatement);
-
-        $this->tracer = $tracer;
-        $this->sql = $sql;
     }
 
-    public function execute($params = null): Result
+    public function execute(): Result
     {
         $span = $this->tracer
             ->start('dbal.stmt.execute')
             ->addTag(new DbStatementTag($this->sql));
 
         try {
-            return parent::execute($params);
+            return parent::execute();
         } catch (\Throwable $t) {
             $span
                 ->addTag(new DbalErrorCodeTag($t->getCode()))


Reviews:
user: login: andrew-demb
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-03-27T13:28:40Z
user: login: drewblin
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-28T14:32:12Z
user: login: drewblin
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-28T14:32:57Z
user: login: andrew-demb
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-03-28T15:08:03Z
user: login: andrew-demb
state: APPROVED
author_association: COLLABORATOR
submitted_at: 2025-03-28T15:08:24Z

Review comments:
diff_hunk: @@ -2,12 +2,13 @@
   "name": "code-tool/doctrine-dbal-jaeger",
   "license": "MIT",
   "require": {
-    "php": "^7.4 || ^8",
-    "doctrine/dbal": "^3.0",
+    "php": "^8.1",
+    "doctrine/dbal": "^4.2",
     "code-tool/jaeger-client-php": "^3"
-  },
+  }
+  ,
   "require-dev": {
-    "phpunit/phpunit": "^7.2 || ^8"
+    "roave/security-advisories": "dev-latest"
path: composer.json
user: login: andrew-demb
body: why is it needed?
created_at: 2025-03-27T13:27:15Z
author_association: COLLABORATOR
diff_hunk: @@ -2,12 +2,13 @@
   "name": "code-tool/doctrine-dbal-jaeger",
   "license": "MIT",
   "require": {
-    "php": "^7.4 || ^8",
-    "doctrine/dbal": "^3.0",
+    "php": "^8.1",
+    "doctrine/dbal": "^4.2",
path: composer.json
user: login: andrew-demb
body: why not 4.0?
created_at: 2025-03-27T13:27:58Z
author_association: COLLABORATOR
diff_hunk: @@ -2,12 +2,13 @@
   "name": "code-tool/doctrine-dbal-jaeger",
   "license": "MIT",
   "require": {
-    "php": "^7.4 || ^8",
-    "doctrine/dbal": "^3.0",
+    "php": "^8.1",
+    "doctrine/dbal": "^4.2",
     "code-tool/jaeger-client-php": "^3"
-  },
+  }
+  ,
   "require-dev": {
-    "phpunit/phpunit": "^7.2 || ^8"
+    "roave/security-advisories": "dev-latest"
path: composer.json
user: login: drewblin
body: As for me, require this package is best practice. One can forgot to call `composer audit`, but this package will not allow to use non-secure package.
created_at: 2025-03-28T14:32:12Z
author_association: CONTRIBUTOR
diff_hunk: @@ -2,12 +2,13 @@
   "name": "code-tool/doctrine-dbal-jaeger",
   "license": "MIT",
   "require": {
-    "php": "^7.4 || ^8",
-    "doctrine/dbal": "^3.0",
+    "php": "^8.1",
+    "doctrine/dbal": "^4.2",
path: composer.json
user: login: drewblin
body: fixed
created_at: 2025-03-28T14:32:57Z
author_association: CONTRIBUTOR
diff_hunk: @@ -2,12 +2,13 @@
   "name": "code-tool/doctrine-dbal-jaeger",
   "license": "MIT",
   "require": {
-    "php": "^7.4 || ^8",
-    "doctrine/dbal": "^3.0",
+    "php": "^8.1",
+    "doctrine/dbal": "^4.2",
     "code-tool/jaeger-client-php": "^3"
-  },
+  }
+  ,
   "require-dev": {
-    "phpunit/phpunit": "^7.2 || ^8"
+    "roave/security-advisories": "dev-latest"
path: composer.json
user: login: andrew-demb
body: OK, let's keep it. Thank you
created_at: 2025-03-28T15:08:03Z
author_association: COLLABORATOR

PR comments:
user: login: drewblin
created_at: 2025-03-27T12:42:55Z
body: Need to create new release branch 3.0.0 and change PR destination to it
author_association: CONTRIBUTOR
user: login: drewblin
created_at: 2025-03-27T12:43:38Z
body: @allflame @andrew-demb Review, please
author_association: CONTRIBUTOR
user: login: andrew-demb
created_at: 2025-03-28T15:13:23Z
body: Thank you @drewblin 
author_association: COLLABORATOR