Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jeremysells/b95d4dabf3af522db8e8 to your computer and use it in GitHub Desktop.
Save jeremysells/b95d4dabf3af522db8e8 to your computer and use it in GitHub Desktop.
Declaration should be compatible with Base
<?php
class ModelA{
public function sayHi() { return "hi"; }
}
class ModelB extends ModelA {
public function sayHi() { return "hello"; }
}
class SomethingA{
public function doStuff(ModelA $model) {
echo $model->sayHi();
}
}
class SomethingB extends SomethingA{
public function doStuff(ModelB $model) {
echo $model->sayHi();
}
}
$something = new SomethingB();
$something->doStuff(new ModelB());
/**
( ! ) Strict standards: Declaration of SomethingB::doStuff() should be compatible with SomethingA::doStuff(ModelA $model) in file.php on line 19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment