G
G
Gleb Vas2018-03-17 20:29:24
PHP
Gleb Vas, 2018-03-17 20:29:24

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

2 answer(s)
D
DevMan, 2018-03-17
@glebvvvsss

That's right: only an object of the specified class can be an argument.
php.net/manual/en/functions.arguments.php#function...

P
Paul Denisevich, 2018-03-18
@deniamnet

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 question

Ask a Question

731 491 924 answers to any question