-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The main goal here was to get inference when iterating over a form or fieldset, both for psalm and in yer IDE - this led to fixing a few more psalm issues here and there. There are a couple of additions to the baseline occurring due to improved inference, but it would have been unwise to fix these. Signed-off-by: George Steel <[email protected]>
- Loading branch information
Showing
7 changed files
with
75 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace LaminasTest\Form\StaticAnalysis; | ||
|
||
use Exception; | ||
use Laminas\Form\ElementInterface; | ||
use Laminas\Form\FieldsetInterface; | ||
use Laminas\Form\Form; | ||
|
||
use function array_keys; | ||
use function array_values; | ||
use function iterator_to_array; | ||
|
||
/** @psalm-suppress UnusedClass, UnusedMethod */ | ||
final class FormIterableTypes | ||
{ | ||
public function firstElement(Form $form): ElementInterface | ||
{ | ||
foreach ($form as $element) { | ||
return $element; | ||
} | ||
|
||
throw new Exception('Form is empty'); | ||
} | ||
|
||
/** @return list<ElementInterface> */ | ||
public function elementList(FieldsetInterface $fieldset): array | ||
{ | ||
return array_values(iterator_to_array($fieldset)); | ||
} | ||
|
||
/** @return list<string> */ | ||
public function elementNames(FieldsetInterface $fieldset): array | ||
{ | ||
return array_keys(iterator_to_array($fieldset)); | ||
} | ||
} |