interface PasswordBrokerContract
{
const PASSWORD_RESET = 'passwords.reset';
public function reset(array $credentials, Closure $callback);
}
class PasswordBroker implements PasswordBrokerContract
{
public function reset(array $credentials, Closure $callback)
{
// implementation
return static::PASSWORD_RESET;
}
}
Does it matter if you use self or static considering that interface constants can't be overridden by a class/interface that inherits them?
It could matter, because even if you can't override interface constants in classes implementing an interface, you can override these constants in classes extending the class that originally implemented the interface:
E.g. the following:
Now this:
would output
passwords.reset.But this:
would output
foobar.But if you didn't use late static binding, and used
self, you'd getpasswords.resetevery time.See it working here.