Test Failed
Push — master ( 2c8b6d...9d1fea )
by Alxarafe
45:51
created
htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel5.php 1 patch
Switch Indentation   +897 added lines, -897 removed lines patch added patch discarded remove patch
@@ -994,76 +994,76 @@  discard block
 block discarded – undo
994 994
 			if ($definedName['isBuiltInName']) {
995 995
 				switch ($definedName['name']) {
996 996
 
997
-				case pack('C', 0x06):
998
-					// print area
999
-					//	in general, formula looks like this: Foo!$C$7:$J$66,Bar!$A$1:$IV$2
1000
-					$ranges = explode(',', $definedName['formula']); // FIXME: what if sheetname contains comma?
1001
-
1002
-					$extractedRanges = array();
1003
-					foreach ($ranges as $range) {
1004
-						// $range should look like one of these
1005
-						//		Foo!$C$7:$J$66
1006
-						//		Bar!$A$1:$IV$2
1007
-
1008
-						$explodes = explode('!', $range);	// FIXME: what if sheetname contains exclamation mark?
1009
-						$sheetName = trim($explodes[0], "'");
1010
-
1011
-						if (count($explodes) == 2) {
1012
-							if (strpos($explodes[1], ':') === FALSE) {
1013
-								$explodes[1] = $explodes[1] . ':' . $explodes[1];
1014
-							}
1015
-							$extractedRanges[] = str_replace('$', '', $explodes[1]); // C7:J66
1016
-						}
1017
-					}
1018
-					if ($docSheet = $this->_phpExcel->getSheetByName($sheetName)) {
1019
-						$docSheet->getPageSetup()->setPrintArea(implode(',', $extractedRanges)); // C7:J66,A1:IV2
1020
-					}
1021
-					break;
1022
-
1023
-				case pack('C', 0x07):
1024
-					// print titles (repeating rows)
1025
-					// Assuming BIFF8, there are 3 cases
1026
-					// 1. repeating rows
1027
-					//		formula looks like this: Sheet!$A$1:$IV$2
1028
-					//		rows 1-2 repeat
1029
-					// 2. repeating columns
1030
-					//		formula looks like this: Sheet!$A$1:$B$65536
1031
-					//		columns A-B repeat
1032
-					// 3. both repeating rows and repeating columns
1033
-					//		formula looks like this: Sheet!$A$1:$B$65536,Sheet!$A$1:$IV$2
1034
-
1035
-					$ranges = explode(',', $definedName['formula']); // FIXME: what if sheetname contains comma?
1036
-
1037
-					foreach ($ranges as $range) {
1038
-						// $range should look like this one of these
1039
-						//		Sheet!$A$1:$B$65536
1040
-						//		Sheet!$A$1:$IV$2
1041
-
1042
-						$explodes = explode('!', $range);
1043
-
1044
-						if (count($explodes) == 2) {
1045
-							if ($docSheet = $this->_phpExcel->getSheetByName($explodes[0])) {
1046
-
1047
-								$extractedRange = $explodes[1];
1048
-								$extractedRange = str_replace('$', '', $extractedRange);
1049
-
1050
-								$coordinateStrings = explode(':', $extractedRange);
1051
-								if (count($coordinateStrings) == 2) {
1052
-									list($firstColumn, $firstRow) = PHPExcel_Cell::coordinateFromString($coordinateStrings[0]);
1053
-									list($lastColumn, $lastRow) = PHPExcel_Cell::coordinateFromString($coordinateStrings[1]);
1054
-
1055
-									if ($firstColumn == 'A' and $lastColumn == 'IV') {
1056
-										// then we have repeating rows
1057
-										$docSheet->getPageSetup()->setRowsToRepeatAtTop(array($firstRow, $lastRow));
1058
-									} elseif ($firstRow == 1 and $lastRow == 65536) {
1059
-										// then we have repeating columns
1060
-										$docSheet->getPageSetup()->setColumnsToRepeatAtLeft(array($firstColumn, $lastColumn));
1061
-									}
1062
-								}
1063
-							}
1064
-						}
1065
-					}
1066
-					break;
997
+				    case pack('C', 0x06):
998
+					    // print area
999
+					    //	in general, formula looks like this: Foo!$C$7:$J$66,Bar!$A$1:$IV$2
1000
+					    $ranges = explode(',', $definedName['formula']); // FIXME: what if sheetname contains comma?
1001
+
1002
+					    $extractedRanges = array();
1003
+					    foreach ($ranges as $range) {
1004
+						    // $range should look like one of these
1005
+						    //		Foo!$C$7:$J$66
1006
+						    //		Bar!$A$1:$IV$2
1007
+
1008
+						    $explodes = explode('!', $range);	// FIXME: what if sheetname contains exclamation mark?
1009
+						    $sheetName = trim($explodes[0], "'");
1010
+
1011
+						    if (count($explodes) == 2) {
1012
+							    if (strpos($explodes[1], ':') === FALSE) {
1013
+								    $explodes[1] = $explodes[1] . ':' . $explodes[1];
1014
+							    }
1015
+							    $extractedRanges[] = str_replace('$', '', $explodes[1]); // C7:J66
1016
+						    }
1017
+					    }
1018
+					    if ($docSheet = $this->_phpExcel->getSheetByName($sheetName)) {
1019
+						    $docSheet->getPageSetup()->setPrintArea(implode(',', $extractedRanges)); // C7:J66,A1:IV2
1020
+					    }
1021
+					    break;
1022
+
1023
+				    case pack('C', 0x07):
1024
+					    // print titles (repeating rows)
1025
+					    // Assuming BIFF8, there are 3 cases
1026
+					    // 1. repeating rows
1027
+					    //		formula looks like this: Sheet!$A$1:$IV$2
1028
+					    //		rows 1-2 repeat
1029
+					    // 2. repeating columns
1030
+					    //		formula looks like this: Sheet!$A$1:$B$65536
1031
+					    //		columns A-B repeat
1032
+					    // 3. both repeating rows and repeating columns
1033
+					    //		formula looks like this: Sheet!$A$1:$B$65536,Sheet!$A$1:$IV$2
1034
+
1035
+					    $ranges = explode(',', $definedName['formula']); // FIXME: what if sheetname contains comma?
1036
+
1037
+					    foreach ($ranges as $range) {
1038
+						    // $range should look like this one of these
1039
+						    //		Sheet!$A$1:$B$65536
1040
+						    //		Sheet!$A$1:$IV$2
1041
+
1042
+						    $explodes = explode('!', $range);
1043
+
1044
+						    if (count($explodes) == 2) {
1045
+							    if ($docSheet = $this->_phpExcel->getSheetByName($explodes[0])) {
1046
+
1047
+								    $extractedRange = $explodes[1];
1048
+								    $extractedRange = str_replace('$', '', $extractedRange);
1049
+
1050
+								    $coordinateStrings = explode(':', $extractedRange);
1051
+								    if (count($coordinateStrings) == 2) {
1052
+									    list($firstColumn, $firstRow) = PHPExcel_Cell::coordinateFromString($coordinateStrings[0]);
1053
+									    list($lastColumn, $lastRow) = PHPExcel_Cell::coordinateFromString($coordinateStrings[1]);
1054
+
1055
+									    if ($firstColumn == 'A' and $lastColumn == 'IV') {
1056
+										    // then we have repeating rows
1057
+										    $docSheet->getPageSetup()->setRowsToRepeatAtTop(array($firstRow, $lastRow));
1058
+									    } elseif ($firstRow == 1 and $lastRow == 65536) {
1059
+										    // then we have repeating columns
1060
+										    $docSheet->getPageSetup()->setColumnsToRepeatAtLeft(array($firstColumn, $lastColumn));
1061
+									    }
1062
+								    }
1063
+							    }
1064
+						    }
1065
+					    }
1066
+					    break;
1067 1067
 
1068 1068
 				}
1069 1069
 			} else {
@@ -2491,12 +2491,12 @@  discard block
 block discarded – undo
2491 2491
 				$builtInId = ord($recordData{2});
2492 2492
 
2493 2493
 				switch ($builtInId) {
2494
-				case 0x00:
2495
-					// currently, we are not using this for anything
2496
-					break;
2494
+				    case 0x00:
2495
+					    // currently, we are not using this for anything
2496
+					    break;
2497 2497
 
2498
-				default:
2499
-					break;
2498
+				    default:
2499
+					    break;
2500 2500
 				}
2501 2501
 
2502 2502
 			} else {
@@ -3305,8 +3305,8 @@  discard block
 block discarded – undo
3305 3305
 			if (!$isNotInit) {
3306 3306
 				$this->_phpSheet->getPageSetup()->setPaperSize($paperSize);
3307 3307
 				switch ($isPortrait) {
3308
-				case 0: $this->_phpSheet->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE); break;
3309
-				case 1: $this->_phpSheet->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT); break;
3308
+				    case 0: $this->_phpSheet->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE); break;
3309
+				    case 1: $this->_phpSheet->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT); break;
3310 3310
 				}
3311 3311
 
3312 3312
 				$this->_phpSheet->getPageSetup()->setScale($scale, false);
@@ -4551,93 +4551,93 @@  discard block
 block discarded – undo
4551 4551
 			}
4552 4552
 
4553 4553
 			switch ($hyperlinkType) {
4554
-			case 'URL':
4555
-				// section 5.58.2: Hyperlink containing a URL
4556
-				// e.g. http://example.org/index.php
4557
-
4558
-				// offset: var; size: 16; GUID of URL Moniker
4559
-				$offset += 16;
4560
-				// offset: var; size: 4; size (in bytes) of character array of the URL including trailing zero word
4561
-				$us = self::_GetInt4d($recordData, $offset);
4562
-				$offset += 4;
4563
-				// offset: var; size: $us; character array of the URL, no Unicode string header, always 16-bit characters, zero-terminated
4564
-				$url = self::_encodeUTF16(substr($recordData, $offset, $us - 2), false);
4565
-                $nullOffset = strpos($url, 0x00);
4566
-				if ($nullOffset)
4567
-                    $url = substr($url,0,$nullOffset);
4568
-				$url .= $hasText ? '#' : '';
4569
-				$offset += $us;
4570
-				break;
4571
-
4572
-			case 'local':
4573
-				// section 5.58.3: Hyperlink to local file
4574
-				// examples:
4575
-				//   mydoc.txt
4576
-				//   ../../somedoc.xls#Sheet!A1
4577
-
4578
-				// offset: var; size: 16; GUI of File Moniker
4579
-				$offset += 16;
4580
-
4581
-				// offset: var; size: 2; directory up-level count.
4582
-				$upLevelCount = self::_GetInt2d($recordData, $offset);
4583
-				$offset += 2;
4584
-
4585
-				// offset: var; size: 4; character count of the shortened file path and name, including trailing zero word
4586
-				$sl = self::_GetInt4d($recordData, $offset);
4587
-				$offset += 4;
4588
-
4589
-				// offset: var; size: sl; character array of the shortened file path and name in 8.3-DOS-format (compressed Unicode string)
4590
-				$shortenedFilePath = substr($recordData, $offset, $sl);
4591
-				$shortenedFilePath = self::_encodeUTF16($shortenedFilePath, true);
4592
-				$shortenedFilePath = substr($shortenedFilePath, 0, -1); // remove trailing zero
4593
-
4594
-				$offset += $sl;
4595
-
4596
-				// offset: var; size: 24; unknown sequence
4597
-				$offset += 24;
4598
-
4599
-				// extended file path
4600
-				// offset: var; size: 4; size of the following file link field including string lenth mark
4601
-				$sz = self::_GetInt4d($recordData, $offset);
4602
-				$offset += 4;
4603
-
4604
-				// only present if $sz > 0
4605
-				if ($sz > 0) {
4606
-					// offset: var; size: 4; size of the character array of the extended file path and name
4607
-					$xl = self::_GetInt4d($recordData, $offset);
4608
-					$offset += 4;
4609
-
4610
-					// offset: var; size 2; unknown
4611
-					$offset += 2;
4612
-
4613
-					// offset: var; size $xl; character array of the extended file path and name.
4614
-					$extendedFilePath = substr($recordData, $offset, $xl);
4615
-					$extendedFilePath = self::_encodeUTF16($extendedFilePath, false);
4616
-					$offset += $xl;
4617
-				}
4618
-
4619
-				// construct the path
4620
-				$url = str_repeat('..\\', $upLevelCount);
4621
-				$url .= ($sz > 0) ?
4622
-					$extendedFilePath : $shortenedFilePath; // use extended path if available
4623
-				$url .= $hasText ? '#' : '';
4624
-
4625
-				break;
4626
-
4627
-
4628
-			case 'UNC':
4629
-				// section 5.58.4: Hyperlink to a File with UNC (Universal Naming Convention) Path
4630
-				// todo: implement
4631
-				return;
4632
-
4633
-			case 'workbook':
4634
-				// section 5.58.5: Hyperlink to the Current Workbook
4635
-				// e.g. Sheet2!B1:C2, stored in text mark field
4636
-				$url = 'sheet://';
4637
-				break;
4638
-
4639
-			default:
4640
-				return;
4554
+			    case 'URL':
4555
+				    // section 5.58.2: Hyperlink containing a URL
4556
+				    // e.g. http://example.org/index.php
4557
+
4558
+				    // offset: var; size: 16; GUID of URL Moniker
4559
+				    $offset += 16;
4560
+				    // offset: var; size: 4; size (in bytes) of character array of the URL including trailing zero word
4561
+				    $us = self::_GetInt4d($recordData, $offset);
4562
+				    $offset += 4;
4563
+				    // offset: var; size: $us; character array of the URL, no Unicode string header, always 16-bit characters, zero-terminated
4564
+				    $url = self::_encodeUTF16(substr($recordData, $offset, $us - 2), false);
4565
+                    $nullOffset = strpos($url, 0x00);
4566
+				    if ($nullOffset)
4567
+                        $url = substr($url,0,$nullOffset);
4568
+				    $url .= $hasText ? '#' : '';
4569
+				    $offset += $us;
4570
+				    break;
4571
+
4572
+			    case 'local':
4573
+				    // section 5.58.3: Hyperlink to local file
4574
+				    // examples:
4575
+				    //   mydoc.txt
4576
+				    //   ../../somedoc.xls#Sheet!A1
4577
+
4578
+				    // offset: var; size: 16; GUI of File Moniker
4579
+				    $offset += 16;
4580
+
4581
+				    // offset: var; size: 2; directory up-level count.
4582
+				    $upLevelCount = self::_GetInt2d($recordData, $offset);
4583
+				    $offset += 2;
4584
+
4585
+				    // offset: var; size: 4; character count of the shortened file path and name, including trailing zero word
4586
+				    $sl = self::_GetInt4d($recordData, $offset);
4587
+				    $offset += 4;
4588
+
4589
+				    // offset: var; size: sl; character array of the shortened file path and name in 8.3-DOS-format (compressed Unicode string)
4590
+				    $shortenedFilePath = substr($recordData, $offset, $sl);
4591
+				    $shortenedFilePath = self::_encodeUTF16($shortenedFilePath, true);
4592
+				    $shortenedFilePath = substr($shortenedFilePath, 0, -1); // remove trailing zero
4593
+
4594
+				    $offset += $sl;
4595
+
4596
+				    // offset: var; size: 24; unknown sequence
4597
+				    $offset += 24;
4598
+
4599
+				    // extended file path
4600
+				    // offset: var; size: 4; size of the following file link field including string lenth mark
4601
+				    $sz = self::_GetInt4d($recordData, $offset);
4602
+				    $offset += 4;
4603
+
4604
+				    // only present if $sz > 0
4605
+				    if ($sz > 0) {
4606
+					    // offset: var; size: 4; size of the character array of the extended file path and name
4607
+					    $xl = self::_GetInt4d($recordData, $offset);
4608
+					    $offset += 4;
4609
+
4610
+					    // offset: var; size 2; unknown
4611
+					    $offset += 2;
4612
+
4613
+					    // offset: var; size $xl; character array of the extended file path and name.
4614
+					    $extendedFilePath = substr($recordData, $offset, $xl);
4615
+					    $extendedFilePath = self::_encodeUTF16($extendedFilePath, false);
4616
+					    $offset += $xl;
4617
+				    }
4618
+
4619
+				    // construct the path
4620
+				    $url = str_repeat('..\\', $upLevelCount);
4621
+				    $url .= ($sz > 0) ?
4622
+					    $extendedFilePath : $shortenedFilePath; // use extended path if available
4623
+				    $url .= $hasText ? '#' : '';
4624
+
4625
+				    break;
4626
+
4627
+
4628
+			    case 'UNC':
4629
+				    // section 5.58.4: Hyperlink to a File with UNC (Universal Naming Convention) Path
4630
+				    // todo: implement
4631
+				    return;
4632
+
4633
+			    case 'workbook':
4634
+				    // section 5.58.5: Hyperlink to the Current Workbook
4635
+				    // e.g. Sheet2!B1:C2, stored in text mark field
4636
+				    $url = 'sheet://';
4637
+				    break;
4638
+
4639
+			    default:
4640
+				    return;
4641 4641
 
4642 4642
 			}
4643 4643
 
@@ -5059,54 +5059,54 @@  discard block
 block discarded – undo
5059 5059
 		$iData = substr($recordData, 8);
5060 5060
 
5061 5061
 		switch ($cf) {
5062
-		case 0x09: // Windows bitmap format
5063
-			// BITMAPCOREINFO
5064
-			// 1. BITMAPCOREHEADER
5065
-			// offset: 0; size: 4; bcSize, Specifies the number of bytes required by the structure
5066
-			$bcSize = self::_GetInt4d($iData, 0);
5067
-//			var_dump($bcSize);
5068
-
5069
-			// offset: 4; size: 2; bcWidth, specifies the width of the bitmap, in pixels
5070
-			$bcWidth = self::_GetInt2d($iData, 4);
5071
-//			var_dump($bcWidth);
5072
-
5073
-			// offset: 6; size: 2; bcHeight, specifies the height of the bitmap, in pixels.
5074
-			$bcHeight = self::_GetInt2d($iData, 6);
5075
-//			var_dump($bcHeight);
5076
-			$ih = imagecreatetruecolor($bcWidth, $bcHeight);
5077
-
5078
-			// offset: 8; size: 2; bcPlanes, specifies the number of planes for the target device. This value must be 1
5079
-
5080
-			// offset: 10; size: 2; bcBitCount specifies the number of bits-per-pixel. This value must be 1, 4, 8, or 24
5081
-			$bcBitCount = self::_GetInt2d($iData, 10);
5082
-//			var_dump($bcBitCount);
5083
-
5084
-			$rgbString = substr($iData, 12);
5085
-			$rgbTriples = array();
5086
-			while (strlen($rgbString) > 0) {
5087
-				$rgbTriples[] = unpack('Cb/Cg/Cr', $rgbString);
5088
-				$rgbString = substr($rgbString, 3);
5089
-			}
5090
-			$x = 0;
5091
-			$y = 0;
5092
-			foreach ($rgbTriples as $i => $rgbTriple) {
5093
-				$color = imagecolorallocate($ih, $rgbTriple['r'], $rgbTriple['g'], $rgbTriple['b']);
5094
-				imagesetpixel($ih, $x, $bcHeight - 1 - $y, $color);
5095
-				$x = ($x + 1) % $bcWidth;
5096
-				$y = $y + floor(($x + 1) / $bcWidth);
5097
-			}
5098
-			//imagepng($ih, 'image.png');
5099
-
5100
-			$drawing = new PHPExcel_Worksheet_Drawing();
5101
-			$drawing->setPath($filename);
5102
-			$drawing->setWorksheet($this->_phpSheet);
5103
-
5104
-			break;
5105
-
5106
-		case 0x02: // Windows metafile or Macintosh PICT format
5107
-		case 0x0e: // native format
5108
-		default;
5109
-			break;
5062
+		    case 0x09: // Windows bitmap format
5063
+			    // BITMAPCOREINFO
5064
+			    // 1. BITMAPCOREHEADER
5065
+			    // offset: 0; size: 4; bcSize, Specifies the number of bytes required by the structure
5066
+			    $bcSize = self::_GetInt4d($iData, 0);
5067
+    //			var_dump($bcSize);
5068
+
5069
+			    // offset: 4; size: 2; bcWidth, specifies the width of the bitmap, in pixels
5070
+			    $bcWidth = self::_GetInt2d($iData, 4);
5071
+    //			var_dump($bcWidth);
5072
+
5073
+			    // offset: 6; size: 2; bcHeight, specifies the height of the bitmap, in pixels.
5074
+			    $bcHeight = self::_GetInt2d($iData, 6);
5075
+    //			var_dump($bcHeight);
5076
+			    $ih = imagecreatetruecolor($bcWidth, $bcHeight);
5077
+
5078
+			    // offset: 8; size: 2; bcPlanes, specifies the number of planes for the target device. This value must be 1
5079
+
5080
+			    // offset: 10; size: 2; bcBitCount specifies the number of bits-per-pixel. This value must be 1, 4, 8, or 24
5081
+			    $bcBitCount = self::_GetInt2d($iData, 10);
5082
+    //			var_dump($bcBitCount);
5083
+
5084
+			    $rgbString = substr($iData, 12);
5085
+			    $rgbTriples = array();
5086
+			    while (strlen($rgbString) > 0) {
5087
+				    $rgbTriples[] = unpack('Cb/Cg/Cr', $rgbString);
5088
+				    $rgbString = substr($rgbString, 3);
5089
+			    }
5090
+			    $x = 0;
5091
+			    $y = 0;
5092
+			    foreach ($rgbTriples as $i => $rgbTriple) {
5093
+				    $color = imagecolorallocate($ih, $rgbTriple['r'], $rgbTriple['g'], $rgbTriple['b']);
5094
+				    imagesetpixel($ih, $x, $bcHeight - 1 - $y, $color);
5095
+				    $x = ($x + 1) % $bcWidth;
5096
+				    $y = $y + floor(($x + 1) / $bcWidth);
5097
+			    }
5098
+			    //imagepng($ih, 'image.png');
5099
+
5100
+			    $drawing = new PHPExcel_Worksheet_Drawing();
5101
+			    $drawing->setPath($filename);
5102
+			    $drawing->setWorksheet($this->_phpSheet);
5103
+
5104
+			    break;
5105
+
5106
+		    case 0x02: // Windows metafile or Macintosh PICT format
5107
+		    case 0x0e: // native format
5108
+		    default;
5109
+			    break;
5110 5110
 
5111 5111
 		}
5112 5112
 
@@ -5298,132 +5298,132 @@  discard block
 block discarded – undo
5298 5298
 			$space5 = isset($space5) ? $space5 : ''; // carriage returns before closing parenthesis
5299 5299
 
5300 5300
 			switch ($token['name']) {
5301
-			case 'tAdd': // addition
5302
-			case 'tConcat': // addition
5303
-			case 'tDiv': // division
5304
-			case 'tEQ': // equality
5305
-			case 'tGE': // greater than or equal
5306
-			case 'tGT': // greater than
5307
-			case 'tIsect': // intersection
5308
-			case 'tLE': // less than or equal
5309
-			case 'tList': // less than or equal
5310
-			case 'tLT': // less than
5311
-			case 'tMul': // multiplication
5312
-			case 'tNE': // multiplication
5313
-			case 'tPower': // power
5314
-			case 'tRange': // range
5315
-			case 'tSub': // subtraction
5316
-				$op2 = array_pop($formulaStrings);
5317
-				$op1 = array_pop($formulaStrings);
5318
-				$formulaStrings[] = "$op1$space1$space0{$token['data']}$op2";
5319
-				unset($space0, $space1);
5320
-				break;
5321
-			case 'tUplus': // unary plus
5322
-			case 'tUminus': // unary minus
5323
-				$op = array_pop($formulaStrings);
5324
-				$formulaStrings[] = "$space1$space0{$token['data']}$op";
5325
-				unset($space0, $space1);
5326
-				break;
5327
-			case 'tPercent': // percent sign
5328
-				$op = array_pop($formulaStrings);
5329
-				$formulaStrings[] = "$op$space1$space0{$token['data']}";
5330
-				unset($space0, $space1);
5331
-				break;
5332
-			case 'tAttrVolatile': // indicates volatile function
5333
-			case 'tAttrIf':
5334
-			case 'tAttrSkip':
5335
-			case 'tAttrChoose':
5336
-				// token is only important for Excel formula evaluator
5337
-				// do nothing
5338
-				break;
5339
-			case 'tAttrSpace': // space / carriage return
5340
-				// space will be used when next token arrives, do not alter formulaString stack
5341
-				switch ($token['data']['spacetype']) {
5342
-				case 'type0':
5343
-					$space0 = str_repeat(' ', $token['data']['spacecount']);
5344
-					break;
5345
-				case 'type1':
5346
-					$space1 = str_repeat("\n", $token['data']['spacecount']);
5347
-					break;
5348
-				case 'type2':
5349
-					$space2 = str_repeat(' ', $token['data']['spacecount']);
5350
-					break;
5351
-				case 'type3':
5352
-					$space3 = str_repeat("\n", $token['data']['spacecount']);
5353
-					break;
5354
-				case 'type4':
5355
-					$space4 = str_repeat(' ', $token['data']['spacecount']);
5356
-					break;
5357
-				case 'type5':
5358
-					$space5 = str_repeat("\n", $token['data']['spacecount']);
5359
-					break;
5360
-				}
5361
-				break;
5362
-			case 'tAttrSum': // SUM function with one parameter
5363
-				$op = array_pop($formulaStrings);
5364
-				$formulaStrings[] = "{$space1}{$space0}SUM($op)";
5365
-				unset($space0, $space1);
5366
-				break;
5367
-			case 'tFunc': // function with fixed number of arguments
5368
-			case 'tFuncV': // function with variable number of arguments
5369
-				if ($token['data']['function'] != '') {
5370
-					// normal function
5371
-					$ops = array(); // array of operators
5372
-					for ($i = 0; $i < $token['data']['args']; ++$i) {
5373
-						$ops[] = array_pop($formulaStrings);
5374
-					}
5375
-					$ops = array_reverse($ops);
5376
-					$formulaStrings[] = "$space1$space0{$token['data']['function']}(" . implode(',', $ops) . ")";
5377
-					unset($space0, $space1);
5378
-				} else {
5379
-					// add-in function
5380
-					$ops = array(); // array of operators
5381
-					for ($i = 0; $i < $token['data']['args'] - 1; ++$i) {
5382
-						$ops[] = array_pop($formulaStrings);
5383
-					}
5384
-					$ops = array_reverse($ops);
5385
-					$function = array_pop($formulaStrings);
5386
-					$formulaStrings[] = "$space1$space0$function(" . implode(',', $ops) . ")";
5387
-					unset($space0, $space1);
5388
-				}
5389
-				break;
5390
-			case 'tParen': // parenthesis
5391
-				$expression = array_pop($formulaStrings);
5392
-				$formulaStrings[] = "$space3$space2($expression$space5$space4)";
5393
-				unset($space2, $space3, $space4, $space5);
5394
-				break;
5395
-			case 'tArray': // array constant
5396
-				$constantArray = self::_readBIFF8ConstantArray($additionalData);
5397
-				$formulaStrings[] = $space1 . $space0 . $constantArray['value'];
5398
-				$additionalData = substr($additionalData, $constantArray['size']); // bite of chunk of additional data
5399
-				unset($space0, $space1);
5400
-				break;
5401
-			case 'tMemArea':
5402
-				// bite off chunk of additional data
5403
-				$cellRangeAddressList = $this->_readBIFF8CellRangeAddressList($additionalData);
5404
-				$additionalData = substr($additionalData, $cellRangeAddressList['size']);
5405
-				$formulaStrings[] = "$space1$space0{$token['data']}";
5406
-				unset($space0, $space1);
5407
-				break;
5408
-			case 'tArea': // cell range address
5409
-			case 'tBool': // boolean
5410
-			case 'tErr': // error code
5411
-			case 'tInt': // integer
5412
-			case 'tMemErr':
5413
-			case 'tMemFunc':
5414
-			case 'tMissArg':
5415
-			case 'tName':
5416
-			case 'tNameX':
5417
-			case 'tNum': // number
5418
-			case 'tRef': // single cell reference
5419
-			case 'tRef3d': // 3d cell reference
5420
-			case 'tArea3d': // 3d cell range reference
5421
-			case 'tRefN':
5422
-			case 'tAreaN':
5423
-			case 'tStr': // string
5424
-				$formulaStrings[] = "$space1$space0{$token['data']}";
5425
-				unset($space0, $space1);
5301
+			    case 'tAdd': // addition
5302
+			    case 'tConcat': // addition
5303
+			    case 'tDiv': // division
5304
+			    case 'tEQ': // equality
5305
+			    case 'tGE': // greater than or equal
5306
+			    case 'tGT': // greater than
5307
+			    case 'tIsect': // intersection
5308
+			    case 'tLE': // less than or equal
5309
+			    case 'tList': // less than or equal
5310
+			    case 'tLT': // less than
5311
+			    case 'tMul': // multiplication
5312
+			    case 'tNE': // multiplication
5313
+			    case 'tPower': // power
5314
+			    case 'tRange': // range
5315
+			    case 'tSub': // subtraction
5316
+				    $op2 = array_pop($formulaStrings);
5317
+				    $op1 = array_pop($formulaStrings);
5318
+				    $formulaStrings[] = "$op1$space1$space0{$token['data']}$op2";
5319
+				    unset($space0, $space1);
5320
+				    break;
5321
+			    case 'tUplus': // unary plus
5322
+			    case 'tUminus': // unary minus
5323
+				    $op = array_pop($formulaStrings);
5324
+				    $formulaStrings[] = "$space1$space0{$token['data']}$op";
5325
+				    unset($space0, $space1);
5326
+				    break;
5327
+			    case 'tPercent': // percent sign
5328
+				    $op = array_pop($formulaStrings);
5329
+				    $formulaStrings[] = "$op$space1$space0{$token['data']}";
5330
+				    unset($space0, $space1);
5331
+				    break;
5332
+			    case 'tAttrVolatile': // indicates volatile function
5333
+			    case 'tAttrIf':
5334
+			    case 'tAttrSkip':
5335
+			    case 'tAttrChoose':
5336
+				    // token is only important for Excel formula evaluator
5337
+				    // do nothing
5338
+				    break;
5339
+			    case 'tAttrSpace': // space / carriage return
5340
+				    // space will be used when next token arrives, do not alter formulaString stack
5341
+				    switch ($token['data']['spacetype']) {
5342
+				        case 'type0':
5343
+					        $space0 = str_repeat(' ', $token['data']['spacecount']);
5344
+					        break;
5345
+				        case 'type1':
5346
+					        $space1 = str_repeat("\n", $token['data']['spacecount']);
5347
+					        break;
5348
+				        case 'type2':
5349
+					        $space2 = str_repeat(' ', $token['data']['spacecount']);
5350
+					        break;
5351
+				        case 'type3':
5352
+					        $space3 = str_repeat("\n", $token['data']['spacecount']);
5353
+					        break;
5354
+				        case 'type4':
5355
+					        $space4 = str_repeat(' ', $token['data']['spacecount']);
5356
+					        break;
5357
+				        case 'type5':
5358
+					        $space5 = str_repeat("\n", $token['data']['spacecount']);
5359
+					        break;
5360
+				    }
5426 5361
 				break;
5362
+			    case 'tAttrSum': // SUM function with one parameter
5363
+				    $op = array_pop($formulaStrings);
5364
+				    $formulaStrings[] = "{$space1}{$space0}SUM($op)";
5365
+				    unset($space0, $space1);
5366
+				    break;
5367
+			    case 'tFunc': // function with fixed number of arguments
5368
+			    case 'tFuncV': // function with variable number of arguments
5369
+				    if ($token['data']['function'] != '') {
5370
+					    // normal function
5371
+					    $ops = array(); // array of operators
5372
+					    for ($i = 0; $i < $token['data']['args']; ++$i) {
5373
+						    $ops[] = array_pop($formulaStrings);
5374
+					    }
5375
+					    $ops = array_reverse($ops);
5376
+					    $formulaStrings[] = "$space1$space0{$token['data']['function']}(" . implode(',', $ops) . ")";
5377
+					    unset($space0, $space1);
5378
+				    } else {
5379
+					    // add-in function
5380
+					    $ops = array(); // array of operators
5381
+					    for ($i = 0; $i < $token['data']['args'] - 1; ++$i) {
5382
+						    $ops[] = array_pop($formulaStrings);
5383
+					    }
5384
+					    $ops = array_reverse($ops);
5385
+					    $function = array_pop($formulaStrings);
5386
+					    $formulaStrings[] = "$space1$space0$function(" . implode(',', $ops) . ")";
5387
+					    unset($space0, $space1);
5388
+				    }
5389
+				    break;
5390
+			    case 'tParen': // parenthesis
5391
+				    $expression = array_pop($formulaStrings);
5392
+				    $formulaStrings[] = "$space3$space2($expression$space5$space4)";
5393
+				    unset($space2, $space3, $space4, $space5);
5394
+				    break;
5395
+			    case 'tArray': // array constant
5396
+				    $constantArray = self::_readBIFF8ConstantArray($additionalData);
5397
+				    $formulaStrings[] = $space1 . $space0 . $constantArray['value'];
5398
+				    $additionalData = substr($additionalData, $constantArray['size']); // bite of chunk of additional data
5399
+				    unset($space0, $space1);
5400
+				    break;
5401
+			    case 'tMemArea':
5402
+				    // bite off chunk of additional data
5403
+				    $cellRangeAddressList = $this->_readBIFF8CellRangeAddressList($additionalData);
5404
+				    $additionalData = substr($additionalData, $cellRangeAddressList['size']);
5405
+				    $formulaStrings[] = "$space1$space0{$token['data']}";
5406
+				    unset($space0, $space1);
5407
+				    break;
5408
+			    case 'tArea': // cell range address
5409
+			    case 'tBool': // boolean
5410
+			    case 'tErr': // error code
5411
+			    case 'tInt': // integer
5412
+			    case 'tMemErr':
5413
+			    case 'tMemFunc':
5414
+			    case 'tMissArg':
5415
+			    case 'tName':
5416
+			    case 'tNameX':
5417
+			    case 'tNum': // number
5418
+			    case 'tRef': // single cell reference
5419
+			    case 'tRef3d': // 3d cell reference
5420
+			    case 'tArea3d': // 3d cell range reference
5421
+			    case 'tRefN':
5422
+			    case 'tAreaN':
5423
+			    case 'tStr': // string
5424
+				    $formulaStrings[] = "$space1$space0{$token['data']}";
5425
+				    unset($space0, $space1);
5426
+				    break;
5427 5427
 			}
5428 5428
 		}
5429 5429
 		$formulaString = $formulaStrings[0];
@@ -5451,546 +5451,546 @@  discard block
 block discarded – undo
5451 5451
 		$name = false; // initialize token name
5452 5452
 
5453 5453
 		switch ($id) {
5454
-		case 0x03: $name = 'tAdd';		$size = 1;	$data = '+';	break;
5455
-		case 0x04: $name = 'tSub';		$size = 1;	$data = '-';	break;
5456
-		case 0x05: $name = 'tMul';		$size = 1;	$data = '*';	break;
5457
-		case 0x06: $name = 'tDiv';		$size = 1;	$data = '/';	break;
5458
-		case 0x07: $name = 'tPower';	$size = 1;	$data = '^';	break;
5459
-		case 0x08: $name = 'tConcat';	$size = 1;	$data = '&';	break;
5460
-		case 0x09: $name = 'tLT';		$size = 1;	$data = '<';	break;
5461
-		case 0x0A: $name = 'tLE';		$size = 1;	$data = '<=';	break;
5462
-		case 0x0B: $name = 'tEQ';		$size = 1;	$data = '=';	break;
5463
-		case 0x0C: $name = 'tGE';		$size = 1;	$data = '>=';	break;
5464
-		case 0x0D: $name = 'tGT';		$size = 1;	$data = '>';	break;
5465
-		case 0x0E: $name = 'tNE';		$size = 1;	$data = '<>';	break;
5466
-		case 0x0F: $name = 'tIsect';	$size = 1;	$data = ' ';	break;
5467
-		case 0x10: $name = 'tList';		$size = 1;	$data = ',';	break;
5468
-		case 0x11: $name = 'tRange';	$size = 1;	$data = ':';	break;
5469
-		case 0x12: $name = 'tUplus';	$size = 1;	$data = '+';	break;
5470
-		case 0x13: $name = 'tUminus';	$size = 1;	$data = '-';	break;
5471
-		case 0x14: $name = 'tPercent';	$size = 1;	$data = '%';	break;
5472
-		case 0x15:	//	parenthesis
5473
-			$name  = 'tParen';
5474
-			$size  = 1;
5475
-			$data = null;
5476
-			break;
5477
-		case 0x16:	//	missing argument
5478
-			$name = 'tMissArg';
5479
-			$size = 1;
5480
-			$data = '';
5481
-			break;
5482
-		case 0x17:	//	string
5483
-			$name = 'tStr';
5484
-			// offset: 1; size: var; Unicode string, 8-bit string length
5485
-			$string = self::_readUnicodeStringShort(substr($formulaData, 1));
5486
-			$size = 1 + $string['size'];
5487
-			$data = self::_UTF8toExcelDoubleQuoted($string['value']);
5488
-			break;
5489
-		case 0x19:	//	Special attribute
5490
-			// offset: 1; size: 1; attribute type flags:
5491
-			switch (ord($formulaData[1])) {
5492
-			case 0x01:
5493
-				$name = 'tAttrVolatile';
5494
-				$size = 4;
5495
-				$data = null;
5496
-				break;
5497
-			case 0x02:
5498
-				$name = 'tAttrIf';
5499
-				$size = 4;
5500
-				$data = null;
5501
-				break;
5502
-			case 0x04:
5503
-				$name = 'tAttrChoose';
5504
-				// offset: 2; size: 2; number of choices in the CHOOSE function ($nc, number of parameters decreased by 1)
5505
-				$nc = self::_GetInt2d($formulaData, 2);
5506
-				// offset: 4; size: 2 * $nc
5507
-				// offset: 4 + 2 * $nc; size: 2
5508
-				$size = 2 * $nc + 6;
5509
-				$data = null;
5510
-				break;
5511
-			case 0x08:
5512
-				$name = 'tAttrSkip';
5513
-				$size = 4;
5514
-				$data = null;
5515
-				break;
5516
-			case 0x10:
5517
-				$name = 'tAttrSum';
5518
-				$size = 4;
5519
-				$data = null;
5520
-				break;
5521
-			case 0x40:
5522
-			case 0x41:
5523
-				$name = 'tAttrSpace';
5524
-				$size = 4;
5525
-				// offset: 2; size: 2; space type and position
5526
-				switch (ord($formulaData[2])) {
5527
-				case 0x00:
5528
-					$spacetype = 'type0';
5529
-					break;
5530
-				case 0x01:
5531
-					$spacetype = 'type1';
5532
-					break;
5533
-				case 0x02:
5534
-					$spacetype = 'type2';
5535
-					break;
5536
-				case 0x03:
5537
-					$spacetype = 'type3';
5538
-					break;
5539
-				case 0x04:
5540
-					$spacetype = 'type4';
5541
-					break;
5542
-				case 0x05:
5543
-					$spacetype = 'type5';
5544
-					break;
5545
-				default:
5546
-					throw new PHPExcel_Reader_Exception('Unrecognized space type in tAttrSpace token');
5547
-					break;
5548
-				}
5549
-				// offset: 3; size: 1; number of inserted spaces/carriage returns
5550
-				$spacecount = ord($formulaData[3]);
5551
-
5552
-				$data = array('spacetype' => $spacetype, 'spacecount' => $spacecount);
5553
-				break;
5454
+		    case 0x03: $name = 'tAdd';		$size = 1;	$data = '+';	break;
5455
+		    case 0x04: $name = 'tSub';		$size = 1;	$data = '-';	break;
5456
+		    case 0x05: $name = 'tMul';		$size = 1;	$data = '*';	break;
5457
+		    case 0x06: $name = 'tDiv';		$size = 1;	$data = '/';	break;
5458
+		    case 0x07: $name = 'tPower';	$size = 1;	$data = '^';	break;
5459
+		    case 0x08: $name = 'tConcat';	$size = 1;	$data = '&';	break;
5460
+		    case 0x09: $name = 'tLT';		$size = 1;	$data = '<';	break;
5461
+		    case 0x0A: $name = 'tLE';		$size = 1;	$data = '<=';	break;
5462
+		    case 0x0B: $name = 'tEQ';		$size = 1;	$data = '=';	break;
5463
+		    case 0x0C: $name = 'tGE';		$size = 1;	$data = '>=';	break;
5464
+		    case 0x0D: $name = 'tGT';		$size = 1;	$data = '>';	break;
5465
+		    case 0x0E: $name = 'tNE';		$size = 1;	$data = '<>';	break;
5466
+		    case 0x0F: $name = 'tIsect';	$size = 1;	$data = ' ';	break;
5467
+		    case 0x10: $name = 'tList';		$size = 1;	$data = ',';	break;
5468
+		    case 0x11: $name = 'tRange';	$size = 1;	$data = ':';	break;
5469
+		    case 0x12: $name = 'tUplus';	$size = 1;	$data = '+';	break;
5470
+		    case 0x13: $name = 'tUminus';	$size = 1;	$data = '-';	break;
5471
+		    case 0x14: $name = 'tPercent';	$size = 1;	$data = '%';	break;
5472
+		    case 0x15:	//	parenthesis
5473
+			    $name  = 'tParen';
5474
+			    $size  = 1;
5475
+			    $data = null;
5476
+			    break;
5477
+		    case 0x16:	//	missing argument
5478
+			    $name = 'tMissArg';
5479
+			    $size = 1;
5480
+			    $data = '';
5481
+			    break;
5482
+		    case 0x17:	//	string
5483
+			    $name = 'tStr';
5484
+			    // offset: 1; size: var; Unicode string, 8-bit string length
5485
+			    $string = self::_readUnicodeStringShort(substr($formulaData, 1));
5486
+			    $size = 1 + $string['size'];
5487
+			    $data = self::_UTF8toExcelDoubleQuoted($string['value']);
5488
+			    break;
5489
+		    case 0x19:	//	Special attribute
5490
+			    // offset: 1; size: 1; attribute type flags:
5491
+			    switch (ord($formulaData[1])) {
5492
+			        case 0x01:
5493
+				        $name = 'tAttrVolatile';
5494
+				        $size = 4;
5495
+				        $data = null;
5496
+				        break;
5497
+			        case 0x02:
5498
+				        $name = 'tAttrIf';
5499
+				        $size = 4;
5500
+				        $data = null;
5501
+				        break;
5502
+			        case 0x04:
5503
+				        $name = 'tAttrChoose';
5504
+				        // offset: 2; size: 2; number of choices in the CHOOSE function ($nc, number of parameters decreased by 1)
5505
+				        $nc = self::_GetInt2d($formulaData, 2);
5506
+				        // offset: 4; size: 2 * $nc
5507
+				        // offset: 4 + 2 * $nc; size: 2
5508
+				        $size = 2 * $nc + 6;
5509
+				        $data = null;
5510
+				        break;
5511
+			        case 0x08:
5512
+				        $name = 'tAttrSkip';
5513
+				        $size = 4;
5514
+				        $data = null;
5515
+				        break;
5516
+			        case 0x10:
5517
+				        $name = 'tAttrSum';
5518
+				        $size = 4;
5519
+				        $data = null;
5520
+				        break;
5521
+			        case 0x40:
5522
+			        case 0x41:
5523
+				        $name = 'tAttrSpace';
5524
+				        $size = 4;
5525
+				        // offset: 2; size: 2; space type and position
5526
+				        switch (ord($formulaData[2])) {
5527
+				            case 0x00:
5528
+					            $spacetype = 'type0';
5529
+					            break;
5530
+				            case 0x01:
5531
+					            $spacetype = 'type1';
5532
+					            break;
5533
+				            case 0x02:
5534
+					            $spacetype = 'type2';
5535
+					            break;
5536
+				            case 0x03:
5537
+					            $spacetype = 'type3';
5538
+					            break;
5539
+				            case 0x04:
5540
+					            $spacetype = 'type4';
5541
+					            break;
5542
+				            case 0x05:
5543
+					            $spacetype = 'type5';
5544
+					            break;
5545
+				            default:
5546
+					            throw new PHPExcel_Reader_Exception('Unrecognized space type in tAttrSpace token');
5547
+					            break;
5548
+				        }
5549
+				    // offset: 3; size: 1; number of inserted spaces/carriage returns
5550
+				    $spacecount = ord($formulaData[3]);
5551
+
5552
+				    $data = array('spacetype' => $spacetype, 'spacecount' => $spacecount);
5553
+				    break;
5554 5554
 			default:
5555 5555
 				throw new PHPExcel_Reader_Exception('Unrecognized attribute flag in tAttr token');
5556 5556
 				break;
5557 5557
 			}
5558 5558
 			break;
5559
-		case 0x1C:	//	error code
5560
-			// offset: 1; size: 1; error code
5561
-			$name = 'tErr';
5562
-			$size = 2;
5563
-			$data = self::_mapErrorCode(ord($formulaData[1]));
5564
-			break;
5565
-		case 0x1D:	//	boolean
5566
-			// offset: 1; size: 1; 0 = false, 1 = true;
5567
-			$name = 'tBool';
5568
-			$size = 2;
5569
-			$data = ord($formulaData[1]) ? 'TRUE' : 'FALSE';
5570
-			break;
5571
-		case 0x1E:	//	integer
5572
-			// offset: 1; size: 2; unsigned 16-bit integer
5573
-			$name = 'tInt';
5574
-			$size = 3;
5575
-			$data = self::_GetInt2d($formulaData, 1);
5576
-			break;
5577
-		case 0x1F:	//	number
5578
-			// offset: 1; size: 8;
5579
-			$name = 'tNum';
5580
-			$size = 9;
5581
-			$data = self::_extractNumber(substr($formulaData, 1));
5582
-			$data = str_replace(',', '.', (string)$data); // in case non-English locale
5583
-			break;
5584
-		case 0x20:	//	array constant
5585
-		case 0x40:
5586
-		case 0x60:
5587
-			// offset: 1; size: 7; not used
5588
-			$name = 'tArray';
5589
-			$size = 8;
5590
-			$data = null;
5591
-			break;
5592
-		case 0x21:	//	function with fixed number of arguments
5593
-		case 0x41:
5594
-		case 0x61:
5595
-			$name = 'tFunc';
5596
-			$size = 3;
5597
-			// offset: 1; size: 2; index to built-in sheet function
5598
-			switch (self::_GetInt2d($formulaData, 1)) {
5599
-			case   2: $function = 'ISNA'; 			$args = 1; 	break;
5600
-			case   3: $function = 'ISERROR'; 		$args = 1; 	break;
5601
-			case  10: $function = 'NA'; 			$args = 0; 	break;
5602
-			case  15: $function = 'SIN'; 			$args = 1; 	break;
5603
-			case  16: $function = 'COS'; 			$args = 1; 	break;
5604
-			case  17: $function = 'TAN'; 			$args = 1; 	break;
5605
-			case  18: $function = 'ATAN'; 			$args = 1; 	break;
5606
-			case  19: $function = 'PI'; 			$args = 0; 	break;
5607
-			case  20: $function = 'SQRT'; 			$args = 1; 	break;
5608
-			case  21: $function = 'EXP'; 			$args = 1; 	break;
5609
-			case  22: $function = 'LN'; 			$args = 1; 	break;
5610
-			case  23: $function = 'LOG10'; 			$args = 1; 	break;
5611
-			case  24: $function = 'ABS'; 			$args = 1; 	break;
5612
-			case  25: $function = 'INT'; 			$args = 1; 	break;
5613
-			case  26: $function = 'SIGN'; 			$args = 1; 	break;
5614
-			case  27: $function = 'ROUND'; 			$args = 2; 	break;
5615
-			case  30: $function = 'REPT'; 			$args = 2; 	break;
5616
-			case  31: $function = 'MID'; 			$args = 3; 	break;
5617
-			case  32: $function = 'LEN'; 			$args = 1; 	break;
5618
-			case  33: $function = 'VALUE'; 			$args = 1; 	break;
5619
-			case  34: $function = 'TRUE'; 			$args = 0; 	break;
5620
-			case  35: $function = 'FALSE'; 			$args = 0; 	break;
5621
-			case  38: $function = 'NOT'; 			$args = 1; 	break;
5622
-			case  39: $function = 'MOD'; 			$args = 2;	break;
5623
-			case  40: $function = 'DCOUNT'; 		$args = 3;	break;
5624
-			case  41: $function = 'DSUM'; 			$args = 3;	break;
5625
-			case  42: $function = 'DAVERAGE'; 		$args = 3;	break;
5626
-			case  43: $function = 'DMIN'; 			$args = 3;	break;
5627
-			case  44: $function = 'DMAX'; 			$args = 3;	break;
5628
-			case  45: $function = 'DSTDEV'; 		$args = 3;	break;
5629
-			case  48: $function = 'TEXT'; 			$args = 2;	break;
5630
-			case  61: $function = 'MIRR'; 			$args = 3;	break;
5631
-			case  63: $function = 'RAND'; 			$args = 0;	break;
5632
-			case  65: $function = 'DATE'; 			$args = 3;	break;
5633
-			case  66: $function = 'TIME'; 			$args = 3;	break;
5634
-			case  67: $function = 'DAY'; 			$args = 1;	break;
5635
-			case  68: $function = 'MONTH'; 			$args = 1;	break;
5636
-			case  69: $function = 'YEAR'; 			$args = 1;	break;
5637
-			case  71: $function = 'HOUR'; 			$args = 1;	break;
5638
-			case  72: $function = 'MINUTE'; 		$args = 1;	break;
5639
-			case  73: $function = 'SECOND'; 		$args = 1;	break;
5640
-			case  74: $function = 'NOW'; 			$args = 0;	break;
5641
-			case  75: $function = 'AREAS'; 			$args = 1;	break;
5642
-			case  76: $function = 'ROWS'; 			$args = 1;	break;
5643
-			case  77: $function = 'COLUMNS'; 		$args = 1;	break;
5644
-			case  83: $function = 'TRANSPOSE'; 		$args = 1;	break;
5645
-			case  86: $function = 'TYPE'; 			$args = 1;	break;
5646
-			case  97: $function = 'ATAN2'; 			$args = 2;	break;
5647
-			case  98: $function = 'ASIN'; 			$args = 1;	break;
5648
-			case  99: $function = 'ACOS'; 			$args = 1;	break;
5649
-			case 105: $function = 'ISREF'; 			$args = 1;	break;
5650
-			case 111: $function = 'CHAR'; 			$args = 1;	break;
5651
-			case 112: $function = 'LOWER'; 			$args = 1;	break;
5652
-			case 113: $function = 'UPPER'; 			$args = 1;	break;
5653
-			case 114: $function = 'PROPER'; 		$args = 1;	break;
5654
-			case 117: $function = 'EXACT'; 			$args = 2;	break;
5655
-			case 118: $function = 'TRIM'; 			$args = 1;	break;
5656
-			case 119: $function = 'REPLACE'; 		$args = 4;	break;
5657
-			case 121: $function = 'CODE'; 			$args = 1;	break;
5658
-			case 126: $function = 'ISERR'; 			$args = 1;	break;
5659
-			case 127: $function = 'ISTEXT'; 		$args = 1;	break;
5660
-			case 128: $function = 'ISNUMBER'; 		$args = 1;	break;
5661
-			case 129: $function = 'ISBLANK'; 		$args = 1;	break;
5662
-			case 130: $function = 'T'; 				$args = 1;	break;
5663
-			case 131: $function = 'N'; 				$args = 1;	break;
5664
-			case 140: $function = 'DATEVALUE'; 		$args = 1;	break;
5665
-			case 141: $function = 'TIMEVALUE'; 		$args = 1;	break;
5666
-			case 142: $function = 'SLN'; 			$args = 3;	break;
5667
-			case 143: $function = 'SYD'; 			$args = 4;	break;
5668
-			case 162: $function = 'CLEAN'; 			$args = 1;	break;
5669
-			case 163: $function = 'MDETERM'; 		$args = 1;	break;
5670
-			case 164: $function = 'MINVERSE'; 		$args = 1;	break;
5671
-			case 165: $function = 'MMULT'; 			$args = 2;	break;
5672
-			case 184: $function = 'FACT'; 			$args = 1;	break;
5673
-			case 189: $function = 'DPRODUCT'; 		$args = 3;	break;
5674
-			case 190: $function = 'ISNONTEXT'; 		$args = 1;	break;
5675
-			case 195: $function = 'DSTDEVP'; 		$args = 3;	break;
5676
-			case 196: $function = 'DVARP'; 			$args = 3;	break;
5677
-			case 198: $function = 'ISLOGICAL'; 		$args = 1;	break;
5678
-			case 199: $function = 'DCOUNTA'; 		$args = 3;	break;
5679
-			case 207: $function = 'REPLACEB'; 		$args = 4;	break;
5680
-			case 210: $function = 'MIDB'; 			$args = 3;	break;
5681
-			case 211: $function = 'LENB'; 			$args = 1;	break;
5682
-			case 212: $function = 'ROUNDUP'; 		$args = 2;	break;
5683
-			case 213: $function = 'ROUNDDOWN'; 		$args = 2;	break;
5684
-			case 214: $function = 'ASC'; 			$args = 1;	break;
5685
-			case 215: $function = 'DBCS'; 			$args = 1;	break;
5686
-			case 221: $function = 'TODAY'; 			$args = 0;	break;
5687
-			case 229: $function = 'SINH'; 			$args = 1;	break;
5688
-			case 230: $function = 'COSH'; 			$args = 1;	break;
5689
-			case 231: $function = 'TANH'; 			$args = 1;	break;
5690
-			case 232: $function = 'ASINH'; 			$args = 1;	break;
5691
-			case 233: $function = 'ACOSH'; 			$args = 1;	break;
5692
-			case 234: $function = 'ATANH'; 			$args = 1;	break;
5693
-			case 235: $function = 'DGET'; 			$args = 3;	break;
5694
-			case 244: $function = 'INFO'; 			$args = 1;	break;
5695
-			case 252: $function = 'FREQUENCY'; 		$args = 2;	break;
5696
-			case 261: $function = 'ERROR.TYPE'; 	$args = 1;	break;
5697
-			case 271: $function = 'GAMMALN'; 		$args = 1;	break;
5698
-			case 273: $function = 'BINOMDIST'; 		$args = 4;	break;
5699
-			case 274: $function = 'CHIDIST'; 		$args = 2;	break;
5700
-			case 275: $function = 'CHIINV'; 		$args = 2;	break;
5701
-			case 276: $function = 'COMBIN'; 		$args = 2;	break;
5702
-			case 277: $function = 'CONFIDENCE'; 	$args = 3;	break;
5703
-			case 278: $function = 'CRITBINOM'; 		$args = 3;	break;
5704
-			case 279: $function = 'EVEN'; 			$args = 1;	break;
5705
-			case 280: $function = 'EXPONDIST'; 		$args = 3;	break;
5706
-			case 281: $function = 'FDIST'; 			$args = 3;	break;
5707
-			case 282: $function = 'FINV'; 			$args = 3;	break;
5708
-			case 283: $function = 'FISHER'; 		$args = 1;	break;
5709
-			case 284: $function = 'FISHERINV'; 		$args = 1;	break;
5710
-			case 285: $function = 'FLOOR'; 			$args = 2;	break;
5711
-			case 286: $function = 'GAMMADIST'; 		$args = 4;	break;
5712
-			case 287: $function = 'GAMMAINV'; 		$args = 3;	break;
5713
-			case 288: $function = 'CEILING'; 		$args = 2;	break;
5714
-			case 289: $function = 'HYPGEOMDIST';	$args = 4;	break;
5715
-			case 290: $function = 'LOGNORMDIST';	$args = 3;	break;
5716
-			case 291: $function = 'LOGINV';			$args = 3;	break;
5717
-			case 292: $function = 'NEGBINOMDIST';	$args = 3;	break;
5718
-			case 293: $function = 'NORMDIST';		$args = 4;	break;
5719
-			case 294: $function = 'NORMSDIST';		$args = 1;	break;
5720
-			case 295: $function = 'NORMINV';		$args = 3;	break;
5721
-			case 296: $function = 'NORMSINV';		$args = 1;	break;
5722
-			case 297: $function = 'STANDARDIZE';	$args = 3;	break;
5723
-			case 298: $function = 'ODD';			$args = 1;	break;
5724
-			case 299: $function = 'PERMUT';			$args = 2;	break;
5725
-			case 300: $function = 'POISSON';		$args = 3;	break;
5726
-			case 301: $function = 'TDIST';			$args = 3;	break;
5727
-			case 302: $function = 'WEIBULL';		$args = 4;	break;
5728
-			case 303: $function = 'SUMXMY2';		$args = 2;	break;
5729
-			case 304: $function = 'SUMX2MY2';		$args = 2;	break;
5730
-			case 305: $function = 'SUMX2PY2';		$args = 2;	break;
5731
-			case 306: $function = 'CHITEST';		$args = 2;	break;
5732
-			case 307: $function = 'CORREL';			$args = 2;	break;
5733
-			case 308: $function = 'COVAR';			$args = 2;	break;
5734
-			case 309: $function = 'FORECAST';		$args = 3;	break;
5735
-			case 310: $function = 'FTEST';			$args = 2;	break;
5736
-			case 311: $function = 'INTERCEPT';		$args = 2;	break;
5737
-			case 312: $function = 'PEARSON';		$args = 2;	break;
5738
-			case 313: $function = 'RSQ';			$args = 2;	break;
5739
-			case 314: $function = 'STEYX';			$args = 2;	break;
5740
-			case 315: $function = 'SLOPE';			$args = 2;	break;
5741
-			case 316: $function = 'TTEST';			$args = 4;	break;
5742
-			case 325: $function = 'LARGE';			$args = 2;	break;
5743
-			case 326: $function = 'SMALL';			$args = 2;	break;
5744
-			case 327: $function = 'QUARTILE';		$args = 2;	break;
5745
-			case 328: $function = 'PERCENTILE';		$args = 2;	break;
5746
-			case 331: $function = 'TRIMMEAN';		$args = 2;	break;
5747
-			case 332: $function = 'TINV';			$args = 2;	break;
5748
-			case 337: $function = 'POWER';			$args = 2;	break;
5749
-			case 342: $function = 'RADIANS';		$args = 1;	break;
5750
-			case 343: $function = 'DEGREES';		$args = 1;	break;
5751
-			case 346: $function = 'COUNTIF';		$args = 2;	break;
5752
-			case 347: $function = 'COUNTBLANK';		$args = 1;	break;
5753
-			case 350: $function = 'ISPMT';			$args = 4;	break;
5754
-			case 351: $function = 'DATEDIF';		$args = 3;	break;
5755
-			case 352: $function = 'DATESTRING';		$args = 1;	break;
5756
-			case 353: $function = 'NUMBERSTRING';	$args = 2;	break;
5757
-			case 360: $function = 'PHONETIC';		$args = 1;	break;
5758
-			case 368: $function = 'BAHTTEXT';		$args = 1;	break;
5759
-			default:
5760
-				throw new PHPExcel_Reader_Exception('Unrecognized function in formula');
5761
-				break;
5762
-			}
5559
+		    case 0x1C:	//	error code
5560
+			    // offset: 1; size: 1; error code
5561
+			    $name = 'tErr';
5562
+			    $size = 2;
5563
+			    $data = self::_mapErrorCode(ord($formulaData[1]));
5564
+			    break;
5565
+		    case 0x1D:	//	boolean
5566
+			    // offset: 1; size: 1; 0 = false, 1 = true;
5567
+			    $name = 'tBool';
5568
+			    $size = 2;
5569
+			    $data = ord($formulaData[1]) ? 'TRUE' : 'FALSE';
5570
+			    break;
5571
+		    case 0x1E:	//	integer
5572
+			    // offset: 1; size: 2; unsigned 16-bit integer
5573
+			    $name = 'tInt';
5574
+			    $size = 3;
5575
+			    $data = self::_GetInt2d($formulaData, 1);
5576
+			    break;
5577
+		    case 0x1F:	//	number
5578
+			    // offset: 1; size: 8;
5579
+			    $name = 'tNum';
5580
+			    $size = 9;
5581
+			    $data = self::_extractNumber(substr($formulaData, 1));
5582
+			    $data = str_replace(',', '.', (string)$data); // in case non-English locale
5583
+			    break;
5584
+		    case 0x20:	//	array constant
5585
+		    case 0x40:
5586
+		    case 0x60:
5587
+			    // offset: 1; size: 7; not used
5588
+			    $name = 'tArray';
5589
+			    $size = 8;
5590
+			    $data = null;
5591
+			    break;
5592
+		    case 0x21:	//	function with fixed number of arguments
5593
+		    case 0x41:
5594
+		    case 0x61:
5595
+			    $name = 'tFunc';
5596
+			    $size = 3;
5597
+			    // offset: 1; size: 2; index to built-in sheet function
5598
+			    switch (self::_GetInt2d($formulaData, 1)) {
5599
+			        case   2: $function = 'ISNA'; 			$args = 1; 	break;
5600
+			        case   3: $function = 'ISERROR'; 		$args = 1; 	break;
5601
+			        case  10: $function = 'NA'; 			$args = 0; 	break;
5602
+			        case  15: $function = 'SIN'; 			$args = 1; 	break;
5603
+			        case  16: $function = 'COS'; 			$args = 1; 	break;
5604
+			        case  17: $function = 'TAN'; 			$args = 1; 	break;
5605
+			        case  18: $function = 'ATAN'; 			$args = 1; 	break;
5606
+			        case  19: $function = 'PI'; 			$args = 0; 	break;
5607
+			        case  20: $function = 'SQRT'; 			$args = 1; 	break;
5608
+			        case  21: $function = 'EXP'; 			$args = 1; 	break;
5609
+			        case  22: $function = 'LN'; 			$args = 1; 	break;
5610
+			        case  23: $function = 'LOG10'; 			$args = 1; 	break;
5611
+			        case  24: $function = 'ABS'; 			$args = 1; 	break;
5612
+			        case  25: $function = 'INT'; 			$args = 1; 	break;
5613
+			        case  26: $function = 'SIGN'; 			$args = 1; 	break;
5614
+			        case  27: $function = 'ROUND'; 			$args = 2; 	break;
5615
+			        case  30: $function = 'REPT'; 			$args = 2; 	break;
5616
+			        case  31: $function = 'MID'; 			$args = 3; 	break;
5617
+			        case  32: $function = 'LEN'; 			$args = 1; 	break;
5618
+			        case  33: $function = 'VALUE'; 			$args = 1; 	break;
5619
+			        case  34: $function = 'TRUE'; 			$args = 0; 	break;
5620
+			        case  35: $function = 'FALSE'; 			$args = 0; 	break;
5621
+			        case  38: $function = 'NOT'; 			$args = 1; 	break;
5622
+			        case  39: $function = 'MOD'; 			$args = 2;	break;
5623
+			        case  40: $function = 'DCOUNT'; 		$args = 3;	break;
5624
+			        case  41: $function = 'DSUM'; 			$args = 3;	break;
5625
+			        case  42: $function = 'DAVERAGE'; 		$args = 3;	break;
5626
+			        case  43: $function = 'DMIN'; 			$args = 3;	break;
5627
+			        case  44: $function = 'DMAX'; 			$args = 3;	break;
5628
+			        case  45: $function = 'DSTDEV'; 		$args = 3;	break;
5629
+			        case  48: $function = 'TEXT'; 			$args = 2;	break;
5630
+			        case  61: $function = 'MIRR'; 			$args = 3;	break;
5631
+			        case  63: $function = 'RAND'; 			$args = 0;	break;
5632
+			        case  65: $function = 'DATE'; 			$args = 3;	break;
5633
+			        case  66: $function = 'TIME'; 			$args = 3;	break;
5634
+			        case  67: $function = 'DAY'; 			$args = 1;	break;
5635
+			        case  68: $function = 'MONTH'; 			$args = 1;	break;
5636
+			        case  69: $function = 'YEAR'; 			$args = 1;	break;
5637
+			        case  71: $function = 'HOUR'; 			$args = 1;	break;
5638
+			        case  72: $function = 'MINUTE'; 		$args = 1;	break;
5639
+			        case  73: $function = 'SECOND'; 		$args = 1;	break;
5640
+			        case  74: $function = 'NOW'; 			$args = 0;	break;
5641
+			        case  75: $function = 'AREAS'; 			$args = 1;	break;
5642
+			        case  76: $function = 'ROWS'; 			$args = 1;	break;
5643
+			        case  77: $function = 'COLUMNS'; 		$args = 1;	break;
5644
+			        case  83: $function = 'TRANSPOSE'; 		$args = 1;	break;
5645
+			        case  86: $function = 'TYPE'; 			$args = 1;	break;
5646
+			        case  97: $function = 'ATAN2'; 			$args = 2;	break;
5647
+			        case  98: $function = 'ASIN'; 			$args = 1;	break;
5648
+			        case  99: $function = 'ACOS'; 			$args = 1;	break;
5649
+			        case 105: $function = 'ISREF'; 			$args = 1;	break;
5650
+			        case 111: $function = 'CHAR'; 			$args = 1;	break;
5651
+			        case 112: $function = 'LOWER'; 			$args = 1;	break;
5652
+			        case 113: $function = 'UPPER'; 			$args = 1;	break;
5653
+			        case 114: $function = 'PROPER'; 		$args = 1;	break;
5654
+			        case 117: $function = 'EXACT'; 			$args = 2;	break;
5655
+			        case 118: $function = 'TRIM'; 			$args = 1;	break;
5656
+			        case 119: $function = 'REPLACE'; 		$args = 4;	break;
5657
+			        case 121: $function = 'CODE'; 			$args = 1;	break;
5658
+			        case 126: $function = 'ISERR'; 			$args = 1;	break;
5659
+			        case 127: $function = 'ISTEXT'; 		$args = 1;	break;
5660
+			        case 128: $function = 'ISNUMBER'; 		$args = 1;	break;
5661
+			        case 129: $function = 'ISBLANK'; 		$args = 1;	break;
5662
+			        case 130: $function = 'T'; 				$args = 1;	break;
5663
+			        case 131: $function = 'N'; 				$args = 1;	break;
5664
+			        case 140: $function = 'DATEVALUE'; 		$args = 1;	break;
5665
+			        case 141: $function = 'TIMEVALUE'; 		$args = 1;	break;
5666
+			        case 142: $function = 'SLN'; 			$args = 3;	break;
5667
+			        case 143: $function = 'SYD'; 			$args = 4;	break;
5668
+			        case 162: $function = 'CLEAN'; 			$args = 1;	break;
5669
+			        case 163: $function = 'MDETERM'; 		$args = 1;	break;
5670
+			        case 164: $function = 'MINVERSE'; 		$args = 1;	break;
5671
+			        case 165: $function = 'MMULT'; 			$args = 2;	break;
5672
+			        case 184: $function = 'FACT'; 			$args = 1;	break;
5673
+			        case 189: $function = 'DPRODUCT'; 		$args = 3;	break;
5674
+			        case 190: $function = 'ISNONTEXT'; 		$args = 1;	break;
5675
+			        case 195: $function = 'DSTDEVP'; 		$args = 3;	break;
5676
+			        case 196: $function = 'DVARP'; 			$args = 3;	break;
5677
+			        case 198: $function = 'ISLOGICAL'; 		$args = 1;	break;
5678
+			        case 199: $function = 'DCOUNTA'; 		$args = 3;	break;
5679
+			        case 207: $function = 'REPLACEB'; 		$args = 4;	break;
5680
+			        case 210: $function = 'MIDB'; 			$args = 3;	break;
5681
+			        case 211: $function = 'LENB'; 			$args = 1;	break;
5682
+			        case 212: $function = 'ROUNDUP'; 		$args = 2;	break;
5683
+			        case 213: $function = 'ROUNDDOWN'; 		$args = 2;	break;
5684
+			        case 214: $function = 'ASC'; 			$args = 1;	break;
5685
+			        case 215: $function = 'DBCS'; 			$args = 1;	break;
5686
+			        case 221: $function = 'TODAY'; 			$args = 0;	break;
5687
+			        case 229: $function = 'SINH'; 			$args = 1;	break;
5688
+			        case 230: $function = 'COSH'; 			$args = 1;	break;
5689
+			        case 231: $function = 'TANH'; 			$args = 1;	break;
5690
+			        case 232: $function = 'ASINH'; 			$args = 1;	break;
5691
+			        case 233: $function = 'ACOSH'; 			$args = 1;	break;
5692
+			        case 234: $function = 'ATANH'; 			$args = 1;	break;
5693
+			        case 235: $function = 'DGET'; 			$args = 3;	break;
5694
+			        case 244: $function = 'INFO'; 			$args = 1;	break;
5695
+			        case 252: $function = 'FREQUENCY'; 		$args = 2;	break;
5696
+			        case 261: $function = 'ERROR.TYPE'; 	$args = 1;	break;
5697
+			        case 271: $function = 'GAMMALN'; 		$args = 1;	break;
5698
+			        case 273: $function = 'BINOMDIST'; 		$args = 4;	break;
5699
+			        case 274: $function = 'CHIDIST'; 		$args = 2;	break;
5700
+			        case 275: $function = 'CHIINV'; 		$args = 2;	break;
5701
+			        case 276: $function = 'COMBIN'; 		$args = 2;	break;
5702
+			        case 277: $function = 'CONFIDENCE'; 	$args = 3;	break;
5703
+			        case 278: $function = 'CRITBINOM'; 		$args = 3;	break;
5704
+			        case 279: $function = 'EVEN'; 			$args = 1;	break;
5705
+			        case 280: $function = 'EXPONDIST'; 		$args = 3;	break;
5706
+			        case 281: $function = 'FDIST'; 			$args = 3;	break;
5707
+			        case 282: $function = 'FINV'; 			$args = 3;	break;
5708
+			        case 283: $function = 'FISHER'; 		$args = 1;	break;
5709
+			        case 284: $function = 'FISHERINV'; 		$args = 1;	break;
5710
+			        case 285: $function = 'FLOOR'; 			$args = 2;	break;
5711
+			        case 286: $function = 'GAMMADIST'; 		$args = 4;	break;
5712
+			        case 287: $function = 'GAMMAINV'; 		$args = 3;	break;
5713
+			        case 288: $function = 'CEILING'; 		$args = 2;	break;
5714
+			        case 289: $function = 'HYPGEOMDIST';	$args = 4;	break;
5715
+			        case 290: $function = 'LOGNORMDIST';	$args = 3;	break;
5716
+			        case 291: $function = 'LOGINV';			$args = 3;	break;
5717
+			        case 292: $function = 'NEGBINOMDIST';	$args = 3;	break;
5718
+			        case 293: $function = 'NORMDIST';		$args = 4;	break;
5719
+			        case 294: $function = 'NORMSDIST';		$args = 1;	break;
5720
+			        case 295: $function = 'NORMINV';		$args = 3;	break;
5721
+			        case 296: $function = 'NORMSINV';		$args = 1;	break;
5722
+			        case 297: $function = 'STANDARDIZE';	$args = 3;	break;
5723
+			        case 298: $function = 'ODD';			$args = 1;	break;
5724
+			        case 299: $function = 'PERMUT';			$args = 2;	break;
5725
+			        case 300: $function = 'POISSON';		$args = 3;	break;
5726
+			        case 301: $function = 'TDIST';			$args = 3;	break;
5727
+			        case 302: $function = 'WEIBULL';		$args = 4;	break;
5728
+			        case 303: $function = 'SUMXMY2';		$args = 2;	break;
5729
+			        case 304: $function = 'SUMX2MY2';		$args = 2;	break;
5730
+			        case 305: $function = 'SUMX2PY2';		$args = 2;	break;
5731
+			        case 306: $function = 'CHITEST';		$args = 2;	break;
5732
+			        case 307: $function = 'CORREL';			$args = 2;	break;
5733
+			        case 308: $function = 'COVAR';			$args = 2;	break;
5734
+			        case 309: $function = 'FORECAST';		$args = 3;	break;
5735
+			        case 310: $function = 'FTEST';			$args = 2;	break;
5736
+			        case 311: $function = 'INTERCEPT';		$args = 2;	break;
5737
+			        case 312: $function = 'PEARSON';		$args = 2;	break;
5738
+			        case 313: $function = 'RSQ';			$args = 2;	break;
5739
+			        case 314: $function = 'STEYX';			$args = 2;	break;
5740
+			        case 315: $function = 'SLOPE';			$args = 2;	break;
5741
+			        case 316: $function = 'TTEST';			$args = 4;	break;
5742
+			        case 325: $function = 'LARGE';			$args = 2;	break;
5743
+			        case 326: $function = 'SMALL';			$args = 2;	break;
5744
+			        case 327: $function = 'QUARTILE';		$args = 2;	break;
5745
+			        case 328: $function = 'PERCENTILE';		$args = 2;	break;
5746
+			        case 331: $function = 'TRIMMEAN';		$args = 2;	break;
5747
+			        case 332: $function = 'TINV';			$args = 2;	break;
5748
+			        case 337: $function = 'POWER';			$args = 2;	break;
5749
+			        case 342: $function = 'RADIANS';		$args = 1;	break;
5750
+			        case 343: $function = 'DEGREES';		$args = 1;	break;
5751
+			        case 346: $function = 'COUNTIF';		$args = 2;	break;
5752
+			        case 347: $function = 'COUNTBLANK';		$args = 1;	break;
5753
+			        case 350: $function = 'ISPMT';			$args = 4;	break;
5754
+			        case 351: $function = 'DATEDIF';		$args = 3;	break;
5755
+			        case 352: $function = 'DATESTRING';		$args = 1;	break;
5756
+			        case 353: $function = 'NUMBERSTRING';	$args = 2;	break;
5757
+			        case 360: $function = 'PHONETIC';		$args = 1;	break;
5758
+			        case 368: $function = 'BAHTTEXT';		$args = 1;	break;
5759
+			        default:
5760
+				        throw new PHPExcel_Reader_Exception('Unrecognized function in formula');
5761
+				        break;
5762
+			    }
5763 5763
 			$data = array('function' => $function, 'args' => $args);
5764 5764
 			break;
5765
-		case 0x22:	//	function with variable number of arguments
5766
-		case 0x42:
5767
-		case 0x62:
5768
-			$name = 'tFuncV';
5769
-			$size = 4;
5770
-			// offset: 1; size: 1; number of arguments
5771
-			$args = ord($formulaData[1]);
5772
-			// offset: 2: size: 2; index to built-in sheet function
5773
-			$index = self::_GetInt2d($formulaData, 2);
5774
-			switch ($index) {
5775
-			case   0: $function = 'COUNT';			break;
5776
-			case   1: $function = 'IF';				break;
5777
-			case   4: $function = 'SUM';			break;
5778
-			case   5: $function = 'AVERAGE';		break;
5779
-			case   6: $function = 'MIN';			break;
5780
-			case   7: $function = 'MAX';			break;
5781
-			case   8: $function = 'ROW';			break;
5782
-			case   9: $function = 'COLUMN';			break;
5783
-			case  11: $function = 'NPV';			break;
5784
-			case  12: $function = 'STDEV';			break;
5785
-			case  13: $function = 'DOLLAR';			break;
5786
-			case  14: $function = 'FIXED';			break;
5787
-			case  28: $function = 'LOOKUP';			break;
5788
-			case  29: $function = 'INDEX';			break;
5789
-			case  36: $function = 'AND';			break;
5790
-			case  37: $function = 'OR';				break;
5791
-			case  46: $function = 'VAR';			break;
5792
-			case  49: $function = 'LINEST';			break;
5793
-			case  50: $function = 'TREND';			break;
5794
-			case  51: $function = 'LOGEST';			break;
5795
-			case  52: $function = 'GROWTH';			break;
5796
-			case  56: $function = 'PV';				break;
5797
-			case  57: $function = 'FV';				break;
5798
-			case  58: $function = 'NPER';			break;
5799
-			case  59: $function = 'PMT';			break;
5800
-			case  60: $function = 'RATE';			break;
5801
-			case  62: $function = 'IRR';			break;
5802
-			case  64: $function = 'MATCH';			break;
5803
-			case  70: $function = 'WEEKDAY';		break;
5804
-			case  78: $function = 'OFFSET';			break;
5805
-			case  82: $function = 'SEARCH';			break;
5806
-			case 100: $function = 'CHOOSE';			break;
5807
-			case 101: $function = 'HLOOKUP';		break;
5808
-			case 102: $function = 'VLOOKUP';		break;
5809
-			case 109: $function = 'LOG';			break;
5810
-			case 115: $function = 'LEFT';			break;
5811
-			case 116: $function = 'RIGHT';			break;
5812
-			case 120: $function = 'SUBSTITUTE';		break;
5813
-			case 124: $function = 'FIND';			break;
5814
-			case 125: $function = 'CELL';			break;
5815
-			case 144: $function = 'DDB';			break;
5816
-			case 148: $function = 'INDIRECT';		break;
5817
-			case 167: $function = 'IPMT';			break;
5818
-			case 168: $function = 'PPMT';			break;
5819
-			case 169: $function = 'COUNTA';			break;
5820
-			case 183: $function = 'PRODUCT';		break;
5821
-			case 193: $function = 'STDEVP';			break;
5822
-			case 194: $function = 'VARP';			break;
5823
-			case 197: $function = 'TRUNC';			break;
5824
-			case 204: $function = 'USDOLLAR';		break;
5825
-			case 205: $function = 'FINDB';			break;
5826
-			case 206: $function = 'SEARCHB';		break;
5827
-			case 208: $function = 'LEFTB';			break;
5828
-			case 209: $function = 'RIGHTB';			break;
5829
-			case 216: $function = 'RANK';			break;
5830
-			case 219: $function = 'ADDRESS';		break;
5831
-			case 220: $function = 'DAYS360';		break;
5832
-			case 222: $function = 'VDB';			break;
5833
-			case 227: $function = 'MEDIAN';			break;
5834
-			case 228: $function = 'SUMPRODUCT';		break;
5835
-			case 247: $function = 'DB';				break;
5836
-			case 255: $function = '';				break;
5837
-			case 269: $function = 'AVEDEV';			break;
5838
-			case 270: $function = 'BETADIST';		break;
5839
-			case 272: $function = 'BETAINV';		break;
5840
-			case 317: $function = 'PROB';			break;
5841
-			case 318: $function = 'DEVSQ';			break;
5842
-			case 319: $function = 'GEOMEAN';		break;
5843
-			case 320: $function = 'HARMEAN';		break;
5844
-			case 321: $function = 'SUMSQ';			break;
5845
-			case 322: $function = 'KURT';			break;
5846
-			case 323: $function = 'SKEW';			break;
5847
-			case 324: $function = 'ZTEST';			break;
5848
-			case 329: $function = 'PERCENTRANK';	break;
5849
-			case 330: $function = 'MODE';			break;
5850
-			case 336: $function = 'CONCATENATE';	break;
5851
-			case 344: $function = 'SUBTOTAL';		break;
5852
-			case 345: $function = 'SUMIF';			break;
5853
-			case 354: $function = 'ROMAN';			break;
5854
-			case 358: $function = 'GETPIVOTDATA';	break;
5855
-			case 359: $function = 'HYPERLINK';		break;
5856
-			case 361: $function = 'AVERAGEA';		break;
5857
-			case 362: $function = 'MAXA';			break;
5858
-			case 363: $function = 'MINA';			break;
5859
-			case 364: $function = 'STDEVPA';		break;
5860
-			case 365: $function = 'VARPA';			break;
5861
-			case 366: $function = 'STDEVA';			break;
5862
-			case 367: $function = 'VARA';			break;
5863
-			default:
5864
-				throw new PHPExcel_Reader_Exception('Unrecognized function in formula');
5865
-				break;
5866
-			}
5765
+		    case 0x22:	//	function with variable number of arguments
5766
+		    case 0x42:
5767
+		    case 0x62:
5768
+			    $name = 'tFuncV';
5769
+			    $size = 4;
5770
+			    // offset: 1; size: 1; number of arguments
5771
+			    $args = ord($formulaData[1]);
5772
+			    // offset: 2: size: 2; index to built-in sheet function
5773
+			    $index = self::_GetInt2d($formulaData, 2);
5774
+			    switch ($index) {
5775
+			        case   0: $function = 'COUNT';			break;
5776
+			        case   1: $function = 'IF';				break;
5777
+			        case   4: $function = 'SUM';			break;
5778
+			        case   5: $function = 'AVERAGE';		break;
5779
+			        case   6: $function = 'MIN';			break;
5780
+			        case   7: $function = 'MAX';			break;
5781
+			        case   8: $function = 'ROW';			break;
5782
+			        case   9: $function = 'COLUMN';			break;
5783
+			        case  11: $function = 'NPV';			break;
5784
+			        case  12: $function = 'STDEV';			break;
5785
+			        case  13: $function = 'DOLLAR';			break;
5786
+			        case  14: $function = 'FIXED';			break;
5787
+			        case  28: $function = 'LOOKUP';			break;
5788
+			        case  29: $function = 'INDEX';			break;
5789
+			        case  36: $function = 'AND';			break;
5790
+			        case  37: $function = 'OR';				break;
5791
+			        case  46: $function = 'VAR';			break;
5792
+			        case  49: $function = 'LINEST';			break;
5793
+			        case  50: $function = 'TREND';			break;
5794
+			        case  51: $function = 'LOGEST';			break;
5795
+			        case  52: $function = 'GROWTH';			break;
5796
+			        case  56: $function = 'PV';				break;
5797
+			        case  57: $function = 'FV';				break;
5798
+			        case  58: $function = 'NPER';			break;
5799
+			        case  59: $function = 'PMT';			break;
5800
+			        case  60: $function = 'RATE';			break;
5801
+			        case  62: $function = 'IRR';			break;
5802
+			        case  64: $function = 'MATCH';			break;
5803
+			        case  70: $function = 'WEEKDAY';		break;
5804
+			        case  78: $function = 'OFFSET';			break;
5805
+			        case  82: $function = 'SEARCH';			break;
5806
+			        case 100: $function = 'CHOOSE';			break;
5807
+			        case 101: $function = 'HLOOKUP';		break;
5808
+			        case 102: $function = 'VLOOKUP';		break;
5809
+			        case 109: $function = 'LOG';			break;
5810
+			        case 115: $function = 'LEFT';			break;
5811
+			        case 116: $function = 'RIGHT';			break;
5812
+			        case 120: $function = 'SUBSTITUTE';		break;
5813
+			        case 124: $function = 'FIND';			break;
5814
+			        case 125: $function = 'CELL';			break;
5815
+			        case 144: $function = 'DDB';			break;
5816
+			        case 148: $function = 'INDIRECT';		break;
5817
+			        case 167: $function = 'IPMT';			break;
5818
+			        case 168: $function = 'PPMT';			break;
5819
+			        case 169: $function = 'COUNTA';			break;
5820
+			        case 183: $function = 'PRODUCT';		break;
5821
+			        case 193: $function = 'STDEVP';			break;
5822
+			        case 194: $function = 'VARP';			break;
5823
+			        case 197: $function = 'TRUNC';			break;
5824
+			        case 204: $function = 'USDOLLAR';		break;
5825
+			        case 205: $function = 'FINDB';			break;
5826
+			        case 206: $function = 'SEARCHB';		break;
5827
+			        case 208: $function = 'LEFTB';			break;
5828
+			        case 209: $function = 'RIGHTB';			break;
5829
+			        case 216: $function = 'RANK';			break;
5830
+			        case 219: $function = 'ADDRESS';		break;
5831
+			        case 220: $function = 'DAYS360';		break;
5832
+			        case 222: $function = 'VDB';			break;
5833
+			        case 227: $function = 'MEDIAN';			break;
5834
+			        case 228: $function = 'SUMPRODUCT';		break;
5835
+			        case 247: $function = 'DB';				break;
5836
+			        case 255: $function = '';				break;
5837
+			        case 269: $function = 'AVEDEV';			break;
5838
+			        case 270: $function = 'BETADIST';		break;
5839
+			        case 272: $function = 'BETAINV';		break;
5840
+			        case 317: $function = 'PROB';			break;
5841
+			        case 318: $function = 'DEVSQ';			break;
5842
+			        case 319: $function = 'GEOMEAN';		break;
5843
+			        case 320: $function = 'HARMEAN';		break;
5844
+			        case 321: $function = 'SUMSQ';			break;
5845
+			        case 322: $function = 'KURT';			break;
5846
+			        case 323: $function = 'SKEW';			break;
5847
+			        case 324: $function = 'ZTEST';			break;
5848
+			        case 329: $function = 'PERCENTRANK';	break;
5849
+			        case 330: $function = 'MODE';			break;
5850
+			        case 336: $function = 'CONCATENATE';	break;
5851
+			        case 344: $function = 'SUBTOTAL';		break;
5852
+			        case 345: $function = 'SUMIF';			break;
5853
+			        case 354: $function = 'ROMAN';			break;
5854
+			        case 358: $function = 'GETPIVOTDATA';	break;
5855
+			        case 359: $function = 'HYPERLINK';		break;
5856
+			        case 361: $function = 'AVERAGEA';		break;
5857
+			        case 362: $function = 'MAXA';			break;
5858
+			        case 363: $function = 'MINA';			break;
5859
+			        case 364: $function = 'STDEVPA';		break;
5860
+			        case 365: $function = 'VARPA';			break;
5861
+			        case 366: $function = 'STDEVA';			break;
5862
+			        case 367: $function = 'VARA';			break;
5863
+			        default:
5864
+				        throw new PHPExcel_Reader_Exception('Unrecognized function in formula');
5865
+				        break;
5866
+			    }
5867 5867
 			$data = array('function' => $function, 'args' => $args);
5868 5868
 			break;
5869
-		case 0x23:	//	index to defined name
5870
-		case 0x43:
5871
-		case 0x63:
5872
-			$name = 'tName';
5873
-			$size = 5;
5874
-			// offset: 1; size: 2; one-based index to definedname record
5875
-			$definedNameIndex = self::_GetInt2d($formulaData, 1) - 1;
5876
-			// offset: 2; size: 2; not used
5877
-			$data = $this->_definedname[$definedNameIndex]['name'];
5878
-			break;
5879
-		case 0x24:	//	single cell reference e.g. A5
5880
-		case 0x44:
5881
-		case 0x64:
5882
-			$name = 'tRef';
5883
-			$size = 5;
5884
-			$data = $this->_readBIFF8CellAddress(substr($formulaData, 1, 4));
5885
-			break;
5886
-		case 0x25:	//	cell range reference to cells in the same sheet (2d)
5887
-		case 0x45:
5888
-		case 0x65:
5889
-			$name = 'tArea';
5890
-			$size = 9;
5891
-			$data = $this->_readBIFF8CellRangeAddress(substr($formulaData, 1, 8));
5892
-			break;
5893
-		case 0x26:	//	Constant reference sub-expression
5894
-		case 0x46:
5895
-		case 0x66:
5896
-			$name = 'tMemArea';
5897
-			// offset: 1; size: 4; not used
5898
-			// offset: 5; size: 2; size of the following subexpression
5899
-			$subSize = self::_GetInt2d($formulaData, 5);
5900
-			$size = 7 + $subSize;
5901
-			$data = $this->_getFormulaFromData(substr($formulaData, 7, $subSize));
5902
-			break;
5903
-		case 0x27:	//	Deleted constant reference sub-expression
5904
-		case 0x47:
5905
-		case 0x67:
5906
-			$name = 'tMemErr';
5907
-			// offset: 1; size: 4; not used
5908
-			// offset: 5; size: 2; size of the following subexpression
5909
-			$subSize = self::_GetInt2d($formulaData, 5);
5910
-			$size = 7 + $subSize;
5911
-			$data = $this->_getFormulaFromData(substr($formulaData, 7, $subSize));
5912
-			break;
5913
-		case 0x29:	//	Variable reference sub-expression
5914
-		case 0x49:
5915
-		case 0x69:
5916
-			$name = 'tMemFunc';
5917
-			// offset: 1; size: 2; size of the following sub-expression
5918
-			$subSize = self::_GetInt2d($formulaData, 1);
5919
-			$size = 3 + $subSize;
5920
-			$data = $this->_getFormulaFromData(substr($formulaData, 3, $subSize));
5921
-			break;
5922
-
5923
-		case 0x2C: // Relative 2d cell reference reference, used in shared formulas and some other places
5924
-		case 0x4C:
5925
-		case 0x6C:
5926
-			$name = 'tRefN';
5927
-			$size = 5;
5928
-			$data = $this->_readBIFF8CellAddressB(substr($formulaData, 1, 4), $baseCell);
5929
-			break;
5930
-
5931
-		case 0x2D:	//	Relative 2d range reference
5932
-		case 0x4D:
5933
-		case 0x6D:
5934
-			$name = 'tAreaN';
5935
-			$size = 9;
5936
-			$data = $this->_readBIFF8CellRangeAddressB(substr($formulaData, 1, 8), $baseCell);
5937
-			break;
5938
-
5939
-		case 0x39:	//	External name
5940
-		case 0x59:
5941
-		case 0x79:
5942
-			$name = 'tNameX';
5943
-			$size = 7;
5944
-			// offset: 1; size: 2; index to REF entry in EXTERNSHEET record
5945
-			// offset: 3; size: 2; one-based index to DEFINEDNAME or EXTERNNAME record
5946
-			$index = self::_GetInt2d($formulaData, 3);
5947
-			// assume index is to EXTERNNAME record
5948
-			$data = $this->_externalNames[$index - 1]['name'];
5949
-			// offset: 5; size: 2; not used
5950
-			break;
5951
-
5952
-		case 0x3A:	//	3d reference to cell
5953
-		case 0x5A:
5954
-		case 0x7A:
5955
-			$name = 'tRef3d';
5956
-			$size = 7;
5957
-
5958
-			try {
5959
-				// offset: 1; size: 2; index to REF entry
5960
-				$sheetRange = $this->_readSheetRangeByRefIndex(self::_GetInt2d($formulaData, 1));
5961
-				// offset: 3; size: 4; cell address
5962
-				$cellAddress = $this->_readBIFF8CellAddress(substr($formulaData, 3, 4));
5963
-
5964
-				$data = "$sheetRange!$cellAddress";
5965
-			} catch (PHPExcel_Exception $e) {
5966
-				// deleted sheet reference
5967
-				$data = '#REF!';
5968
-			}
5969
-
5970
-			break;
5971
-		case 0x3B:	//	3d reference to cell range
5972
-		case 0x5B:
5973
-		case 0x7B:
5974
-			$name = 'tArea3d';
5975
-			$size = 11;
5976
-
5977
-			try {
5978
-				// offset: 1; size: 2; index to REF entry
5979
-				$sheetRange = $this->_readSheetRangeByRefIndex(self::_GetInt2d($formulaData, 1));
5980
-				// offset: 3; size: 8; cell address
5981
-				$cellRangeAddress = $this->_readBIFF8CellRangeAddress(substr($formulaData, 3, 8));
5982
-
5983
-				$data = "$sheetRange!$cellRangeAddress";
5984
-			} catch (PHPExcel_Exception $e) {
5985
-				// deleted sheet reference
5986
-				$data = '#REF!';
5987
-			}
5988
-
5989
-			break;
5990
-		// Unknown cases	// don't know how to deal with
5991
-		default:
5992
-			throw new PHPExcel_Reader_Exception('Unrecognized token ' . sprintf('%02X', $id) . ' in formula');
5993
-			break;
5869
+		    case 0x23:	//	index to defined name
5870
+		    case 0x43:
5871
+		    case 0x63:
5872
+			    $name = 'tName';
5873
+			    $size = 5;
5874
+			    // offset: 1; size: 2; one-based index to definedname record
5875
+			    $definedNameIndex = self::_GetInt2d($formulaData, 1) - 1;
5876
+			    // offset: 2; size: 2; not used
5877
+			    $data = $this->_definedname[$definedNameIndex]['name'];
5878
+			    break;
5879
+		    case 0x24:	//	single cell reference e.g. A5
5880
+		    case 0x44:
5881
+		    case 0x64:
5882
+			    $name = 'tRef';
5883
+			    $size = 5;
5884
+			    $data = $this->_readBIFF8CellAddress(substr($formulaData, 1, 4));
5885
+			    break;
5886
+		    case 0x25:	//	cell range reference to cells in the same sheet (2d)
5887
+		    case 0x45:
5888
+		    case 0x65:
5889
+			    $name = 'tArea';
5890
+			    $size = 9;
5891
+			    $data = $this->_readBIFF8CellRangeAddress(substr($formulaData, 1, 8));
5892
+			    break;
5893
+		    case 0x26:	//	Constant reference sub-expression
5894
+		    case 0x46:
5895
+		    case 0x66:
5896
+			    $name = 'tMemArea';
5897
+			    // offset: 1; size: 4; not used
5898
+			    // offset: 5; size: 2; size of the following subexpression
5899
+			    $subSize = self::_GetInt2d($formulaData, 5);
5900
+			    $size = 7 + $subSize;
5901
+			    $data = $this->_getFormulaFromData(substr($formulaData, 7, $subSize));
5902
+			    break;
5903
+		    case 0x27:	//	Deleted constant reference sub-expression
5904
+		    case 0x47:
5905
+		    case 0x67:
5906
+			    $name = 'tMemErr';
5907
+			    // offset: 1; size: 4; not used
5908
+			    // offset: 5; size: 2; size of the following subexpression
5909
+			    $subSize = self::_GetInt2d($formulaData, 5);
5910
+			    $size = 7 + $subSize;
5911
+			    $data = $this->_getFormulaFromData(substr($formulaData, 7, $subSize));
5912
+			    break;
5913
+		    case 0x29:	//	Variable reference sub-expression
5914
+		    case 0x49:
5915
+		    case 0x69:
5916
+			    $name = 'tMemFunc';
5917
+			    // offset: 1; size: 2; size of the following sub-expression
5918
+			    $subSize = self::_GetInt2d($formulaData, 1);
5919
+			    $size = 3 + $subSize;
5920
+			    $data = $this->_getFormulaFromData(substr($formulaData, 3, $subSize));
5921
+			    break;
5922
+
5923
+		    case 0x2C: // Relative 2d cell reference reference, used in shared formulas and some other places
5924
+		    case 0x4C:
5925
+		    case 0x6C:
5926
+			    $name = 'tRefN';
5927
+			    $size = 5;
5928
+			    $data = $this->_readBIFF8CellAddressB(substr($formulaData, 1, 4), $baseCell);
5929
+			    break;
5930
+
5931
+		    case 0x2D:	//	Relative 2d range reference
5932
+		    case 0x4D:
5933
+		    case 0x6D:
5934
+			    $name = 'tAreaN';
5935
+			    $size = 9;
5936
+			    $data = $this->_readBIFF8CellRangeAddressB(substr($formulaData, 1, 8), $baseCell);
5937
+			    break;
5938
+
5939
+		    case 0x39:	//	External name
5940
+		    case 0x59:
5941
+		    case 0x79:
5942
+			    $name = 'tNameX';
5943
+			    $size = 7;
5944
+			    // offset: 1; size: 2; index to REF entry in EXTERNSHEET record
5945
+			    // offset: 3; size: 2; one-based index to DEFINEDNAME or EXTERNNAME record
5946
+			    $index = self::_GetInt2d($formulaData, 3);
5947
+			    // assume index is to EXTERNNAME record
5948
+			    $data = $this->_externalNames[$index - 1]['name'];
5949
+			    // offset: 5; size: 2; not used
5950
+			    break;
5951
+
5952
+		    case 0x3A:	//	3d reference to cell
5953
+		    case 0x5A:
5954
+		    case 0x7A:
5955
+			    $name = 'tRef3d';
5956
+			    $size = 7;
5957
+
5958
+			    try {
5959
+				    // offset: 1; size: 2; index to REF entry
5960
+				    $sheetRange = $this->_readSheetRangeByRefIndex(self::_GetInt2d($formulaData, 1));
5961
+				    // offset: 3; size: 4; cell address
5962
+				    $cellAddress = $this->_readBIFF8CellAddress(substr($formulaData, 3, 4));
5963
+
5964
+				    $data = "$sheetRange!$cellAddress";
5965
+			    } catch (PHPExcel_Exception $e) {
5966
+				    // deleted sheet reference
5967
+				    $data = '#REF!';
5968
+			    }
5969
+
5970
+			    break;
5971
+		    case 0x3B:	//	3d reference to cell range
5972
+		    case 0x5B:
5973
+		    case 0x7B:
5974
+			    $name = 'tArea3d';
5975
+			    $size = 11;
5976
+
5977
+			    try {
5978
+				    // offset: 1; size: 2; index to REF entry
5979
+				    $sheetRange = $this->_readSheetRangeByRefIndex(self::_GetInt2d($formulaData, 1));
5980
+				    // offset: 3; size: 8; cell address
5981
+				    $cellRangeAddress = $this->_readBIFF8CellRangeAddress(substr($formulaData, 3, 8));
5982
+
5983
+				    $data = "$sheetRange!$cellRangeAddress";
5984
+			    } catch (PHPExcel_Exception $e) {
5985
+				    // deleted sheet reference
5986
+				    $data = '#REF!';
5987
+			    }
5988
+
5989
+			    break;
5990
+		    // Unknown cases	// don't know how to deal with
5991
+		    default:
5992
+			    throw new PHPExcel_Reader_Exception('Unrecognized token ' . sprintf('%02X', $id) . ' in formula');
5993
+			    break;
5994 5994
 		}
5995 5995
 
5996 5996
 		return array(
@@ -6457,35 +6457,35 @@  discard block
 block discarded – undo
6457 6457
 		$identifier = ord($valueData[0]);
6458 6458
 
6459 6459
 		switch ($identifier) {
6460
-		case 0x00: // empty constant (what is this?)
6461
-			$value = '';
6462
-			$size = 9;
6463
-			break;
6464
-		case 0x01: // number
6465
-			// offset: 1; size: 8; IEEE 754 floating-point value
6466
-			$value = self::_extractNumber(substr($valueData, 1, 8));
6467
-			$size = 9;
6468
-			break;
6469
-		case 0x02: // string value
6470
-			// offset: 1; size: var; Unicode string, 16-bit string length
6471
-			$string = self::_readUnicodeStringLong(substr($valueData, 1));
6472
-			$value = '"' . $string['value'] . '"';
6473
-			$size = 1 + $string['size'];
6474
-			break;
6475
-		case 0x04: // boolean
6476
-			// offset: 1; size: 1; 0 = FALSE, 1 = TRUE
6477
-			if (ord($valueData[1])) {
6478
-				$value = 'TRUE';
6479
-			} else {
6480
-				$value = 'FALSE';
6481
-			}
6482
-			$size = 9;
6483
-			break;
6484
-		case 0x10: // error code
6485
-			// offset: 1; size: 1; error code
6486
-			$value = self::_mapErrorCode(ord($valueData[1]));
6487
-			$size = 9;
6488
-			break;
6460
+		    case 0x00: // empty constant (what is this?)
6461
+			    $value = '';
6462
+			    $size = 9;
6463
+			    break;
6464
+		    case 0x01: // number
6465
+			    // offset: 1; size: 8; IEEE 754 floating-point value
6466
+			    $value = self::_extractNumber(substr($valueData, 1, 8));
6467
+			    $size = 9;
6468
+			    break;
6469
+		    case 0x02: // string value
6470
+			    // offset: 1; size: var; Unicode string, 16-bit string length
6471
+			    $string = self::_readUnicodeStringLong(substr($valueData, 1));
6472
+			    $value = '"' . $string['value'] . '"';
6473
+			    $size = 1 + $string['size'];
6474
+			    break;
6475
+		    case 0x04: // boolean
6476
+			    // offset: 1; size: 1; 0 = FALSE, 1 = TRUE
6477
+			    if (ord($valueData[1])) {
6478
+				    $value = 'TRUE';
6479
+			    } else {
6480
+				    $value = 'FALSE';
6481
+			    }
6482
+			    $size = 9;
6483
+			    break;
6484
+		    case 0x10: // error code
6485
+			    // offset: 1; size: 1; error code
6486
+			    $value = self::_mapErrorCode(ord($valueData[1]));
6487
+			    $size = 9;
6488
+			    break;
6489 6489
 		}
6490 6490
 		return array(
6491 6491
 			'value' => $value,
Please login to merge, or discard this patch.
CodeSniffer/Standards/MySource/Sniffs/Channels/UnusedSystemSniff.php 1 patch
Switch Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -111,33 +111,33 @@
 block discarded – undo
111 111
             }
112 112
 
113 113
             switch ($tokens[$i]['code']) {
114
-            case T_DOUBLE_COLON:
115
-                $usedName = strtolower($tokens[($i - 1)]['content']);
116
-                if ($usedName === $systemName) {
117
-                    // The included system was used, so it is fine.
118
-                    return;
119
-                }
120
-                break;
121
-            case T_EXTENDS:
122
-                $classNameToken = $phpcsFile->findNext(T_STRING, ($i + 1));
123
-                $className      = strtolower($tokens[$classNameToken]['content']);
124
-                if ($className === $systemName) {
125
-                    // The included system was used, so it is fine.
126
-                    return;
127
-                }
128
-                break;
129
-            case T_IMPLEMENTS:
130
-                $endImplements = $phpcsFile->findNext(array(T_EXTENDS, T_OPEN_CURLY_BRACKET), ($i + 1));
131
-                for ($x = ($i + 1); $x < $endImplements; $x++) {
132
-                    if ($tokens[$x]['code'] === T_STRING) {
133
-                        $className = strtolower($tokens[$x]['content']);
134
-                        if ($className === $systemName) {
135
-                            // The included system was used, so it is fine.
136
-                            return;
114
+                case T_DOUBLE_COLON:
115
+                    $usedName = strtolower($tokens[($i - 1)]['content']);
116
+                    if ($usedName === $systemName) {
117
+                        // The included system was used, so it is fine.
118
+                        return;
119
+                    }
120
+                    break;
121
+                case T_EXTENDS:
122
+                    $classNameToken = $phpcsFile->findNext(T_STRING, ($i + 1));
123
+                    $className      = strtolower($tokens[$classNameToken]['content']);
124
+                    if ($className === $systemName) {
125
+                        // The included system was used, so it is fine.
126
+                        return;
127
+                    }
128
+                    break;
129
+                case T_IMPLEMENTS:
130
+                    $endImplements = $phpcsFile->findNext(array(T_EXTENDS, T_OPEN_CURLY_BRACKET), ($i + 1));
131
+                    for ($x = ($i + 1); $x < $endImplements; $x++) {
132
+                        if ($tokens[$x]['code'] === T_STRING) {
133
+                            $className = strtolower($tokens[$x]['content']);
134
+                            if ($className === $systemName) {
135
+                                // The included system was used, so it is fine.
136
+                                return;
137
+                            }
137 138
                         }
138 139
                     }
139
-                }
140
-                break;
140
+                    break;
141 141
             }//end switch
142 142
         }//end for
143 143
 
Please login to merge, or discard this patch.
CodeSniffer/Standards/MySource/Sniffs/Channels/IncludeOwnSystemSniff.php 1 patch
Switch Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -63,17 +63,17 @@
 block discarded – undo
63 63
         $typeName = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, ($stackPtr + 2), null, false, true);
64 64
         $typeName = trim($tokens[$typeName]['content'], " '");
65 65
         switch (strtolower($tokens[($stackPtr + 1)]['content'])) {
66
-        case 'includesystem' :
67
-            $included = strtolower($typeName);
68
-            break;
69
-        case 'includeasset' :
70
-            $included = strtolower($typeName).'assettype';
71
-            break;
72
-        case 'includewidget' :
73
-            $included = strtolower($typeName).'widgettype';
74
-            break;
75
-        default:
76
-            return;
66
+            case 'includesystem' :
67
+                $included = strtolower($typeName);
68
+                break;
69
+            case 'includeasset' :
70
+                $included = strtolower($typeName).'assettype';
71
+                break;
72
+            case 'includewidget' :
73
+                $included = strtolower($typeName).'widgettype';
74
+                break;
75
+            default:
76
+                return;
77 77
         }
78 78
 
79 79
         if ($included === strtolower($ownClass)) {
Please login to merge, or discard this patch.
squizlabs/php_codesniffer/CodeSniffer/Standards/AbstractPatternSniff.php 1 patch
Switch Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -890,26 +890,26 @@
 block discarded – undo
890 890
         $nestedBraces      = 0;
891 891
         for ($start = $from; $start >= 0; $start--) {
892 892
             switch ($pattern[$start]) {
893
-            case '(':
894
-                if ($nestedParenthesis === 0) {
895
-                    $skip['to'] = 'parenthesis_closer';
896
-                }
893
+                case '(':
894
+                    if ($nestedParenthesis === 0) {
895
+                        $skip['to'] = 'parenthesis_closer';
896
+                    }
897 897
 
898
-                $nestedParenthesis--;
899
-                break;
900
-            case '{':
901
-                if ($nestedBraces === 0) {
902
-                    $skip['to'] = 'scope_closer';
903
-                }
898
+                    $nestedParenthesis--;
899
+                    break;
900
+                case '{':
901
+                    if ($nestedBraces === 0) {
902
+                        $skip['to'] = 'scope_closer';
903
+                    }
904 904
 
905
-                $nestedBraces--;
906
-                break;
907
-            case '}':
908
-                $nestedBraces++;
909
-                break;
910
-            case ')':
911
-                $nestedParenthesis++;
912
-                break;
905
+                    $nestedBraces--;
906
+                    break;
907
+                case '}':
908
+                    $nestedBraces++;
909
+                    break;
910
+                case ')':
911
+                    $nestedParenthesis++;
912
+                    break;
913 913
             }//end switch
914 914
 
915 915
             if (isset($skip['to']) === true) {
Please login to merge, or discard this patch.
CodeSniffer/Standards/PSR2/Sniffs/Methods/MethodDeclarationSniff.php 1 patch
Switch Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -80,18 +80,18 @@
 block discarded – undo
80 80
         $prefix = $stackPtr;
81 81
         while (($prefix = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$methodPrefixes, ($prefix - 1), $prev)) !== false) {
82 82
             switch ($tokens[$prefix]['code']) {
83
-            case T_STATIC:
84
-                $static = $prefix;
85
-                break;
86
-            case T_ABSTRACT:
87
-                $abstract = $prefix;
88
-                break;
89
-            case T_FINAL:
90
-                $final = $prefix;
91
-                break;
92
-            default:
93
-                $visibility = $prefix;
94
-                break;
83
+                case T_STATIC:
84
+                    $static = $prefix;
85
+                    break;
86
+                case T_ABSTRACT:
87
+                    $abstract = $prefix;
88
+                    break;
89
+                case T_FINAL:
90
+                    $final = $prefix;
91
+                    break;
92
+                default:
93
+                    $visibility = $prefix;
94
+                    break;
95 95
             }
96 96
         }
97 97
 
Please login to merge, or discard this patch.
CodeSniffer/Standards/Generic/Sniffs/Files/LineEndingsSniff.php 1 patch
Switch Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -110,18 +110,18 @@
 block discarded – undo
110 110
         if ($fix === true) {
111 111
             $tokens = $phpcsFile->getTokens();
112 112
             switch ($this->eolChar) {
113
-            case '\n':
114
-                $eolChar = "\n";
115
-                break;
116
-            case '\r':
117
-                $eolChar = "\r";
118
-                break;
119
-            case '\r\n':
120
-                $eolChar = "\r\n";
121
-                break;
122
-            default:
123
-                $eolChar = $this->eolChar;
124
-                break;
113
+                case '\n':
114
+                    $eolChar = "\n";
115
+                    break;
116
+                case '\r':
117
+                    $eolChar = "\r";
118
+                    break;
119
+                case '\r\n':
120
+                    $eolChar = "\r\n";
121
+                    break;
122
+                default:
123
+                    $eolChar = $this->eolChar;
124
+                    break;
125 125
             }
126 126
 
127 127
             for ($i = 0; $i < $phpcsFile->numTokens; $i++) {
Please login to merge, or discard this patch.
htdocs/includes/squizlabs/php_codesniffer/CodeSniffer/Tokenizers/PHP.php 1 patch
Switch Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -1565,24 +1565,24 @@  discard block
 block discarded – undo
1565 1565
 
1566 1566
         if ($token[0] === T_STRING) {
1567 1567
             switch ($cacheKey) {
1568
-            case 'false':
1569
-                $newToken['type'] = 'T_FALSE';
1570
-                break;
1571
-            case 'true':
1572
-                $newToken['type'] = 'T_TRUE';
1573
-                break;
1574
-            case 'null':
1575
-                $newToken['type'] = 'T_NULL';
1576
-                break;
1577
-            case 'self':
1578
-                $newToken['type'] = 'T_SELF';
1579
-                break;
1580
-            case 'parent':
1581
-                $newToken['type'] = 'T_PARENT';
1582
-                break;
1583
-            default:
1584
-                $newToken['type'] = 'T_STRING';
1585
-                break;
1568
+                case 'false':
1569
+                    $newToken['type'] = 'T_FALSE';
1570
+                    break;
1571
+                case 'true':
1572
+                    $newToken['type'] = 'T_TRUE';
1573
+                    break;
1574
+                case 'null':
1575
+                    $newToken['type'] = 'T_NULL';
1576
+                    break;
1577
+                case 'self':
1578
+                    $newToken['type'] = 'T_SELF';
1579
+                    break;
1580
+                case 'parent':
1581
+                    $newToken['type'] = 'T_PARENT';
1582
+                    break;
1583
+                default:
1584
+                    $newToken['type'] = 'T_STRING';
1585
+                    break;
1586 1586
             }
1587 1587
 
1588 1588
             $newToken['code'] = constant($newToken['type']);
@@ -1624,84 +1624,84 @@  discard block
 block discarded – undo
1624 1624
         $newToken = array();
1625 1625
 
1626 1626
         switch ($token) {
1627
-        case '{':
1628
-            $newToken['type'] = 'T_OPEN_CURLY_BRACKET';
1629
-            break;
1630
-        case '}':
1631
-            $newToken['type'] = 'T_CLOSE_CURLY_BRACKET';
1632
-            break;
1633
-        case '[':
1634
-            $newToken['type'] = 'T_OPEN_SQUARE_BRACKET';
1635
-            break;
1636
-        case ']':
1637
-            $newToken['type'] = 'T_CLOSE_SQUARE_BRACKET';
1638
-            break;
1639
-        case '(':
1640
-            $newToken['type'] = 'T_OPEN_PARENTHESIS';
1641
-            break;
1642
-        case ')':
1643
-            $newToken['type'] = 'T_CLOSE_PARENTHESIS';
1644
-            break;
1645
-        case ':':
1646
-            $newToken['type'] = 'T_COLON';
1647
-            break;
1648
-        case '.':
1649
-            $newToken['type'] = 'T_STRING_CONCAT';
1650
-            break;
1651
-        case ';':
1652
-            $newToken['type'] = 'T_SEMICOLON';
1653
-            break;
1654
-        case '=':
1655
-            $newToken['type'] = 'T_EQUAL';
1656
-            break;
1657
-        case '*':
1658
-            $newToken['type'] = 'T_MULTIPLY';
1659
-            break;
1660
-        case '/':
1661
-            $newToken['type'] = 'T_DIVIDE';
1662
-            break;
1663
-        case '+':
1664
-            $newToken['type'] = 'T_PLUS';
1665
-            break;
1666
-        case '-':
1667
-            $newToken['type'] = 'T_MINUS';
1668
-            break;
1669
-        case '%':
1670
-            $newToken['type'] = 'T_MODULUS';
1671
-            break;
1672
-        case '^':
1673
-            $newToken['type'] = 'T_BITWISE_XOR';
1674
-            break;
1675
-        case '&':
1676
-            $newToken['type'] = 'T_BITWISE_AND';
1677
-            break;
1678
-        case '|':
1679
-            $newToken['type'] = 'T_BITWISE_OR';
1680
-            break;
1681
-        case '<':
1682
-            $newToken['type'] = 'T_LESS_THAN';
1683
-            break;
1684
-        case '>':
1685
-            $newToken['type'] = 'T_GREATER_THAN';
1686
-            break;
1687
-        case '!':
1688
-            $newToken['type'] = 'T_BOOLEAN_NOT';
1689
-            break;
1690
-        case ',':
1691
-            $newToken['type'] = 'T_COMMA';
1692
-            break;
1693
-        case '@':
1694
-            $newToken['type'] = 'T_ASPERAND';
1695
-            break;
1696
-        case '$':
1697
-            $newToken['type'] = 'T_DOLLAR';
1698
-            break;
1699
-        case '`':
1700
-            $newToken['type'] = 'T_BACKTICK';
1701
-            break;
1702
-        default:
1703
-            $newToken['type'] = 'T_NONE';
1704
-            break;
1627
+            case '{':
1628
+                $newToken['type'] = 'T_OPEN_CURLY_BRACKET';
1629
+                break;
1630
+            case '}':
1631
+                $newToken['type'] = 'T_CLOSE_CURLY_BRACKET';
1632
+                break;
1633
+            case '[':
1634
+                $newToken['type'] = 'T_OPEN_SQUARE_BRACKET';
1635
+                break;
1636
+            case ']':
1637
+                $newToken['type'] = 'T_CLOSE_SQUARE_BRACKET';
1638
+                break;
1639
+            case '(':
1640
+                $newToken['type'] = 'T_OPEN_PARENTHESIS';
1641
+                break;
1642
+            case ')':
1643
+                $newToken['type'] = 'T_CLOSE_PARENTHESIS';
1644
+                break;
1645
+            case ':':
1646
+                $newToken['type'] = 'T_COLON';
1647
+                break;
1648
+            case '.':
1649
+                $newToken['type'] = 'T_STRING_CONCAT';
1650
+                break;
1651
+            case ';':
1652
+                $newToken['type'] = 'T_SEMICOLON';
1653
+                break;
1654
+            case '=':
1655
+                $newToken['type'] = 'T_EQUAL';
1656
+                break;
1657
+            case '*':
1658
+                $newToken['type'] = 'T_MULTIPLY';
1659
+                break;
1660
+            case '/':
1661
+                $newToken['type'] = 'T_DIVIDE';
1662
+                break;
1663
+            case '+':
1664
+                $newToken['type'] = 'T_PLUS';
1665
+                break;
1666
+            case '-':
1667
+                $newToken['type'] = 'T_MINUS';
1668
+                break;
1669
+            case '%':
1670
+                $newToken['type'] = 'T_MODULUS';
1671
+                break;
1672
+            case '^':
1673
+                $newToken['type'] = 'T_BITWISE_XOR';
1674
+                break;
1675
+            case '&':
1676
+                $newToken['type'] = 'T_BITWISE_AND';
1677
+                break;
1678
+            case '|':
1679
+                $newToken['type'] = 'T_BITWISE_OR';
1680
+                break;
1681
+            case '<':
1682
+                $newToken['type'] = 'T_LESS_THAN';
1683
+                break;
1684
+            case '>':
1685
+                $newToken['type'] = 'T_GREATER_THAN';
1686
+                break;
1687
+            case '!':
1688
+                $newToken['type'] = 'T_BOOLEAN_NOT';
1689
+                break;
1690
+            case ',':
1691
+                $newToken['type'] = 'T_COMMA';
1692
+                break;
1693
+            case '@':
1694
+                $newToken['type'] = 'T_ASPERAND';
1695
+                break;
1696
+            case '$':
1697
+                $newToken['type'] = 'T_DOLLAR';
1698
+                break;
1699
+            case '`':
1700
+                $newToken['type'] = 'T_BACKTICK';
1701
+                break;
1702
+            default:
1703
+                $newToken['type'] = 'T_NONE';
1704
+                break;
1705 1705
         }//end switch
1706 1706
 
1707 1707
         $newToken['code']    = constant($newToken['type']);
Please login to merge, or discard this patch.
htdocs/includes/squizlabs/php_codesniffer/CodeSniffer/Tokenizers/CSS.php 1 patch
Switch Indentation   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -284,12 +284,32 @@  discard block
 block discarded – undo
284 284
             }
285 285
 
286 286
             switch ($token['code']) {
287
-            case T_OPEN_CURLY_BRACKET:
288
-                // Opening curly brackets for an At-rule do not start a style
289
-                // definition. We also reset the asperand flag here because the next
290
-                // opening curly bracket could be indeed the start of a style
291
-                // definition.
292
-                if ($asperandStart === true) {
287
+                case T_OPEN_CURLY_BRACKET:
288
+                    // Opening curly brackets for an At-rule do not start a style
289
+                    // definition. We also reset the asperand flag here because the next
290
+                    // opening curly bracket could be indeed the start of a style
291
+                    // definition.
292
+                    if ($asperandStart === true) {
293
+                        if (PHP_CODESNIFFER_VERBOSITY > 1) {
294
+                            if ($inStyleDef === true) {
295
+                                echo "\t\t* style definition closed *".PHP_EOL;
296
+                            }
297
+
298
+                            if ($asperandStart === true) {
299
+                                echo "\t\t* at-rule definition closed *".PHP_EOL;
300
+                            }
301
+                        }
302
+
303
+                        $inStyleDef    = false;
304
+                        $asperandStart = false;
305
+                    } else {
306
+                        $inStyleDef = true;
307
+                        if (PHP_CODESNIFFER_VERBOSITY > 1) {
308
+                            echo "\t\t* style definition opened *".PHP_EOL;
309
+                        }
310
+                    }
311
+                    break;
312
+                case T_CLOSE_CURLY_BRACKET:
293 313
                     if (PHP_CODESNIFFER_VERBOSITY > 1) {
294 314
                         if ($inStyleDef === true) {
295 315
                             echo "\t\t* style definition closed *".PHP_EOL;
@@ -302,186 +322,166 @@  discard block
 block discarded – undo
302 322
 
303 323
                     $inStyleDef    = false;
304 324
                     $asperandStart = false;
305
-                } else {
306
-                    $inStyleDef = true;
307
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
308
-                        echo "\t\t* style definition opened *".PHP_EOL;
309
-                    }
310
-                }
311
-                break;
312
-            case T_CLOSE_CURLY_BRACKET:
313
-                if (PHP_CODESNIFFER_VERBOSITY > 1) {
314
-                    if ($inStyleDef === true) {
315
-                        echo "\t\t* style definition closed *".PHP_EOL;
316
-                    }
317
-
318
-                    if ($asperandStart === true) {
319
-                        echo "\t\t* at-rule definition closed *".PHP_EOL;
320
-                    }
321
-                }
322
-
323
-                $inStyleDef    = false;
324
-                $asperandStart = false;
325
-                break;
326
-            case T_MINUS:
327
-                // Minus signs are often used instead of spaces inside
328
-                // class names, IDs and styles.
329
-                if ($finalTokens[($stackPtr + 1)]['code'] === T_STRING) {
330
-                    if ($finalTokens[($stackPtr - 1)]['code'] === T_STRING) {
331
-                        $newContent = $finalTokens[($stackPtr - 1)]['content'].'-'.$finalTokens[($stackPtr + 1)]['content'];
332
-
325
+                    break;
326
+                case T_MINUS:
327
+                    // Minus signs are often used instead of spaces inside
328
+                    // class names, IDs and styles.
329
+                    if ($finalTokens[($stackPtr + 1)]['code'] === T_STRING) {
330
+                        if ($finalTokens[($stackPtr - 1)]['code'] === T_STRING) {
331
+                            $newContent = $finalTokens[($stackPtr - 1)]['content'].'-'.$finalTokens[($stackPtr + 1)]['content'];
332
+
333
+                            if (PHP_CODESNIFFER_VERBOSITY > 1) {
334
+                                echo "\t\t* token is a string joiner; ignoring this and previous token".PHP_EOL;
335
+                                $old = PHP_CodeSniffer::prepareForOutput($finalTokens[($stackPtr + 1)]['content']);
336
+                                $new = PHP_CodeSniffer::prepareForOutput($newContent);
337
+                                echo "\t\t=> token ".($stackPtr + 1)." content changed from \"$old\" to \"$new\"".PHP_EOL;
338
+                            }
339
+
340
+                            $finalTokens[($stackPtr + 1)]['content'] = $newContent;
341
+                            unset($finalTokens[$stackPtr]);
342
+                            unset($finalTokens[($stackPtr - 1)]);
343
+                        } else {
344
+                            $newContent = '-'.$finalTokens[($stackPtr + 1)]['content'];
345
+
346
+                            $finalTokens[($stackPtr + 1)]['content'] = $newContent;
347
+                            unset($finalTokens[$stackPtr]);
348
+                        }
349
+                    } else if ($finalTokens[($stackPtr + 1)]['code'] === T_LNUMBER) {
350
+                        // They can also be used to provide negative numbers.
333 351
                         if (PHP_CODESNIFFER_VERBOSITY > 1) {
334
-                            echo "\t\t* token is a string joiner; ignoring this and previous token".PHP_EOL;
335
-                            $old = PHP_CodeSniffer::prepareForOutput($finalTokens[($stackPtr + 1)]['content']);
336
-                            $new = PHP_CodeSniffer::prepareForOutput($newContent);
337
-                            echo "\t\t=> token ".($stackPtr + 1)." content changed from \"$old\" to \"$new\"".PHP_EOL;
352
+                            echo "\t\t* token is part of a negative number; adding content to next token and ignoring *".PHP_EOL;
353
+                            $content = PHP_CodeSniffer::prepareForOutput($finalTokens[($stackPtr + 1)]['content']);
354
+                            echo "\t\t=> token ".($stackPtr + 1)." content changed from \"$content\" to \"-$content\"".PHP_EOL;
338 355
                         }
339 356
 
340
-                        $finalTokens[($stackPtr + 1)]['content'] = $newContent;
357
+                        $finalTokens[($stackPtr + 1)]['content'] = '-'.$finalTokens[($stackPtr + 1)]['content'];
341 358
                         unset($finalTokens[$stackPtr]);
342
-                        unset($finalTokens[($stackPtr - 1)]);
343
-                    } else {
344
-                        $newContent = '-'.$finalTokens[($stackPtr + 1)]['content'];
359
+                    }//end if
345 360
 
346
-                        $finalTokens[($stackPtr + 1)]['content'] = $newContent;
347
-                        unset($finalTokens[$stackPtr]);
348
-                    }
349
-                } else if ($finalTokens[($stackPtr + 1)]['code'] === T_LNUMBER) {
350
-                    // They can also be used to provide negative numbers.
351
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
352
-                        echo "\t\t* token is part of a negative number; adding content to next token and ignoring *".PHP_EOL;
353
-                        $content = PHP_CodeSniffer::prepareForOutput($finalTokens[($stackPtr + 1)]['content']);
354
-                        echo "\t\t=> token ".($stackPtr + 1)." content changed from \"$content\" to \"-$content\"".PHP_EOL;
355
-                    }
356
-
357
-                    $finalTokens[($stackPtr + 1)]['content'] = '-'.$finalTokens[($stackPtr + 1)]['content'];
358
-                    unset($finalTokens[$stackPtr]);
359
-                }//end if
360
-
361
-                break;
362
-            case T_COLON:
363
-                // Only interested in colons that are defining styles.
364
-                if ($inStyleDef === false) {
365 361
                     break;
366
-                }
367
-
368
-                for ($x = ($stackPtr - 1); $x >= 0; $x--) {
369
-                    if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$finalTokens[$x]['code']]) === false) {
362
+                case T_COLON:
363
+                    // Only interested in colons that are defining styles.
364
+                    if ($inStyleDef === false) {
370 365
                         break;
371 366
                     }
372
-                }
373 367
 
374
-                if (PHP_CODESNIFFER_VERBOSITY > 1) {
375
-                    $type = $finalTokens[$x]['type'];
376
-                    echo "\t\t=> token $x changed from $type to T_STYLE".PHP_EOL;
377
-                }
378
-
379
-                $finalTokens[$x]['type'] = 'T_STYLE';
380
-                $finalTokens[$x]['code'] = T_STYLE;
381
-                break;
382
-            case T_STRING:
383
-                if (strtolower($token['content']) === 'url') {
384
-                    // Find the next content.
385
-                    for ($x = ($stackPtr + 1); $x < $numTokens; $x++) {
368
+                    for ($x = ($stackPtr - 1); $x >= 0; $x--) {
386 369
                         if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$finalTokens[$x]['code']]) === false) {
387 370
                             break;
388 371
                         }
389 372
                     }
390 373
 
391
-                    // Needs to be in the format "url(" for it to be a URL.
392
-                    if ($finalTokens[$x]['code'] !== T_OPEN_PARENTHESIS) {
393
-                        continue 2;
374
+                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
375
+                        $type = $finalTokens[$x]['type'];
376
+                        echo "\t\t=> token $x changed from $type to T_STYLE".PHP_EOL;
394 377
                     }
395 378
 
396
-                    // Make sure the content isn't empty.
397
-                    for ($y = ($x + 1); $y < $numTokens; $y++) {
398
-                        if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$finalTokens[$y]['code']]) === false) {
399
-                            break;
379
+                    $finalTokens[$x]['type'] = 'T_STYLE';
380
+                    $finalTokens[$x]['code'] = T_STYLE;
381
+                    break;
382
+                case T_STRING:
383
+                    if (strtolower($token['content']) === 'url') {
384
+                        // Find the next content.
385
+                        for ($x = ($stackPtr + 1); $x < $numTokens; $x++) {
386
+                            if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$finalTokens[$x]['code']]) === false) {
387
+                                break;
388
+                            }
400 389
                         }
401
-                    }
402 390
 
403
-                    if ($finalTokens[$y]['code'] === T_CLOSE_PARENTHESIS) {
404
-                        continue 2;
405
-                    }
406
-
407
-                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
408
-                        for ($i = ($stackPtr + 1); $i <= $y; $i++) {
409
-                            $type    = $finalTokens[$i]['type'];
410
-                            $content = PHP_CodeSniffer::prepareForOutput($finalTokens[$i]['content']);
411
-                            echo "\tProcess token $i: $type => $content".PHP_EOL;
391
+                        // Needs to be in the format "url(" for it to be a URL.
392
+                        if ($finalTokens[$x]['code'] !== T_OPEN_PARENTHESIS) {
393
+                            continue 2;
412 394
                         }
413 395
 
414
-                        echo "\t\t* token starts a URL *".PHP_EOL;
415
-                    }
396
+                        // Make sure the content isn't empty.
397
+                        for ($y = ($x + 1); $y < $numTokens; $y++) {
398
+                            if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$finalTokens[$y]['code']]) === false) {
399
+                                break;
400
+                            }
401
+                        }
416 402
 
417
-                    // Join all the content together inside the url() statement.
418
-                    $newContent = '';
419
-                    for ($i = ($x + 2); $i < $numTokens; $i++) {
420
-                        if ($finalTokens[$i]['code'] === T_CLOSE_PARENTHESIS) {
421
-                            break;
403
+                        if ($finalTokens[$y]['code'] === T_CLOSE_PARENTHESIS) {
404
+                            continue 2;
422 405
                         }
423 406
 
424
-                        $newContent .= $finalTokens[$i]['content'];
425 407
                         if (PHP_CODESNIFFER_VERBOSITY > 1) {
426
-                            $content = PHP_CodeSniffer::prepareForOutput($finalTokens[$i]['content']);
427
-                            echo "\t\t=> token $i added to URL string and ignored: $content".PHP_EOL;
408
+                            for ($i = ($stackPtr + 1); $i <= $y; $i++) {
409
+                                $type    = $finalTokens[$i]['type'];
410
+                                $content = PHP_CodeSniffer::prepareForOutput($finalTokens[$i]['content']);
411
+                                echo "\tProcess token $i: $type => $content".PHP_EOL;
412
+                            }
413
+
414
+                            echo "\t\t* token starts a URL *".PHP_EOL;
428 415
                         }
429 416
 
430
-                        unset($finalTokens[$i]);
431
-                    }
417
+                        // Join all the content together inside the url() statement.
418
+                        $newContent = '';
419
+                        for ($i = ($x + 2); $i < $numTokens; $i++) {
420
+                            if ($finalTokens[$i]['code'] === T_CLOSE_PARENTHESIS) {
421
+                                break;
422
+                            }
432 423
 
433
-                    $stackPtr = $i;
424
+                            $newContent .= $finalTokens[$i]['content'];
425
+                            if (PHP_CODESNIFFER_VERBOSITY > 1) {
426
+                                $content = PHP_CodeSniffer::prepareForOutput($finalTokens[$i]['content']);
427
+                                echo "\t\t=> token $i added to URL string and ignored: $content".PHP_EOL;
428
+                            }
434 429
 
435
-                    // If the content inside the "url()" is in double quotes
436
-                    // there will only be one token and so we don't have to do
437
-                    // anything except change its type. If it is not empty,
438
-                    // we need to do some token merging.
439
-                    $finalTokens[($x + 1)]['type'] = 'T_URL';
440
-                    $finalTokens[($x + 1)]['code'] = T_URL;
430
+                            unset($finalTokens[$i]);
431
+                        }
441 432
 
442
-                    if ($newContent !== '') {
443
-                        $finalTokens[($x + 1)]['content'] .= $newContent;
444
-                        if (PHP_CODESNIFFER_VERBOSITY > 1) {
445
-                            $content = PHP_CodeSniffer::prepareForOutput($finalTokens[($x + 1)]['content']);
446
-                            echo "\t\t=> token content changed to: $content".PHP_EOL;
433
+                        $stackPtr = $i;
434
+
435
+                        // If the content inside the "url()" is in double quotes
436
+                        // there will only be one token and so we don't have to do
437
+                        // anything except change its type. If it is not empty,
438
+                        // we need to do some token merging.
439
+                        $finalTokens[($x + 1)]['type'] = 'T_URL';
440
+                        $finalTokens[($x + 1)]['code'] = T_URL;
441
+
442
+                        if ($newContent !== '') {
443
+                            $finalTokens[($x + 1)]['content'] .= $newContent;
444
+                            if (PHP_CODESNIFFER_VERBOSITY > 1) {
445
+                                $content = PHP_CodeSniffer::prepareForOutput($finalTokens[($x + 1)]['content']);
446
+                                echo "\t\t=> token content changed to: $content".PHP_EOL;
447
+                            }
447 448
                         }
448
-                    }
449
-                } else if ($finalTokens[$stackPtr]['content'][0] === '-'
450
-                    && $finalTokens[($stackPtr + 1)]['code'] === T_STRING
451
-                ) {
452
-                    if (isset($finalTokens[($stackPtr - 1)]) === true
453
-                        && $finalTokens[($stackPtr - 1)]['code'] === T_STRING
449
+                    } else if ($finalTokens[$stackPtr]['content'][0] === '-'
450
+                        && $finalTokens[($stackPtr + 1)]['code'] === T_STRING
454 451
                     ) {
455
-                        $newContent = $finalTokens[($stackPtr - 1)]['content'].$finalTokens[$stackPtr]['content'].$finalTokens[($stackPtr + 1)]['content'];
456
-
457
-                        if (PHP_CODESNIFFER_VERBOSITY > 1) {
458
-                            echo "\t\t* token is a string joiner; ignoring this and previous token".PHP_EOL;
459
-                            $old = PHP_CodeSniffer::prepareForOutput($finalTokens[($stackPtr + 1)]['content']);
460
-                            $new = PHP_CodeSniffer::prepareForOutput($newContent);
461
-                            echo "\t\t=> token ".($stackPtr + 1)." content changed from \"$old\" to \"$new\"".PHP_EOL;
452
+                        if (isset($finalTokens[($stackPtr - 1)]) === true
453
+                            && $finalTokens[($stackPtr - 1)]['code'] === T_STRING
454
+                        ) {
455
+                            $newContent = $finalTokens[($stackPtr - 1)]['content'].$finalTokens[$stackPtr]['content'].$finalTokens[($stackPtr + 1)]['content'];
456
+
457
+                            if (PHP_CODESNIFFER_VERBOSITY > 1) {
458
+                                echo "\t\t* token is a string joiner; ignoring this and previous token".PHP_EOL;
459
+                                $old = PHP_CodeSniffer::prepareForOutput($finalTokens[($stackPtr + 1)]['content']);
460
+                                $new = PHP_CodeSniffer::prepareForOutput($newContent);
461
+                                echo "\t\t=> token ".($stackPtr + 1)." content changed from \"$old\" to \"$new\"".PHP_EOL;
462
+                            }
463
+
464
+                            $finalTokens[($stackPtr + 1)]['content'] = $newContent;
465
+                            unset($finalTokens[$stackPtr]);
466
+                            unset($finalTokens[($stackPtr - 1)]);
467
+                        } else {
468
+                            $newContent = $finalTokens[$stackPtr]['content'].$finalTokens[($stackPtr + 1)]['content'];
469
+
470
+                            $finalTokens[($stackPtr + 1)]['content'] = $newContent;
471
+                            unset($finalTokens[$stackPtr]);
462 472
                         }
473
+                    }//end if
463 474
 
464
-                        $finalTokens[($stackPtr + 1)]['content'] = $newContent;
465
-                        unset($finalTokens[$stackPtr]);
466
-                        unset($finalTokens[($stackPtr - 1)]);
467
-                    } else {
468
-                        $newContent = $finalTokens[$stackPtr]['content'].$finalTokens[($stackPtr + 1)]['content'];
469
-
470
-                        $finalTokens[($stackPtr + 1)]['content'] = $newContent;
471
-                        unset($finalTokens[$stackPtr]);
475
+                    break;
476
+                case T_ASPERAND:
477
+                    $asperandStart = true;
478
+                    if (PHP_CODESNIFFER_VERBOSITY > 1) {
479
+                        echo "\t\t* at-rule definition opened *".PHP_EOL;
472 480
                     }
473
-                }//end if
474
-
475
-                break;
476
-            case T_ASPERAND:
477
-                $asperandStart = true;
478
-                if (PHP_CODESNIFFER_VERBOSITY > 1) {
479
-                    echo "\t\t* at-rule definition opened *".PHP_EOL;
480
-                }
481
-                break;
482
-            default:
483
-                // Nothing special to be done with this token.
484
-                break;
481
+                    break;
482
+                default:
483
+                    // Nothing special to be done with this token.
484
+                    break;
485 485
             }//end switch
486 486
         }//end for
487 487
 
Please login to merge, or discard this patch.
dolibarr/htdocs/includes/squizlabs/php_codesniffer/CodeSniffer/CLI.php 1 patch
Switch Indentation   +298 added lines, -298 removed lines patch added patch discarded remove patch
@@ -487,72 +487,72 @@  discard block
 block discarded – undo
487 487
     public function processShortArgument($arg, $pos)
488 488
     {
489 489
         switch ($arg) {
490
-        case 'h':
491
-        case '?':
492
-            $this->printUsage();
493
-            exit(0);
494
-        case 'i' :
495
-            $this->printInstalledStandards();
496
-            exit(0);
497
-        case 'v' :
498
-            if ($this->values['quiet'] === true) {
499
-                // Ignore when quiet mode is enabled.
500
-                break;
501
-            }
490
+            case 'h':
491
+            case '?':
492
+                $this->printUsage();
493
+                exit(0);
494
+            case 'i' :
495
+                $this->printInstalledStandards();
496
+                exit(0);
497
+            case 'v' :
498
+                if ($this->values['quiet'] === true) {
499
+                    // Ignore when quiet mode is enabled.
500
+                    break;
501
+                }
502 502
 
503
-            if (isset($this->values['verbosity']) === false) {
504
-                $this->values['verbosity'] = 1;
505
-            } else {
506
-                $this->values['verbosity']++;
507
-            }
508
-            break;
509
-        case 'l' :
510
-            $this->values['local'] = true;
511
-            break;
512
-        case 's' :
513
-            $this->values['showSources'] = true;
514
-            break;
515
-        case 'a' :
516
-            $this->values['interactive'] = true;
517
-            break;
518
-        case 'e':
519
-            $this->values['explain'] = true;
520
-            break;
521
-        case 'p' :
522
-            if ($this->values['quiet'] === true) {
523
-                // Ignore when quiet mode is enabled.
503
+                if (isset($this->values['verbosity']) === false) {
504
+                    $this->values['verbosity'] = 1;
505
+                } else {
506
+                    $this->values['verbosity']++;
507
+                }
524 508
                 break;
525
-            }
509
+            case 'l' :
510
+                $this->values['local'] = true;
511
+                break;
512
+            case 's' :
513
+                $this->values['showSources'] = true;
514
+                break;
515
+            case 'a' :
516
+                $this->values['interactive'] = true;
517
+                break;
518
+            case 'e':
519
+                $this->values['explain'] = true;
520
+                break;
521
+            case 'p' :
522
+                if ($this->values['quiet'] === true) {
523
+                    // Ignore when quiet mode is enabled.
524
+                    break;
525
+                }
526 526
 
527
-            $this->values['showProgress'] = true;
528
-            break;
529
-        case 'q' :
530
-            // Quiet mode disables a few other settings as well.
531
-            $this->values['quiet']        = true;
532
-            $this->values['showProgress'] = false;
533
-            $this->values['verbosity']    = 0;
534
-            break;
535
-        case 'd' :
536
-            $ini = explode('=', $this->_cliArgs[($pos + 1)]);
537
-            $this->_cliArgs[($pos + 1)] = '';
538
-            if (isset($ini[1]) === true) {
539
-                ini_set($ini[0], $ini[1]);
540
-            } else {
541
-                ini_set($ini[0], true);
542
-            }
543
-            break;
544
-        case 'n' :
545
-            $this->values['warningSeverity'] = 0;
546
-            break;
547
-        case 'w' :
548
-            $this->values['warningSeverity'] = null;
549
-            break;
550
-        default:
551
-            if ($this->dieOnUnknownArg === false) {
552
-                $this->values[$arg] = $arg;
553
-            } else {
554
-                $this->processUnknownArgument('-'.$arg, $pos);
555
-            }
527
+                $this->values['showProgress'] = true;
528
+                break;
529
+            case 'q' :
530
+                // Quiet mode disables a few other settings as well.
531
+                $this->values['quiet']        = true;
532
+                $this->values['showProgress'] = false;
533
+                $this->values['verbosity']    = 0;
534
+                break;
535
+            case 'd' :
536
+                $ini = explode('=', $this->_cliArgs[($pos + 1)]);
537
+                $this->_cliArgs[($pos + 1)] = '';
538
+                if (isset($ini[1]) === true) {
539
+                    ini_set($ini[0], $ini[1]);
540
+                } else {
541
+                    ini_set($ini[0], true);
542
+                }
543
+                break;
544
+            case 'n' :
545
+                $this->values['warningSeverity'] = 0;
546
+                break;
547
+            case 'w' :
548
+                $this->values['warningSeverity'] = null;
549
+                break;
550
+            default:
551
+                if ($this->dieOnUnknownArg === false) {
552
+                    $this->values[$arg] = $arg;
553
+                } else {
554
+                    $this->processUnknownArgument('-'.$arg, $pos);
555
+                }
556 556
         }//end switch
557 557
 
558 558
     }//end processShortArgument()
@@ -569,290 +569,290 @@  discard block
 block discarded – undo
569 569
     public function processLongArgument($arg, $pos)
570 570
     {
571 571
         switch ($arg) {
572
-        case 'help':
573
-            $this->printUsage();
574
-            exit(0);
575
-        case 'version':
576
-            echo 'PHP_CodeSniffer version '.PHP_CodeSniffer::VERSION.' ('.PHP_CodeSniffer::STABILITY.') ';
577
-            echo 'by Squiz (http://www.squiz.net)'.PHP_EOL;
578
-            exit(0);
579
-        case 'colors':
580
-            $this->values['colors'] = true;
581
-            break;
582
-        case 'no-colors':
583
-            $this->values['colors'] = false;
584
-            break;
585
-        case 'config-set':
586
-            if (isset($this->_cliArgs[($pos + 1)]) === false
587
-                || isset($this->_cliArgs[($pos + 2)]) === false
588
-            ) {
589
-                echo 'ERROR: Setting a config option requires a name and value'.PHP_EOL.PHP_EOL;
572
+            case 'help':
590 573
                 $this->printUsage();
591 574
                 exit(0);
592
-            }
593
-
594
-            $key     = $this->_cliArgs[($pos + 1)];
595
-            $value   = $this->_cliArgs[($pos + 2)];
596
-            $current = PHP_CodeSniffer::getConfigData($key);
597
-
598
-            try {
599
-                PHP_CodeSniffer::setConfigData($key, $value);
600
-            } catch (Exception $e) {
601
-                echo $e->getMessage().PHP_EOL;
602
-                exit(2);
603
-            }
604
-
605
-            if ($current === null) {
606
-                echo "Config value \"$key\" added successfully".PHP_EOL;
607
-            } else {
608
-                echo "Config value \"$key\" updated successfully; old value was \"$current\"".PHP_EOL;
609
-            }
610
-            exit(0);
611
-        case 'config-delete':
612
-            if (isset($this->_cliArgs[($pos + 1)]) === false) {
613
-                echo 'ERROR: Deleting a config option requires the name of the option'.PHP_EOL.PHP_EOL;
614
-                $this->printUsage();
575
+            case 'version':
576
+                echo 'PHP_CodeSniffer version '.PHP_CodeSniffer::VERSION.' ('.PHP_CodeSniffer::STABILITY.') ';
577
+                echo 'by Squiz (http://www.squiz.net)'.PHP_EOL;
615 578
                 exit(0);
616
-            }
579
+            case 'colors':
580
+                $this->values['colors'] = true;
581
+                break;
582
+            case 'no-colors':
583
+                $this->values['colors'] = false;
584
+                break;
585
+            case 'config-set':
586
+                if (isset($this->_cliArgs[($pos + 1)]) === false
587
+                    || isset($this->_cliArgs[($pos + 2)]) === false
588
+                ) {
589
+                    echo 'ERROR: Setting a config option requires a name and value'.PHP_EOL.PHP_EOL;
590
+                    $this->printUsage();
591
+                    exit(0);
592
+                }
593
+
594
+                $key     = $this->_cliArgs[($pos + 1)];
595
+                $value   = $this->_cliArgs[($pos + 2)];
596
+                $current = PHP_CodeSniffer::getConfigData($key);
617 597
 
618
-            $key     = $this->_cliArgs[($pos + 1)];
619
-            $current = PHP_CodeSniffer::getConfigData($key);
620
-            if ($current === null) {
621
-                echo "Config value \"$key\" has not been set".PHP_EOL;
622
-            } else {
623 598
                 try {
624
-                    PHP_CodeSniffer::setConfigData($key, null);
599
+                    PHP_CodeSniffer::setConfigData($key, $value);
625 600
                 } catch (Exception $e) {
626 601
                     echo $e->getMessage().PHP_EOL;
627 602
                     exit(2);
628 603
                 }
629 604
 
630
-                echo "Config value \"$key\" removed successfully; old value was \"$current\"".PHP_EOL;
631
-            }
632
-            exit(0);
633
-        case 'config-show':
634
-            $data = PHP_CodeSniffer::getAllConfigData();
635
-            $this->printConfigData($data);
636
-            exit(0);
637
-        case 'runtime-set':
638
-            if (isset($this->_cliArgs[($pos + 1)]) === false
639
-                || isset($this->_cliArgs[($pos + 2)]) === false
640
-            ) {
641
-                echo 'ERROR: Setting a runtime config option requires a name and value'.PHP_EOL.PHP_EOL;
642
-                $this->printUsage();
643
-                exit(0);
644
-            }
645
-
646
-            $key   = $this->_cliArgs[($pos + 1)];
647
-            $value = $this->_cliArgs[($pos + 2)];
648
-            $this->_cliArgs[($pos + 1)] = '';
649
-            $this->_cliArgs[($pos + 2)] = '';
650
-            PHP_CodeSniffer::setConfigData($key, $value, true);
651
-            break;
652
-        default:
653
-            if (substr($arg, 0, 7) === 'sniffs=') {
654
-                $sniffs = explode(',', substr($arg, 7));
655
-                foreach ($sniffs as $sniff) {
656
-                    if (substr_count($sniff, '.') !== 2) {
657
-                        echo 'ERROR: The specified sniff code "'.$sniff.'" is invalid'.PHP_EOL.PHP_EOL;
658
-                        $this->printUsage();
659
-                        exit(2);
660
-                    }
605
+                if ($current === null) {
606
+                    echo "Config value \"$key\" added successfully".PHP_EOL;
607
+                } else {
608
+                    echo "Config value \"$key\" updated successfully; old value was \"$current\"".PHP_EOL;
661 609
                 }
662
-
663
-                $this->values['sniffs'] = $sniffs;
664
-            } else if (substr($arg, 0, 8) === 'exclude=') {
665
-                $sniffs = explode(',', substr($arg, 8));
666
-                foreach ($sniffs as $sniff) {
667
-                    if (substr_count($sniff, '.') !== 2) {
668
-                        echo 'ERROR: The specified sniff code "'.$sniff.'" is invalid'.PHP_EOL.PHP_EOL;
669
-                        $this->printUsage();
670
-                        exit(2);
671
-                    }
610
+                exit(0);
611
+            case 'config-delete':
612
+                if (isset($this->_cliArgs[($pos + 1)]) === false) {
613
+                    echo 'ERROR: Deleting a config option requires the name of the option'.PHP_EOL.PHP_EOL;
614
+                    $this->printUsage();
615
+                    exit(0);
672 616
                 }
673 617
 
674
-                $this->values['exclude'] = $sniffs;
675
-            } else if (substr($arg, 0, 10) === 'bootstrap=') {
676
-                $files = explode(',', substr($arg, 10));
677
-                foreach ($files as $file) {
678
-                    $path = PHP_CodeSniffer::realpath($file);
679
-                    if ($path === false) {
680
-                        echo 'ERROR: The specified bootstrap file "'.$file.'" does not exist'.PHP_EOL.PHP_EOL;
681
-                        $this->printUsage();
618
+                $key     = $this->_cliArgs[($pos + 1)];
619
+                $current = PHP_CodeSniffer::getConfigData($key);
620
+                if ($current === null) {
621
+                    echo "Config value \"$key\" has not been set".PHP_EOL;
622
+                } else {
623
+                    try {
624
+                        PHP_CodeSniffer::setConfigData($key, null);
625
+                    } catch (Exception $e) {
626
+                        echo $e->getMessage().PHP_EOL;
682 627
                         exit(2);
683 628
                     }
684 629
 
685
-                    $this->values['bootstrap'][] = $path;
630
+                    echo "Config value \"$key\" removed successfully; old value was \"$current\"".PHP_EOL;
686 631
                 }
687
-            } else if (substr($arg, 0, 10) === 'file-list=') {
688
-                $fileList = substr($arg, 10);
689
-                $path     = PHP_CodeSniffer::realpath($fileList);
690
-                if ($path === false) {
691
-                    echo 'ERROR: The specified file list "'.$file.'" does not exist'.PHP_EOL.PHP_EOL;
632
+                exit(0);
633
+            case 'config-show':
634
+                $data = PHP_CodeSniffer::getAllConfigData();
635
+                $this->printConfigData($data);
636
+                exit(0);
637
+            case 'runtime-set':
638
+                if (isset($this->_cliArgs[($pos + 1)]) === false
639
+                    || isset($this->_cliArgs[($pos + 2)]) === false
640
+                ) {
641
+                    echo 'ERROR: Setting a runtime config option requires a name and value'.PHP_EOL.PHP_EOL;
692 642
                     $this->printUsage();
693
-                    exit(2);
643
+                    exit(0);
694 644
                 }
695 645
 
696
-                $files = file($path);
697
-                foreach ($files as $inputFile) {
698
-                    $inputFile = trim($inputFile);
646
+                $key   = $this->_cliArgs[($pos + 1)];
647
+                $value = $this->_cliArgs[($pos + 2)];
648
+                $this->_cliArgs[($pos + 1)] = '';
649
+                $this->_cliArgs[($pos + 2)] = '';
650
+                PHP_CodeSniffer::setConfigData($key, $value, true);
651
+                break;
652
+            default:
653
+                if (substr($arg, 0, 7) === 'sniffs=') {
654
+                    $sniffs = explode(',', substr($arg, 7));
655
+                    foreach ($sniffs as $sniff) {
656
+                        if (substr_count($sniff, '.') !== 2) {
657
+                            echo 'ERROR: The specified sniff code "'.$sniff.'" is invalid'.PHP_EOL.PHP_EOL;
658
+                            $this->printUsage();
659
+                            exit(2);
660
+                        }
661
+                    }
699 662
 
700
-                    // Skip empty lines.
701
-                    if ($inputFile === '') {
702
-                        continue;
663
+                    $this->values['sniffs'] = $sniffs;
664
+                } else if (substr($arg, 0, 8) === 'exclude=') {
665
+                    $sniffs = explode(',', substr($arg, 8));
666
+                    foreach ($sniffs as $sniff) {
667
+                        if (substr_count($sniff, '.') !== 2) {
668
+                            echo 'ERROR: The specified sniff code "'.$sniff.'" is invalid'.PHP_EOL.PHP_EOL;
669
+                            $this->printUsage();
670
+                            exit(2);
671
+                        }
703 672
                     }
704 673
 
705
-                    $realFile = PHP_CodeSniffer::realpath($inputFile);
706
-                    if ($realFile === false) {
707
-                        echo 'ERROR: The specified file "'.$inputFile.'" does not exist'.PHP_EOL.PHP_EOL;
674
+                    $this->values['exclude'] = $sniffs;
675
+                } else if (substr($arg, 0, 10) === 'bootstrap=') {
676
+                    $files = explode(',', substr($arg, 10));
677
+                    foreach ($files as $file) {
678
+                        $path = PHP_CodeSniffer::realpath($file);
679
+                        if ($path === false) {
680
+                            echo 'ERROR: The specified bootstrap file "'.$file.'" does not exist'.PHP_EOL.PHP_EOL;
681
+                            $this->printUsage();
682
+                            exit(2);
683
+                        }
684
+
685
+                        $this->values['bootstrap'][] = $path;
686
+                    }
687
+                } else if (substr($arg, 0, 10) === 'file-list=') {
688
+                    $fileList = substr($arg, 10);
689
+                    $path     = PHP_CodeSniffer::realpath($fileList);
690
+                    if ($path === false) {
691
+                        echo 'ERROR: The specified file list "'.$file.'" does not exist'.PHP_EOL.PHP_EOL;
708 692
                         $this->printUsage();
709 693
                         exit(2);
710 694
                     }
711 695
 
712
-                    $this->values['files'][] = $realFile;
713
-                }
714
-            } else if (substr($arg, 0, 11) === 'stdin-path=') {
715
-                $this->values['stdinPath'] = PHP_CodeSniffer::realpath(substr($arg, 11));
696
+                    $files = file($path);
697
+                    foreach ($files as $inputFile) {
698
+                        $inputFile = trim($inputFile);
716 699
 
717
-                // It may not exist and return false instead, so just use whatever they gave us.
718
-                if ($this->values['stdinPath'] === false) {
719
-                    $this->values['stdinPath'] = trim(substr($arg, 11));
720
-                }
721
-            } else if (substr($arg, 0, 12) === 'report-file=') {
722
-                $this->values['reportFile'] = PHP_CodeSniffer::realpath(substr($arg, 12));
700
+                        // Skip empty lines.
701
+                        if ($inputFile === '') {
702
+                            continue;
703
+                        }
723 704
 
724
-                // It may not exist and return false instead.
725
-                if ($this->values['reportFile'] === false) {
726
-                    $this->values['reportFile'] = substr($arg, 12);
705
+                        $realFile = PHP_CodeSniffer::realpath($inputFile);
706
+                        if ($realFile === false) {
707
+                            echo 'ERROR: The specified file "'.$inputFile.'" does not exist'.PHP_EOL.PHP_EOL;
708
+                            $this->printUsage();
709
+                            exit(2);
710
+                        }
727 711
 
728
-                    $dir = dirname($this->values['reportFile']);
729
-                    if (is_dir($dir) === false) {
730
-                        echo 'ERROR: The specified report file path "'.$this->values['reportFile'].'" points to a non-existent directory'.PHP_EOL.PHP_EOL;
731
-                        $this->printUsage();
732
-                        exit(2);
712
+                        $this->values['files'][] = $realFile;
733 713
                     }
714
+                } else if (substr($arg, 0, 11) === 'stdin-path=') {
715
+                    $this->values['stdinPath'] = PHP_CodeSniffer::realpath(substr($arg, 11));
734 716
 
735
-                    if ($dir === '.') {
736
-                        // Passed report file is a file in the current directory.
737
-                        $this->values['reportFile'] = getcwd().'/'.basename($this->values['reportFile']);
738
-                    } else {
739
-                        if ($dir{0} === '/') {
740
-                            // An absolute path.
741
-                            $dir = PHP_CodeSniffer::realpath($dir);
742
-                        } else {
743
-                            $dir = PHP_CodeSniffer::realpath(getcwd().'/'.$dir);
717
+                    // It may not exist and return false instead, so just use whatever they gave us.
718
+                    if ($this->values['stdinPath'] === false) {
719
+                        $this->values['stdinPath'] = trim(substr($arg, 11));
720
+                    }
721
+                } else if (substr($arg, 0, 12) === 'report-file=') {
722
+                    $this->values['reportFile'] = PHP_CodeSniffer::realpath(substr($arg, 12));
723
+
724
+                    // It may not exist and return false instead.
725
+                    if ($this->values['reportFile'] === false) {
726
+                        $this->values['reportFile'] = substr($arg, 12);
727
+
728
+                        $dir = dirname($this->values['reportFile']);
729
+                        if (is_dir($dir) === false) {
730
+                            echo 'ERROR: The specified report file path "'.$this->values['reportFile'].'" points to a non-existent directory'.PHP_EOL.PHP_EOL;
731
+                            $this->printUsage();
732
+                            exit(2);
744 733
                         }
745 734
 
746
-                        if ($dir !== false) {
747
-                            // Report file path is relative.
748
-                            $this->values['reportFile'] = $dir.'/'.basename($this->values['reportFile']);
735
+                        if ($dir === '.') {
736
+                            // Passed report file is a file in the current directory.
737
+                            $this->values['reportFile'] = getcwd().'/'.basename($this->values['reportFile']);
738
+                        } else {
739
+                            if ($dir{0} === '/') {
740
+                                // An absolute path.
741
+                                $dir = PHP_CodeSniffer::realpath($dir);
742
+                            } else {
743
+                                $dir = PHP_CodeSniffer::realpath(getcwd().'/'.$dir);
744
+                            }
745
+
746
+                            if ($dir !== false) {
747
+                                // Report file path is relative.
748
+                                $this->values['reportFile'] = $dir.'/'.basename($this->values['reportFile']);
749
+                            }
749 750
                         }
750
-                    }
751
-                }//end if
751
+                    }//end if
752 752
 
753
-                if (is_dir($this->values['reportFile']) === true) {
754
-                    echo 'ERROR: The specified report file path "'.$this->values['reportFile'].'" is a directory'.PHP_EOL.PHP_EOL;
755
-                    $this->printUsage();
756
-                    exit(2);
757
-                }
758
-            } else if (substr($arg, 0, 13) === 'report-width=') {
759
-                $this->values['reportWidth'] = $this->_validateReportWidth(substr($arg, 13));
760
-            } else if (substr($arg, 0, 7) === 'report='
761
-                || substr($arg, 0, 7) === 'report-'
762
-            ) {
763
-                if ($arg[6] === '-') {
764
-                    // This is a report with file output.
765
-                    $split = strpos($arg, '=');
766
-                    if ($split === false) {
767
-                        $report = substr($arg, 7);
768
-                        $output = null;
769
-                    } else {
770
-                        $report = substr($arg, 7, ($split - 7));
771
-                        $output = substr($arg, ($split + 1));
772
-                        if ($output === false) {
753
+                    if (is_dir($this->values['reportFile']) === true) {
754
+                        echo 'ERROR: The specified report file path "'.$this->values['reportFile'].'" is a directory'.PHP_EOL.PHP_EOL;
755
+                        $this->printUsage();
756
+                        exit(2);
757
+                    }
758
+                } else if (substr($arg, 0, 13) === 'report-width=') {
759
+                    $this->values['reportWidth'] = $this->_validateReportWidth(substr($arg, 13));
760
+                } else if (substr($arg, 0, 7) === 'report='
761
+                    || substr($arg, 0, 7) === 'report-'
762
+                ) {
763
+                    if ($arg[6] === '-') {
764
+                        // This is a report with file output.
765
+                        $split = strpos($arg, '=');
766
+                        if ($split === false) {
767
+                            $report = substr($arg, 7);
773 768
                             $output = null;
774 769
                         } else {
775
-                            $dir = dirname($output);
776
-                            if ($dir === '.') {
777
-                                // Passed report file is a filename in the current directory.
778
-                                $output = getcwd().'/'.basename($output);
770
+                            $report = substr($arg, 7, ($split - 7));
771
+                            $output = substr($arg, ($split + 1));
772
+                            if ($output === false) {
773
+                                $output = null;
779 774
                             } else {
780
-                                if ($dir{0} === '/') {
781
-                                    // An absolute path.
782
-                                    $dir = PHP_CodeSniffer::realpath($dir);
775
+                                $dir = dirname($output);
776
+                                if ($dir === '.') {
777
+                                    // Passed report file is a filename in the current directory.
778
+                                    $output = getcwd().'/'.basename($output);
783 779
                                 } else {
784
-                                    $dir = PHP_CodeSniffer::realpath(getcwd().'/'.$dir);
785
-                                }
786
-
787
-                                if ($dir !== false) {
788
-                                    // Report file path is relative.
789
-                                    $output = $dir.'/'.basename($output);
780
+                                    if ($dir{0} === '/') {
781
+                                        // An absolute path.
782
+                                        $dir = PHP_CodeSniffer::realpath($dir);
783
+                                    } else {
784
+                                        $dir = PHP_CodeSniffer::realpath(getcwd().'/'.$dir);
785
+                                    }
786
+
787
+                                    if ($dir !== false) {
788
+                                        // Report file path is relative.
789
+                                        $output = $dir.'/'.basename($output);
790
+                                    }
790 791
                                 }
791
-                            }
792
+                            }//end if
792 793
                         }//end if
794
+                    } else {
795
+                        // This is a single report.
796
+                        $report = substr($arg, 7);
797
+                        $output = null;
793 798
                     }//end if
794
-                } else {
795
-                    // This is a single report.
796
-                    $report = substr($arg, 7);
797
-                    $output = null;
798
-                }//end if
799
-
800
-                $this->values['reports'][$report] = $output;
801
-            } else if (substr($arg, 0, 9) === 'standard=') {
802
-                $standards = trim(substr($arg, 9));
803
-                if ($standards !== '') {
804
-                    $this->values['standard'] = explode(',', $standards);
805
-                }
806
-            } else if (substr($arg, 0, 11) === 'extensions=') {
807
-                if (isset($this->values['extensions']) === false) {
808
-                    $this->values['extensions'] = array();
809
-                }
810 799
 
811
-                $this->values['extensions'] = array_merge($this->values['extensions'], explode(',', substr($arg, 11)));
812
-            } else if (substr($arg, 0, 9) === 'severity=') {
813
-                $this->values['errorSeverity']   = (int) substr($arg, 9);
814
-                $this->values['warningSeverity'] = $this->values['errorSeverity'];
815
-            } else if (substr($arg, 0, 15) === 'error-severity=') {
816
-                $this->values['errorSeverity'] = (int) substr($arg, 15);
817
-            } else if (substr($arg, 0, 17) === 'warning-severity=') {
818
-                $this->values['warningSeverity'] = (int) substr($arg, 17);
819
-            } else if (substr($arg, 0, 7) === 'ignore=') {
820
-                // Split the ignore string on commas, unless the comma is escaped
821
-                // using 1 or 3 slashes (\, or \\\,).
822
-                $ignored = preg_split(
823
-                    '/(?<=(?<!\\\\)\\\\\\\\),|(?<!\\\\),/',
824
-                    substr($arg, 7)
825
-                );
826
-                foreach ($ignored as $pattern) {
827
-                    $pattern = trim($pattern);
828
-                    if ($pattern === '') {
829
-                        continue;
800
+                    $this->values['reports'][$report] = $output;
801
+                } else if (substr($arg, 0, 9) === 'standard=') {
802
+                    $standards = trim(substr($arg, 9));
803
+                    if ($standards !== '') {
804
+                        $this->values['standard'] = explode(',', $standards);
805
+                    }
806
+                } else if (substr($arg, 0, 11) === 'extensions=') {
807
+                    if (isset($this->values['extensions']) === false) {
808
+                        $this->values['extensions'] = array();
830 809
                     }
831 810
 
832
-                    $this->values['ignored'][$pattern] = 'absolute';
833
-                }
834
-            } else if (substr($arg, 0, 10) === 'generator=') {
835
-                $this->values['generator'] = substr($arg, 10);
836
-            } else if (substr($arg, 0, 9) === 'encoding=') {
837
-                $this->values['encoding'] = strtolower(substr($arg, 9));
838
-            } else if (substr($arg, 0, 10) === 'tab-width=') {
839
-                $this->values['tabWidth'] = (int) substr($arg, 10);
840
-            } else {
841
-                if ($this->dieOnUnknownArg === false) {
842
-                    $eqPos = strpos($arg, '=');
843
-                    if ($eqPos === false) {
844
-                        $this->values[$arg] = $arg;
845
-                    } else {
846
-                        $value = substr($arg, ($eqPos + 1));
847
-                        $arg   = substr($arg, 0, $eqPos);
848
-                        $this->values[$arg] = $value;
811
+                    $this->values['extensions'] = array_merge($this->values['extensions'], explode(',', substr($arg, 11)));
812
+                } else if (substr($arg, 0, 9) === 'severity=') {
813
+                    $this->values['errorSeverity']   = (int) substr($arg, 9);
814
+                    $this->values['warningSeverity'] = $this->values['errorSeverity'];
815
+                } else if (substr($arg, 0, 15) === 'error-severity=') {
816
+                    $this->values['errorSeverity'] = (int) substr($arg, 15);
817
+                } else if (substr($arg, 0, 17) === 'warning-severity=') {
818
+                    $this->values['warningSeverity'] = (int) substr($arg, 17);
819
+                } else if (substr($arg, 0, 7) === 'ignore=') {
820
+                    // Split the ignore string on commas, unless the comma is escaped
821
+                    // using 1 or 3 slashes (\, or \\\,).
822
+                    $ignored = preg_split(
823
+                        '/(?<=(?<!\\\\)\\\\\\\\),|(?<!\\\\),/',
824
+                        substr($arg, 7)
825
+                    );
826
+                    foreach ($ignored as $pattern) {
827
+                        $pattern = trim($pattern);
828
+                        if ($pattern === '') {
829
+                            continue;
830
+                        }
831
+
832
+                        $this->values['ignored'][$pattern] = 'absolute';
849 833
                     }
834
+                } else if (substr($arg, 0, 10) === 'generator=') {
835
+                    $this->values['generator'] = substr($arg, 10);
836
+                } else if (substr($arg, 0, 9) === 'encoding=') {
837
+                    $this->values['encoding'] = strtolower(substr($arg, 9));
838
+                } else if (substr($arg, 0, 10) === 'tab-width=') {
839
+                    $this->values['tabWidth'] = (int) substr($arg, 10);
850 840
                 } else {
851
-                    $this->processUnknownArgument('--'.$arg, $pos);
852
-                }
853
-            }//end if
841
+                    if ($this->dieOnUnknownArg === false) {
842
+                        $eqPos = strpos($arg, '=');
843
+                        if ($eqPos === false) {
844
+                            $this->values[$arg] = $arg;
845
+                        } else {
846
+                            $value = substr($arg, ($eqPos + 1));
847
+                            $arg   = substr($arg, 0, $eqPos);
848
+                            $this->values[$arg] = $value;
849
+                        }
850
+                    } else {
851
+                        $this->processUnknownArgument('--'.$arg, $pos);
852
+                    }
853
+                }//end if
854 854
 
855
-            break;
855
+                break;
856 856
         }//end switch
857 857
 
858 858
     }//end processLongArgument()
Please login to merge, or discard this patch.