Skip to content

Commit 8adee52

Browse files
authored
Improve psalm annotations in Result class (#636)
1 parent 010ac44 commit 8adee52

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- Chg #625: Improve meaning and use pluralization in error message for `OneOf` and `AtLeast` rules (@arogachev)
1414
- Chg #626: Disallow `$min` greater than amount of `$attributes` in `AtLeast` configuration (@arogachev)
1515
- Bug #632: Fix property name usage in error messages of rules in `Nested` rule (@vjik)
16+
- Enh #636: Improve psalm annotations in `Result` class (@vjik)
1617

1718
## 1.1.0 April 06, 2023
1819

src/Result.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ final class Result
1717
{
1818
/**
1919
* @var Error[] Validation errors.
20+
* @psalm-var list<Error>
2021
*/
2122
private array $errors = [];
2223

@@ -61,6 +62,8 @@ public function getErrors(): array
6162
* Get errors messages as an array of strings.
6263
*
6364
* @return string[] Array messages as strings.
65+
*
66+
* @psalm-return list<string>
6467
*/
6568
public function getErrorMessages(): array
6669
{
@@ -121,6 +124,8 @@ public function getErrorMessagesIndexedByAttribute(): array
121124
* @param string $attribute Attribute name.
122125
*
123126
* @return Error[] Array of error objects.
127+
*
128+
* @psalm-return list<Error>
124129
*/
125130
public function getAttributeErrors(string $attribute): array
126131
{
@@ -139,6 +144,8 @@ public function getAttributeErrors(string $attribute): array
139144
* Get an array of error messages for the attribute specified.
140145
*
141146
* @return string[] Error messages.
147+
*
148+
* @psalm-return list<string>
142149
*/
143150
public function getAttributeErrorMessages(string $attribute): array
144151
{
@@ -190,6 +197,8 @@ public function getAttributeErrorMessagesIndexedByPath(
190197
* Get common error messages that are not attached to any attribute.
191198
*
192199
* @return string[] Error messages.
200+
*
201+
* @psalm-return list<string>
193202
*/
194203
public function getCommonErrorMessages(): array
195204
{

0 commit comments

Comments
 (0)