Skip to content

Commit

Permalink
Merge branch 'main' into php8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveLiddament authored Dec 10, 2023
2 parents f2d989a + 06868ad commit e4106ea
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ vendor/
.idea/
.phpunit.cache/
.php-cs-fixer.cache
composer.lock
14 changes: 2 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,7 @@ E.g. in the example the error is `Can not call method`. No additional informatio

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

```php
class CallableFromRuleErrorFormatter extends ConstantStringErrorMessageFormatter
{
public function __construct()
{
parent::__construct('Can not call method');
}
}
```

The next step is to update the test to tell it to use this formatter.
Update the test to tell it to use a `ConstantStringErrorMessageFormatter`.

```php
class CallableFromRuleTest extends AbstractRuleTestCase
Expand All @@ -102,7 +92,7 @@ class CallableFromRuleTest extends AbstractRuleTestCase

protected function getErrorFormatter(): ErrorMessageFormatter
{
return new CallableFromRuleErrorFormatter();
return new ConstantStringErrorMessageFormatter("Can not call method");
}
}
```
Expand Down
4 changes: 2 additions & 2 deletions src/ConstantStringErrorMessageFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace DaveLiddament\PhpstanRuleTestHelper;

abstract class ConstantStringErrorMessageFormatter extends ErrorMessageFormatter
class ConstantStringErrorMessageFormatter extends ErrorMessageFormatter
{
protected function __construct(
public function __construct(
private string $errorMessage,
) {
}
Expand Down

0 comments on commit e4106ea

Please sign in to comment.