Last active
August 29, 2015 14:07
-
-
Save vijaycs85/ecc6b554408ec53735a7 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
<?php | |
$lm = new \LanguageManager(); | |
$lm->getLanguages(); | |
Class LanguageManager { | |
protected $language; | |
public function getLanguages() { | |
if (!isset($this->language)) { | |
$default = new stdClass(); | |
$default->name = 'default'; | |
$this->language = $default; | |
} | |
if (TRUE) { | |
$default->name = 'override'; | |
} | |
// This return 'override'. Which is why we clone. | |
print_r($this->language); | |
} | |
} | |
// this is what we have now............ | |
<?php | |
$lm = new \LanguageManager(); | |
$lm->getLanguages(); | |
Class LanguageManager { | |
protected $language; | |
public function getLanguages() { | |
if (!isset($this->language)) { | |
$default = new stdClass(); | |
$default->name = 'default'; | |
$this->language = $default; | |
} | |
if (TRUE) { | |
$default = new stdClass(); | |
$default->name = 'override'; | |
} | |
print_r($this->language); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment