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

[v2] Intersection types not recognized in docblocks #6

Closed
weierophinney opened this issue Dec 31, 2019 · 6 comments · Fixed by #49
Closed

[v2] Intersection types not recognized in docblocks #6

weierophinney opened this issue Dec 31, 2019 · 6 comments · Fixed by #49
Assignees
Labels
Bug Something isn't working
Milestone

Comments

@weierophinney
Copy link
Member

2.0.0-alpha.3 standard does not recognize and improperly reformats intersect types(&) in phpdoc:

     /**
      * Inject a service into the container mock.
      *
      * Adjust `has('service')` and `get('service')` returns.
      *
-     * @param ContainerInterface&ObjectProphecy $container
+     * @param ContainerInterface &ObjectProphecy $container
      * @param mixed              $service
      */
     protected function injectServiceInContainer(ObjectProphecy $container, string $serviceName, $service) : void
     {
         $container->has($serviceName)->willReturn(true);
         $container->get($serviceName)->willReturn($service);
     }

Intersections types are supported by PhpStorm, phpstan and present in the draft for phpdoc PSR
https://github.com/php-fig/fig-standards/blob/master/proposed/phpdoc.md#details


Originally posted by @Xerkus at zendframework/zend-coding-standard#16

@weierophinney
Copy link
Member Author

For reference, please see: squizlabs/PHP_CodeSniffer#2410


Originally posted by @michalbundyra at zendframework/zend-coding-standard#16 (comment)

@geerteltink
Copy link
Member

There is no sniff for this yet.

@Xerkus
Copy link
Member

Xerkus commented Jan 14, 2020

I would rather classify this as a bug as reformatted intersect types become invalid.

Intersection types are fairly new (eg PhpStorm added support for them in 2018, phpstan in 2017 with 0.9 release, PSR-5 is still in draft however). We won't see them often and when they are used cs ignore rules can be used until support added in upstream

@geerteltink geerteltink added Bug Something isn't working and removed Feature Request labels Mar 17, 2020
@geerteltink
Copy link
Member

Fixed by squizlabs/PHP_CodeSniffer#2919

@geerteltink geerteltink linked a pull request Oct 25, 2020 that will close this issue
@geerteltink geerteltink self-assigned this Oct 25, 2020
@geerteltink geerteltink added this to the 2.1.2 milestone Oct 25, 2020
@geerteltink
Copy link
Member

Fixed in #49

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants