Sandokan
Sandokan

Reputation: 1105

Missing return statement in PhpStorm

I fall in a strange problem of PhpStorm. I'm using the trial version of 2016.1, I've this method inside my own class:

/**
 * Set arbitrary log
 * @param $level string level of the error message
 * @param $mex string The message
 * @param $ctx array context of the problem
 */

public function log($level, $mex, array $ctx = array())
{
    $mex = $this->Message($level, $mex, $ctx);
    $this->write($mex);
}

Now PhpStorm underlined in green all the php doc with this message:

Missing @return tag in function/method PHPDOC comment

but I missing the @return 'cause I don't need it in this function. I only need to store the information passed as parameter inside another method.

Is a PhpStorm bug or I did wrong something?

Upvotes: 4

Views: 8533

Answers (2)

FullStackEngineer
FullStackEngineer

Reputation: 311

My class method in which it was highlighting the warning "missing @return tag in function/method" was implementing an interface and the PHPDoc for that method in the interface had a "@return mixed".

Now I am not returning anything in my actual method, so I changed PHPDoc in the interface to "@return void". Looks like it fixed the problem.(there is no more warning through the code inspection).

Upvotes: 3

user399666
user399666

Reputation: 19879

For the sake of documentation, you could you use:

@return void

Upvotes: 7

Related Questions