* @return
* <ul>
* <li> -1 if the index of this stackframe is less.
- * <li> 0 if the index of both stackfream is equal (should no happen).
- * <li> 1 if the index of this stackfram is greater.
+ * <li> 0 if the index of both stackframes are equal (should no happen).
+ * <li> 1 if the index of this stackframe is greater.
* </ul>
*/
public int compareTo(Object obj) {
- //if (index < ((PHPStackFrame) obj).getIndex()) {
- // return -1;
- //} else if (index > ((PHPStackFrame) obj).getIndex()) {
- // return 1;
- //}
-
- //return 0;
- return Integer.signum(index - ((PHPStackFrame) obj).getIndex());
+ if (!(obj instanceof PHPStackFrame)) {
+ throw new IllegalArgumentException("A PHPStackFrame can only be compared with another PHPStackFrame");
+ }
+ int frameIndex = ((PHPStackFrame) obj).getIndex();
+ if (index < frameIndex) {
+ return -1;
+ } else if (index > frameIndex) {
+ return 1;
+ }
+ return 0;
}
}