Skip to content

Instantly share code, notes, and snippets.

@telless
Created February 15, 2018 14:46
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 telless/657df088cdf3eff026a5247c85cc8481 to your computer and use it in GitHub Desktop.
Save telless/657df088cdf3eff026a5247c85cc8481 to your computer and use it in GitHub Desktop.
<?php
class FooParent
{
}
class Foo extends FooParent
{
}
class FooChild extends Foo
{
}
class Bar
{
public function func(Foo $test): Foo
{
// implementation
}
}
class BarBadChild extends Bar
{
public function func(FooChild $test, int $yetAnotherBadArgument): FooParent
{
// implementation
}
}
class BarGoodChild extends Bar
{
public function func(FooParent $test, int $yetAnotherGoodArgument = null): FooChild
{
// implementation
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment