77use Override ;
88use PgSql \Result as PgSqlResult ;
99use PhpDb \Adapter \Driver \ConnectionInterface ;
10+ use PhpDb \Adapter \Driver \DriverAwareInterface ;
1011use PhpDb \Adapter \Driver \DriverInterface ;
1112use PhpDb \Adapter \Driver \ResultInterface ;
1213use PhpDb \Adapter \Driver \StatementInterface ;
2425 */
2526class Driver implements DriverInterface, ProfilerAwareInterface
2627{
27- use DatabasePlatformNameTrait;
28-
2928 protected ?ProfilerInterface $ profiler = null ;
3029
3130 /** @var array */
@@ -34,9 +33,9 @@ class Driver implements DriverInterface, ProfilerAwareInterface
3433 ];
3534
3635 public function __construct (
37- protected readonly ConnectionInterface &Connection $ connection ,
38- protected readonly StatementInterface &Statement $ statementPrototype ,
39- protected readonly ResultInterface &Result $ resultPrototype ,
36+ protected readonly DriverAwareInterface & ConnectionInterface &Connection $ connection ,
37+ protected readonly DriverAwareInterface & StatementInterface &Statement $ statementPrototype = new Statement () ,
38+ protected readonly ResultInterface &Result $ resultPrototype = new Result () ,
4039 array $ options = []
4140 ) {
4241 $ this ->checkEnvironment ();
@@ -55,9 +54,15 @@ public function setProfiler(
5554 ): DriverInterface &ProfilerAwareInterface {
5655 $ this ->profiler = $ profiler ;
5756
58- $ this ->connection ->setProfiler ($ profiler );
57+ // @phpstan-ignore instanceof.alwaysTrue
58+ if ($ this ->connection instanceof ProfilerAwareInterface) {
59+ $ this ->connection ->setProfiler ($ profiler );
60+ }
5961
60- $ this ->statementPrototype ->setProfiler ($ profiler );
62+ // @phpstan-ignore instanceof.alwaysTrue
63+ if ($ this ->statementPrototype instanceof ProfilerAwareInterface) {
64+ $ this ->statementPrototype ->setProfiler ($ profiler );
65+ }
6166
6267 return $ this ;
6368 }
0 commit comments