I am wondering if it is possible while using the keyword \'new\' to return a reference to an existing object instead of a new object. And if not, what would be the best way to a
Wouldn't it just be easier to directly store the object references in your instances
var?
if (!isset(self::$instances[$myparam])) {
self::$instances[$myParam] = ... new object here ...;
} else
return &self::$instances[$myParam];
}
Just guessing, but it seems that storing your simple integer parameter as an array key to the instances cache would be "cheaper" than storing an sha1 signature of a serialized structure that could potentially NOT be the same even if the object has the same initial parameter.