Skip to content

Commit 930f96d

Browse files
committed
Simplify failure description returned by PHPMatcherConstraint
1 parent 8d08946 commit 930f96d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/PHPUnit/PHPMatcherConstraint.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Coduo\PHPMatcher\PHPUnit;
66

77
use Coduo\PHPMatcher\Backtrace;
8+
use Coduo\PHPMatcher\Backtrace\VoidBacktrace;
89
use Coduo\PHPMatcher\PHPMatcher;
910
use PHPUnit\Framework\Constraint\Constraint;
1011
use PHPUnit\Util\Json;
@@ -42,10 +43,12 @@ public function toString() : string
4243

4344
protected function failureDescription($other) : string
4445
{
45-
return parent::failureDescription($other)
46-
. "\nPattern: " . $this->exporter()->export($this->pattern)
47-
. "\nError: " . $this->matcher->error()
48-
. "\nBacktrace: \n" . $this->matcher->backtrace();
46+
$backtrace = $this->matcher->backtrace();
47+
48+
return $backtrace instanceof VoidBacktrace
49+
? $this->matcher->error()
50+
: $this->matcher->error()
51+
. "\nBacktrace: \n" . $this->matcher->backtrace();
4952
}
5053

5154
protected function matches($value) : bool

0 commit comments

Comments
 (0)