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

Multiline array documentation phpdoc support #2497

Closed
simPod opened this issue Oct 10, 2019 · 4 comments
Closed

Multiline array documentation phpdoc support #2497

simPod opened this issue Oct 10, 2019 · 4 comments

Comments

@simPod
Copy link
Contributor

simPod commented Oct 10, 2019

Multiline array structure documentation is currently not possible but seems handy for wide arrays.

<?php

declare(strict_types=1);

final class A
{
    /**
     * @param array{
     *   a: string,
     *   b: int
     *   } $result
     */
    public function aaa(array $result) : void
    {
    }
}

PHPDoc tag @param has invalid value (array{
a: string,
b: int): Unexpected token "\n *", expected TOKEN_IDENTIFIER at offset 24 |

https://phpstan.org/r/7e3b0b6d-e264-4f31-b70c-1beefac23a8b

Not sure whether phpstan thing though.

@ondrejmirtes
Copy link
Member

@JanTvrdik, who is the author of the brilliant phpdoc-parser, does not find this feasible.

@muglug
Copy link
Contributor

muglug commented Oct 11, 2019

I'm not sure why it's not feasible — Psalm does it without incident. As Ondrej has pointed out, it's less efficient to use arrays instead of objects, but that's a separate issue.

@simPod
Copy link
Contributor Author

simPod commented Oct 11, 2019

@muglug yup, I'm receiving array from JSON RPC API and converting it to object, but I was thinking documenting its shape would be good idea 🤔

The problem with single line shape documentation is that it fits to 2 4K screens minimum and new issues arise (like IDE tries to wrap it to multiple lines when autoformatting, violation of max line length sniff etc.)

@ondrejmirtes maybe we can move this issue to phpdoc-parser repo, did not know it existed at the time of creating this.

@ondrejmirtes
Copy link
Member

Implemented: phpstan/phpdoc-parser#33

@lock lock bot locked as resolved and limited conversation to collaborators Dec 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants