GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Branch master (9269d3)
by Telyn
03:20
created
sprites/S16Frame.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -17,19 +17,19 @@  discard block
 block discarded – undo
17 17
     
18 18
     /// @brief Instantiate an S16Frame
19 19
     
20
-    public function S16Frame($reader,$encoding='565',$width=false,$height=false,$offset=false)
20
+    public function S16Frame($reader, $encoding = '565', $width = false, $height = false, $offset = false)
21 21
     {
22
-        if($reader instanceof IReader) {
22
+        if ($reader instanceof IReader) {
23 23
             $this->reader = $reader;
24 24
             $this->encoding = $encoding;
25
-            if($width === false || $height === false || $offset === false) {
25
+            if ($width === false || $height === false || $offset === false) {
26 26
                 $this->offset = $this->reader->ReadInt(4);
27 27
                 parent::SpriteFrame($this->reader->ReadInt(2), $this->reader->ReadInt(2));
28 28
             } else {
29
-                parent::SpriteFrame($width,$height);
29
+                parent::SpriteFrame($width, $height);
30 30
                 $this->offset = $offset;
31 31
             }
32
-        } else if(get_resource_type($reader) == 'gd') {
32
+        } else if (get_resource_type($reader) == 'gd') {
33 33
             $this->gdImage = $reader;
34 34
             $this->decoded = true;
35 35
             $this->encoding = $encoding;
@@ -44,23 +44,23 @@  discard block
 block discarded – undo
44 44
      * @return s16 image data in the format specified
45 45
      */
46 46
 
47
-    public function Encode($format='565') {
47
+    public function Encode($format = '565') {
48 48
         $this->EnsureDecoded();
49 49
         $data = ''; 
50
-        for($y = 0; $y < $this->GetHeight(); $y++) {
51
-            for($x = 0; $x < $this->GetWidth(); $x++ ) {
50
+        for ($y = 0; $y < $this->GetHeight(); $y++) {
51
+            for ($x = 0; $x < $this->GetWidth(); $x++) {
52 52
 
53
-                $pixel = $this->GetPixel($x,$y);
54
-                if($pixel['red'] > 255 || $pixel['green'] > 255 || $pixel['blue'] > 255) {
53
+                $pixel = $this->GetPixel($x, $y);
54
+                if ($pixel['red'] > 255 || $pixel['green'] > 255 || $pixel['blue'] > 255) {
55 55
                     throw new Exception('Pixel colour out of range.');
56 56
                 }
57 57
                 $newpixel = 0;
58
-                if($this->encoding == '555') {
58
+                if ($this->encoding == '555') {
59 59
                     $newpixel = (($pixel['red'] << 7) & 0xF800) | (($pixel['green'] << 2) & 0x03E0) | (($pixel['blue'] >> 3) & 0x001F);
60 60
                 } else {
61 61
                     $newpixel = (($pixel['red'] << 8) & 0xF800) | (($pixel['green'] << 3) & 0x07E0) | (($pixel['blue'] >> 3) & 0x001F);
62 62
                 }
63
-                $data .= pack('v',$newpixel);
63
+                $data .= pack('v', $newpixel);
64 64
             }
65 65
         }
66 66
         return $data;
@@ -73,24 +73,24 @@  discard block
 block discarded – undo
73 73
      * TODO: Internal documentation S16Frame::Decode()
74 74
      */
75 75
     protected function Decode() {
76
-        if($this->decoded) { return $this->gdImage; }
76
+        if ($this->decoded) { return $this->gdImage; }
77 77
 
78 78
             $image = imagecreatetruecolor($this->GetWidth(),
79 79
                 $this->GetHeight());
80 80
         $this->reader->Seek($this->offset);
81
-        for($y = 0; $y < $this->GetHeight(); $y++)
81
+        for ($y = 0; $y < $this->GetHeight(); $y++)
82 82
         {
83
-            for($x = 0; $x < $this->GetWidth(); $x++)
83
+            for ($x = 0; $x < $this->GetWidth(); $x++)
84 84
             {
85 85
                 $pixel = $this->reader->ReadInt(2);
86 86
                 $red = 0; $green = 0; $blue = 0;
87
-                if($this->encoding == "565")
87
+                if ($this->encoding == "565")
88 88
                 {
89 89
                     $red   = ($pixel & 0xF800) >> 8;
90 90
                     $green = ($pixel & 0x07E0) >> 3;
91 91
                     $blue  = ($pixel & 0x001F) << 3;
92 92
                 }
93
-                else if($this->encoding == "555")
93
+                else if ($this->encoding == "555")
94 94
                 {
95 95
                     $red   = ($pixel & 0x7C00) >> 7;
96 96
                     $green = ($pixel & 0x03E0) >> 2;
Please login to merge, or discard this patch.
sprites/C16Frame.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
      * @param $reader An IReader or GD image resource.
26 26
      * @param $encoding The encoding of the C16 frame (555 or 565). Defaults to 565
27 27
      */
28
-    public function C16Frame($reader,$encoding='565')
28
+    public function C16Frame($reader, $encoding = '565')
29 29
     {
30
-        if($reader instanceof IReader) {
30
+        if ($reader instanceof IReader) {
31 31
             $this->reader = $reader;
32 32
             $this->encoding = $encoding;
33 33
             $this->offset = $this->reader->ReadInt(4);
@@ -35,17 +35,17 @@  discard block
 block discarded – undo
35 35
             $width = $this->reader->ReadInt(2);
36 36
             $height = $this->reader->ReadInt(2);
37 37
 
38
-            parent::SpriteFrame($width,$height);
38
+            parent::SpriteFrame($width, $height);
39 39
 
40
-            for($x = 0; $x < ($height - 1); $x++)
40
+            for ($x = 0; $x < ($height-1); $x++)
41 41
             {
42 42
                 $this->lineOffset[$x] = $this->reader->ReadInt(4);
43 43
             }
44
-        } else if(is_resource($reader)) {
45
-            if(get_resource_type($reader) == 'gd') {
44
+        } else if (is_resource($reader)) {
45
+            if (get_resource_type($reader) == 'gd') {
46 46
 
47
-                $this->encoding = ($encoding=='555')?'555':'565';
48
-                parent::SpriteFrame(imagesx($reader),imagesy($reader),true);
47
+                $this->encoding = ($encoding == '555') ? '555' : '565';
48
+                parent::SpriteFrame(imagesx($reader), imagesy($reader), true);
49 49
                 $this->gdImage = $reader;
50 50
             }
51 51
         } else {
@@ -70,37 +70,37 @@  discard block
 block discarded – undo
70 70
         $image = imagecreatetruecolor($this->GetWidth(),
71 71
             $this->GetHeight());
72 72
         $this->reader->Seek($this->offset);
73
-        for($y = 0; $y < $this->GetHeight(); $y++)
73
+        for ($y = 0; $y < $this->GetHeight(); $y++)
74 74
         {
75
-            for($x = 0; $x < $this->GetWidth();)
75
+            for ($x = 0; $x < $this->GetWidth();)
76 76
             {
77 77
                 $run = $this->reader->ReadInt(2);
78
-                if(($run & 0x0001) > 0)
78
+                if (($run & 0x0001) > 0)
79 79
                     $run_type = "colour";
80 80
                 else
81 81
                     $run_type = "black";
82 82
                 $run_length = ($run & 0x7FFF) >> 1;
83
-                if($run_type == "black")
83
+                if ($run_type == "black")
84 84
                 {
85
-                    $z = $x + $run_length;
86
-                    for(;$x < $z; $x++)
85
+                    $z = $x+$run_length;
86
+                    for (;$x < $z; $x++)
87 87
                     {
88 88
                         imagesetpixel($image, $x, $y, imagecolorallocate($image, 0, 0, 0));
89 89
                     }
90 90
                 }
91 91
                 else //colour run
92 92
                 {
93
-                    $z = $x + $run_length;
94
-                    for(;$x < $z; $x++)
93
+                    $z = $x+$run_length;
94
+                    for (;$x < $z; $x++)
95 95
                     {
96 96
                         $pixel = $this->reader->ReadInt(2);
97
-                        if($this->encoding == "565")
97
+                        if ($this->encoding == "565")
98 98
                         {
99 99
                             $red   = ($pixel & 0xF800) >> 8;
100 100
                             $green = ($pixel & 0x07E0) >> 3;
101 101
                             $blue  = ($pixel & 0x001F) << 3;
102 102
                         }
103
-                        else if($this->encoding == "555")
103
+                        else if ($this->encoding == "555")
104 104
                         {
105 105
                             $red   = ($pixel & 0x7C00) >> 7;
106 106
                             $green = ($pixel & 0x03E0) >> 2;
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
                         imagesetpixel($image, $x, $y, $colour);
111 111
                     }
112 112
                 }
113
-                if($x == $this->GetWidth())
113
+                if ($x == $this->GetWidth())
114 114
                     $this->reader->Skip(2);
115 115
             }
116 116
         }
@@ -127,21 +127,21 @@  discard block
 block discarded – undo
127 127
     public function Encode() {
128 128
         $data = '';
129 129
         $lineOffsets = array();
130
-        for($y = 0; $y < $this->GetHeight(); $y++) {
130
+        for ($y = 0; $y < $this->GetHeight(); $y++) {
131 131
             $wasblack = 0;
132 132
             $runlength = 0;
133
-            if($y > 0) {
133
+            if ($y > 0) {
134 134
                 $lineOffsets[] = strlen($data);
135 135
             }
136 136
             $colourRunData = '';
137
-            for($x = 0; $x < $this->GetWidth(); $x++) {
137
+            for ($x = 0; $x < $this->GetWidth(); $x++) {
138 138
 
139
-                $pixel = $this->GetPixel($x,$y);
140
-                if($pixel['red'] > 255 || $pixel['green'] > 255 || $pixel['blue'] > 255) {
139
+                $pixel = $this->GetPixel($x, $y);
140
+                if ($pixel['red'] > 255 || $pixel['green'] > 255 || $pixel['blue'] > 255) {
141 141
                     throw new Exception('Pixel colour out of range.');
142 142
                 }
143 143
                 $newpixel = 0;
144
-                if($this->encoding == '555') {
144
+                if ($this->encoding == '555') {
145 145
                     $newpixel = (($pixel['red'] << 7) & 0xF800) | (($pixel['green'] << 2) & 0x03E0) | (($pixel['blue'] >> 3) & 0x001F);
146 146
                 } else {
147 147
                     $newpixel = (($pixel['red'] << 8) & 0xF800) | (($pixel['green'] << 3) & 0x07E0) | (($pixel['blue'] >> 3) & 0x001F);
@@ -149,48 +149,48 @@  discard block
 block discarded – undo
149 149
 
150 150
 
151 151
                 // if isblack !== wasblack
152
-                if(($newpixel == 0) !== $wasblack || $runlength > 32766) {
152
+                if (($newpixel == 0) !== $wasblack || $runlength > 32766) {
153 153
                     //end the run if this isn't the first run
154
-                    if($wasblack !== 0) {
154
+                    if ($wasblack !== 0) {
155 155
 
156 156
                         //output data.
157 157
                         $run = $runlength << 1;
158
-                        if($wasblack) {
159
-                            $data .= pack('v',$run);
158
+                        if ($wasblack) {
159
+                            $data .= pack('v', $run);
160 160
 
161 161
                         } else {
162 162
                             $run = $run | 1;
163
-                            $data .= pack('v',$run);
163
+                            $data .= pack('v', $run);
164 164
                             $data .= $colourRunData;
165 165
                             $colourRunData = '';
166 166
                         }
167 167
                     }
168 168
                     //start a new run
169
-                    if($newpixel == 0) {
169
+                    if ($newpixel == 0) {
170 170
                         $wasblack = true;
171 171
                         $colourRunData = '';
172 172
                     } else {
173 173
                         $wasblack = false;
174
-                        $colourRunData = pack('v',$newpixel);
174
+                        $colourRunData = pack('v', $newpixel);
175 175
                     }
176 176
                     $runlength = 1;
177 177
 
178 178
                 } else {
179
-                    if(!$wasblack) {
180
-                        $colourRunData .= pack('v',$newpixel);
179
+                    if (!$wasblack) {
180
+                        $colourRunData .= pack('v', $newpixel);
181 181
                     }
182 182
                     $runlength++;
183 183
                 }
184 184
 
185
-                if($x == ($this->GetWidth()-1)) {
185
+                if ($x == ($this->GetWidth()-1)) {
186 186
                     //end run and output data.
187 187
                     $run = $runlength << 1;
188
-                    if($wasblack) {
189
-                        $data .= pack('v',$run);
188
+                    if ($wasblack) {
189
+                        $data .= pack('v', $run);
190 190
 
191 191
                     } else {
192 192
                         $run = $run | 1;
193
-                        $data .= pack('v',$run);
193
+                        $data .= pack('v', $run);
194 194
                         $data .= $colourRunData;
195 195
                         $colourRunData = '';
196 196
                     }
Please login to merge, or discard this patch.
sprites/SPRFile.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -19,24 +19,24 @@
 block discarded – undo
19 19
 		parent::SpriteFile('SPR');
20 20
 		$frameCount = $reader->ReadInt(2);
21 21
 		
22
-		for($i=0;$i<$frameCount;$i++) {
22
+		for ($i = 0; $i < $frameCount; $i++) {
23 23
 			$offset = $reader->ReadInt(4);
24 24
 			$width = $reader->ReadInt(2);
25 25
 			$height = $reader->ReadInt(2);
26
-			$this->AddFrame(new SPRFrame($reader,$width,$height,$offset));
26
+			$this->AddFrame(new SPRFrame($reader, $width, $height, $offset));
27 27
 		}
28 28
 	}
29 29
 
30 30
     /// @brief Compiles the SPR file into a binary string
31 31
 	public function Compile() {
32
-	  $data = pack('v',$this->GetFrameCount());
32
+	  $data = pack('v', $this->GetFrameCount());
33 33
 	  $offset = 2+(8*$this->GetFrameCount());
34
-	  foreach($this->GetFrames() as $frame) {
35
-	    $data .= pack('V',$offset);
36
-	    $data .= pack('vv',$frame->GetWidth(),$frame->GetHeight());
34
+	  foreach ($this->GetFrames() as $frame) {
35
+	    $data .= pack('V', $offset);
36
+	    $data .= pack('vv', $frame->GetWidth(), $frame->GetHeight());
37 37
 	    $offset += $frame->GetWidth()*$frame->GetHeight();
38 38
 	  }
39
-	  foreach($this->GetFrames() as $frame) {
39
+	  foreach ($this->GetFrames() as $frame) {
40 40
 	    $data .= $frame->Encode();
41 41
 	  }
42 42
 	  return $data;
Please login to merge, or discard this patch.
sprites/SpriteFile.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
    * @param $frame A SpriteFrame
55 55
    * @param $position Where to put the frame. Currently un-used.
56 56
    */
57
-  public function AddFrame(SpriteFrame $frame, $position=false) {
57
+  public function AddFrame(SpriteFrame $frame, $position = false) {
58 58
       /*
59 59
       if($position === false) {
60 60
           $position = sizeof($this->frames);
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
           $position = sizeof($this->frames) - $position;
63 63
       }
64 64
       */
65
-      if($this->spritefiletype == substr(get_class($frame),0,3)) {
65
+      if ($this->spritefiletype == substr(get_class($frame), 0, 3)) {
66 66
           //$this->frames[$position] = $frame;
67 67
           $this->frames[] = $frame;
68 68
       } else {
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
    * backwards from the end of the frames array.
80 80
    */
81 81
   public function ReplaceFrame(SpriteFrame $frame, $position) {
82
-      if($position < 0) {
83
-          $position = sizeof($this->frames) - $position;
82
+      if ($position < 0) {
83
+          $position = sizeof($this->frames)-$position;
84 84
       }
85 85
       $this->frames[$position] = $frame->ToSpriteFrame($this->spritefiletype);
86 86
   }
Please login to merge, or discard this patch.
sprites/SpriteFrame.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -22,10 +22,10 @@  discard block
 block discarded – undo
22 22
      * Width and height must both be non-zero.
23 23
      * @see C16Frame::C16Frame()
24 24
      */
25
-    public function SpriteFrame($width,$height,$decoded=false) {
26
-        if($width == 0) {
25
+    public function SpriteFrame($width, $height, $decoded = false) {
26
+        if ($width == 0) {
27 27
             throw new Exception('Zero width');
28
-        } else if($height == 0) {
28
+        } else if ($height == 0) {
29 29
             throw new Exception('Zero height');
30 30
         }
31 31
         $this->width = $width;
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
      * @param $y The y-coordinate of the pixel to get.
74 74
      * @return An associative array containing the keys 'red','green','blue','alpha'.
75 75
      */
76
-    public function GetPixel($x,$y) {
76
+    public function GetPixel($x, $y) {
77 77
         $this->EnsureDecoded();
78 78
         $colori = imagecolorat($this->gdImage, $x, $y);
79 79
         $color = imagecolorsforindex($this->gdImage, $colori);
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
      * @param $g The green component of the pixel. 0-255.
89 89
      * @param $b The blue component of the pixel. 0-255.
90 90
      */
91
-    public function SetPixel($x,$y,$r,$g,$b) {
91
+    public function SetPixel($x, $y, $r, $g, $b) {
92 92
         $this->EnsureDecoded();
93 93
         imagesetpixel($this->gdImage, $x, $y, imagecolorallocate($this->gdImage, $r, $g, $b));
94 94
     }
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
      * if it does't already.
102 102
      */
103 103
     protected function EnsureDecoded() {
104
-        if(!$this->decoded)
104
+        if (!$this->decoded)
105 105
             $this->Decode();
106 106
 
107 107
         $this->decoded = true;
@@ -133,10 +133,10 @@  discard block
 block discarded – undo
133 133
      */
134 134
     public function ToSpriteFrame($type) {
135 135
         $this->EnsureDecoded();
136
-        if(substr(get_class($this),0,3) == $type && substr(get_class($this),3) == 'Frame') {
136
+        if (substr(get_class($this), 0, 3) == $type && substr(get_class($this), 3) == 'Frame') {
137 137
             return $this;
138 138
         }
139
-        switch($type) {
139
+        switch ($type) {
140 140
         case 'C16':
141 141
             return new C16Frame($this->GetGDImage());
142 142
         case 'S16':
Please login to merge, or discard this patch.
caos/highlight/CAOSHighlighter.php 1 patch
Spacing   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-define('FORMAT_C1','C1');
4
-define('FORMAT_C2','C2');
5
-define('FORMAT_C3','C3');
6
-define('FORMAT_DS','DS');
3
+define('FORMAT_C1', 'C1');
4
+define('FORMAT_C2', 'C2');
5
+define('FORMAT_C3', 'C3');
6
+define('FORMAT_DS', 'DS');
7 7
 
8 8
 
9 9
 /// @brief Class for highlighting CAOS 
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
         require_once(dirname(__FILE__).'/'.$format.'/Operators.php');
64 64
 
65 65
         //put into arrays
66
-        $this->caosCommandVariables = call_user_func(array($format.'CAOSCommandVariables','GetTokens'));
67
-        $this->caosCommands = call_user_func(array($format.'CAOSCommands','GetTokens'));
68
-        $this->caosVariables = call_user_func(array($format.'CAOSVariables','GetTokens'));
69
-        $this->caosOperators = call_user_func(array($format.'CAOSOperators','GetTokens'));
70
-        $this->caosFlowControls = call_user_func(array($format.'CAOSFlowControls','GetTokens'));
66
+        $this->caosCommandVariables = call_user_func(array($format.'CAOSCommandVariables', 'GetTokens'));
67
+        $this->caosCommands = call_user_func(array($format.'CAOSCommands', 'GetTokens'));
68
+        $this->caosVariables = call_user_func(array($format.'CAOSVariables', 'GetTokens'));
69
+        $this->caosOperators = call_user_func(array($format.'CAOSOperators', 'GetTokens'));
70
+        $this->caosFlowControls = call_user_func(array($format.'CAOSFlowControls', 'GetTokens'));
71 71
     }
72 72
 
73 73
     /// @brief Highlights the given CAOS script.
@@ -78,21 +78,21 @@  discard block
 block discarded – undo
78 78
      * @param $script the CAOS script as a string.
79 79
      */
80 80
     public function HighlightScript($script) {
81
-        if(strpos($script,"\r") !== false) {
82
-            $script = str_replace("\r\n","\n",$script); //get rid of mac and windows newlines.
83
-            $script = str_replace("\r","\n",$script);
81
+        if (strpos($script, "\r") !== false) {
82
+            $script = str_replace("\r\n", "\n", $script); //get rid of mac and windows newlines.
83
+            $script = str_replace("\r", "\n", $script);
84 84
         }
85 85
         //remove tabs and spaces before newlines.
86
-        $script = str_replace(" \n","\n",$script);
87
-        $script = str_replace("\t",'',$script);
86
+        $script = str_replace(" \n", "\n", $script);
87
+        $script = str_replace("\t", '', $script);
88 88
         $script = $this->SmartRemoveMultipleSpaces($script);
89
-        $this->scriptLines = explode("\n",$script);
89
+        $this->scriptLines = explode("\n", $script);
90 90
 
91 91
         //now that we have the lines, we can make the list of subroutines.
92 92
         $this->ScanForSubroutines();
93 93
         $this->currentLine = 0;
94 94
         $this->highlightedLines = array();
95
-        while(($line = $this->HighlightNextLine()) !== false) {
95
+        while (($line = $this->HighlightNextLine()) !== false) {
96 96
 
97 97
             $this->highlightedLines[] = $line;
98 98
         }
@@ -111,22 +111,22 @@  discard block
 block discarded – undo
111 111
         $newString = array();
112 112
         $inString = false;
113 113
         $inComment = false;
114
-        for($i=0;$i<strlen($text);$i++) {
114
+        for ($i = 0; $i < strlen($text); $i++) {
115 115
             $character = $text{$i};
116
-            if($character == '"') {
116
+            if ($character == '"') {
117 117
                 $inString = !$inString;
118
-            } else if($character == '*') {
118
+            } else if ($character == '*') {
119 119
                 $inComment = true;
120
-            } else if($character == "\n" ) {
120
+            } else if ($character == "\n") {
121 121
                 $inComment = false;
122
-            } else if(!$inString && !$inComment && $character == ' ') {
123
-                while($i+2 < strlen($text) && $text{$i+1} == ' ') {
122
+            } else if (!$inString && !$inComment && $character == ' ') {
123
+                while ($i+2 < strlen($text) && $text{$i+1} == ' ') {
124 124
                     $i++;
125 125
                 }
126 126
             }
127 127
             $newString[] = $character;
128 128
         }
129
-        return trim(implode('',$newString));
129
+        return trim(implode('', $newString));
130 130
     }
131 131
 
132 132
     /// @endcond
@@ -140,9 +140,9 @@  discard block
 block discarded – undo
140 140
      */
141 141
     private function ScanForSubroutines() {
142 142
         //expects $scriptLines to be filled out
143
-        foreach($this->scriptLines as $line) {
144
-            $words = explode(' ',strtolower($line));
145
-            if($words[0] == 'subr') {
143
+        foreach ($this->scriptLines as $line) {
144
+            $words = explode(' ', strtolower($line));
145
+            if ($words[0] == 'subr') {
146 146
                 $this->scriptSubroutines[] = $words[1];
147 147
             }
148 148
         }	
@@ -158,20 +158,20 @@  discard block
 block discarded – undo
158 158
      * CAOS highlighted and contains a lot of strange logic.
159 159
      */
160 160
     private function HighlightNextLine() {
161
-        if(sizeof($this->scriptLines) <= $this->currentLine) {
161
+        if (sizeof($this->scriptLines) <= $this->currentLine) {
162 162
             return false;
163 163
         }
164 164
         $line = $this->scriptLines[$this->currentLine];
165 165
         //$line = $this->SmartRemoveMultipleSpaces($line);
166
-        if(strlen($line) == 0 && $this->currentIndent > 0) {
166
+        if (strlen($line) == 0 && $this->currentIndent > 0) {
167 167
             $highlightedLine = $this->CreateIndentForThisLine('')."\n";
168 168
             $this->currentLine++;
169 169
             return $highlightedLine;
170
-        } else if(strlen($line) == 0) {
170
+        } else if (strlen($line) == 0) {
171 171
             $this->currentLine++;
172 172
             return '';
173 173
         }
174
-        $words = explode(' ',$line);
174
+        $words = explode(' ', $line);
175 175
 
176 176
         $this->SetIndentForThisLine($words[0]);
177 177
 
@@ -182,83 +182,83 @@  discard block
 block discarded – undo
182 182
         $firstToken = '';
183 183
 
184 184
         //if last line is a comment and this line starts with scrp set last line's indent to 0 (remove whitespace at front)
185
-        if(in_array($words[0],array('scrp','rscr'))) {
186
-            if(!empty($this->scriptLines[$this->currentLine-1])) {
187
-                if($this->scriptLines[$this->currentLine-1]{0} == '*') {
185
+        if (in_array($words[0], array('scrp', 'rscr'))) {
186
+            if (!empty($this->scriptLines[$this->currentLine-1])) {
187
+                if ($this->scriptLines[$this->currentLine-1]{0} == '*') {
188 188
                     $this->highlightedLines[$this->currentLine-1] = ltrim($this->highlightedLines[$this->currentLine-1]);
189 189
                 }
190 190
             }
191 191
         } 
192 192
 
193
-        for($this->currentWord=0;$this->currentWord<sizeof($words);$this->currentWord++) {
193
+        for ($this->currentWord = 0; $this->currentWord < sizeof($words); $this->currentWord++) {
194 194
 
195 195
             $word = $words[$this->currentWord];
196 196
             $highlightedWord = $word;
197
-            if($inString) {
198
-                if($this->currentWord == sizeof($words)-1) {
199
-                    if(strpos($word,'"') === false) {
197
+            if ($inString) {
198
+                if ($this->currentWord == sizeof($words)-1) {
199
+                    if (strpos($word, '"') === false) {
200 200
                         $highlightedWord = htmlentities($word).'</span>';
201
-                        $highlightedLineBeforeString = substr($highlightedLine,0,$whenStringBegan);
202
-                        $highlightedLineAfterString = substr($highlightedLine,$whenStringBegan);
201
+                        $highlightedLineBeforeString = substr($highlightedLine, 0, $whenStringBegan);
202
+                        $highlightedLineAfterString = substr($highlightedLine, $whenStringBegan);
203 203
                         $highlightedLineAfterString .= $highlightedWord;
204
-                        $highlightedLineAfterString = str_replace('<span class="string">','<span class="error">',$highlightedLineAfterString);
204
+                        $highlightedLineAfterString = str_replace('<span class="string">', '<span class="error">', $highlightedLineAfterString);
205 205
                         $highlightedLine = $highlightedLineBeforeString.$highlightedLineAfterString;
206 206
                         $inString = false;
207 207
                         continue;
208 208
 
209 209
                     }
210 210
                 }
211
-                if(($position = strpos($word,'"')) !== false) {
212
-                    $firstHalf = substr($word,0,$position);
213
-                    $secondHalf = substr($word,$position+1);
211
+                if (($position = strpos($word, '"')) !== false) {
212
+                    $firstHalf = substr($word, 0, $position);
213
+                    $secondHalf = substr($word, $position+1);
214 214
 
215 215
                     $highlightedWord = htmlentities($firstHalf).'"</span>'; //end the string
216
-                    if($secondHalf != '') {
216
+                    if ($secondHalf != '') {
217 217
                         $highlightedWord .= '<span class="error">'.htmlentities($secondHalf).'</span>';
218 218
                     }
219
-                    $inString=false;
219
+                    $inString = false;
220 220
                 } else {
221 221
                     $highlightedLine .= $word.' ';
222 222
                     continue;					
223 223
                 }
224
-            } else if($inByteString) {
225
-                if($this->currentWord == sizeof($words)-1) {
226
-                    if(strpos($word,']') === false) {
224
+            } else if ($inByteString) {
225
+                if ($this->currentWord == sizeof($words)-1) {
226
+                    if (strpos($word, ']') === false) {
227 227
                         $highlightedWord = htmlentities($word).'</span>';
228
-                        $highlightedLineBeforeString = substr($highlightedLine,0,$whenStringBegan);
229
-                        $highlightedLineAfterString = substr($highlightedLine,$whenStringBegan);
228
+                        $highlightedLineBeforeString = substr($highlightedLine, 0, $whenStringBegan);
229
+                        $highlightedLineAfterString = substr($highlightedLine, $whenStringBegan);
230 230
                         $highlightedLineAfterString .= $highlightedWord;
231
-                        $highlightedLineAfterString = str_replace('<span class="bytestring">','<span class="error">',$highlightedLineAfterString);
231
+                        $highlightedLineAfterString = str_replace('<span class="bytestring">', '<span class="error">', $highlightedLineAfterString);
232 232
                         $highlightedLine = $highlightedLineBeforeString.$highlightedLineAfterString;
233 233
                         continue;
234 234
                     }
235 235
                 }
236
-                if(($position = strpos($word,']')) !== false) {
237
-                    $firstHalf = substr($word,0,$position);
238
-                    $secondHalf = substr($word,$position+1);
236
+                if (($position = strpos($word, ']')) !== false) {
237
+                    $firstHalf = substr($word, 0, $position);
238
+                    $secondHalf = substr($word, $position+1);
239 239
 
240 240
                     $highlightedWord = htmlentities($firstHalf).']</span>'; //end the string
241
-                    if($secondHalf != '') {
241
+                    if ($secondHalf != '') {
242 242
                         $highlightedWord .= '<span class="error">'.htmlentities($secondHalf).'</span>';
243 243
                     }
244
-                    $inByteString=false;
244
+                    $inByteString = false;
245 245
                 } else {
246 246
                     $highlightedLine .= $word.' ';
247 247
                     continue;
248 248
                 }
249
-            } else if($firstToken != '') {
249
+            } else if ($firstToken != '') {
250 250
                 //sort out unquoted strings
251
-                if($this->currentWord == 1) {
252
-                    if($firstToken == 'subr') {
253
-                        if(strlen($word) == 4 || $this->scriptFormat != FORMAT_C2) {
251
+                if ($this->currentWord == 1) {
252
+                    if ($firstToken == 'subr') {
253
+                        if (strlen($word) == 4 || $this->scriptFormat != FORMAT_C2) {
254 254
                             $highlightedWord = '<span class="label">'.$word.'</span>';
255 255
                         } else {
256 256
                             $highlightedWord = '<span class="error">'.$word.'</span>';
257 257
                         }
258
-                    } else if($firstToken == 'gsub') {
259
-                        if(in_array($word,$this->scriptSubroutines)) {
258
+                    } else if ($firstToken == 'gsub') {
259
+                        if (in_array($word, $this->scriptSubroutines)) {
260 260
                             //C3/DS allow for any length of subroutine name, C2 and C1 probably only allow 4-character names.
261
-                            if(in_array($this->scriptFormat,array(FORMAT_C3,FORMAT_DS)) || strlen($word) == 4) {
261
+                            if (in_array($this->scriptFormat, array(FORMAT_C3, FORMAT_DS)) || strlen($word) == 4) {
262 262
                                 $highlightedWord = '<span class="label">'.$word.'</span>';
263 263
                             } else {
264 264
                                 $highlightedWord = '<span class="error">'.$word.'</span>';
@@ -267,29 +267,29 @@  discard block
 block discarded – undo
267 267
                             $highlightedWord = '<span class="error">'.$word.'</span>';
268 268
                         }
269 269
                     }
270
-                    if($this->scriptFormat == FORMAT_C2) {
271
-                        if(in_array(strtolower($firstToken),array('tokn','snde','sndc','sndl','sndq','plbs'))) {
272
-                            if(strlen($word) == 4) {
270
+                    if ($this->scriptFormat == FORMAT_C2) {
271
+                        if (in_array(strtolower($firstToken), array('tokn', 'snde', 'sndc', 'sndl', 'sndq', 'plbs'))) {
272
+                            if (strlen($word) == 4) {
273 273
                                 $highlightedWord = '<span class="string">'.$word.'</span>';
274 274
                             } else {
275 275
                                 $highlightedWord = '<span class="error">'.$word.'</span>';
276 276
                             }
277 277
                         }
278 278
                     }
279
-                } else if($this->currentWord == 2) {
280
-                    if($this->scriptFormat == 'C2') {
281
-                        if(preg_match('/^new: (scen|simp|cbtn|comp|vhcl|lift|bkbd|cbub)$/i',$firstToken)) {
282
-                            if(strlen($word) == 4) {
279
+                } else if ($this->currentWord == 2) {
280
+                    if ($this->scriptFormat == 'C2') {
281
+                        if (preg_match('/^new: (scen|simp|cbtn|comp|vhcl|lift|bkbd|cbub)$/i', $firstToken)) {
282
+                            if (strlen($word) == 4) {
283 283
                                 $highlightedWord = '<span class="string">'.$word.'</span>';
284 284
                             } else {
285 285
                                 $highlightedWord = '<span class="error">'.$word.'</span>';
286 286
                             }
287 287
                         }
288 288
                     }
289
-                } else if($this->currentWord == sizeof($words)-1) {
290
-                    if($this->scriptFormat == 'C2') {
291
-                        if(strtolower($firstToken) == 'rmsc') {
292
-                            if(strlen($word) == 4) {
289
+                } else if ($this->currentWord == sizeof($words)-1) {
290
+                    if ($this->scriptFormat == 'C2') {
291
+                        if (strtolower($firstToken) == 'rmsc') {
292
+                            if (strlen($word) == 4) {
293 293
                                 $highlightedWord = '<span class="string">'.$word.'</span>';
294 294
                             } else {
295 295
                                 $highlightedWord = '<span class="error">'.$word.'</span>';
@@ -298,17 +298,17 @@  discard block
 block discarded – undo
298 298
                     }
299 299
                 }
300 300
             }
301
-            if($highlightedWord == $word) {
301
+            if ($highlightedWord == $word) {
302 302
                 $highlightedWord = $this->TryToHighlightToken($word);
303
-                if($this->currentWord == 0) {
303
+                if ($this->currentWord == 0) {
304 304
                     $firstToken = $word;
305 305
                 }
306 306
                 //Highlight two-word block.
307
-                if($highlightedWord == $word && $this->currentWord < sizeof($words)-1) {
307
+                if ($highlightedWord == $word && $this->currentWord < sizeof($words)-1) {
308 308
                     $wordPair = $word.' '.$words[$this->currentWord+1];
309 309
                     $highlightedWord = $this->TryToHighlightToken($wordPair);
310
-                    if($highlightedWord != $wordPair) {
311
-                        if($this->currentWord == 0) {
310
+                    if ($highlightedWord != $wordPair) {
311
+                        if ($this->currentWord == 0) {
312 312
                             $firstToken = $wordPair;
313 313
                         }
314 314
                         $this->currentWord++;
@@ -316,46 +316,46 @@  discard block
 block discarded – undo
316 316
                         $highlightedWord = $word;
317 317
                     }
318 318
                 }
319
-                if($highlightedWord == $word) { //invalid caos command
320
-                    if($word{0} == '"' && $this->scriptFormat != FORMAT_C2) { //if it begins a string. (C2 has no strings)
319
+                if ($highlightedWord == $word) { //invalid caos command
320
+                    if ($word{0} == '"' && $this->scriptFormat != FORMAT_C2) { //if it begins a string. (C2 has no strings)
321 321
                         $whenStringBegan = strlen($highlightedLine);
322 322
                         $highlightedWord = '<span class="string">'.htmlentities($word);
323
-                        if($word{strlen($word)-1} == '"') {
323
+                        if ($word{strlen($word)-1} == '"') {
324 324
                             $highlightedWord .= '</span>'; //end the string
325 325
                             $inString = false;
326
-                        } else if($this->currentWord == sizeof($words)-1) {
326
+                        } else if ($this->currentWord == sizeof($words)-1) {
327 327
                             $highlightedWord = '<span class="error">'.htmlentities($word).'</span>';
328 328
                             $inString = false;
329 329
                         } else {
330 330
                             $inString = true;
331 331
                         }
332
-                    } else if($word{0} == '[') { //begins a bytestring
332
+                    } else if ($word{0} == '[') { //begins a bytestring
333 333
                         $highlightedWord = '<span class="bytestring">'.htmlentities($word);
334 334
                         $whenStringBegan = strlen($highlightedLine);
335
-                        if($this->scriptFormat == 'C2') {
335
+                        if ($this->scriptFormat == 'C2') {
336 336
                             //c2 bytestrings are part of the original term, on they're own they're wrong!
337 337
                             $highlightedWord = '<span class="error">'.htmlentities($word);
338 338
                         }
339
-                        if($word{strlen($word)-1} == ']') {
339
+                        if ($word{strlen($word)-1} == ']') {
340 340
                             $highlightedWord .= '</span>';
341 341
                             $inByteString = false;
342
-                        } else if($this->currentWord == sizeof($words)-1) {
342
+                        } else if ($this->currentWord == sizeof($words)-1) {
343 343
                             $highlightedWord = '<span class="error">'.htmlentities($word).'</span>';
344 344
                             $inByteString = false;
345 345
                         } else {
346 346
                             $inByteString = true;
347 347
                         }
348
-                    } else if(is_numeric($word)) {
348
+                    } else if (is_numeric($word)) {
349 349
                         $highlightedWord = '<span class="number">'.htmlentities($word).'</span>';
350
-                    } else if($word{0} == '*') { // because of SmartRemoveMultipleSpaces, prints exactly as written :)
350
+                    } else if ($word{0} == '*') { // because of SmartRemoveMultipleSpaces, prints exactly as written :)
351 351
                         $highlightedWord = '<span class="comment">';
352
-                        for($i=$this->currentWord;$i<sizeof($words);$i++)
352
+                        for ($i = $this->currentWord; $i < sizeof($words); $i++)
353 353
                         {
354
-                            if($i!=$this->currentWord)
354
+                            if ($i != $this->currentWord)
355 355
                             {
356
-                                $highlightedWord.=' ';
356
+                                $highlightedWord .= ' ';
357 357
                             }
358
-                            $highlightedWord.= htmlentities($words[$i]);
358
+                            $highlightedWord .= htmlentities($words[$i]);
359 359
                         }
360 360
                         $highlightedWord .= '</span>';
361 361
                         $highlightedLine .= $highlightedWord;
@@ -387,27 +387,27 @@  discard block
 block discarded – undo
387 387
 
388 388
         //first position commands + flow controls only
389 389
         //2nd position commands + command variables + variables only.
390
-        if(in_array($lcword,$this->caosCommands)) {
390
+        if (in_array($lcword, $this->caosCommands)) {
391 391
             $word = '<span class="command">'.htmlentities($word).'</span>';
392
-        } else if(in_array($lcword,$this->caosVariables)) {
392
+        } else if (in_array($lcword, $this->caosVariables)) {
393 393
             $word = '<span class="variable">'.htmlentities($word).'</span>';
394 394
             //vaXX, ovXX
395
-        } else if(in_array($this->scriptFormat,array('C2','C3','DS')) && preg_match("/^(va|ov)[0-9]{2}$/", $lcword)) {
395
+        } else if (in_array($this->scriptFormat, array('C2', 'C3', 'DS')) && preg_match("/^(va|ov)[0-9]{2}$/", $lcword)) {
396 396
             $word = '<span class="variable">'.htmlentities($word).'</span>';
397 397
             //mvXX
398
-        } else if(in_array($this->scriptFormat,array('C3','DS')) && preg_match('/^(mv)[0-9]{2}$/',$lcword)) {
398
+        } else if (in_array($this->scriptFormat, array('C3', 'DS')) && preg_match('/^(mv)[0-9]{2}$/', $lcword)) {
399 399
             $word = '<span class="variable">'.htmlentities($word).'</span>';
400 400
             //obvX
401
-        } else if(in_array($this->scriptFormat,array('C1','C2')) && preg_match('/^(obv)[0-9]$/',$lcword)) {
401
+        } else if (in_array($this->scriptFormat, array('C1', 'C2')) && preg_match('/^(obv)[0-9]$/', $lcword)) {
402 402
             $word = '<span class="variable">'.htmlentities($word).'</span>';
403
-        } else if($this->scriptFormat == 'C2' && preg_match('/^([Aa][Nn][Ii][Mm]|[Pp][Rr][Ll][Dd])(\[[0-9]+R?\])$/',$word,$matches)) {
403
+        } else if ($this->scriptFormat == 'C2' && preg_match('/^([Aa][Nn][Ii][Mm]|[Pp][Rr][Ll][Dd])(\[[0-9]+R?\])$/', $word, $matches)) {
404 404
             $word = '<span class="variable">'.strtolower($matches[1]).'</span><span class="bytestring">'.$matches[2].'</span>';
405
-        } else if(in_array($lcword,$this->caosOperators)) {
405
+        } else if (in_array($lcword, $this->caosOperators)) {
406 406
             $word = '<span class="operator">'.htmlentities($word).'</span>';
407
-        } else if(in_array($lcword,$this->caosFlowControls)) {
407
+        } else if (in_array($lcword, $this->caosFlowControls)) {
408 408
             $word = '<span class="flowcontrol">'.htmlentities($word).'</span>';
409
-        } else if(in_array($lcword,$this->caosCommandVariables)) {
410
-            if($this->currentWord == 0) {
409
+        } else if (in_array($lcword, $this->caosCommandVariables)) {
410
+            if ($this->currentWord == 0) {
411 411
                 $word = '<span class="command">'.htmlentities($word).'</span>';
412 412
             } else {
413 413
                 $word = '<span class="variable">'.htmlentities($word).'</span>';
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
      * @param $firstword The first word of the line
427 427
      */
428 428
     private function SetIndentForThisLine($firstword) {
429
-        switch($firstword) {
429
+        switch ($firstword) {
430 430
         case 'scrp':
431 431
         case 'endm':
432 432
         case 'rscr':
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
      * Sets the indent for the next line
457 457
      */
458 458
     private function SetIndentForNextLine($firstword) {
459
-        switch($firstword) {
459
+        switch ($firstword) {
460 460
         case 'scrp':
461 461
         case 'rscr':
462 462
         case 'iscr':
@@ -490,14 +490,14 @@  discard block
 block discarded – undo
490 490
      */
491 491
     private function CreateIndentForThisLine($firstword) {
492 492
         $indent = '';
493
-        if(in_array($firstword,array('scrp','rscr'))) {
494
-            if(!empty($this->previousLineCode)) {
495
-                if($this->previousLineCode{0} != '*') {
493
+        if (in_array($firstword, array('scrp', 'rscr'))) {
494
+            if (!empty($this->previousLineCode)) {
495
+                if ($this->previousLineCode{0} != '*') {
496 496
                     $indent = "\n";
497 497
                 }
498 498
             }
499 499
         }
500
-        for($i=0;$i<$this->currentIndent;$i++) {
500
+        for ($i = 0; $i < $this->currentIndent; $i++) {
501 501
             $indent .= "\t";
502 502
         }
503 503
         return $indent;
Please login to merge, or discard this patch.
caos/highlight/C2/FlowControls.php 1 patch
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,8 +5,7 @@
 block discarded – undo
5 5
 class C2CAOSFlowControls {
6 6
     /// @brief Returns an array of tokens.
7 7
 	public static function GetTokens() {
8
-		return array
9
-		(
8
+		return array(
10 9
 			'enum',
11 10
 			'esee',
12 11
 			'etch',
Please login to merge, or discard this patch.
caos/highlight/C2/Variables.php 1 patch
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,8 +9,7 @@
 block discarded – undo
9 9
 class C2CAOSVariables {
10 10
     /// @brief Returns an array of tokens.
11 11
 	public static function GetTokens() {
12
-		return array
13
-		(
12
+		return array(
14 13
 			'ownr',
15 14
 			'from',
16 15
 			'pntr',
Please login to merge, or discard this patch.
caos/highlight/C2/Commands.php 1 patch
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,8 +6,7 @@
 block discarded – undo
6 6
 class C2CAOSCommands {
7 7
     /// @brief Returns an array of tokens.
8 8
 	public static function GetTokens() {
9
-	    return array
10
-	    (
9
+	    return array(
11 10
 		    //creation
12 11
 		    'new: scen',
13 12
 		    'new: simp',
Please login to merge, or discard this patch.