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

php - Webix Data Loading from Laravel Link -

libGdx unable to find files in android application data directory -

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