ZF-11280: No meaningful code

Description

If you remove all occurrences of the string "case (2 <= $argc):" from the classes: Zend_Form, Zend_File_Transfer_Adapter_Abstrakt, Zend_Form_displaygroup and Zend_Form_Element, meaning the code will not change.

Comments

http://zendframework.ru/forum/index.php/… use google translator for details

I want to emphasize the difference between "switch" and "if" variants. The code:


    $argc = 1;
    $decorator = $options = $default = '';
    switch (true) { 
        case (0 == $argc): 
            break; 
        case (1 <= $argc): 
            $decorator = 'case_1 '; 
        case (2 <= $argc): 
            $options = 'case_2 '; 
        default: 
            $default = 'default'; 
            break; 
    }
    echo $decorator.$options.$default."
"; $decorator = $options = $default = ''; if(0 == $argc) { //break; do nothing } else { if(1 <= $argc) { $decorator = 'case_1 '; if(2 <= $argc) { $options = 'case_2 '; } } $default = 'default'; } echo $decorator.$options.$default."
";
]

gives the following result: case_1 case_2 default case_1 default

Initial patch. Switch statements replaced by conditionals

Your code is only another way to code things. Every switch statement can be recoded to an if statement. There is no pro and no con about such a change as performance is equal.

Actually I find the switch statement easier to read as you can without reading easily see what happens when you give 0, 1 or more parameters.

Closing as non-issue because it's no bug and there is no improvement by integration.

Btw: The fall-through is intentionally as you can see when you read the code carefully

Ok. But if you remove the string "case (2 <= $argc):", "case (3 <= $argc):" and "default:" from clauses, referred to, it is still easier to read.

And would then break functionallity (at last for the file component).

No, do not break. Because, if "1 <= $argc" is true, then PHP will execute all of the statements after the condition "case (1 <= $argc):", regardless of other case-conditions.