Zend Framework

Zend_Filter_Word_SeparatorToCamelCase incorrect match pattern

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.6.0RC2, 1.6.0RC3
  • Fix Version/s: 1.9.0
  • Component/s: Zend_Filter
  • Labels:
    None

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

Original
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')"));
}
Suggestion
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')"));
}

[A-Z] changed to [a-z]
strtoupper changed to strtolower

Not sure if the match pattern for self::isUnicodeSupportEnabled (true) needs to be changed as well.

Issue Links

Activity

Hide
Ralph Schindler added a comment -

Will address within 2 weeks

Show
Ralph Schindler added a comment - Will address within 2 weeks
Hide
Thomas Weidner added a comment -

Fixed with r16188

Show
Thomas Weidner added a comment - Fixed with r16188

People

Vote (1)
Watch (0)

Dates

  • Due:
    Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
1h
Original Estimate - 1 hour
Remaining:
1h
Remaining Estimate - 1 hour
Logged:
Not Specified
Time Spent - Not Specified