Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General type inference improvements #246

Merged
merged 1 commit into from
Nov 20, 2023

Conversation

gsteel
Copy link
Member

@gsteel gsteel commented Nov 19, 2023

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.

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]>
Comment on lines -304 to +309
if (
empty($messageSet)
|| (! is_array($messageSet) && ! $messageSet instanceof Traversable)
) {
if ($messageSet === []) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ElementInterface::getMessages() has a native array return type

@@ -203,13 +207,14 @@ public function has(string $elementOrFieldset): bool
*/
public function get(string $elementOrFieldset): ElementInterface
{
if (! $this->has($elementOrFieldset)) {
$element = $this->iterator->get($elementOrFieldset);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this behaviour change safe to perform? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it is:

public function has(string $elementOrFieldset): bool
{
return $this->iterator->get($elementOrFieldset) !== null;
}

@@ -203,13 +207,14 @@ public function has(string $elementOrFieldset): bool
*/
public function get(string $elementOrFieldset): ElementInterface
{
if (! $this->has($elementOrFieldset)) {
$element = $this->iterator->get($elementOrFieldset);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it is:

public function has(string $elementOrFieldset): bool
{
return $this->iterator->get($elementOrFieldset) !== null;
}

@Slamdunk Slamdunk self-assigned this Nov 20, 2023
@Slamdunk Slamdunk added this to the 3.16.0 milestone Nov 20, 2023
@Slamdunk Slamdunk merged commit dc899f6 into laminas:3.16.x Nov 20, 2023
11 checks passed
@gsteel gsteel deleted the iterable-type-inference branch November 20, 2023 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants