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

Add parameter type hints to tests #2369

Merged
merged 2 commits into from
Oct 24, 2021
Merged

Conversation

franmomu
Copy link
Contributor

Q A
Type improvement
BC Break no
Fixed issues

Summary

I can split it in several PRs if it's necessary.

@franmomu franmomu added the Task label Sep 14, 2021
@franmomu franmomu force-pushed the add_types_6 branch 2 times, most recently from cc67707 to fba6112 Compare September 14, 2021 07:29
* @dataProvider provideProxiedExprMethods
*/
public function testProxiedExprMethods($method, array $args = []): void
public function testProxiedExprMethods(string $method, $args = []): void
Copy link
Member

Choose a reason for hiding this comment

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

It doesn't look like there is a Closure in use. The previous array type seemed to be fitting. What do I miss?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nothing 😬 , I do missed this because of the name of the function is used in other tests, thanks!

@@ -119,6 +121,9 @@ public function testAtomicCollectionUnset($clearWith): void
$this->assertCount(0, $user->phonenumbers);
}

/**
* @return array<array{array|ArrayCollection|null}>
Copy link
Member

Choose a reason for hiding this comment

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

This looks like an overkill and I myself as a maintainer wouldn't like to write this, let alone contributors. Each array gets passed as arguments to a function that can be typed so I'd argue that's enough. Is there any way of opting out of defining types for data providers?

Copy link
Contributor Author

@franmomu franmomu Sep 21, 2021

Choose a reason for hiding this comment

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

I was trying to add this information to also fix issues with phpcs sniff SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification and fix issues with static analysis tools (phpstan level 6) where you should define the iterable type.

But I understand this may seem overkill, we could do the same here as the return types I guess, keeping the rule and for phpstan we could use something like phpstan/phpstan-phpunit#63 (comment).

Copy link
Member

Choose a reason for hiding this comment

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

That'd be great 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I already removed those phpdoc (I may have left some, I'll check tomorrow)

Copy link
Member

Choose a reason for hiding this comment

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

Awesome, feel free to merge 👍

@IonBazan IonBazan merged commit 7880b86 into doctrine:2.3.x Oct 24, 2021
@franmomu franmomu deleted the add_types_6 branch October 25, 2021 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants