Skip to content

Commit

Permalink
[OutputEscaper] Moved __get() from Escaper to ObjectEscaper.
Browse files Browse the repository at this point in the history
  • Loading branch information
kriswallsmith committed Jul 9, 2010
1 parent 8dc5fa6 commit ab26f9f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
12 changes: 0 additions & 12 deletions src/Symfony/Components/OutputEscaper/Escaper.php
Expand Up @@ -233,18 +233,6 @@ public function getRawValue()
return $this->value;
}

/**
* Gets a value from the escaper.
*
* @param string $var Value to get
*
* @return mixed Value
*/
public function __get($var)
{
return $this->escape($this->escaper, $this->value->$var);
}

/**
* Sets the current charset.
*
Expand Down
12 changes: 12 additions & 0 deletions src/Symfony/Components/OutputEscaper/ObjectDecorator.php
Expand Up @@ -94,4 +94,16 @@ public function __toString()
{
return $this->escape($this->escaper, (string) $this->value);
}

/**
* Gets a value from the escaper.
*
* @param string $key The name of the value to get
*
* @return mixed The value from the wrapped object
*/
public function __get($key)
{
return $this->escape($this->escaper, $this->value->$key);
}
}
Expand Up @@ -36,10 +36,17 @@ public function testMagicToString()
{
$this->assertEquals('<strong>escaped!</strong>', self::$escaped->__toString(), 'The escaped object behaves like the real object');
}

public function testMagicGet()
{
$this->assertEquals('<em>escape me</em>', self::$escaped->someMember, 'The escaped object behaves like the real object');
}
}

class OutputEscaperTest
{
public $someMember = '<em>escape me</em>';

public function __toString()
{
return $this->getTitle();
Expand Down

0 comments on commit ab26f9f

Please sign in to comment.