Ok, here is tonights installment. I've added a singleton capabilty.
You can fetch a singleton with the property notation.
PHP Code:
$value = $registry->className
This is equivelent to
PHP Code:
$value = $registry->className();
except that it will always return the same object in subsequent calls.
You can also set values
PHP Code:
$registry->foo = new StdClass();
$registry->bar = "any data";
If it is necessary to inject a value and a singleton is available, the singleton will be injected. Otherwise, a new instance will be created (as in the last version). This newly created instance will not become a singleton. Is this the best behavior?
I ran into what appears to be a SimpleTest bug in testing this. The following assertion fails.
PHP Code:
$this->assertNotIdentical(new StdClass(), new StdClass());
Here is the current code:
registry.inc.php
registry.test.php
Next, I think __call is getting to be a bit complicated. I think some refactoring may be in order.
Bookmarks