amp icon indicating copy to clipboard operation
amp copied to clipboard

Adding documentation for static analysis tools

Open dantleech opened this issue 6 years ago • 3 comments

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

dantleech avatar Mar 28 '20 07:03 dantleech

See https://github.com/amphp/amp/pull/301

enumag avatar Mar 28 '20 08:03 enumag

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

enumag avatar Mar 28 '20 08:03 enumag

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.

razshare avatar Jun 11 '22 12:06 razshare