-1
public function update(?User $user, Post $post)
{
   return $user->id === $post->user_id;
}

In the above function there is a '?' in front of User model type hinting.

What is the use case of this operator in function parameter?

Abdur Rahman
  • 762
  • 6
  • 17
  • Possible duplicate of https://stackoverflow.com/questions/48450739/what-do-the-question-marks-do-before-the-types-of-variables-in-the-parameters – Syscall Mar 05 '20 at 16:26

1 Answers1

1

This means that the argument is also allowed to be null: Nullable Types

Laurens
  • 2,596
  • 11
  • 21