How to document a Laravel model attribute as deprecated?

444 Views Asked by At

I have an eloquent model in Laravel that I would like to mark an user_id attribute as deprecated using the @deprectated tag in PHPDoc.

I can add the @property tag to my model to document user_id but if I try to add the deprecated tag my IDE (vscode) still does not inform me that the attribute is deprecated.

Looking at the documentation I can't see any way of combining both @property and @deprecated.

Does anyone know a way for me to document this correctly?

The model

/**
 * App\Task\Models\Task
 *
 * @property null|int $user_id
 */
final class Task extends Model
{
    protected $guarded = ['id'];

    protected $casts = [
        'user_id' => 'int',
    ];

    protected $fillable = [
        'user_id',
    ];

}

Attempted Code

@property @deprecated null|int $user_id

Versions

  • Laravel: 10
  • PHP: 8.2
  • VSCode: 1.80.2
  • VSCode extension PHP Intelephense: 1.9.5
1

There are 1 best solutions below

1
Abdulla Nilam On BEST ANSWER

These are two different attributes. So you can't declare it in one line.

/**
 * App\Task\Models\Task
 *
 * @property null|int $user_id
 * @deprecated @property null|int $user_id This property will be removed.
 */
final class Task extends Model

}