Skip to content

Instantly share code, notes, and snippets.

@mindplay-dk
Last active May 28, 2017 13:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mindplay-dk/e988902ed2d587dc05a1d8cb164b88c4 to your computer and use it in GitHub Desktop.
Save mindplay-dk/e988902ed2d587dc05a1d8cb164b88c4 to your computer and use it in GitHub Desktop.
hello
<?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