Going over The SplSubject interface on the php manual site and noticed.
SplSubject {
/* Methods */
abstract public void attach ( SplObserver $observer )
abstract public void detach ( SplObserver $observer )
abstract public void notify ( void )
}
I can't figure out what the key word "abstract" does in the code or why it is there. Also never seen/used a function return type in php (Such as void)?
Thank you
The interface declaration you've seen there is pseudo code. Meaning it is not meant to be executable PHP code.
They have added the type info for the obvious reason of showing the expected return type of the method.
Don't ask me why they have chosen to explicitly add the
abstract
keyword. Normally every method declared in an interface is "abstract". Probably they wanted to emphasize that.