Open nunomaduro opened 6 years ago
class CountryIsoTypeRepository implements CountryIsoTypeRepositoryContract
{
private $app; // <-- No need for Phpdocs, the constructor is explicit.
public function __construct(ApplicationContract $app)
{
$this->app = $app;
}
class CountryIsoTypeRepository implements CountryIsoTypeRepositoryContract
{
/**
* @var \Fully\Qualified\Namespace\ApplicationContract;
*/
private $app;
public function __construct(ApplicationContract $app)
{
$this->app = $app;
}
I think the second one is more readable as we can have a lot of property on the class so it can be hard to know direclty what is $app
;
This issue addresses the usage of comments/phpdocs.
comments/phpdocs should be avoided as much as possible by writing expressive code.
Don't use docblocks for methods that can be fully type hinted (unless you need a description).
Only add a description when it provides more context than the method/class signature itself. Use full sentences for descriptions, including a period at the end.
Part of this proposal was inspired in https://guidelines.spatie.be/code-style/laravel-php#docblocks
Class or interface headers:
Good:
Good:
Bad:
Methods:
Good:
Good:
Bad:
Bad:
Comments:
Good:
Class attributes:
Good:
Good:
Bad:
I think there is no need of going deeper on this proposal. You get the point. If something is not clear please write on the comments before voting.