Skip to content

Commit 1a2719e

Browse files
Fix issues identified by Psalm
1 parent a31e88a commit 1a2719e

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

.psalm/baseline.xml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,7 @@
469469
</MissingParamType>
470470
</file>
471471
<file src="src/Framework/MockObject/Generator.php">
472-
<ArgumentTypeCoercion occurrences="4">
473-
<code>$className</code>
472+
<ArgumentTypeCoercion occurrences="3">
474473
<code>$className</code>
475474
<code>$className</code>
476475
<code>$interfaceName</code>
@@ -482,9 +481,6 @@
482481
<InvalidReturnType occurrences="1">
483482
<code>MockObject&amp;RealInstanceType</code>
484483
</InvalidReturnType>
485-
<InvalidStringClass occurrences="1">
486-
<code>new $className</code>
487-
</InvalidStringClass>
488484
<MissingParamType occurrences="1">
489485
<code>$type</code>
490486
</MissingParamType>

src/Framework/MockObject/MockClass.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ final class MockClass implements MockType
2323
private $classCode;
2424

2525
/**
26-
* @var string
26+
* @var class-string
2727
*/
2828
private $mockName;
2929

@@ -32,13 +32,19 @@ final class MockClass implements MockType
3232
*/
3333
private $configurableMethods;
3434

35+
/**
36+
* @psalm-param class-string $mockName
37+
*/
3538
public function __construct(string $classCode, string $mockName, array $configurableMethods)
3639
{
3740
$this->classCode = $classCode;
3841
$this->mockName = $mockName;
3942
$this->configurableMethods = $configurableMethods;
4043
}
4144

45+
/**
46+
* @psalm-return class-string
47+
*/
4248
public function generate(): string
4349
{
4450
if (!class_exists($this->mockName, false)) {

src/Framework/MockObject/MockTrait.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,22 @@ final class MockTrait implements MockType
2222
private $classCode;
2323

2424
/**
25-
* @var string
25+
* @var class-string
2626
*/
2727
private $mockName;
2828

29+
/**
30+
* @psalm-param class-string $mockName
31+
*/
2932
public function __construct(string $classCode, string $mockName)
3033
{
3134
$this->classCode = $classCode;
3235
$this->mockName = $mockName;
3336
}
3437

38+
/**
39+
* @psalm-return class-string
40+
*/
3541
public function generate(): string
3642
{
3743
if (!class_exists($this->mockName, false)) {

src/Framework/MockObject/MockType.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,8 @@
1414
*/
1515
interface MockType
1616
{
17+
/**
18+
* @psalm-return class-string
19+
*/
1720
public function generate(): string;
1821
}

0 commit comments

Comments
 (0)