That's a fairly good exercise. I remember taking a data structures course a few years ago, and we had to implement these things from scratch (sort of similar to what you did). Any chance this is inspired by such a course?
Just some things I noticed:
You could simplify the empty() function:
PHP Code:
public function empty() {
return front() == null;
}
And, the front() function just needs to be:
PHP Code:
public function front() {
return this.data[0];
}
I have a feeling you may have ported that bit over from Java or something from the way you're dealing with the null case.