Automatically adding return types to methods and functions

1.6k Views Asked by At

Is there an option to automatically add return types, or at least all me to generate them?

What I want is my methods before PhpStorm generates the return types:

function isValid() 
{
    return true;
}

After

function isValid(): bool
{
    return true;
}

Is this possible?

1

There are 1 best solutions below

0
Martin On BEST ANSWER

This issue was already answered at: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000163824-Automatically-add-return-type-declarations-

By someone whose profile picture looks like that of LazyOne. ;-)

Their answer (quoted and link added) is:

... If you are talking about adding ": QueryBuilder" declaration for PHP 7.x -- the "Php Inspections (EA Extended)" plugin has such intentions/quick fixes; not sure if PhpStorm has the same/similar out of the box.