Many of laravel constructors have @return void in their PHPDoc.
Example:
https://github.com/laravel/framework/blob/5.2/src/Illuminate/Database/Eloquent/Model.php#L273
It's incorrect because constructors return objects of self type.
Documentation:
https://phpdoc.org/docs/latest/references/phpdoc/tags/return.html
It is RECOMMENDED when documenting to use this tag with every function and method. Exceptions to this recommendation are:
constructors, the @return tag MAY be omitted here, in which case @return self is implied.
We should omit @return void in constructors or replace them with @return self.
phpdoc.org is incorrect
My 2 cents:
@return self does not make sense, the constructor does not return anything.
@return void could make sense, but PHP 7.1 does not think so:
class Foo {
public function __construct() : void {}
}
Fatal error: Constructor Foo::__construct() cannot declare a return type
For what it's worth, I think that __construct() is the only exception where @return should be omitted.
Most helpful comment
phpdoc.org is incorrect