I know about LSP and why the following code gives:
PHP Fatal error: declaration UnauthenticatedUser :: executeCommand (UnauthenticatedCommand $ c) must be compatible with User :: executeCommand (command $ c) in the file /tmp/test.php on line 13
However, I would say that the two interfaces Commandand UnauthenticatedCommandare equivalent (since they are the only marker interface).
Given these facts, what would be a pure approach [1] to make it impossible for a user who has not passed verification to do anything else UnauthenticatedCommand?
<?php
interface Command {
}
interface UnauthenticatedCommand extends Command {
}
interface User {
public function executeCommand(Command $c);
}
class UnauthenticatedUser implements User {
public function executeCommand(UnauthenticatedCommand $c) {
}
}
[1] pure meaning, not using introspection, neither programmatically nor with engine support ( instanceof).
source
share