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

Adding documentation for static analysis tools #305

Open
dantleech opened this issue Mar 28, 2020 · 3 comments
Open

Adding documentation for static analysis tools #305

dantleech opened this issue Mar 28, 2020 · 3 comments

Comments

@dantleech
Copy link

dantleech commented Mar 28, 2020

Hey,

Has any thought been given to supporting phpstan/psalm generics e.g.

class Foo
{
    /**
     * @return Promise<MyDomainThing>
     */
    public function wait(): Promise { // ... }
}

Otherewise, what's the best way to document a Promise that's compatible with SA tools?

Psalm has some stubs for Amp: https://github.com/vimeo/psalm/blob/master/src/Psalm/Internal/Stubs/Amp.php

@enumag
Copy link
Contributor

enumag commented Mar 28, 2020

See #301

@enumag
Copy link
Contributor

enumag commented Mar 28, 2020

But yeah we might want to apply the rest of the Psalm stubs too.

@dantleech dantleech changed the title How to document Promise types / generics? Adding generic docs for SA tools Mar 28, 2020
@kelunik kelunik changed the title Adding generic docs for SA tools Adding documentation for static analysis tools Apr 15, 2020
@razshare
Copy link

It's been 2 years, but just to be clear you're trying to achieve something like this right? (using psalm)
image

Psalm does it out of the box for me in VSCode, though you may want to disable autocompletion for Intelephense if you're using that plugin, it seems to conflict with psalm when it comes to PHPDocs ontop of duplicating some other autocompletions aswell.

Here's my psalm.xml, I hope it helps:

<?xml version="1.0"?>
<psalm
    errorLevel="7"
    resolveFromConfigFile="true"
    ensureArrayStringOffsetsExist="true"
    ensureArrayIntOffsetsExist="true"
    checkForThrowsInGlobalScope="true"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="https://getpsalm.org/schema/config"
    xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
    <projectFiles>
        <directory name="src" />
        <directory name="tests" />
        <ignoreFiles>
            <directory name="vendor" />
        </ignoreFiles>
    </projectFiles>
</psalm>

ps: I can't seem to get it working in PHPStorm (with psalm) unfortunately.

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

No branches or pull requests

4 participants