Skip to content

Add #[\ReturnTypeWillChange] for PHP 8.1 support #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/FakePdoStatementTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ public function rowCount() : int
* @param int $cursor_orientation
* @param int $cursor_offset
*/
#[\ReturnTypeWillChange]
public function fetch(
$fetch_style = -123,
$cursor_orientation = \PDO::FETCH_ORI_NEXT,
Expand Down Expand Up @@ -391,6 +392,7 @@ public function fetch(
* @param int $column
* @return null|scalar
*/
#[\ReturnTypeWillChange]
public function fetchColumn($column = 0)
{
/** @var array<int, scalar>|false $row */
Expand Down
7 changes: 7 additions & 0 deletions src/FakePdoTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public function __construct(string $dsn, string $username = '', string $passwd =
$this->server = Server::getOrCreate('primary');
}

#[\ReturnTypeWillChange]
public function setAttribute($key, $value)
{
if ($key === \PDO::ATTR_EMULATE_PREPARES) {
Expand Down Expand Up @@ -132,6 +133,7 @@ public function useStrictMode() : bool
return $this->strict_mode;
}

#[\ReturnTypeWillChange]
public function beginTransaction()
{
if (Server::hasSnapshot('transaction')) {
Expand All @@ -142,11 +144,13 @@ public function beginTransaction()
return true;
}

#[\ReturnTypeWillChange]
public function commit()
{
return Server::deleteSnapshot('transaction');
}

#[\ReturnTypeWillChange]
public function rollback()
{
if (!Server::hasSnapshot('transaction')) {
Expand All @@ -157,6 +161,7 @@ public function rollback()
return true;
}

#[\ReturnTypeWillChange]
public function inTransaction()
{
return Server::hasSnapshot('transaction');
Expand All @@ -166,6 +171,7 @@ public function inTransaction()
* @param string $statement
* @return int|false
*/
#[\ReturnTypeWillChange]
public function exec($statement)
{
$statement = trim($statement);
Expand All @@ -188,6 +194,7 @@ public function exec($statement)
* @param int $parameter_type
* @return string
*/
#[\ReturnTypeWillChange]
public function quote($string, $parameter_type = \PDO::PARAM_STR)
{
// @see https://github.com/php/php-src/blob/php-8.0.2/ext/mysqlnd/mysqlnd_charset.c#L860-L878
Expand Down
2 changes: 2 additions & 0 deletions src/Php8/FakePdo.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class FakePdo extends PDO implements FakePdoInterface
* @param array $options
* @return FakePdoStatement
*/
#[\ReturnTypeWillChange]
public function prepare($statement, array $options = [])
{
return new FakePdoStatement($this, $statement, $this->real);
Expand All @@ -25,6 +26,7 @@ public function prepare($statement, array $options = [])
* @param mixed ...$fetchModeArgs
* @return FakePdoStatement
*/
#[\ReturnTypeWillChange]
public function query(string $statement, ?int $mode = PDO::ATTR_DEFAULT_FETCH_MODE, mixed ...$fetchModeArgs)
{
$sth = $this->prepare($statement);
Expand Down
2 changes: 2 additions & 0 deletions src/Php8/FakePdoStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class FakePdoStatement extends \PDOStatement
* @param ?array $params
* @return bool
*/
#[\ReturnTypeWillChange]
public function execute(?array $params = null)
{
return $this->universalExecute($params);
Expand Down Expand Up @@ -41,6 +42,7 @@ public function setFetchMode(int $mode, ...$args) : bool
* @param array|null $ctorArgs
* @return false|T
*/
#[\ReturnTypeWillChange]
public function fetchObject(?string $class = \stdClass::class, ?array $ctorArgs = null)
{
return $this->universalFetchObject($class, $ctorArgs);
Expand Down