Skip to content

Instantly share code, notes, and snippets.

@jmikola
Created December 3, 2010 18:45
Show Gist options
  • Select an option

  • Save jmikola/727351 to your computer and use it in GitHub Desktop.

Select an option

Save jmikola/727351 to your computer and use it in GitHub Desktop.
Testing static::nonStaticMethod()
<?php
class A {
private function foo() {
echo "success!\n";
}
public function test() {
$this->foo();
static::foo();
}
}
class B extends A {
/* foo() will be copied to B, hence its scope will still be A and
* the call be successful */
}
class C extends A {
public function foo() {
echo "great success!\n";
/* original method is replaced; the scope of the new one is C */
}
}
$b = new B();
$b->test();
$c = new C();
$c->test();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment