Working on my TemporalData class, i realized that it should be an
abstract class. It's the way I intended to use it all along, but I somehow forgot that PHP now supports abstract classes and didn't define it as such.
The TemporalData class has a couple of
static methods used for selecting objects from the database, and I use
late static bindings (a php 5.3 feature) to figure out which class the call came through and in turn which table to query. If you were to call one of those methods directly on TemporalData it wouldn't have any way of knowing which table to query, so I used this code to block such calls:
$class = get_called_class();
if ($class == 'TemporalData') {
throw new Exception("TemporalData::open() can not be called directly, only through its subclasses.");
}
I thought I could get rid of this check now that I defined the class to be abstract. Turns out this isn't the case:
abstract class A {
public static function foo
() { echo "I'm in your foo(), eating your bar!\n"; }
}
A::foo();
Output:
I'm in your foo(), eating your bar!
Tested with php 5.2.6 and 5.3.0beta1.