-
-
Save mindplay-dk/e988902ed2d587dc05a1d8cb164b88c4 to your computer and use it in GitHub Desktop.
hello
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
interface Identity { | |
public function getID(): string; | |
} | |
class User implements Identity { | |
public function getID(): string { | |
return "3a85dea1-061a-4296-9fe5-514ade8ee969"; | |
} | |
} | |
interface Repository { | |
public function save(Identity $item); | |
} | |
class UserRepository implements Repository { | |
public function save($item) { # accidental type-hint omission - succeeds | |
// ... | |
} | |
} | |
$user = new User(); | |
$repo = new UserRepository(); | |
$repo->save(new stdClass()); // call succeeds - failure (hopefully) occurs deep in some other code? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment