Skip to content

Instantly share code, notes, and snippets.

@anyt
Last active August 29, 2015 14:23
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 anyt/4d622b316387bc436ce6 to your computer and use it in GitHub Desktop.
Save anyt/4d622b316387bc436ce6 to your computer and use it in GitHub Desktop.
<?php
class A {
protected $kernel;
public function handle() {
print 1;
}
public function __construct() {
}
}
class B {
protected $kernel;
public function handle() {
$this->kernel->handle();
// some extra logic;
print 2;
}
public function __construct($kernel) {
$this->kernel = $kernel;
}
}
class C {
protected $kernel;
public function handle() {
$this->kernel->handle();
// some extra logic;
print 3;
}
public function __construct($kernel) {
$this->kernel = $kernel;
}
}
$a = new A();
$a = new B($a);
$a = new C($a);
$a->handle(); // will print 123;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment