php - Why there is a class name before the argument name in a function declaration? -


i have seen in mvc frameworks.

class hotel{  function add(addrequest $post){ $this->save($post->all()); }  } 

here "addrequest" class has been inherited.i dont quiet idea of it.all knew binds/validates arguments has been passed function before being used in function.anyone can explain well? how "addrequest" being implemented in code?

this type declaration (formerly known type hinting). function reject $post passed function that's not of addrequest type.

if you're not explicitly injecting yourself, chances framework using reflection automatically determine , inject required dependency. example, laravel uses extensively in version 5.


Comments

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -