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

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -