[OutputEscaper] made getEscaper*() methods more consistent with the way you can change the escaping strategy in __call()
This commit is contained in:
parent
c065be88b5
commit
e23c3cc702
@ -145,11 +145,11 @@ class ArrayDecorator extends BaseEscaper implements \Iterator, \ArrayAccess, \Co
|
||||
* Escapes a key from the array using the specified escaper.
|
||||
*
|
||||
* @param string $key The array key
|
||||
* @param mixed $escaper The escaping method (a PHP callable or a named escaper)
|
||||
* @param string $escaper The escaping strategy prefixed with esc_ (see __call())
|
||||
*/
|
||||
public function getEscapedKey($key, $escaper)
|
||||
{
|
||||
return Escaper::escape($escaper, $this->value[$key]);
|
||||
return Escaper::escape(substr($escaper, 4), $this->value[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -100,11 +100,11 @@ class ObjectDecorator extends BaseEscaper implements \ArrayAccess, \Countable
|
||||
* Escapes an object property using the specified escaper.
|
||||
*
|
||||
* @param string $key The object property name
|
||||
* @param mixed $escaper The escaping method (a PHP callable or a named escaper)
|
||||
* @param string $escaper The escaping strategy prefixed with esc_ (see __call())
|
||||
*/
|
||||
public function getEscapedProperty($key, $escaper)
|
||||
{
|
||||
return Escaper::escape($escaper, $this->value->$key);
|
||||
return Escaper::escape(substr($escaper, 4), $this->value->$key);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -168,11 +168,11 @@ class ObjectDecorator extends BaseEscaper implements \ArrayAccess, \Countable
|
||||
* Escapes a key from the array using the specified escaper.
|
||||
*
|
||||
* @param string $key The array key
|
||||
* @param mixed $escaper The escaping method (a PHP callable or a named escaper)
|
||||
* @param string $escaper The escaping strategy prefixed with esc_ (see __call())
|
||||
*/
|
||||
public function getEscapedKey($key, $escaper)
|
||||
{
|
||||
return Escaper::escape($escaper, $this->value[$key]);
|
||||
return Escaper::escape(substr($escaper, 4), $this->value[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,7 +26,7 @@ class ArrayDecoratorTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testGetEscapedKey()
|
||||
{
|
||||
$this->assertEquals('<strong>escaped!</strong>', self::$escaped->getEscapedKey(0, 'raw'), '->getEscapedKey() returns the value with an other escaper');
|
||||
$this->assertEquals('<strong>escaped!</strong>', self::$escaped->getEscapedKey(0, 'esc_raw'), '->getEscapedKey() returns the value with an other escaper');
|
||||
}
|
||||
|
||||
public function testArrayAccessInterface()
|
||||
|
Reference in New Issue
Block a user