Skip to content
This repository
Browse code

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 authored

Showing 1 changed file with 4 additions and 2 deletions. Show diff stats Hide diff stats

  1. 6  view/SSViewer.php
6  view/SSViewer.php
@@ -31,8 +31,8 @@ class SSViewer_Scope {
31 31
 	protected $itemIteratorTotal;   //Total number of items in the iterator
32 32
 	
33 33
 	private $popIndex; // A pointer into the item stack for which item should be scope on the next pop call
34  
-	private $upIndex; // A pointer into the item stack for which item is "up" from this one
35  
-	private $currentIndex; // A pointer into the item stack for which item is this one (or null if not in stack yet)
  34
+	private $upIndex = null; // A pointer into the item stack for which item is "up" from this one
  35
+	private $currentIndex = null; // A pointer into the item stack for which item is this one (or null if not in stack yet)
36 36
 	
37 37
 	private $localIndex;
38 38
 
@@ -56,6 +56,8 @@ function obj($name){
56 56
 		
57 57
 		switch ($name) {
58 58
 			case 'Up':
  59
+				if ($this->upIndex === null) user_error('Up called when we\'re already at the top of the scope', E_USER_ERROR);
  60
+
59 61
 				list($this->item, $this->itemIterator, $unused2, $this->upIndex, $this->currentIndex) = $this->itemStack[$this->upIndex];
60 62
 				break;
61 63
 			

0 notes on commit 5c33632

Please sign in to comment.
Something went wrong with that request. Please try again.