L
L
l4m3r2018-09-24 20:46:45
PHP
l4m3r, 2018-09-24 20:46:45

Full or partial documentation?

Is it necessary, in a good way, to document the obvious things:

/**
  * Order model.
  * 
  * @property Car $car
  */
class Order {

  /**
     *
     * Get the car record associated with the order. 
     *
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function car()
    {
        return $this->hasOne('App\Models\Car');
    }

Or you can ignore:
/**
  * @property Car $car
  */
class Order {
  /*
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function car()
    {
        return $this->hasOne('App\Models\Car');
    }

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
DevMan, 2018-09-24
@l4m3r

it makes sense to fill in if documentation is generated for these blocks later.
if the dockblock is purely for yourself, then you can omit it.

S
Saboteur, 2018-09-24
@saboteur_kiev

I would instead
// * Get the car record associated with the order.
the name of the function would be renamed to get_car or get_car_record

G
grinat, 2018-09-24
@grinat

The main problem with annotations in weakly typed languages ​​is:
/**
* function which return dog
*/
getDog () {
return new Dog()
}
A year later:
/**
* function which return dog
*/
getDog () {
if ($this ->temperatureInZimbabve > 30 && $this->isHuman) {
$human = new Elepant()
$human->isLeopard = $this->getAnimalType(true, false)
return $human
}
return new Beer()
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question