Zend Framework

Zend_Filter_Inflector default null 'filter' method param

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Won't Fix
  • Affects Version/s: None
  • Fix Version/s: 1.9.0
  • Component/s: Zend_Filter
  • Labels:
    None
  • Fix Version Priority:
    Nice to Have

Description

@version $Id: Inflector.php 7078 2007-12-11 14:29:33Z matthew $

Zend_Filter_Inflector method 'filter' needs at least one param ($source).
If you define only 'static' rules (without, for example, default ':' prefix) and set value to each one and you don't need to replace it with a $source array you should call 'filter' method without param.

Sure, as workaround you can call filter(null), filter(array()), ...

Actual code:

public function filter($source)
{
    [...]
}

Proposed code:

public function filter($source = null)
{
    [...]
}

Activity

Hide
Wil Sinclair added a comment -

Please evaluate and categorize/assign as necessary.

Show
Wil Sinclair added a comment - Please evaluate and categorize/assign as necessary.
Hide
Ralph Schindler added a comment -

Can you supply a valid use case?

Show
Ralph Schindler added a comment - Can you supply a valid use case?
Hide
Aldo Armiento added a comment -
$sFilenameFormat = 'log%t.txt';
$aFilenameFormatRules = array('t' => time());
$zendInflector = new Zend_Filter_Inflector($sFilenameFormat, $aFilenameFormatRules);
$zendInflector->setTargetReplacementIdentifier('%');
echo $zendInflector->filter(null);
Show
Aldo Armiento added a comment -
$sFilenameFormat = 'log%t.txt';
$aFilenameFormatRules = array('t' => time());
$zendInflector = new Zend_Filter_Inflector($sFilenameFormat, $aFilenameFormatRules);
$zendInflector->setTargetReplacementIdentifier('%');
echo $zendInflector->filter(null);
Hide
Thomas Weidner added a comment -

There is one problem with this suggestion.

It breaks the filter interface.

The filter interface defines one parameter to be in the filter method without a default value.
So the proposed change can not be applied.

Erasing the interface would mean that you can't use this filter within other components... can't be done.

Changing the interface to allow optional parameters is also a problem as this would mean to change all existing and also all user-land filters.

Actually I see no way to allow

$inflector->filter();

@ralph:
Your opinion ?

Show
Thomas Weidner added a comment - There is one problem with this suggestion. It breaks the filter interface. The filter interface defines one parameter to be in the filter method without a default value. So the proposed change can not be applied. Erasing the interface would mean that you can't use this filter within other components... can't be done. Changing the interface to allow optional parameters is also a problem as this would mean to change all existing and also all user-land filters. Actually I see no way to allow $inflector->filter(); @ralph: Your opinion ?
Hide
Thomas Weidner added a comment -

Closing as "won't fix".

Filters are converting/filtering input and create output.
Therefor a filter needs to have a input.

Changing the interface would lead to inconsistency with other existing filters even userland filters.
As there is no way to allow both, this issue is closed.

Show
Thomas Weidner added a comment - Closing as "won't fix". Filters are converting/filtering input and create output. Therefor a filter needs to have a input. Changing the interface would lead to inconsistency with other existing filters even userland filters. As there is no way to allow both, this issue is closed.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: