passing isset on everything

21 Views Asked by At

I am maintaining a codebase which many people are working on. I have a situation where a function is being passed with needs to have isset passed and checked on all items before it returns. Instead of me adding an isset for each setProperty as is in foo_item2 example, is there a way to make it apply to all setProperty calls?

function &someFooFunction($row, $details = true) {           
$foo = new otherFooItem();
$foo->setProperty($row['foo_item1']);           
if (isset($row['foo_item2'])) {      
$foo->setProperty($row['foo_item2']);      
}      
$foo->setProperty($row['foo_item3']);      
return $foo;      
}

I keep adding if (isset($row['foo'])) { for each line and there are 100's of lines.

0

There are 0 best solutions below