Created
July 14, 2013 16:45
-
-
Save feketegy/5994894 to your computer and use it in GitHub Desktop.
This file contains 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
// --== GOOD ==-- | |
class SomeClass | |
{ | |
protected $_db = null; | |
public function __construct(Database $db) | |
{ | |
$this->_db = $db; | |
} | |
} | |
$dic = DIC::create('database'); | |
$a = new SomeClass($dic['database']); | |
// --== BAD ==-- | |
class SomeClass | |
{ | |
protected $_db = null; | |
public function __construct(DIC $dic) | |
{ | |
$this->_db = $dic['database']; | |
} | |
} | |
$dic = DIC::create('database'); | |
$a = new SomeClass($dic); | |
// --== WORST ==-- | |
class SomeClass | |
{ | |
protected $_db = null; | |
public function __construct() | |
{ | |
$dic = DIC::create('database'); | |
$this->_db = $dic['database']; | |
} | |
} | |
$a = new SomeClass(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment