Answer the question
In order to leave comments, you need to log in
What does this expression mean?
public function method(Subject $subject) {
//do something
}
I can't figure out what the expression in the argument brackets means. Before I thought that it could be some kind of typing like in java, but apparently this is not so. I tried to enter this design into Google, but it did not work. It would be useful to at least know the name of this language construct, so that at least he knows what to google to get at least some useful information from the search.
Answer the question
In order to leave comments, you need to log in
That's right: only an object of the specified class can be an argument.
php.net/manual/en/functions.arguments.php#function...
PHP type hinting. In other words, the value passed to the function can only be of the Subject type, in this case an object/instance of the Subject class.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question