Skip to content

Commit

Permalink
Merge pull request #33 from Usuyuki/php81
Browse files Browse the repository at this point in the history
Add #[\ReturnTypeWillChange] for PHP 8.1 support
  • Loading branch information
muglug authored Jun 30, 2022
2 parents 3be4c68 + a8b60ef commit 3425b60
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
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

0 comments on commit 3425b60

Please sign in to comment.