Phpinspectionsea: Handle intersection types with parentheses

Created on 8 May 2019  路  7Comments  路  Source: kalessil/phpinspectionsea


| Subject | Details |
| :------------- | :---------------------------------------------------------------------------- |
| Plugin | EA Extended v3.0.13 |
| Language level | PHP 7.3 |

Please add support for intersection types with parentheses, so the plugin supports @param (Foo&MockObject)|null in addition to @param Foo&MockObject.

  • Foo&MockObject: the argument is an object of both class Foo and class MockObject
  • (Foo&MockObject)|null: the argument is an object of both class Foo and class MockObject or null

As explained by @ondrejmirtes in https://github.com/phpstan/phpstan/issues/1877, the parentheses are required to disambiguate the annotation. However, neither PhpStorm itself nor the EA Extended plugin understand the syntax:

See https://youtrack.jetbrains.com/issue/WI-45275 for the PhpStorm bug report.

bug / false-positive fixed

Most helpful comment

Checked, I'll enhance type-resolving on our end for mocking support. I also can disable the inspection in test context but will keep t as plan "B".

All 7 comments

Silly question, before I do investigation: will the issue remain with https://plugins.jetbrains.com/plugin/9674-phpunit-enhancement plugin installed?

I am pretty sure the issue will remain.

Ok, I'll check then. Most probably we have to wait for PhpStorm ticket to happen (as we heavily using the type resolver from the IDE).

I think so, too.

Checked, I'll enhance type-resolving on our end for mocking support. I also can disable the inspection in test context but will keep t as plan "B".

Fixed (test-context gets skipped)!

Thank you @kalessil.

Was this page helpful?
0 / 5 - 0 ratings