Answer the question
In order to leave comments, you need to log in
Why is PHPDoc needed in php-7?
Please tell me why you need to specify the type of the method parameter and the type of what the method returns in phpDoc, if in the seventh version of php in the method itself you can specify the type of parameters and the type of the return value? It's a pointless duplication. Why do they do it?
/**
* Very important function
*
* @param string $param
* @return array
*/
function func(string $param) :array {
}
Answer the question
In order to leave comments, you need to log in
There are scenarios in which a function returns values that cannot be described by a hint. Roughly speaking like this
/**
* @return Product|false
*/
public function getProduct(int $id)
{
// ...
}
You can also add that they are used by static analyzers , as well as various IDEs (for the same static analysis)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question