phpstormphpcs

PHP Code Sniffer shows warning in PhpStorm but not in CLI


I have a little function in a class:

/**
 * @return float|int
 */
private function getPrice()
{
    return rand(1000, 1000000) / 10;
}

In PhpStorm I am getting a warning by phpcs.

Missing function's return type declaration

But when I am running the phpcs from command line by:

phpcs --standard=PSR12 ./

I am getting no error message about this return type.

I've tried to search it in ruleset, but there is only a comment about this:

<!-- When you have a return type declaration present, there MUST be one space after the colon followed by the type declaration. The colon and declaration MUST be on the same line as the argument list cl
<!-- checked by PSR12.Functions.ReturnTypeDeclaration -->

But I did not see any rule for this.

Can somebody help me, how can I turn it on from the ruleset.xml or from command line?


Solution

  • Missing function's return type declaration is a PhpStorm inspection; it doesn't come from PHP_CodeSniffer, which doesn't have this feature yet.