Skip to content

Instantly share code, notes, and snippets.

@taylorotwell
Last active March 9, 2018 16:36
Show Gist options
  • Save taylorotwell/ee2f782aec59aa53863fd09c8e47f304 to your computer and use it in GitHub Desktop.
Save taylorotwell/ee2f782aec59aa53863fd09c8e47f304 to your computer and use it in GitHub Desktop.
<?php
class Decorator
{
public function __construct($target)
{
$this->target = $target;
}
public function __call($method, $parameters)
{
return $this->target->{$method}(...$parameters);
}
}
class Target
{
}
class Consumer
{
public function doesWork(Target $target)
{
};
}
// Doesn't work becuase type-hints are a waste of time and lead to poorly coded, brittle systems... :)
$consumer->doesWork(new Decorator(new Target));
@Ocramius
Copy link

@nicholasruunu that's already provided by the userland library mentioned above

@Potherca
Copy link

Potherca commented Jun 3, 2017

// Doesn't work becuase type-hints are a waste of time and lead to poorly coded, brittle systems... :)

I'm just gonna grammar nazi this and point out that "becuase" is spelled wrong.

Also, you seem to have misspelled "type-hints" as that is not how you spell "idiots" ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment