Skip to content

Instantly share code, notes, and snippets.

@cursosdesarrolloweb
Created November 28, 2020 08:58
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 cursosdesarrolloweb/6c47f4ffd2f0e7a29106df84206df521 to your computer and use it in GitHub Desktop.
Save cursosdesarrolloweb/6c47f4ffd2f0e7a29106df84206df521 to your computer and use it in GitHub Desktop.
<?php
class Foo {
public function run(): string {
return __CLASS__;
}
}
class Bar {
public function run(): string {
return __CLASS__;
}
}
class FooBar {
public function execute(Foo|Bar $executable): string|int {
return $executable->run();
}
}
$fooBar = new FooBar;
echo $fooBar->execute(new Foo);
echo $fooBar->execute(new Bar);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment