Skip to content

Commit

Permalink
Clarify psalm types in Result (#668)
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik committed Mar 7, 2024
1 parent 150eb8a commit 8c1bc60
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 1.3.0 under development

- New #665: Add methods `addErrorWithFormatOnly()` and `addErrorWithoutPostProcessing()` to `Result` object (@vjik)
- Enh #668: Clarify psalm types in `Result` (@vjik)

## 1.2.0 February 21, 2024

Expand Down
5 changes: 4 additions & 1 deletion composer-require-checker.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"symbol-whitelist": [
"Yiisoft\\Yii\\Debug\\Collector\\CollectorTrait",
"Yiisoft\\Yii\\Debug\\Collector\\SummaryCollectorInterface"
"Yiisoft\\Yii\\Debug\\Collector\\SummaryCollectorInterface",
"JetBrains\\PhpStorm\\ArrayShape",
"JetBrains\\PhpStorm\\ExpectedValues",
"JetBrains\\PhpStorm\\Language"
],
"php-core-extensions": [
"Core",
Expand Down
9 changes: 9 additions & 0 deletions src/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ final class Result
{
/**
* @var Error[] Validation errors.
* @psalm-var list<Error>
*/
private array $errors = [];

Expand Down Expand Up @@ -51,6 +52,7 @@ public function isAttributeValid(string $attribute): bool

/**
* @return Error[] Validation errors.
* @psalm-return list<Error>
*/
public function getErrors(): array
{
Expand All @@ -61,6 +63,7 @@ public function getErrors(): array
* Get errors messages as an array of strings.
*
* @return string[] Array messages as strings.
* @psalm-return list<string>
*/
public function getErrorMessages(): array
{
Expand Down Expand Up @@ -121,6 +124,8 @@ public function getErrorMessagesIndexedByAttribute(): array
* @param string $attribute Attribute name.
*
* @return Error[] Array of error objects.
*
* @psalm-return list<Error>
*/
public function getAttributeErrors(string $attribute): array
{
Expand All @@ -139,6 +144,8 @@ public function getAttributeErrors(string $attribute): array
* Get an array of error messages for the attribute specified.
*
* @return string[] Error messages.
*
* @psalm-return list<string>
*/
public function getAttributeErrorMessages(string $attribute): array
{
Expand Down Expand Up @@ -190,6 +197,8 @@ public function getAttributeErrorMessagesIndexedByPath(
* Get common error messages that are not attached to any attribute.
*
* @return string[] Error messages.
*
* @psalm-return list<string>
*/
public function getCommonErrorMessages(): array
{
Expand Down

0 comments on commit 8c1bc60

Please sign in to comment.