Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit 578a3d5

Browse files
committed
Fixes bug caused by inconsistent ArgumentCountError conversion.
1 parent 2b8dbe3 commit 578a3d5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Shim/GetCompatibleExceptionName.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ final public function getCompatibleExceptionName($exceptionName)
4545
} else {
4646
if ($exceptionName === 'ParseError') {
4747
$this->getTestcase()->markTestSkipped('Parse errors can not be caught in PHP5');
48+
} elseif ($exceptionName === 'ArgumentCountError') {
49+
// PHP 7.1 thrown when too few arguments are passed to a user-defined function or method.
50+
$alternative = '\\PHPUnit_Framework_Error_Warning';
51+
52+
$matchingExceptionName = '\\PHPUnit\\Framework\\Error\\Warning';
53+
if (class_exists($matchingExceptionName) === false) {
54+
$matchingExceptionName = $alternative;
55+
}
4856
} else {
4957
$exceptionName = $this->getMatchingExceptionName($exceptionName);
5058

@@ -84,8 +92,6 @@ private function isPhpUnitExceptionNeeded($exceptionName)
8492
private function getMatchingExceptionName($exceptionName)
8593
{
8694
$matchingExceptions = array(
87-
// PHP 7.1 thrown when too few arguments are passed to a user-defined function or method.
88-
'ArgumentCountError' => '\PHPUnit_Framework_Error',
8995
// PHP 7.0 thrown when an assertion made via assert() fails.
9096
'AssertionError' => '\PHPUnit_Framework_Error_Warning',
9197
// PHP 7.0 thrown when an attempt is made to divide a number by zero.

0 commit comments

Comments
 (0)