Skip to content

Commit

Permalink
#224 - further performance optimizations (avoiding recursive calls wh…
Browse files Browse the repository at this point in the history
…en not needed)
  • Loading branch information
Ocramius committed Jan 9, 2015
1 parent da7339e commit 1fad9fe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class MagicGet extends MagicMethodGenerator
* @var string
*/
private $callParentTemplate = <<<'PHP'
%s
$this->%s && ! $this->%s && $this->%s('__get', array('name' => $name));
if (isset(self::$%s[$name])) {
return $this->$name;
Expand Down Expand Up @@ -137,8 +137,9 @@ public function __construct(

$this->setBody(sprintf(
$this->callParentTemplate,
'$this->' . $initializerProperty->getName() . ' && $this->' . $callInitializer->getName()
. '(\'__get\', array(\'name\' => $name));',
$initializerProperty->getName(),
$initializationTracker->getName(),
$callInitializer->getName(),
$publicProperties->getName(),
$protectedProperties->getName(),
$initializationTracker->getName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class MagicGetTest extends PHPUnit_Framework_TestCase
* @var string
*/
private $expectedCode = <<<'PHP'
$this->foo && $this->baz('__get', array('name' => $name));
$this->foo && ! $this->init && $this->baz('__get', array('name' => $name));
if (isset(self::$bar[$name])) {
return $this->$name;
Expand Down

0 comments on commit 1fad9fe

Please sign in to comment.