Created
December 2, 2012 07:43
-
-
Save suin/4187625 to your computer and use it in GitHub Desktop.
parent::parent::parentコンストラクタパターン
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Foo | |
{ | |
public function __construct() | |
{ | |
$this->value = __CLASS__; | |
} | |
} | |
class Bar extends Foo | |
{ | |
public function __construct() | |
{ | |
// 俺のサブクラスには、Fooのコンストラクタを使わせないぜ! | |
} | |
} | |
class Baz extends Bar | |
{ | |
public function __construct() | |
{ | |
// 無駄無駄ァ!! | |
Foo::__construct(); | |
} | |
} | |
var_dump(new Baz); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
アンチパターンです。