Skip to content

Instantly share code, notes, and snippets.

@lividgreen
Created June 12, 2018 16:13
Show Gist options
  • Save lividgreen/ff877fcd0b853844a7a943956f57592e to your computer and use it in GitHub Desktop.
Save lividgreen/ff877fcd0b853844a7a943956f57592e to your computer and use it in GitHub Desktop.
<?php
interface WithButter {
}
interface WithHam {
}
class Bread {
public function withButter() {
return new class extends self implements WithButter {}
}
public function withHam() {
return new class extends self implements WithHam {}
}
}
class Me {
function eat(WithButter $goodFood) {...}
}
$i = new Me();
$i->eat(new Bread()->withButter()->withHam());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment