electrical/php-mainframe — Issue #1: Suggestion: allow Init to receive and return arrays?
Author: RVN-BR
Created: 2012-03-06 18:04:37+00:00
State: open

Hi @electrical.

I would like to hear your thoughts on allowing init to receive and return an array into Init?

That way we can instantiate/access multiple classes/objects in a single line of code (adding this single line to the top of every required function for example)

something such as this:

list($DB, $MyBaseObject) = mainframe::Init(array("DB","MyBaseObject"));

Supporting this would be pretty easy, something like adding:

if (is_array($class)){
foreach($class as $currentclass){
$returnarray[] = self::Init($currentclass);
}
return $returnarray;
}

to the top of the Init function.

(Untested)

any comments? reasons against this? (I agree it doesnt look too pretty but it allows us to cut down to 1 line of code for importing 2 or 3 objects)...