Pushing instantiated class in an array I've just stumbled upon something today that seemed "unethical" in PHP. What I originally thought as malpractice, turned out to work just fine. Basically what I was wondering is if pushing an instantiated class in an array was considered proper?

Example:

$array = array();

array_push($array, new myClass());

foreach($array as $i =&gt; $class)
{
    $class-&gt;doSomething();  
}


Although this example is quite vague, the idea is there. Any input or alternatives on this matter would be great.
That example looks like a very simple "chain of command" implementation.
Looks fine to me, nothing unusual (though YYMV depending on the code-base).

You'll see things like this as an alternative to long blocks of procedural code, often when there's a bunch of distinct actions to perform that have no relation to one another. It's a nice way to clean up and cut up large classes to keep things "SRP"'d.