0

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?

LazyOne
  • 158,824
  • 45
  • 388
  • 391
vaso123
  • 12,347
  • 4
  • 34
  • 64

1 Answers1

0

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

Eugene Morozov
  • 2,790
  • 1
  • 10
  • 17
  • So, then where this is come from? PHPStorm PSR12 settings, or php-cs-fixer? Does PHP Cs fixer gaves wantings? – vaso123 Feb 21 '23 at 12:21
  • 1
    You can find the inspection in PhpStorm at `Settings | Editor | Inspections PHP | Type compatibility | Missing return type declaration` – Eugene Morozov Feb 24 '23 at 14:09