Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MINOR: When Up called and we are at the top of the scope, throw a use…

…ful error, not just an index undefined error
  • Loading branch information...
commit 5c336329b662ce1ba22c3cd91bf870d7e877ab3b 1 parent 556950d
Hamish Friedlander hafriedlander authored
Showing with 4 additions and 2 deletions.
  1. +4 −2 view/SSViewer.php
6 view/SSViewer.php
View
@@ -31,8 +31,8 @@ class SSViewer_Scope {
protected $itemIteratorTotal; //Total number of items in the iterator
private $popIndex; // A pointer into the item stack for which item should be scope on the next pop call
- private $upIndex; // A pointer into the item stack for which item is "up" from this one
- private $currentIndex; // A pointer into the item stack for which item is this one (or null if not in stack yet)
+ private $upIndex = null; // A pointer into the item stack for which item is "up" from this one
+ private $currentIndex = null; // A pointer into the item stack for which item is this one (or null if not in stack yet)
private $localIndex;
@@ -56,6 +56,8 @@ function obj($name){
switch ($name) {
case 'Up':
+ if ($this->upIndex === null) user_error('Up called when we\'re already at the top of the scope', E_USER_ERROR);
+
list($this->item, $this->itemIterator, $unused2, $this->upIndex, $this->currentIndex) = $this->itemStack[$this->upIndex];
break;
Please sign in to comment.
Something went wrong with that request. Please try again.