Looking at PHP's documentation about interfaces, specifically here: PHP: Object Interfaces - Manual. The following code is given as a working example. Could someone explain what the bareword 'Baz' being declared as part of the function signature is please?
<?php
interface a
{
public function foo();
}
interface b extends a
{
public function baz(Baz $baz);
}
// This will work
class c implements b
{
public function foo()
{
}
public function baz(Baz $baz)
{
}
}
It is called type hinting.
The baz() method expects the first argument, $baz, to be an object of the type Baz. An object's type comes from either the class that it is built from, or from an interface that it implements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With