Skip to content

Commit

Permalink
[OutputEscaper] Added magic __isset() method to object escaper.
Browse files Browse the repository at this point in the history
  • Loading branch information
kriswallsmith committed Jul 9, 2010
1 parent ab26f9f commit fe7e01c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Symfony/Components/OutputEscaper/ObjectDecorator.php
Expand Up @@ -106,4 +106,16 @@ public function __get($key)
{
return $this->escape($this->escaper, $this->value->$key);
}

/**
* Checks whether a value is set on the wrapped object.
*
* @param string $key The name of the value to check
*
* @return boolean Returns true if the value is set
*/
public function __isset($key)
{
return isset($this->value->$key);
}
}
Expand Up @@ -41,6 +41,12 @@ public function testMagicGet()
{
$this->assertEquals('<em>escape me</em>', self::$escaped->someMember, 'The escaped object behaves like the real object');
}

public function testMagicIsset()
{
$this->assertTrue(isset(self::$escaped->someMember), 'The escaped object behaves like the real object');
$this->assertFalse(isset(self::$escaped->invalidMember), 'The escaped object behaves like the real object');
}
}

class OutputEscaperTest
Expand Down

0 comments on commit fe7e01c

Please sign in to comment.