Skip to content

Commit

Permalink
Add missing runtime deprecations related to FC Result API (doctrine#4529
Browse files Browse the repository at this point in the history
  • Loading branch information
beberlei committed Apr 2, 2021
1 parent a7b57b7 commit b63901b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
8 changes: 8 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Note about upgrading: Doctrine uses static and runtime mechanisms to raise
awareness about deprecated code.

- Use of `@deprecated` docblock that is detected by IDEs (like PHPStorm) or
Static Analysis tools (like Psalm, phpstan)
- Use of our low-overhead runtime deprecation API, details:
https://github.com/doctrine/deprecations/

# Upgrade to 2.12

## Deprecated non-zero based positional parameter keys
Expand Down
20 changes: 20 additions & 0 deletions lib/Doctrine/DBAL/ForwardCompatibility/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Exception\NoKeyValue;
use Doctrine\DBAL\Result as BaseResult;
use Doctrine\Deprecations\Deprecation;
use IteratorAggregate;
use PDO;
use Traversable;
Expand Down Expand Up @@ -70,6 +71,12 @@ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
*/
public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/4019',
'Result::fetch() is deprecated, use Result::fetchNumeric(), fetchAssociative() or fetchOne() instead.'
);

return $this->stmt->fetch($fetchMode, $cursorOrientation, $cursorOffset);
}

Expand All @@ -80,6 +87,13 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX
*/
public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/4019',
'Result::fetchAll() is deprecated, use Result::fetchAllNumeric(), fetchAllAssociative() or ' .
'fetchFirstColumn() instead.'
);

return $this->stmt->fetchAll($fetchMode, $fetchArgument, $ctorArgs);
}

Expand All @@ -90,6 +104,12 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n
*/
public function fetchColumn($columnIndex = 0)
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/4019',
'Result::fetchColumn() is deprecated, use Result::fetchOne() instead.'
);

return $this->stmt->fetchColumn($columnIndex);
}

Expand Down

0 comments on commit b63901b

Please sign in to comment.