9
9
use Doctrine \DBAL \Jaeger \Tag \DbalErrorCodeTag ;
10
10
use Doctrine \DBAL \Jaeger \Tag \DbalNestingLevelTag ;
11
11
use Doctrine \DBAL \Jaeger \Tag \DbalRowNumberTag ;
12
+ use Doctrine \DBAL \Result ;
13
+ use Doctrine \DBAL \Statement ;
12
14
use Jaeger \Tag \DbInstanceTag ;
13
15
use Jaeger \Tag \DbStatementTag ;
14
16
use Jaeger \Tag \DbType ;
@@ -54,18 +56,18 @@ public function connect(): bool
54
56
}
55
57
}
56
58
57
- public function prepare ($ prepareString )
59
+ public function prepare (string $ sql ): Statement
58
60
{
59
61
$ span = $ this ->tracer
60
62
->start ('dbal.prepare ' )
61
63
->addTag (new DbInstanceTag ($ this ->getDatabase ()))
62
64
->addTag (new DbUser ($ this ->getUsername ()))
63
65
->addTag (new DbType ($ this ->getDatabasePlatform ()->getName ()))
64
66
->addTag (new DbalAutoCommitTag ($ this ->isAutoCommit ()))
65
- ->addTag (new DbStatementTag ($ this ->cutLongSql ($ prepareString )))
67
+ ->addTag (new DbStatementTag ($ this ->cutLongSql ($ sql )))
66
68
->addTag (new DbalNestingLevelTag ($ this ->getTransactionNestingLevel ()));
67
69
try {
68
- return parent ::prepare ($ prepareString );
70
+ return parent ::prepare ($ sql );
69
71
} catch (\Exception $ e ) {
70
72
$ span ->addTag (new DbalErrorCodeTag ($ e ->getCode ()))
71
73
->addTag (new ErrorTag ());
@@ -75,18 +77,18 @@ public function prepare($prepareString)
75
77
}
76
78
}
77
79
78
- public function executeQuery ($ query , array $ params = [], $ types = [], QueryCacheProfile $ qcp = null )
80
+ public function executeQuery (string $ sql , array $ params = [], $ types = [], QueryCacheProfile $ qcp = null ): Result
79
81
{
80
82
$ span = $ this ->tracer
81
83
->start ('dbal.execute ' )
82
84
->addTag (new DbInstanceTag ($ this ->getDatabase ()))
83
85
->addTag (new DbUser ($ this ->getUsername ()))
84
86
->addTag (new DbType ($ this ->getDatabasePlatform ()->getName ()))
85
87
->addTag (new DbalAutoCommitTag ($ this ->isAutoCommit ()))
86
- ->addTag (new DbStatementTag ($ this ->cutLongSql ($ query )))
88
+ ->addTag (new DbStatementTag ($ this ->cutLongSql ($ sql )))
87
89
->addTag (new DbalNestingLevelTag ($ this ->getTransactionNestingLevel ()));
88
90
try {
89
- return parent ::executeQuery ($ query , $ params , $ types , $ qcp );
91
+ return parent ::executeQuery ($ sql , $ params , $ types , $ qcp );
90
92
} catch (\Exception $ e ) {
91
93
$ span ->addTag (new DbalErrorCodeTag ($ e ->getCode ()))
92
94
->addTag (new ErrorTag ());
@@ -96,18 +98,18 @@ public function executeQuery($query, array $params = [], $types = [], QueryCache
96
98
}
97
99
}
98
100
99
- public function executeUpdate ($ query , array $ params = [], array $ types = [])
101
+ public function executeUpdate (string $ sql , array $ params = [], array $ types = []): int
100
102
{
101
103
$ span = $ this ->tracer
102
104
->start ('dbal.execute ' )
103
105
->addTag (new DbInstanceTag ($ this ->getDatabase ()))
104
106
->addTag (new DbUser ($ this ->getUsername ()))
105
107
->addTag (new DbType ($ this ->getDatabasePlatform ()->getName ()))
106
108
->addTag (new DbalAutoCommitTag ($ this ->isAutoCommit ()))
107
- ->addTag (new DbStatementTag ($ this ->cutLongSql ($ query )))
109
+ ->addTag (new DbStatementTag ($ this ->cutLongSql ($ sql )))
108
110
->addTag (new DbalNestingLevelTag ($ this ->getTransactionNestingLevel ()));
109
111
try {
110
- return parent ::executeUpdate ($ query , $ params , $ types );
112
+ return parent ::executeUpdate ($ sql , $ params , $ types );
111
113
} catch (\Exception $ e ) {
112
114
$ span ->addTag (new DbalErrorCodeTag ($ e ->getCode ()))
113
115
->addTag (new ErrorTag ());
@@ -117,19 +119,18 @@ public function executeUpdate($query, array $params = [], array $types = [])
117
119
}
118
120
}
119
121
120
- public function query ()
122
+ public function query (string $ sql ): Result
121
123
{
122
- $ args = func_get_args ();
123
124
$ span = $ this ->tracer
124
125
->start ('dbal.query ' )
125
- ->addTag (new DbStatementTag ($ this ->cutLongSql ($ args [ 0 ] )))
126
+ ->addTag (new DbStatementTag ($ this ->cutLongSql ($ sql )))
126
127
->addTag (new DbInstanceTag ($ this ->getDatabase ()))
127
128
->addTag (new DbUser ($ this ->getUsername ()))
128
129
->addTag (new DbType ($ this ->getDatabasePlatform ()->getName ()))
129
130
->addTag (new DbalAutoCommitTag ($ this ->isAutoCommit ()))
130
131
->addTag (new DbalNestingLevelTag ($ this ->getTransactionNestingLevel ()));
131
132
try {
132
- return parent ::query (... $ args );
133
+ return parent ::query ($ sql );
133
134
} catch (\Exception $ e ) {
134
135
$ span ->addTag (new DbalErrorCodeTag ($ e ->getCode ()))
135
136
->addTag (new ErrorTag ());
@@ -139,7 +140,7 @@ public function query()
139
140
}
140
141
}
141
142
142
- public function exec ($ statement )
143
+ public function exec (string $ sql ): int
143
144
{
144
145
$ span = $ this ->tracer
145
146
->start ('dbal.exec ' )
@@ -149,7 +150,7 @@ public function exec($statement)
149
150
->addTag (new DbalAutoCommitTag ($ this ->isAutoCommit ()))
150
151
->addTag (new DbalNestingLevelTag ($ this ->getTransactionNestingLevel ()));
151
152
try {
152
- $ rows = parent ::exec ($ statement );
153
+ $ rows = parent ::exec ($ sql );
153
154
$ span ->addTag (new DbalRowNumberTag ($ rows ));
154
155
155
156
return $ rows ;
@@ -162,7 +163,7 @@ public function exec($statement)
162
163
}
163
164
}
164
165
165
- public function beginTransaction ()
166
+ public function beginTransaction (): bool
166
167
{
167
168
$ span = $ this ->tracer
168
169
->start ('dbal.transaction ' )
@@ -171,7 +172,7 @@ public function beginTransaction()
171
172
->addTag (new DbType ($ this ->getDatabasePlatform ()->getName ()))
172
173
->addTag (new DbalAutoCommitTag ($ this ->isAutoCommit ()));
173
174
try {
174
- parent ::beginTransaction ();
175
+ return parent ::beginTransaction ();
175
176
} catch (\Exception $ e ) {
176
177
$ span ->addTag (new DbalErrorCodeTag ($ e ->getCode ()))
177
178
->addTag (new ErrorTag ());
@@ -181,7 +182,7 @@ public function beginTransaction()
181
182
}
182
183
}
183
184
184
- public function commit ()
185
+ public function commit (): bool
185
186
{
186
187
$ span = $ this ->tracer
187
188
->start ('dbal.commit ' )
@@ -190,7 +191,7 @@ public function commit()
190
191
->addTag (new DbType ($ this ->getDatabasePlatform ()->getName ()))
191
192
->addTag (new DbalAutoCommitTag ($ this ->isAutoCommit ()));
192
193
try {
193
- parent ::commit ();
194
+ return parent ::commit ();
194
195
} catch (\Exception $ e ) {
195
196
$ span ->addTag (new DbalErrorCodeTag ($ e ->getCode ()))
196
197
->addTag (new ErrorTag ());
@@ -200,7 +201,7 @@ public function commit()
200
201
}
201
202
}
202
203
203
- public function rollBack ()
204
+ public function rollBack (): bool
204
205
{
205
206
$ span = $ this ->tracer
206
207
->start ('dbal.rollback ' )
0 commit comments