Skip to content

Commit e4106ea

Browse files
Merge branch 'main' into php8.3
2 parents f2d989a + 06868ad commit e4106ea

File tree

3 files changed

+5
-14
lines changed

3 files changed

+5
-14
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ vendor/
44
.idea/
55
.phpunit.cache/
66
.php-cs-fixer.cache
7+
composer.lock

README.md

+2-12
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,7 @@ E.g. in the example the error is `Can not call method`. No additional informatio
8282

8383
Create a class that extends `ConstantErrorFormatter` and pass the error message to the constructor.
8484

85-
```php
86-
class CallableFromRuleErrorFormatter extends ConstantStringErrorMessageFormatter
87-
{
88-
public function __construct()
89-
{
90-
parent::__construct('Can not call method');
91-
}
92-
}
93-
```
94-
95-
The next step is to update the test to tell it to use this formatter.
85+
Update the test to tell it to use a `ConstantStringErrorMessageFormatter`.
9686

9787
```php
9888
class CallableFromRuleTest extends AbstractRuleTestCase
@@ -102,7 +92,7 @@ class CallableFromRuleTest extends AbstractRuleTestCase
10292

10393
protected function getErrorFormatter(): ErrorMessageFormatter
10494
{
105-
return new CallableFromRuleErrorFormatter();
95+
return new ConstantStringErrorMessageFormatter("Can not call method");
10696
}
10797
}
10898
```

src/ConstantStringErrorMessageFormatter.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
namespace DaveLiddament\PhpstanRuleTestHelper;
66

7-
abstract class ConstantStringErrorMessageFormatter extends ErrorMessageFormatter
7+
class ConstantStringErrorMessageFormatter extends ErrorMessageFormatter
88
{
9-
protected function __construct(
9+
public function __construct(
1010
private string $errorMessage,
1111
) {
1212
}

0 commit comments

Comments
 (0)