Simetrical wrote:
Might it be a good idea, in these factory functions, to check whether the object returned is an instance of the intended class? Like, if someone replaces all Title objects with MyTitles that *don't* extend Title, that would cause some havoc, not least as we start adding type hinting. It's probably best to catch that particular mistake early.
So instead of "if ($objResult === NULL)", something like:
if (!is_object($objResult) || !is_a($objResult, self::getRealClass())) // must use is_a because instanceof doesn't work with strings
Correct me if I'm wrong, but this looks like you're going to instantiate the "normal" class if the extension provided an object of the wrong class. It would be way more helpful to the extension developer if it threw an exception or some sort of error message instead, e.g. "Error: ".typeof($objResult)." is not a subclass of ".self::getRealClass() or something like that.