Skip to content

Commit 22be9b9

Browse files
Temporary annotations for PHP 8.1 compatibility (php-debugbar#512)
1 parent 2f5f629 commit 22be9b9

File tree

2 files changed

+44
-27
lines changed

2 files changed

+44
-27
lines changed

src/DebugBar/DataCollector/PDO/TraceablePDO.php

Lines changed: 40 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ public function __construct(PDO $pdo)
2323
$this->pdo->setAttribute(PDO::ATTR_STATEMENT_CLASS, [TraceablePDOStatement::class, [$this]]);
2424
}
2525

26-
/**
27-
* Initiates a transaction
28-
*
29-
* @link http://php.net/manual/en/pdo.begintransaction.php
30-
* @return bool TRUE on success or FALSE on failure.
31-
*/
26+
/**
27+
* Initiates a transaction
28+
*
29+
* @link http://php.net/manual/en/pdo.begintransaction.php
30+
* @return bool TRUE on success or FALSE on failure.
31+
*/
32+
#[\ReturnTypeWillChange]
3233
public function beginTransaction()
3334
{
3435
return $this->pdo->beginTransaction();
@@ -40,6 +41,7 @@ public function beginTransaction()
4041
* @link http://php.net/manual/en/pdo.commit.php
4142
* @return bool TRUE on success or FALSE on failure.
4243
*/
44+
#[\ReturnTypeWillChange]
4345
public function commit()
4446
{
4547
return $this->pdo->commit();
@@ -51,6 +53,7 @@ public function commit()
5153
* @link http://php.net/manual/en/pdo.errorinfo.php
5254
* @return array PDO::errorInfo returns an array of error information
5355
*/
56+
#[\ReturnTypeWillChange]
5457
public function errorCode()
5558
{
5659
return $this->pdo->errorCode();
@@ -62,6 +65,7 @@ public function errorCode()
6265
* @link http://php.net/manual/en/pdo.errorinfo.php
6366
* @return array PDO::errorInfo returns an array of error information
6467
*/
68+
#[\ReturnTypeWillChange]
6569
public function errorInfo()
6670
{
6771
return $this->pdo->errorInfo();
@@ -77,6 +81,7 @@ public function errorInfo()
7781
* return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE.
7882
* Please read the section on Booleans for more information
7983
*/
84+
#[\ReturnTypeWillChange]
8085
public function exec($statement)
8186
{
8287
return $this->profileCall('exec', $statement, func_get_args());
@@ -90,6 +95,7 @@ public function exec($statement)
9095
* @return mixed A successful call returns the value of the requested PDO attribute.
9196
* An unsuccessful call returns null.
9297
*/
98+
#[\ReturnTypeWillChange]
9399
public function getAttribute($attribute)
94100
{
95101
return $this->pdo->getAttribute($attribute);
@@ -101,6 +107,7 @@ public function getAttribute($attribute)
101107
* @link http://php.net/manual/en/pdo.intransaction.php
102108
* @return bool TRUE if a transaction is currently active, and FALSE if not.
103109
*/
110+
#[\ReturnTypeWillChange]
104111
public function inTransaction()
105112
{
106113
return $this->pdo->inTransaction();
@@ -114,37 +121,40 @@ public function inTransaction()
114121
* @return string If a sequence name was not specified for the name parameter, PDO::lastInsertId
115122
* returns a string representing the row ID of the last row that was inserted into the database.
116123
*/
124+
#[\ReturnTypeWillChange]
117125
public function lastInsertId($name = null)
118126
{
119127
return $this->pdo->lastInsertId($name);
120128
}
121129

122-
/**
123-
* Prepares a statement for execution and returns a statement object
124-
*
125-
* @link http://php.net/manual/en/pdo.prepare.php
126-
* @param string $statement This must be a valid SQL statement template for the target DB server.
127-
* @param array $driver_options [optional] This array holds one or more key=>value pairs to
128-
* set attribute values for the PDOStatement object that this method returns.
129-
* @return TraceablePDOStatement|bool If the database server successfully prepares the statement,
130-
* PDO::prepare returns a PDOStatement object. If the database server cannot successfully prepare
131-
* the statement, PDO::prepare returns FALSE or emits PDOException (depending on error handling).
132-
*/
130+
/**
131+
* Prepares a statement for execution and returns a statement object
132+
*
133+
* @link http://php.net/manual/en/pdo.prepare.php
134+
* @param string $statement This must be a valid SQL statement template for the target DB server.
135+
* @param array $driver_options [optional] This array holds one or more key=>value pairs to
136+
* set attribute values for the PDOStatement object that this method returns.
137+
* @return TraceablePDOStatement|bool If the database server successfully prepares the statement,
138+
* PDO::prepare returns a PDOStatement object. If the database server cannot successfully prepare
139+
* the statement, PDO::prepare returns FALSE or emits PDOException (depending on error handling).
140+
*/
141+
#[\ReturnTypeWillChange]
133142
public function prepare($statement, $driver_options = [])
134143
{
135144
return $this->pdo->prepare($statement, $driver_options);
136145
}
137146

138-
/**
139-
* Executes an SQL statement, returning a result set as a PDOStatement object
140-
*
141-
* @link http://php.net/manual/en/pdo.query.php
142-
* @param string $statement
143-
* @param int $fetchMode
144-
* @param mixed ...$fetchModeArgs
145-
* @return TraceablePDOStatement|bool PDO::query returns a PDOStatement object, or FALSE on
146-
* failure.
147-
*/
147+
/**
148+
* Executes an SQL statement, returning a result set as a PDOStatement object
149+
*
150+
* @link http://php.net/manual/en/pdo.query.php
151+
* @param string $statement
152+
* @param int $fetchMode
153+
* @param mixed ...$fetchModeArgs
154+
* @return TraceablePDOStatement|bool PDO::query returns a PDOStatement object, or FALSE on
155+
* failure.
156+
*/
157+
#[\ReturnTypeWillChange]
148158
public function query($statement, $fetchMode = null, ...$fetchModeArgs)
149159
{
150160
return $this->profileCall('query', $statement, func_get_args());
@@ -160,6 +170,7 @@ public function query($statement, $fetchMode = null, ...$fetchModeArgs)
160170
* @return string|bool A quoted string that is theoretically safe to pass into an SQL statement.
161171
* Returns FALSE if the driver does not support quoting in this way.
162172
*/
173+
#[\ReturnTypeWillChange]
163174
public function quote($string, $parameter_type = PDO::PARAM_STR)
164175
{
165176
return $this->pdo->quote($string, $parameter_type);
@@ -171,6 +182,7 @@ public function quote($string, $parameter_type = PDO::PARAM_STR)
171182
* @link http://php.net/manual/en/pdo.rollback.php
172183
* @return bool TRUE on success or FALSE on failure.
173184
*/
185+
#[\ReturnTypeWillChange]
174186
public function rollBack()
175187
{
176188
return $this->pdo->rollBack();
@@ -184,6 +196,7 @@ public function rollBack()
184196
* @param mixed $value
185197
* @return bool TRUE on success or FALSE on failure.
186198
*/
199+
#[\ReturnTypeWillChange]
187200
public function setAttribute($attribute, $value)
188201
{
189202
return $this->pdo->setAttribute($attribute, $value);

src/DebugBar/DataCollector/PDO/TraceablePDOStatement.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ protected function __construct(TraceablePDO $pdo)
3939
* @param mixed $driverdata [optional] Optional parameter(s) for the driver.
4040
* @return bool TRUE on success or FALSE on failure.
4141
*/
42+
#[\ReturnTypeWillChange]
4243
public function bindColumn($column, &$param, $type = null, $maxlen = null, $driverdata = null)
4344
{
4445
$this->boundParameters[$column] = $param;
@@ -61,6 +62,7 @@ public function bindColumn($column, &$param, $type = null, $maxlen = null, $driv
6162
* @param mixed $driver_options [optional]
6263
* @return bool TRUE on success or FALSE on failure.
6364
*/
65+
#[\ReturnTypeWillChange]
6466
public function bindParam($parameter, &$variable, $data_type = PDO::PARAM_STR, $length = null, $driver_options = null)
6567
{
6668
$this->boundParameters[$parameter] = $variable;
@@ -80,6 +82,7 @@ public function bindParam($parameter, &$variable, $data_type = PDO::PARAM_STR, $
8082
* constants.
8183
* @return bool TRUE on success or FALSE on failure.
8284
*/
85+
#[\ReturnTypeWillChange]
8386
public function bindValue($parameter, $value, $data_type = PDO::PARAM_STR)
8487
{
8588
$this->boundParameters[$parameter] = $value;
@@ -96,6 +99,7 @@ public function bindValue($parameter, $value, $data_type = PDO::PARAM_STR)
9699
* @throws PDOException
97100
* @return bool TRUE on success or FALSE on failure.
98101
*/
102+
#[\ReturnTypeWillChange]
99103
public function execute($input_parameters = null)
100104
{
101105
$preparedId = spl_object_hash($this);

0 commit comments

Comments
 (0)