Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
parameters:
ignoreErrors:
-
message: '#^Parameter \#1 \$value of function strval expects bool\|float\|int\|resource\|string\|null, mixed given\.$#'
message: '#^Parameter \#1 \$value of function strval expects bool\|float\|GMP\|int\|resource\|string\|null, mixed given\.$#'
identifier: argument.type
count: 2
path: src/Prophecy/Argument/Token/ExactValueToken.php

-
message: '#^Parameter \#2 \$array of function implode expects array\<string\>, array\<mixed\> given\.$#'
identifier: argument.type
count: 1
path: src/Prophecy/Argument/Token/InArrayToken.php

-
message: '#^Parameter \#2 \$array of function implode expects array\<string\>, array\<mixed\> given\.$#'
identifier: argument.type
count: 1
path: src/Prophecy/Argument/Token/NotInArrayToken.php

-
message: '#^Method Prophecy\\Doubler\\CachedDoubler\:\:createDoubleClass\(\) should return class\-string\<Prophecy\\Doubler\\DoubleInterface&T of object\> but returns class\-string\.$#'
identifier: return.type
Expand Down Expand Up @@ -48,6 +60,12 @@ parameters:
count: 1
path: src/Prophecy/Doubler/LazyDouble.php

-
message: '#^Property Prophecy\\Doubler\\LazyDouble\:\:\$class \(ReflectionClass\<T of object\>\|null\) is never assigned ReflectionClass\<T of object\> so it can be removed from the property type\.$#'
identifier: property.unusedType
count: 1
path: src/Prophecy/Doubler/LazyDouble.php

-
message: '#^Call to function method_exists\(\) with ReflectionMethod and ''hasTentativeReturnT…'' will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
Expand Down
3 changes: 2 additions & 1 deletion spec/Prophecy/Comparator/ClosureComparatorSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ function it_accepts_only_closures()

function it_asserts_that_different_closures_are_different()
{
$this->shouldThrow()->duringAssertEquals(function () {}, function () {});
$this->shouldThrow(new \SebastianBergmann\Comparator\ComparisonFailure(null, null, '', '', 'all closures are different if not identical'))
->duringAssertEquals(function () {}, function () {});
}

function it_asserts_that_closures_are_equal_if_its_the_same_closure()
Expand Down
7 changes: 5 additions & 2 deletions src/Prophecy/Comparator/ClosureComparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ public function accepts($expected, $actual): bool
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false): void
{
if ($expected !== $actual) {
// Support for sebastian/comparator < 5
if ((new \ReflectionMethod(ComparisonFailure::class, '__construct'))->getNumberOfParameters() >= 6) {
// sebastian/comparator < 5 has a 6-param constructor with $identical (bool) as 5th param,
// while >= 8 also has 6 params but with $contextLines (int) as 6th param.
// Checking the parameter name avoids passing wrong types to the wrong signature.
$r = new \ReflectionMethod(ComparisonFailure::class, '__construct');
if ($r->getNumberOfParameters() >= 6 && $r->getParameters()[4]->getName() === 'identical') {
// @phpstan-ignore-next-line
throw new ComparisonFailure($expected, $actual, '', '', false, 'all closures are different if not identical');
}
Expand Down