Skip to content

Commit

Permalink
Closes #4297
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Jul 20, 2020
1 parent 0af9fbf commit b3881ca
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions ChangeLog-9.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ Here is a detailed list of changes for the configuration of code coverage and lo

### Removed

* [#4297](https://github.com/sebastianbergmann/phpunit/issues/4297): Deprecate `at()` matcher
* The `cacheTokens` attribute is no longer supported in XML configuration files

[9.3.0]: https://github.com/sebastianbergmann/phpunit/compare/9.2...master
3 changes: 3 additions & 0 deletions src/Framework/MockObject/Rule/InvokedAtIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

/**
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/4297
* @codeCoverageIgnore
*/
final class InvokedAtIndex extends InvocationOrder
{
Expand Down
19 changes: 19 additions & 0 deletions src/Framework/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use function array_flip;
use function array_keys;
use function array_merge;
use function array_pop;
use function array_search;
use function array_unique;
use function array_values;
Expand All @@ -32,6 +33,7 @@
use function class_exists;
use function clearstatcache;
use function count;
use function debug_backtrace;
use function defined;
use function explode;
use function get_class;
Expand Down Expand Up @@ -410,9 +412,26 @@ public static function atMost(int $allowedInvocations): InvokedAtMostCountMatche
/**
* Returns a matcher that matches when the method is executed
* at the given index.
*
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/4297
* @codeCoverageIgnore
*/
public static function at(int $index): InvokedAtIndexMatcher
{
$stack = debug_backtrace();

while (!empty($stack)) {
$frame = array_pop($stack);

if (isset($frame['object']) && $frame['object'] instanceof self) {
$frame['object']->addWarning(
'The at() matcher has been deprecated. It will be removed in PHPUnit 10. Please refactor your test to not rely on the order in which methods are invoked.'
);

break;
}
}

return new InvokedAtIndexMatcher($index);
}

Expand Down

0 comments on commit b3881ca

Please sign in to comment.