Hi,
I’m looking at some source code and dont understand some of the syntax. In the example below what does the “Storage\StorageInterface” section mean?
public function setStorage(Storage\\StorageInterface $storage) {
}
Thanks!
Hi,
I’m looking at some source code and dont understand some of the syntax. In the example below what does the “Storage\StorageInterface” section mean?
public function setStorage(Storage\\StorageInterface $storage) {
}
Thanks!
Storage is a namespace, the slash is a separator, and StorageInterface is likely an Interface defined elsewhere in the system (it is an object).
The string as a whole is placing a constraint on the parameter $storage stating it should be of type StorageInterface which is located in the Storage namespace.
Hope that helps.
Hi Banana Man (your real name’s not Eric, is it?)
Storage\StorageInterface is a type hint, it tells the method setStorage that the parameter $storage must be an object that implements an interface called Storage\StorageInterface.
Sorry, i cant reveal my true identity!
Thanks for the responses. That clarifies it for me.