Following code snippet did raise warnings concerning missing single
array values ($buffer[$SourceColumnNo] is NULL for some keys)
if(is_numeric($SourceColumnNo =
array_search($ColumnName, $SourceColumns[$SourceFileName])))
{
/*
* The table column name was found in the current source file
* now store it with the column order number of the table at the correct
* position of the ValueArray which will later be transferred to the
* table. Sometimes the decimal seperator is given as comma "," instead
* of point "." this is adjusted as well.
*/
$ValueArray[$ColumnNo] = str_replace(",", ".",
trim($buffer[$SourceColumnNo]));
}
My solution was to wrap around if(isset($buffer[$SourceColumnNo])){...}
Is there a way to get this additional if condition into the code snippet
without evaluating the warning raising second part?
Putting both conditions into the clause still causes both conditions to
be evaluated, regardles if the full clause maybe never true because
FALSE AND sth. will always be FALSE.
if(isset($buffer[$SourceColumnNo]) AND is_numeric($SourceColumnNo =
array_search($ColumnName, $SourceColumns[$SourceFileName]))){...};
Is for instance this evaluation behaviour controllable?
Error suppression with @ is not acceptable and try / catch with error to
exception conversion is as well causing code overhead and reduces
readability.
As third option is to use ternary operator:
if(isset($buffer[$SourceColumnNo]) ? (is_numeric($SourceColumnNo =
array_search($ColumnName, $SourceColumns[$SourceFileName]))) : FALSE){};
Is this real good practise? Is this code still readable and does it
still meet common maintainability requirements?
Thanks for your help.
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php