for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Rinvex\Testimonials\Traits;
use Illuminate\Database\Eloquent\Relations\HasMany;
trait HasTestimonials
{
/**
* Register a deleted model event with the dispatcher.
*
* @param \Closure|string $callback
* @return void
*/
abstract public static function deleted($callback);
* Define a one-to-many relationship.
* @param string $related
* @param string $foreignKey
$foreignKey
string|null
This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.
@param
It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.
* @param string $localKey
$localKey
* @return \Illuminate\Database\Eloquent\Relations\HasMany
abstract public function hasMany($related, $foreignKey = null, $localKey = null);
* Boot the HasTestimonials trait for the model.
public static function bootHasTestimonials()
static::deleted(function (self $model) {
$model->testimonials()->delete();
});
}
* Get all attached testimonials to the model.
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
HasMany
This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.
@return
public function testimonials(): HasMany
return $this->hasMany(config('rinvex.testimonials.models.testimonial'), 'user_id', 'id');
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.