Skip to content

Commit 90ca485

Browse files
committed
Fixed phpstan error
1 parent 12691a4 commit 90ca485

11 files changed

+33
-29
lines changed

src/Constraint/Builder/BuilderProducesCodeThat.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ final class BuilderProducesCodeThat extends UnaryOperator
1414
{
1515
public function __construct(
1616
private readonly string $builderCompilePath,
17-
$constraint,
17+
mixed $constraint,
1818
) {
1919
parent::__construct($constraint);
2020
}

src/Constraint/Pipeline/IteratesLike.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ private function asIterator(iterable $iterable): \Iterator
3737
return new \IteratorIterator($iterable);
3838
}
3939

40-
public function matches($other): bool
40+
public function matches(mixed $other): bool
4141
{
4242
$both = new \MultipleIterator(\MultipleIterator::MIT_NEED_ANY);
4343

@@ -54,7 +54,7 @@ public function matches($other): bool
5454
return !$iterator->valid();
5555
}
5656

57-
protected function failureDescription($other): string
57+
protected function failureDescription(mixed $other): string
5858
{
5959
return sprintf(
6060
'%s iterates like %s',

src/Constraint/Pipeline/PipelineExtractsLike.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ private function passThroughCoroutine(): \Generator
5050
}
5151
}
5252

53-
public function matches($other): bool
53+
public function matches(mixed $other): bool
5454
{
5555
$both = new \MultipleIterator(\MultipleIterator::MIT_NEED_ANY);
5656

@@ -82,7 +82,7 @@ public function matches($other): bool
8282
return !$iterator->valid();
8383
}
8484

85-
protected function failureDescription($other): string
85+
protected function failureDescription(mixed $other): string
8686
{
8787
return sprintf(
8888
'%s pipeline extracts like %s',

src/Constraint/Pipeline/PipelineLoadsLike.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ private function asIterator(iterable $iterable): \Iterator
4747
return new \IteratorIterator($iterable);
4848
}
4949

50-
public function matches($other): bool
50+
public function matches(mixed $other): bool
5151
{
5252
$both = new \MultipleIterator(\MultipleIterator::MIT_NEED_ANY);
5353

@@ -102,7 +102,7 @@ public function matches($other): bool
102102
return !$iterator->valid();
103103
}
104104

105-
protected function failureDescription($other): string
105+
protected function failureDescription(mixed $other): string
106106
{
107107
return sprintf(
108108
'%s pipeline loads like %s',

src/Constraint/Pipeline/PipelineTransformsLike.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ private function asIterator(iterable $iterable): \Iterator
4747
return new \IteratorIterator($iterable);
4848
}
4949

50-
public function matches($other): bool
50+
public function matches(mixed $other): bool
5151
{
5252
$both = new \MultipleIterator(\MultipleIterator::MIT_NEED_ANY);
5353

@@ -102,7 +102,7 @@ public function matches($other): bool
102102
return !$iterator->valid();
103103
}
104104

105-
protected function failureDescription($other): string
105+
protected function failureDescription(mixed $other): string
106106
{
107107
return sprintf(
108108
'%s pipeline transforms like %s',

src/Constraint/Pipeline/PipelineWritesFile.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ private function asIterator(iterable $iterable): \Iterator
4141
return new \IteratorIterator($iterable);
4242
}
4343

44-
public function matches($other): bool
44+
public function matches(mixed $other): bool
4545
{
4646
if (!$other instanceof LoaderInterface) {
4747
$this->fail($other, strtr('Expected an instance of %expected%, but got %actual%.', [
@@ -81,15 +81,13 @@ public function matches($other): bool
8181
);
8282
}
8383

84-
iterator_count($iterator);
85-
8684
$constraint = new FileExists();
8785
$constraint->evaluate($this->expected);
8886

8987
return !$iterator->valid();
9088
}
9189

92-
protected function failureDescription($other): string
90+
protected function failureDescription(mixed $other): string
9391
{
9492
return sprintf(
9593
'%s pipeline writes file %s',

src/Mock/ApiClientMockBuilder.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ final class ApiClientMockBuilder implements Builder
1414
{
1515
private Node\Expr $node;
1616

17+
/** @param array<Node\Arg|Node\VariadicPlaceholder> $mockedArgs */
1718
public function __construct(
1819
private readonly string $mockedClientBuilder,
1920
private readonly ?array $mockedArgs = []

src/Mock/ExceptionBuilder.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,15 @@ public function __construct(
1919
$this->arguments = $arguments;
2020
}
2121

22-
public function getNode(): Node
22+
public function getNode(): Node\Expr
2323
{
2424
return new Node\Expr\New_(
2525
class: new Node\Name\FullyQualified($this->class),
26-
args: [
27-
array_map(
28-
fn (Node\Expr $value, int|string $key) => !\is_string($key) ? new Node\Arg(value: $value) : new Node\Arg(value: $value, name: new Node\Identifier($key)),
29-
$this->arguments,
30-
array_keys($this->arguments),
31-
),
32-
]
26+
args: array_map(
27+
fn (Node\Expr $value, int|string $key) => !\is_string($key) ? new Node\Arg(value: $value) : new Node\Arg(value: $value, name: new Node\Identifier($key)),
28+
$this->arguments,
29+
array_keys($this->arguments),
30+
),
3331
);
3432
}
3533
}

src/Mock/RequestMatcher/RequestMatcherBuilder.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@
77
use Http\Message\RequestMatcher;
88
use PhpParser\Node;
99

10-
final class RequestMatcherBuilder implements RequestMatcherBuilderInterface
10+
final readonly class RequestMatcherBuilder implements RequestMatcherBuilderInterface
1111
{
12+
/**
13+
* @param list<string> $methods
14+
* @param list<string> $schemes
15+
*/
1216
public function __construct(
13-
private readonly ?string $path = null,
14-
private readonly ?string $host = null,
15-
private $methods = [],
16-
private $schemes = []
17+
private ?string $path = null,
18+
private ?string $host = null,
19+
private array $methods = [],
20+
private array $schemes = []
1721
) {}
1822

19-
public function getNode(): Node
23+
public function getNode(): Node\Expr
2024
{
2125
return new Node\Expr\New_(
2226
class: new Node\Name\FullyQualified(RequestMatcher::class),

src/Mock/RequestMatcher/RequestMatcherBuilderInterface.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@
55
namespace Kiboko\Component\PHPUnitExtension\Mock\RequestMatcher;
66

77
use PhpParser\Builder;
8+
use PhpParser\Node;
89

9-
interface RequestMatcherBuilderInterface extends Builder {}
10+
interface RequestMatcherBuilderInterface extends Builder {
11+
public function getNode(): Node\Expr;
12+
}

src/Mock/ResponseBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public function __construct(
1313
private string $path,
1414
) {}
1515

16-
public function getNode(): Node
16+
public function getNode(): Node\Expr
1717
{
1818
return new Node\Expr\Include_(new Node\Scalar\String_($this->path), Node\Expr\Include_::TYPE_INCLUDE);
1919
}

0 commit comments

Comments
 (0)