ZF-4097: Zend_Filter_Word_SeparatorToCamelCase incorrect match pattern
Description
Not sure if Zend_Filter_Word_SeparatorToCamelCase is what I should be using, but my intention was to filter the string "zend_framework" to "zendFramework".
$obj = new Zend_Filter();
$obj->addFilter(new Zend_Filter_Word_UnderscoreToCamelCase('_'));
echo $obj->filter("zend_framework"); // Prints "Zend_framework"
echo $obj->filter("zend_Framework"); // Prints "ZendFramework"
echo $obj->filter("zendFramework"); // Prints "ZendFramework"
echo $obj->filter("zendframework"); // Prints "Zendframework"
echo $obj->filter("_zendframework"); // Prints "_zendframework"
echo $obj->filter("_zend_framework"); // Prints "_zend_framework"
Zend_Filter_Word_SeparatorToCamelCase
if (self::isUnicodeSupportEnabled()) {
parent::setMatchPattern(array('#('.$pregQuotedSeparator.')(\p{L}{1})#e','#(^\p{Ll}{1})#e'));
parent::setReplacement(array("strtoupper('\\2')","strtoupper('\\1')"));
} else {
parent::setMatchPattern(array('#('.$pregQuotedSeparator.')([A-Z]{1})#e','#(^[a-z]{1})#e'));
parent::setReplacement(array("strtoupper('\\2')","strtoupper('\\1')"));
}
if (self::isUnicodeSupportEnabled()) {
parent::setMatchPattern(array('#('.$pregQuotedSeparator.')(\p{L}{1})#e','#(^\p{Ll}{1})#e'));
parent::setReplacement(array("strtoupper('\\2')","strtolower('\\1')"));
} else {
parent::setMatchPattern(array('#('.$pregQuotedSeparator.')([a-z]{1})#e','#(^[a-z]{1})#e'));
parent::setReplacement(array("strtoupper('\\2')","strtolower('\\1')"));
}
{color:green}[A-Z]{color} changed to {color:green}[a-z]{color} {color:green}strtoupper{color} changed to {color:green}strtolower{color}
Not sure if the match pattern for self::isUnicodeSupportEnabled (true) needs to be changed as well.
Comments
Posted by Ralph Schindler (ralph) on 2009-01-11T21:35:10.000+0000
Will address within 2 weeks
Posted by Thomas Weidner (thomas) on 2009-06-20T12:22:45.000+0000
Fixed with r16188