PHP variable after class name (Class $var)

2729 views php
0

I'm sure there is somewhere an answer to my question, but since I don't know how it's called, it is hard to search for it.

In Laravel, there are methods that look like this:

public function edit(Post $post)
{
    //
}

What does the Post in front of the $post variable do?

Thank in advance!

answered question

2 Answers

10

It's an object type hint definition.

https://phpenthusiast.com/object-oriented-php-tutorials/type-hinting <- There you can find more informations.

posted this

Have an answer?

JD

Please login first before posting an answer.