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

Intersection types vs PhpStorm – who is wrong? #1877

Closed
leofeyer opened this Issue Feb 6, 2019 · 3 comments

Comments

Projects
None yet
2 participants
@leofeyer
Copy link

leofeyer commented Feb 6, 2019

Please see the following code snippet:

use My\Namespace\Foo;
use PHPUnit\Framework\MockObject\MockObject;

/**
 * @param Foo&MockObject|null $foo
 */
private function mockBar($foo = null): Bar
{
}

PhpStan fails with the following message: PHPDoc tag @param has invalid value (Foo&MockObject|null $foo): Unexpected token "|", expected TOKEN_VARIABLE

If I change the phpDoc to

/**
 * @param (Foo&MockObject)|null $foo
 */

PhpStan is happy, however, PhpStorm now says Import 'My\Namespace\Foo' is never used and suggest to delete the use statement.

Now who is wrong here? 😄

@ondrejmirtes

This comment has been minimized.

Copy link
Member

ondrejmirtes commented Feb 6, 2019

@leofeyer

This comment has been minimized.

Copy link
Author

leofeyer commented Feb 6, 2019

Please report the problem in PhpStorm issue tracker.

Will do. Thanks for clarifying.

@leofeyer

This comment has been minimized.

Copy link
Author

leofeyer commented Feb 6, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment