Passed
Pull Request — master (#4)
by
unknown
04:42
created
lib/phpqrcode/qrrscode.php 1 patch
Braces   +38 added lines, -13 removed lines patch added patch discarded remove patch
@@ -63,11 +63,23 @@  discard block
 block discarded – undo
63 63
 			$rs = null;
64 64
             
65 65
 			// Check parameter ranges
66
-			if($symsize < 0 || $symsize > 8)                     return $rs;
67
-			if($fcr < 0 || $fcr >= (1<<$symsize))                return $rs;
68
-			if($prim <= 0 || $prim >= (1<<$symsize))             return $rs;
69
-			if($nroots < 0 || $nroots >= (1<<$symsize))          return $rs; // Can't have more roots than symbol values!
70
-			if($pad < 0 || $pad >= ((1<<$symsize) -1 - $nroots)) return $rs; // Too much padding
66
+			if($symsize < 0 || $symsize > 8) {
67
+				return $rs;
68
+			}
69
+			if($fcr < 0 || $fcr >= (1<<$symsize)) {
70
+				return $rs;
71
+			}
72
+			if($prim <= 0 || $prim >= (1<<$symsize)) {
73
+				return $rs;
74
+			}
75
+			if($nroots < 0 || $nroots >= (1<<$symsize)) {
76
+				return $rs;
77
+			}
78
+			// Can't have more roots than symbol values!
79
+			if($pad < 0 || $pad >= ((1<<$symsize) -1 - $nroots)) {
80
+				return $rs;
81
+			}
82
+			// Too much padding
71 83
 
72 84
 			$rs = new QRrsItem();
73 85
 			$rs->mm = $symsize;
@@ -133,8 +145,9 @@  discard block
 block discarded – undo
133 145
 			}
134 146
             
135 147
 			// convert rs->genpoly[] to index form for quicker encoding
136
-			for ($i = 0; $i <= $nroots; $i++)
137
-				$rs->genpoly[$i] = $rs->index_of[$rs->genpoly[$i]];
148
+			for ($i = 0; $i <= $nroots; $i++) {
149
+							$rs->genpoly[$i] = $rs->index_of[$rs->genpoly[$i]];
150
+			}
138 151
 
139 152
 			return $rs;
140 153
 		}
@@ -192,12 +205,24 @@  discard block
 block discarded – undo
192 205
 		public static function init_rs($symsize, $gfpoly, $fcr, $prim, $nroots, $pad)
193 206
 		{
194 207
 			foreach(self::$items as $rs) {
195
-				if($rs->pad != $pad)       continue;
196
-				if($rs->nroots != $nroots) continue;
197
-				if($rs->mm != $symsize)    continue;
198
-				if($rs->gfpoly != $gfpoly) continue;
199
-				if($rs->fcr != $fcr)       continue;
200
-				if($rs->prim != $prim)     continue;
208
+				if($rs->pad != $pad) {
209
+					continue;
210
+				}
211
+				if($rs->nroots != $nroots) {
212
+					continue;
213
+				}
214
+				if($rs->mm != $symsize) {
215
+					continue;
216
+				}
217
+				if($rs->gfpoly != $gfpoly) {
218
+					continue;
219
+				}
220
+				if($rs->fcr != $fcr) {
221
+					continue;
222
+				}
223
+				if($rs->prim != $prim) {
224
+					continue;
225
+				}
201 226
 
202 227
 				return $rs;
203 228
 			}
Please login to merge, or discard this patch.
lib/phpqrcode/qrbitstream.php 1 patch
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -108,13 +108,15 @@  discard block
 block discarded – undo
108 108
 		//----------------------------------------------------------------------
109 109
 		public function appendNum($bits, $num)
110 110
 		{
111
-			if ($bits == 0) 
112
-				return 0;
111
+			if ($bits == 0) {
112
+							return 0;
113
+			}
113 114
 
114 115
 			$b = QRbitstream::newFromNum($bits, $num);
115 116
             
116
-			if(is_null($b))
117
-				return -1;
117
+			if(is_null($b)) {
118
+							return -1;
119
+			}
118 120
 
119 121
 			$ret = $this->append($b);
120 122
 			unset($b);
@@ -125,13 +127,15 @@  discard block
 block discarded – undo
125 127
 		//----------------------------------------------------------------------
126 128
 		public function appendBytes($size, $data)
127 129
 		{
128
-			if ($size == 0) 
129
-				return 0;
130
+			if ($size == 0) {
131
+							return 0;
132
+			}
130 133
 
131 134
 			$b = QRbitstream::newFromBytes($size, $data);
132 135
             
133
-			if(is_null($b))
134
-				return -1;
136
+			if(is_null($b)) {
137
+							return -1;
138
+			}
135 139
 
136 140
 			$ret = $this->append($b);
137 141
 			unset($b);
Please login to merge, or discard this patch.
lib/phpqrcode/phpqrcode.php 1 patch
Braces   +194 added lines, -109 removed lines patch added patch discarded remove patch
@@ -176,8 +176,9 @@  discard block
 block discarded – undo
176 176
 		{
177 177
 			$barcode_array = array();
178 178
             
179
-			if (!is_array($mode))
180
-				$mode = explode(',', $mode);
179
+			if (!is_array($mode)) {
180
+							$mode = explode(',', $mode);
181
+			}
181 182
                 
182 183
 			$eccLevel = 'L';
183 184
                 
@@ -194,8 +195,9 @@  discard block
 block discarded – undo
194 195
                 
195 196
 			foreach ($qrTab as $line) {
196 197
 				$arrAdd = array();
197
-				foreach(str_split($line) as $char)
198
-					$arrAdd[] = ($char=='1')?1:0;
198
+				foreach(str_split($line) as $char) {
199
+									$arrAdd[] = ($char=='1')?1:0;
200
+				}
199 201
 				$barcode_array['bcode'][] = $arrAdd;
200 202
 			}
201 203
                     
@@ -223,8 +225,9 @@  discard block
 block discarded – undo
223 225
 				
224 226
 				$width = count($frame);
225 227
 				$bitMask = array_fill(0, $width, array_fill(0, $width, 0));
226
-				for ($maskNo = 0; $maskNo < 8; $maskNo++)
227
-					$mask->makeMaskNo($maskNo, $width, $frame, $bitMask, true);
228
+				for ($maskNo = 0; $maskNo < 8; $maskNo++) {
229
+									$mask->makeMaskNo($maskNo, $width, $frame, $bitMask, true);
230
+				}
228 231
 			}
229 232
 			
230 233
 			QRtools::markTime('after_build_cache');
@@ -261,8 +264,9 @@  discard block
 block discarded – undo
261 264
 			list($usec, $sec) = explode(" ", microtime());
262 265
 			$time = ((float)$usec + (float)$sec);
263 266
             
264
-			if (!isset($GLOBALS['qr_time_bench']))
265
-				$GLOBALS['qr_time_bench'] = array();
267
+			if (!isset($GLOBALS['qr_time_bench'])) {
268
+							$GLOBALS['qr_time_bench'] = array();
269
+			}
266 270
             
267 271
 			$GLOBALS['qr_time_bench'][$markerId] = $time;
268 272
 		}
@@ -427,8 +431,9 @@  discard block
 block discarded – undo
427 431
 
428 432
 			for($i=1; $i<= QRSPEC_VERSION_MAX; $i++) {
429 433
 				$words  = self::$capacity[$i][QRCAP_WORDS] - self::$capacity[$i][QRCAP_EC][$level];
430
-				if($words >= $size) 
431
-					return $i;
434
+				if($words >= $size) {
435
+									return $i;
436
+				}
432 437
 			}
433 438
 
434 439
 			return -1;
@@ -446,8 +451,9 @@  discard block
 block discarded – undo
446 451
 		//----------------------------------------------------------------------
447 452
 		public static function lengthIndicator($mode, $version)
448 453
 		{
449
-			if ($mode == QR_MODE_STRUCTURE)
450
-				return 0;
454
+			if ($mode == QR_MODE_STRUCTURE) {
455
+							return 0;
456
+			}
451 457
                 
452 458
 			if ($version <= 9) {
453 459
 				$l = 0;
@@ -463,8 +469,9 @@  discard block
 block discarded – undo
463 469
 		//----------------------------------------------------------------------
464 470
 		public static function maximumWords($mode, $version)
465 471
 		{
466
-			if($mode == QR_MODE_STRUCTURE) 
467
-				return 3;
472
+			if($mode == QR_MODE_STRUCTURE) {
473
+							return 3;
474
+			}
468 475
                 
469 476
 			if($version <= 9) {
470 477
 				$l = 0;
@@ -610,8 +617,9 @@  discard block
 block discarded – undo
610 617
 		//----------------------------------------------------------------------
611 618
 		public static function putAlignmentPattern($version, &$frame, $width)
612 619
 		{
613
-			if($version < 2)
614
-				return;
620
+			if($version < 2) {
621
+							return;
622
+			}
615 623
 
616 624
 			$d = self::$alignmentPattern[$version][1] - self::$alignmentPattern[$version][0];
617 625
 			if($d < 0) {
@@ -663,8 +671,9 @@  discard block
 block discarded – undo
663 671
 		//----------------------------------------------------------------------
664 672
 		public static function getVersionPattern($version)
665 673
 		{
666
-			if($version < 7 || $version > QRSPEC_VERSION_MAX)
667
-				return 0;
674
+			if($version < 7 || $version > QRSPEC_VERSION_MAX) {
675
+							return 0;
676
+			}
668 677
 
669 678
 			return self::$versionPattern[$version -7];
670 679
 		}
@@ -681,11 +690,13 @@  discard block
 block discarded – undo
681 690
 
682 691
 		public static function getFormatInfo($mask, $level)
683 692
 		{
684
-			if($mask < 0 || $mask > 7)
685
-				return 0;
693
+			if($mask < 0 || $mask > 7) {
694
+							return 0;
695
+			}
686 696
                 
687
-			if($level < 0 || $level > 3)
688
-				return 0;                
697
+			if($level < 0 || $level > 3) {
698
+							return 0;
699
+			}
689 700
 
690 701
 			return self::$formatInfo[$level][$mask];
691 702
 		}
@@ -865,8 +876,9 @@  discard block
 block discarded – undo
865 876
 		//----------------------------------------------------------------------
866 877
 		public static function newFrame($version)
867 878
 		{
868
-			if($version < 1 || $version > QRSPEC_VERSION_MAX) 
869
-				return null;
879
+			if($version < 1 || $version > QRSPEC_VERSION_MAX) {
880
+							return null;
881
+			}
870 882
 
871 883
 			if(!isset(self::$frames[$version])) {
872 884
                 
@@ -884,8 +896,9 @@  discard block
 block discarded – undo
884 896
 				}
885 897
 			}
886 898
             
887
-			if(is_null(self::$frames[$version]))
888
-				return null;
899
+			if(is_null(self::$frames[$version])) {
900
+							return null;
901
+			}
889 902
 
890 903
 			return self::$frames[$version];
891 904
 		}
@@ -950,7 +963,7 @@  discard block
 block discarded – undo
950 963
 					ImagePng($image, $filename);
951 964
 					header("Content-type: image/png");
952 965
 					ImagePng($image);
953
-				}else{
966
+				} else{
954 967
 					ImagePng($image, $filename);
955 968
 				}
956 969
 			}
@@ -1210,8 +1223,9 @@  discard block
 block discarded – undo
1210 1223
 		{
1211 1224
 			$bits = 0;
1212 1225
 
1213
-			if($version == 0) 
1214
-				$version = 1;
1226
+			if($version == 0) {
1227
+							$version = 1;
1228
+			}
1215 1229
 
1216 1230
 			switch($this->mode) {
1217 1231
 				case QR_MODE_NUM:        $bits = QRinput::estimateBitsModeNum($this->size);    break;
@@ -1270,8 +1284,9 @@  discard block
 block discarded – undo
1270 1284
 							break;
1271 1285
 					}
1272 1286
                     
1273
-					if($ret < 0)
1274
-						return -1;
1287
+					if($ret < 0) {
1288
+											return -1;
1289
+					}
1275 1290
 				}
1276 1291
 
1277 1292
 				return $this->bstream->size();
@@ -1488,8 +1503,9 @@  discard block
 block discarded – undo
1488 1503
 		//----------------------------------------------------------------------
1489 1504
 		public static function checkModeKanji($size, $data)
1490 1505
 		{
1491
-			if($size & 1)
1492
-				return false;
1506
+			if($size & 1) {
1507
+							return false;
1508
+			}
1493 1509
 
1494 1510
 			for($i=0; $i<$size; $i+=2) {
1495 1511
 				$val = (ord($data[$i]) << 8) | ord($data[$i+1]);
@@ -1509,8 +1525,9 @@  discard block
 block discarded – undo
1509 1525
 
1510 1526
 		public static function check($mode, $size, $data)
1511 1527
 		{
1512
-			if($size <= 0) 
1513
-				return false;
1528
+			if($size <= 0) {
1529
+							return false;
1530
+			}
1514 1531
 
1515 1532
 			switch($mode) {
1516 1533
 				case QR_MODE_NUM:       return self::checkModeNum($size, $data);   break;
@@ -1575,8 +1592,9 @@  discard block
 block discarded – undo
1575 1592
 					$chunks = (int)($payload / 11);
1576 1593
 					$remain = $payload - $chunks * 11;
1577 1594
 					$size = $chunks * 2;
1578
-					if($remain >= 6) 
1579
-						$size++;
1595
+					if($remain >= 6) {
1596
+											$size++;
1597
+					}
1580 1598
 					break;
1581 1599
 				case QR_MODE_8:
1582 1600
 					$size = (int)($payload / 8);
@@ -1593,8 +1611,12 @@  discard block
 block discarded – undo
1593 1611
 			}
1594 1612
             
1595 1613
 			$maxsize = QRspec::maximumWords($mode, $version);
1596
-			if($size < 0) $size = 0;
1597
-			if($size > $maxsize) $size = $maxsize;
1614
+			if($size < 0) {
1615
+				$size = 0;
1616
+			}
1617
+			if($size > $maxsize) {
1618
+				$size = $maxsize;
1619
+			}
1598 1620
 
1599 1621
 			return $size;
1600 1622
 		}
@@ -1607,8 +1629,9 @@  discard block
 block discarded – undo
1607 1629
 			foreach($this->items as $item) {
1608 1630
 				$bits = $item->encodeBitStream($this->version);
1609 1631
                 
1610
-				if($bits < 0) 
1611
-					return -1;
1632
+				if($bits < 0) {
1633
+									return -1;
1634
+				}
1612 1635
                     
1613 1636
 				$total += $bits;
1614 1637
 			}
@@ -1627,8 +1650,9 @@  discard block
 block discarded – undo
1627 1650
 			for(;;) {
1628 1651
 				$bits = $this->createBitStream();
1629 1652
                 
1630
-				if($bits < 0) 
1631
-					return -1;
1653
+				if($bits < 0) {
1654
+									return -1;
1655
+				}
1632 1656
                     
1633 1657
 				$ver = QRspec::getMinimumVersion((int)(($bits + 7) / 8), $this->level);
1634 1658
 				if($ver < 0) {
@@ -1665,8 +1689,9 @@  discard block
 block discarded – undo
1665 1689
 			$padding = new QRbitstream();
1666 1690
 			$ret = $padding->appendNum($words * 8 - $bits + 4, 0);
1667 1691
             
1668
-			if($ret < 0) 
1669
-				return $ret;
1692
+			if($ret < 0) {
1693
+							return $ret;
1694
+			}
1670 1695
 
1671 1696
 			$padlen = $maxwords - $words;
1672 1697
             
@@ -1679,8 +1704,9 @@  discard block
 block discarded – undo
1679 1704
                 
1680 1705
 				$ret = $padding->appendBytes($padlen, $padbuf);
1681 1706
                 
1682
-				if($ret < 0)
1683
-					return $ret;
1707
+				if($ret < 0) {
1708
+									return $ret;
1709
+				}
1684 1710
                 
1685 1711
 			}
1686 1712
 
@@ -1857,13 +1883,15 @@  discard block
 block discarded – undo
1857 1883
 		//----------------------------------------------------------------------
1858 1884
 		public function appendNum($bits, $num)
1859 1885
 		{
1860
-			if ($bits == 0) 
1861
-				return 0;
1886
+			if ($bits == 0) {
1887
+							return 0;
1888
+			}
1862 1889
 
1863 1890
 			$b = QRbitstream::newFromNum($bits, $num);
1864 1891
             
1865
-			if(is_null($b))
1866
-				return -1;
1892
+			if(is_null($b)) {
1893
+							return -1;
1894
+			}
1867 1895
 
1868 1896
 			$ret = $this->append($b);
1869 1897
 			unset($b);
@@ -1874,13 +1902,15 @@  discard block
 block discarded – undo
1874 1902
 		//----------------------------------------------------------------------
1875 1903
 		public function appendBytes($size, $data)
1876 1904
 		{
1877
-			if ($size == 0) 
1878
-				return 0;
1905
+			if ($size == 0) {
1906
+							return 0;
1907
+			}
1879 1908
 
1880 1909
 			$b = QRbitstream::newFromBytes($size, $data);
1881 1910
             
1882
-			if(is_null($b))
1883
-				return -1;
1911
+			if(is_null($b)) {
1912
+							return -1;
1913
+			}
1884 1914
 
1885 1915
 			$ret = $this->append($b);
1886 1916
 			unset($b);
@@ -1984,8 +2014,9 @@  discard block
 block discarded – undo
1984 2014
 		//----------------------------------------------------------------------
1985 2015
 		public static function isdigitat($str, $pos)
1986 2016
 		{    
1987
-			if ($pos >= strlen($str))
1988
-				return false;
2017
+			if ($pos >= strlen($str)) {
2018
+							return false;
2019
+			}
1989 2020
             
1990 2021
 			return ((ord($str[$pos]) >= ord('0'))&&(ord($str[$pos]) <= ord('9')));
1991 2022
 		}
@@ -1993,8 +2024,9 @@  discard block
 block discarded – undo
1993 2024
 		//----------------------------------------------------------------------
1994 2025
 		public static function isalnumat($str, $pos)
1995 2026
 		{
1996
-			if ($pos >= strlen($str))
1997
-				return false;
2027
+			if ($pos >= strlen($str)) {
2028
+							return false;
2029
+			}
1998 2030
                 
1999 2031
 			return (QRinput::lookAnTable(ord($str[$pos])) >= 0);
2000 2032
 		}
@@ -2002,8 +2034,9 @@  discard block
 block discarded – undo
2002 2034
 		//----------------------------------------------------------------------
2003 2035
 		public function identifyMode($pos)
2004 2036
 		{
2005
-			if ($pos >= strlen($this->dataStr)) 
2006
-				return QR_MODE_NUL;
2037
+			if ($pos >= strlen($this->dataStr)) {
2038
+							return QR_MODE_NUL;
2039
+			}
2007 2040
                 
2008 2041
 			$c = $this->dataStr[$pos];
2009 2042
             
@@ -2057,8 +2090,9 @@  discard block
 block discarded – undo
2057 2090
 			}
2058 2091
             
2059 2092
 			$ret = $this->input->append(QR_MODE_NUM, $run, str_split($this->dataStr));
2060
-			if($ret < 0)
2061
-				return -1;
2093
+			if($ret < 0) {
2094
+							return -1;
2095
+			}
2062 2096
 
2063 2097
 			return $run;
2064 2098
 		}
@@ -2104,8 +2138,9 @@  discard block
 block discarded – undo
2104 2138
 			}
2105 2139
 
2106 2140
 			$ret = $this->input->append(QR_MODE_AN, $run, str_split($this->dataStr));
2107
-			if($ret < 0)
2108
-				return -1;
2141
+			if($ret < 0) {
2142
+							return -1;
2143
+			}
2109 2144
 
2110 2145
 			return $run;
2111 2146
 		}
@@ -2120,8 +2155,9 @@  discard block
 block discarded – undo
2120 2155
 			}
2121 2156
             
2122 2157
 			$ret = $this->input->append(QR_MODE_KANJI, $p, str_split($this->dataStr));
2123
-			if($ret < 0)
2124
-				return -1;
2158
+			if($ret < 0) {
2159
+							return -1;
2160
+			}
2125 2161
 
2126 2162
 			return $run;
2127 2163
 		}
@@ -2175,8 +2211,9 @@  discard block
 block discarded – undo
2175 2211
 			$run = $p;
2176 2212
 			$ret = $this->input->append(QR_MODE_8, $run, str_split($this->dataStr));
2177 2213
             
2178
-			if($ret < 0)
2179
-				return -1;
2214
+			if($ret < 0) {
2215
+							return -1;
2216
+			}
2180 2217
 
2181 2218
 			return $run;
2182 2219
 		}
@@ -2186,8 +2223,9 @@  discard block
 block discarded – undo
2186 2223
 		{
2187 2224
 			while (strlen($this->dataStr) > 0)
2188 2225
 			{
2189
-				if($this->dataStr == '')
2190
-					return 0;
2226
+				if($this->dataStr == '') {
2227
+									return 0;
2228
+				}
2191 2229
 
2192 2230
 				$mode = $this->identifyMode(0);
2193 2231
                 
@@ -2195,16 +2233,22 @@  discard block
 block discarded – undo
2195 2233
 					case QR_MODE_NUM: $length = $this->eatNum(); break;
2196 2234
 					case QR_MODE_AN:  $length = $this->eatAn(); break;
2197 2235
 					case QR_MODE_KANJI:
2198
-						if ($this->modeHint == QR_MODE_KANJI)
2199
-								$length = $this->eatKanji();
2200
-						else    $length = $this->eat8();
2236
+						if ($this->modeHint == QR_MODE_KANJI) {
2237
+														$length = $this->eatKanji();
2238
+						} else {
2239
+							$length = $this->eat8();
2240
+						}
2201 2241
 						break;
2202 2242
 					default: $length = $this->eat8(); break;
2203 2243
                 
2204 2244
 				}
2205 2245
 
2206
-				if($length == 0) return 0;
2207
-				if($length < 0)  return -1;
2246
+				if($length == 0) {
2247
+					return 0;
2248
+				}
2249
+				if($length < 0) {
2250
+					return -1;
2251
+				}
2208 2252
                 
2209 2253
 				$this->dataStr = substr($this->dataStr, $length);
2210 2254
 			}
@@ -2240,8 +2284,9 @@  discard block
 block discarded – undo
2240 2284
 
2241 2285
 			$split = new QRsplit($string, $input, $modeHint);
2242 2286
             
2243
-			if(!$casesensitive)
2244
-				$split->toUpper();
2287
+			if(!$casesensitive) {
2288
+							$split->toUpper();
2289
+			}
2245 2290
                 
2246 2291
 			return $split->splitString();
2247 2292
 		}
@@ -2318,11 +2363,23 @@  discard block
 block discarded – undo
2318 2363
 			$rs = null;
2319 2364
             
2320 2365
 			// Check parameter ranges
2321
-			if($symsize < 0 || $symsize > 8)                     return $rs;
2322
-			if($fcr < 0 || $fcr >= (1<<$symsize))                return $rs;
2323
-			if($prim <= 0 || $prim >= (1<<$symsize))             return $rs;
2324
-			if($nroots < 0 || $nroots >= (1<<$symsize))          return $rs; // Can't have more roots than symbol values!
2325
-			if($pad < 0 || $pad >= ((1<<$symsize) -1 - $nroots)) return $rs; // Too much padding
2366
+			if($symsize < 0 || $symsize > 8) {
2367
+				return $rs;
2368
+			}
2369
+			if($fcr < 0 || $fcr >= (1<<$symsize)) {
2370
+				return $rs;
2371
+			}
2372
+			if($prim <= 0 || $prim >= (1<<$symsize)) {
2373
+				return $rs;
2374
+			}
2375
+			if($nroots < 0 || $nroots >= (1<<$symsize)) {
2376
+				return $rs;
2377
+			}
2378
+			// Can't have more roots than symbol values!
2379
+			if($pad < 0 || $pad >= ((1<<$symsize) -1 - $nroots)) {
2380
+				return $rs;
2381
+			}
2382
+			// Too much padding
2326 2383
 
2327 2384
 			$rs = new QRrsItem();
2328 2385
 			$rs->mm = $symsize;
@@ -2388,8 +2445,9 @@  discard block
 block discarded – undo
2388 2445
 			}
2389 2446
             
2390 2447
 			// convert rs->genpoly[] to index form for quicker encoding
2391
-			for ($i = 0; $i <= $nroots; $i++)
2392
-				$rs->genpoly[$i] = $rs->index_of[$rs->genpoly[$i]];
2448
+			for ($i = 0; $i <= $nroots; $i++) {
2449
+							$rs->genpoly[$i] = $rs->index_of[$rs->genpoly[$i]];
2450
+			}
2393 2451
 
2394 2452
 			return $rs;
2395 2453
 		}
@@ -2447,12 +2505,24 @@  discard block
 block discarded – undo
2447 2505
 		public static function init_rs($symsize, $gfpoly, $fcr, $prim, $nroots, $pad)
2448 2506
 		{
2449 2507
 			foreach(self::$items as $rs) {
2450
-				if($rs->pad != $pad)       continue;
2451
-				if($rs->nroots != $nroots) continue;
2452
-				if($rs->mm != $symsize)    continue;
2453
-				if($rs->gfpoly != $gfpoly) continue;
2454
-				if($rs->fcr != $fcr)       continue;
2455
-				if($rs->prim != $prim)     continue;
2508
+				if($rs->pad != $pad) {
2509
+					continue;
2510
+				}
2511
+				if($rs->nroots != $nroots) {
2512
+					continue;
2513
+				}
2514
+				if($rs->mm != $symsize) {
2515
+					continue;
2516
+				}
2517
+				if($rs->gfpoly != $gfpoly) {
2518
+					continue;
2519
+				}
2520
+				if($rs->fcr != $fcr) {
2521
+					continue;
2522
+				}
2523
+				if($rs->prim != $prim) {
2524
+					continue;
2525
+				}
2456 2526
 
2457 2527
 				return $rs;
2458 2528
 			}
@@ -2591,8 +2661,9 @@  discard block
 block discarded – undo
2591 2661
 		{
2592 2662
 			$codeArr = array();
2593 2663
             
2594
-			foreach ($bitFrame as $line)
2595
-				$codeArr[] = join('', $line);
2664
+			foreach ($bitFrame as $line) {
2665
+							$codeArr[] = join('', $line);
2666
+			}
2596 2667
                 
2597 2668
 			return gzcompress(join("\n", $codeArr), 9);
2598 2669
 		}
@@ -2603,8 +2674,9 @@  discard block
 block discarded – undo
2603 2674
 			$codeArr = array();
2604 2675
             
2605 2676
 			$codeLines = explode("\n", gzuncompress($code));
2606
-			foreach ($codeLines as $line)
2607
-				$codeArr[] = str_split($line);
2677
+			foreach ($codeLines as $line) {
2678
+							$codeArr[] = str_split($line);
2679
+			}
2608 2680
             
2609 2681
 			return $codeArr;
2610 2682
 		}
@@ -2622,16 +2694,18 @@  discard block
 block discarded – undo
2622 2694
 					$bitMask = self::unserial(file_get_contents($fileName));
2623 2695
 				} else {
2624 2696
 					$bitMask = $this->generateMaskNo($maskNo, $width, $s);
2625
-					if (!file_exists(QR_CACHE_DIR.'mask_'.$maskNo))
2626
-						mkdir(QR_CACHE_DIR.'mask_'.$maskNo);
2697
+					if (!file_exists(QR_CACHE_DIR.'mask_'.$maskNo)) {
2698
+											mkdir(QR_CACHE_DIR.'mask_'.$maskNo);
2699
+					}
2627 2700
 					file_put_contents($fileName, self::serial($bitMask));
2628 2701
 				}
2629 2702
 			} else {
2630 2703
 				$bitMask = $this->generateMaskNo($maskNo, $width, $s);
2631 2704
 			}
2632 2705
 
2633
-			if ($maskGenOnly)
2634
-				return;
2706
+			if ($maskGenOnly) {
2707
+							return;
2708
+			}
2635 2709
                 
2636 2710
 			$d = $s;
2637 2711
 
@@ -2698,8 +2772,9 @@  discard block
 block discarded – undo
2698 2772
                 
2699 2773
 				$frameY = $frame[$y];
2700 2774
                 
2701
-				if ($y>0)
2702
-					$frameYM = $frame[$y-1];
2775
+				if ($y>0) {
2776
+									$frameYM = $frame[$y-1];
2777
+				}
2703 2778
                 
2704 2779
 				for($x=0; $x<$width; $x++) {
2705 2780
 					if(($x > 0) && ($y > 0)) {
@@ -2912,14 +2987,17 @@  discard block
 block discarded – undo
2912 2987
 				$blockNo++;
2913 2988
 			}
2914 2989
 
2915
-			if(QRspec::rsBlockNum2($spec) == 0)
2916
-				return 0;
2990
+			if(QRspec::rsBlockNum2($spec) == 0) {
2991
+							return 0;
2992
+			}
2917 2993
 
2918 2994
 			$dl = QRspec::rsDataCodes2($spec);
2919 2995
 			$el = QRspec::rsEccCodes2($spec);
2920 2996
 			$rs = QRrs::init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el);
2921 2997
             
2922
-			if($rs == NULL) return -1;
2998
+			if($rs == NULL) {
2999
+				return -1;
3000
+			}
2923 3001
             
2924 3002
 			for($i=0; $i<QRspec::rsBlockNum2($spec); $i++) {
2925 3003
 				$ecc = array_slice($this->ecccode,$eccPos);
@@ -3057,7 +3135,9 @@  discard block
 block discarded – undo
3057 3135
 			}
3058 3136
 
3059 3137
 			$input = new QRinput($version, $level);
3060
-			if($input == NULL) return NULL;
3138
+			if($input == NULL) {
3139
+				return NULL;
3140
+			}
3061 3141
 
3062 3142
 			$ret = $input->append(QR_MODE_8, strlen($string), str_split($string));
3063 3143
 			if($ret < 0) {
@@ -3077,7 +3157,9 @@  discard block
 block discarded – undo
3077 3157
 			}
3078 3158
 
3079 3159
 			$input = new QRinput($version, $level);
3080
-			if($input == NULL) return NULL;
3160
+			if($input == NULL) {
3161
+				return NULL;
3162
+			}
3081 3163
 
3082 3164
 			$ret = QRsplit::splitStringToQRinput($string, $input, $hint, $casesensitive);
3083 3165
 			if($ret < 0) {
@@ -3187,7 +3269,9 @@  discard block
 block discarded – undo
3187 3269
 						}
3188 3270
 					}
3189 3271
 				}
3190
-				if($x < 0 || $y < 0) return null;
3272
+				if($x < 0 || $y < 0) {
3273
+					return null;
3274
+				}
3191 3275
 
3192 3276
 				$this->x = $x;
3193 3277
 				$this->y = $y;
@@ -3294,8 +3378,9 @@  discard block
 block discarded – undo
3294 3378
 				$err = ob_get_contents();
3295 3379
 				ob_end_clean();
3296 3380
                 
3297
-				if ($err != '')
3298
-					QRtools::log($outfile, $err);
3381
+				if ($err != '') {
3382
+									QRtools::log($outfile, $err);
3383
+				}
3299 3384
                 
3300 3385
 				$maxSize = (int)(QR_PNG_MAXIMUM_SIZE / (count($tab)+2*$this->margin));
3301 3386
                 
Please login to merge, or discard this patch.
lib/phpqrcode/qrspec.php 1 patch
Braces   +27 added lines, -18 removed lines patch added patch discarded remove patch
@@ -115,8 +115,9 @@  discard block
 block discarded – undo
115 115
 
116 116
 			for($i=1; $i<= QRSPEC_VERSION_MAX; $i++) {
117 117
 				$words  = self::$capacity[$i][QRCAP_WORDS] - self::$capacity[$i][QRCAP_EC][$level];
118
-				if($words >= $size) 
119
-					return $i;
118
+				if($words >= $size) {
119
+									return $i;
120
+				}
120 121
 			}
121 122
 
122 123
 			return -1;
@@ -134,8 +135,9 @@  discard block
 block discarded – undo
134 135
 		//----------------------------------------------------------------------
135 136
 		public static function lengthIndicator($mode, $version)
136 137
 		{
137
-			if ($mode == QR_MODE_STRUCTURE)
138
-				return 0;
138
+			if ($mode == QR_MODE_STRUCTURE) {
139
+							return 0;
140
+			}
139 141
                 
140 142
 			if ($version <= 9) {
141 143
 				$l = 0;
@@ -151,8 +153,9 @@  discard block
 block discarded – undo
151 153
 		//----------------------------------------------------------------------
152 154
 		public static function maximumWords($mode, $version)
153 155
 		{
154
-			if($mode == QR_MODE_STRUCTURE) 
155
-				return 3;
156
+			if($mode == QR_MODE_STRUCTURE) {
157
+							return 3;
158
+			}
156 159
                 
157 160
 			if($version <= 9) {
158 161
 				$l = 0;
@@ -298,8 +301,9 @@  discard block
 block discarded – undo
298 301
 		//----------------------------------------------------------------------
299 302
 		public static function putAlignmentPattern($version, &$frame, $width)
300 303
 		{
301
-			if($version < 2)
302
-				return;
304
+			if($version < 2) {
305
+							return;
306
+			}
303 307
 
304 308
 			$d = self::$alignmentPattern[$version][1] - self::$alignmentPattern[$version][0];
305 309
 			if($d < 0) {
@@ -351,8 +355,9 @@  discard block
 block discarded – undo
351 355
 		//----------------------------------------------------------------------
352 356
 		public static function getVersionPattern($version)
353 357
 		{
354
-			if($version < 7 || $version > QRSPEC_VERSION_MAX)
355
-				return 0;
358
+			if($version < 7 || $version > QRSPEC_VERSION_MAX) {
359
+							return 0;
360
+			}
356 361
 
357 362
 			return self::$versionPattern[$version -7];
358 363
 		}
@@ -369,11 +374,13 @@  discard block
 block discarded – undo
369 374
 
370 375
 		public static function getFormatInfo($mask, $level)
371 376
 		{
372
-			if($mask < 0 || $mask > 7)
373
-				return 0;
377
+			if($mask < 0 || $mask > 7) {
378
+							return 0;
379
+			}
374 380
                 
375
-			if($level < 0 || $level > 3)
376
-				return 0;                
381
+			if($level < 0 || $level > 3) {
382
+							return 0;
383
+			}
377 384
 
378 385
 			return self::$formatInfo[$level][$mask];
379 386
 		}
@@ -553,8 +560,9 @@  discard block
 block discarded – undo
553 560
 		//----------------------------------------------------------------------
554 561
 		public static function newFrame($version)
555 562
 		{
556
-			if($version < 1 || $version > QRSPEC_VERSION_MAX) 
557
-				return null;
563
+			if($version < 1 || $version > QRSPEC_VERSION_MAX) {
564
+							return null;
565
+			}
558 566
 
559 567
 			if(!isset(self::$frames[$version])) {
560 568
                 
@@ -572,8 +580,9 @@  discard block
 block discarded – undo
572 580
 				}
573 581
 			}
574 582
             
575
-			if(is_null(self::$frames[$version]))
576
-				return null;
583
+			if(is_null(self::$frames[$version])) {
584
+							return null;
585
+			}
577 586
 
578 587
 			return self::$frames[$version];
579 588
 		}
Please login to merge, or discard this patch.
lib/phpqrcode/qrmask.php 1 patch
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -119,8 +119,9 @@  discard block
 block discarded – undo
119 119
 		{
120 120
 			$codeArr = array();
121 121
             
122
-			foreach ($bitFrame as $line)
123
-				$codeArr[] = join('', $line);
122
+			foreach ($bitFrame as $line) {
123
+							$codeArr[] = join('', $line);
124
+			}
124 125
                 
125 126
 			return gzcompress(join("\n", $codeArr), 9);
126 127
 		}
@@ -131,8 +132,9 @@  discard block
 block discarded – undo
131 132
 			$codeArr = array();
132 133
             
133 134
 			$codeLines = explode("\n", gzuncompress($code));
134
-			foreach ($codeLines as $line)
135
-				$codeArr[] = str_split($line);
135
+			foreach ($codeLines as $line) {
136
+							$codeArr[] = str_split($line);
137
+			}
136 138
             
137 139
 			return $codeArr;
138 140
 		}
@@ -150,16 +152,18 @@  discard block
 block discarded – undo
150 152
 					$bitMask = self::unserial(file_get_contents($fileName));
151 153
 				} else {
152 154
 					$bitMask = $this->generateMaskNo($maskNo, $width, $s);
153
-					if (!file_exists(QR_CACHE_DIR.'mask_'.$maskNo))
154
-						mkdir(QR_CACHE_DIR.'mask_'.$maskNo);
155
+					if (!file_exists(QR_CACHE_DIR.'mask_'.$maskNo)) {
156
+											mkdir(QR_CACHE_DIR.'mask_'.$maskNo);
157
+					}
155 158
 					file_put_contents($fileName, self::serial($bitMask));
156 159
 				}
157 160
 			} else {
158 161
 				$bitMask = $this->generateMaskNo($maskNo, $width, $s);
159 162
 			}
160 163
 
161
-			if ($maskGenOnly)
162
-				return;
164
+			if ($maskGenOnly) {
165
+							return;
166
+			}
163 167
                 
164 168
 			$d = $s;
165 169
 
@@ -226,8 +230,9 @@  discard block
 block discarded – undo
226 230
                 
227 231
 				$frameY = $frame[$y];
228 232
                 
229
-				if ($y>0)
230
-					$frameYM = $frame[$y-1];
233
+				if ($y>0) {
234
+									$frameYM = $frame[$y-1];
235
+				}
231 236
                 
232 237
 				for($x=0; $x<$width; $x++) {
233 238
 					if(($x > 0) && ($y > 0)) {
Please login to merge, or discard this patch.
lib/MiniTemplator.class.php 1 patch
Braces   +150 added lines, -73 removed lines patch added patch discarded remove patch
@@ -175,7 +175,9 @@  discard block
 block discarded – undo
175 175
    if (!$this->readFileIntoString($fileName,$s)) {
176 176
 	  $this->triggerError ("Error while reading template file " . $fileName . ".");
177 177
 	  return false; }
178
-   if (!$this->setTemplateString($s)) return false;
178
+   if (!$this->setTemplateString($s)) {
179
+   	return false;
180
+   }
179 181
    return true; }
180 182
 
181 183
 /**
@@ -280,16 +282,22 @@  discard block
 block discarded – undo
280 282
    $p = 0;
281 283
    while (true) {
282 284
 	  $p0 = strpos($this->template,'<!--',$p);
283
-	  if ($p0 === false) break;
285
+	  if ($p0 === false) {
286
+	  	break;
287
+	  }
284 288
 	  $p = strpos($this->template,'-->',$p0);
285 289
 	  if ($p === false) {
286 290
 		 $this->triggerError ("Invalid HTML comment in template at offset $p0.");
287 291
 		 return false; }
288 292
 	  $p += 3;
289 293
 	  $cmdL = substr($this->template,$p0+4,$p-$p0-7);
290
-	  if (!$this->processTemplateCommand($cmdL,$p0,$p,$resumeFromStart))
291
-		 return false;
292
-	  if ($resumeFromStart) $p = $p0; }
294
+	  if (!$this->processTemplateCommand($cmdL,$p0,$p,$resumeFromStart)) {
295
+	  		 return false;
296
+	  }
297
+	  if ($resumeFromStart) {
298
+	  	$p = $p0;
299
+	  }
300
+	  }
293 301
    return true; }
294 302
 
295 303
 /**
@@ -300,20 +308,25 @@  discard block
 block discarded – undo
300 308
    $resumeFromStart = false;
301 309
    $p = 0;
302 310
    $cmd = '';
303
-   if (!$this->parseWord($cmdL,$p,$cmd)) return true;
311
+   if (!$this->parseWord($cmdL,$p,$cmd)) {
312
+   	return true;
313
+   }
304 314
    $parms = substr($cmdL,$p);
305 315
    switch (strtoupper($cmd)) {
306 316
 	  case '$BEGINBLOCK':
307
-		 if (!$this->processBeginBlockCmd($parms,$cmdTPosBegin,$cmdTPosEnd))
308
-			return false;
317
+		 if (!$this->processBeginBlockCmd($parms,$cmdTPosBegin,$cmdTPosEnd)) {
318
+		 			return false;
319
+		 }
309 320
 		 break;
310 321
 	  case '$ENDBLOCK':
311
-		 if (!$this->processEndBlockCmd($parms,$cmdTPosBegin,$cmdTPosEnd))
312
-			return false;
322
+		 if (!$this->processEndBlockCmd($parms,$cmdTPosBegin,$cmdTPosEnd)) {
323
+		 			return false;
324
+		 }
313 325
 		 break;
314 326
 	  case '$INCLUDE':
315
-		 if (!$this->processincludeCmd($parms,$cmdTPosBegin,$cmdTPosEnd))
316
-			return false;
327
+		 if (!$this->processincludeCmd($parms,$cmdTPosBegin,$cmdTPosEnd)) {
328
+		 			return false;
329
+		 }
317 330
 		 $resumeFromStart = true;
318 331
 		 break;
319 332
 	  default:
@@ -385,8 +398,9 @@  discard block
 block discarded – undo
385 398
    $btr =& $this->blockTab[$blockNo];
386 399
    $btr = array();
387 400
    $btr['blockName'] = $blockName;
388
-   if (!$this->lookupBlockName($blockName,$btr['nextWithSameName']))
389
-	  $btr['nextWithSameName'] = -1;
401
+   if (!$this->lookupBlockName($blockName,$btr['nextWithSameName'])) {
402
+   	  $btr['nextWithSameName'] = -1;
403
+   }
390 404
    $btr['definitionIsOpen'] = true;
391 405
    $btr['instances'] = 0;
392 406
    $btr['firstBlockInstNo'] = -1;
@@ -436,7 +450,9 @@  discard block
 block discarded – undo
436 450
    if (strlen($this->template) > $this->maxInclTemplateSize) {
437 451
 	  $this->triggerError ("Subtemplate include aborted because the internal template string is longer than $this->maxInclTemplateSize characters.");
438 452
 	  return false; }
439
-   if (!$this->loadSubtemplate($subtemplateName,$subtemplate)) return false;
453
+   if (!$this->loadSubtemplate($subtemplateName,$subtemplate)) {
454
+   	return false;
455
+   }
440 456
    // (Copying the template to insert a subtemplate is a bit slow. In a future implementation of MiniTemplator,
441 457
    // a table could be used that contains references to the string fragments.)
442 458
    $this->template = substr($this->template,0,$tPos1) . $subtemplate . substr($this->template,$tPos2);
@@ -451,7 +467,9 @@  discard block
 block discarded – undo
451 467
    $p = 0;
452 468
    while (true) {
453 469
 	  $p = strpos($this->template, '${', $p);
454
-	  if ($p === false) break;
470
+	  if ($p === false) {
471
+	  	break;
472
+	  }
455 473
 	  $p0 = $p;
456 474
 	  $p = strpos($this->template, '}', $p);
457 475
 	  if ($p === false) {
@@ -469,8 +487,9 @@  discard block
 block discarded – undo
469 487
 * @access private
470 488
 */
471 489
 function registerVariableReference ($varName, $tPosBegin, $tPosEnd) {
472
-   if (!$this->lookupVariableName($varName,$varNo))
473
-	  $this->registerVariable($varName,$varNo);
490
+   if (!$this->lookupVariableName($varName,$varNo)) {
491
+   	  $this->registerVariable($varName,$varNo);
492
+   }
474 493
    $varRefNo = $this->varRefTabCnt++;
475 494
    $vrtr =& $this->varRefTab[$varRefNo];
476 495
    $vrtr = array();
@@ -510,12 +529,14 @@  discard block
 block discarded – undo
510 529
 			$nextBlockNo += 1;
511 530
 			continue; }}
512 531
 	  $btr =& $this->blockTab[$activeBlockNo];
513
-	  if ($varRefTPos < $btr['tPosBegin'])
514
-		 $this->programLogicError(1);
532
+	  if ($varRefTPos < $btr['tPosBegin']) {
533
+	  		 $this->programLogicError(1);
534
+	  }
515 535
 	  $blockVarNo = $btr['blockVarCnt']++;
516 536
 	  $btr['blockVarNoToVarNoMap'][$blockVarNo] = $varNo;
517
-	  if ($btr['firstVarRefNo'] == -1)
518
-		 $btr['firstVarRefNo'] = $varRefNo;
537
+	  if ($btr['firstVarRefNo'] == -1) {
538
+	  		 $btr['firstVarRefNo'] = $varRefNo;
539
+	  }
519 540
 	  $vrtr['blockNo'] = $activeBlockNo;
520 541
 	  $vrtr['blockVarNo'] = $blockVarNo;
521 542
 	  $varRefNo += 1; }}
@@ -531,8 +552,9 @@  discard block
 block discarded – undo
531 552
 * @access public
532 553
 */
533 554
 function reset() {
534
-   for ($varNo=0; $varNo<$this->varTabCnt; $varNo++)
535
-	  $this->varTab[$varNo]['varValue'] = '';
555
+   for ($varNo=0; $varNo<$this->varTabCnt; $varNo++) {
556
+   	  $this->varTab[$varNo]['varValue'] = '';
557
+   }
536 558
    for ($blockNo=0; $blockNo<$this->blockTabCnt; $blockNo++) {
537 559
 	  $btr =& $this->blockTab[$blockNo];
538 560
 	  $btr['instances'] = 0;
@@ -559,7 +581,9 @@  discard block
 block discarded – undo
559 581
 function setVariable ($variableName, $variableValue, $isOptional=false) {
560 582
    if (!$this->templateValid) {$this->triggerError ("Template not valid."); return false; }
561 583
    if (!$this->lookupVariableName($variableName,$varNo)) {
562
-	  if ($isOptional) return true;
584
+	  if ($isOptional) {
585
+	  	return true;
586
+	  }
563 587
 	  $this->triggerError ("Variable \"$variableName\" not defined in template.");
564 588
 	  return false; }
565 589
    $this->varTab[$varNo]['varValue'] = $variableValue;
@@ -627,20 +651,23 @@  discard block
 block discarded – undo
627 651
    $btr = & $this->blockTab[$blockNo];
628 652
    $this->registerBlockInstance($blockInstNo);
629 653
    $bitr = & $this->blockInstTab[$blockInstNo];
630
-   if ($btr['firstBlockInstNo'] == -1)
631
-	  $btr['firstBlockInstNo'] = $blockInstNo;
632
-   if ($btr['lastBlockInstNo'] != -1)
633
-	  $this->blockInstTab[$btr['lastBlockInstNo']]['nextBlockInstNo'] = $blockInstNo;
654
+   if ($btr['firstBlockInstNo'] == -1) {
655
+   	  $btr['firstBlockInstNo'] = $blockInstNo;
656
+   }
657
+   if ($btr['lastBlockInstNo'] != -1) {
658
+   	  $this->blockInstTab[$btr['lastBlockInstNo']]['nextBlockInstNo'] = $blockInstNo;
659
+   }
634 660
 		 // set forward pointer of chain
635 661
    $btr['lastBlockInstNo'] = $blockInstNo;
636 662
    $parentBlockNo = $btr['parentBlockNo'];
637 663
    $blockVarCnt = $btr['blockVarCnt'];
638 664
    $bitr['blockNo'] = $blockNo;
639 665
    $bitr['instanceLevel'] = $btr['instances']++;
640
-   if ($parentBlockNo == -1)
641
-	  $bitr['parentInstLevel'] = -1;
642
-	else
643
-	  $bitr['parentInstLevel'] = $this->blockTab[$parentBlockNo]['instances'];
666
+   if ($parentBlockNo == -1) {
667
+   	  $bitr['parentInstLevel'] = -1;
668
+   } else {
669
+		  $bitr['parentInstLevel'] = $this->blockTab[$parentBlockNo]['instances'];
670
+	}
644 671
    $bitr['nextBlockInstNo'] = -1;
645 672
    $bitr['blockVarTab'] = array();
646 673
    // copy instance variables for this block
@@ -687,7 +714,9 @@  discard block
 block discarded – undo
687 714
 */
688 715
 function generateOutputToFile($fileName) {
689 716
    $fh = fopen($fileName, "wb");
690
-   if ($fh === false) return false;
717
+   if ($fh === false) {
718
+   	return false;
719
+   }
691 720
    $this->outputMode = 1;
692 721
    $this->outputFileHandle = $fh;
693 722
    $ok = $this->generateOutputPage();
@@ -717,14 +746,18 @@  discard block
 block discarded – undo
717 746
 */
718 747
 function generateOutputPage() {
719 748
    if (!$this->templateValid) {$this->triggerError ("Template not valid."); return false; }
720
-   if ($this->blockTab[0]['instances'] == 0)
721
-	  $this->addBlockByNo (0);        // add main block
749
+   if ($this->blockTab[0]['instances'] == 0) {
750
+   	  $this->addBlockByNo (0);
751
+   }
752
+   // add main block
722 753
    for ($blockNo=0; $blockNo < $this->blockTabCnt; $blockNo++) {
723 754
 	   $btr =& $this->blockTab[$blockNo];
724 755
 	   $btr['currBlockInstNo'] = $btr['firstBlockInstNo']; }
725 756
    $this->outputError = false;
726 757
    $this->writeBlockInstances (0, -1);
727
-   if ($this->outputError) return false;
758
+   if ($this->outputError) {
759
+   	return false;
760
+   }
728 761
    return true; }
729 762
 
730 763
 /**
@@ -737,11 +770,16 @@  discard block
 block discarded – undo
737 770
    $btr =& $this->blockTab[$blockNo];
738 771
    while (!$this->outputError) {
739 772
 	  $blockInstNo = $btr['currBlockInstNo'];
740
-	  if ($blockInstNo == -1) break;
773
+	  if ($blockInstNo == -1) {
774
+	  	break;
775
+	  }
741 776
 	  $bitr =& $this->blockInstTab[$blockInstNo];
742
-	  if ($bitr['parentInstLevel'] < $parentInstLevel)
743
-		 $this->programLogicError (2);
744
-	  if ($bitr['parentInstLevel'] > $parentInstLevel) break;
777
+	  if ($bitr['parentInstLevel'] < $parentInstLevel) {
778
+	  		 $this->programLogicError (2);
779
+	  }
780
+	  if ($bitr['parentInstLevel'] > $parentInstLevel) {
781
+	  	break;
782
+	  }
745 783
 	  $this->writeBlockInstance ($blockInstNo);
746 784
 	  $btr['currBlockInstNo'] = $bitr['nextBlockInstNo']; }}
747 785
 
@@ -774,15 +812,17 @@  discard block
 block discarded – undo
774 812
 		 if ($subBtr['tPosBegin'] < $tPos2) {
775 813
 			$tPos2 = $subBtr['tPosBegin'];
776 814
 			$kind = 2; }}
777
-	  if ($tPos2 > $tPos)
778
-		 $this->writeString (substr($this->template,$tPos,$tPos2-$tPos));
815
+	  if ($tPos2 > $tPos) {
816
+	  		 $this->writeString (substr($this->template,$tPos,$tPos2-$tPos));
817
+	  }
779 818
 	  switch ($kind) {
780 819
 		 case 0:         // end of block
781 820
 			return;
782 821
 		 case 1:         // variable
783 822
 			$vrtr =& $this->varRefTab[$varRefNo];
784
-			if ($vrtr['blockNo'] != $blockNo)
785
-			   $this->programLogicError (4);
823
+			if ($vrtr['blockNo'] != $blockNo) {
824
+						   $this->programLogicError (4);
825
+			}
786 826
 			$variableValue = $bitr['blockVarTab'][$vrtr['blockVarNo']];
787 827
 			$this->writeString ($variableValue);
788 828
 			$tPos = $vrtr['tPosEnd'];
@@ -790,8 +830,9 @@  discard block
 block discarded – undo
790 830
 			break;
791 831
 		 case 2:         // sub block
792 832
 			$subBtr =& $this->blockTab[$subBlockNo];
793
-			if ($subBtr['parentBlockNo'] != $blockNo)
794
-			   $this->programLogicError (3);
833
+			if ($subBtr['parentBlockNo'] != $blockNo) {
834
+						   $this->programLogicError (3);
835
+			}
795 836
 			$this->writeBlockInstances ($subBlockNo, $bitr['instanceLevel']);  // recursive call
796 837
 			$tPos = $subBtr['tPosEnd'];
797 838
 			$subBlockNo += 1;
@@ -801,15 +842,20 @@  discard block
 block discarded – undo
801 842
 * @access private
802 843
 */
803 844
 function writeString($s) {
804
-   if ($this->outputError) return;
845
+   if ($this->outputError) {
846
+   	return;
847
+   }
805 848
    switch ($this->outputMode) {
806 849
 	  case 0:            // output to PHP output stream
807
-		 if (!print($s))
808
-			$this->outputError = true;
850
+		 if (!print($s)) {
851
+		 			$this->outputError = true;
852
+		 }
809 853
 		 break;
810 854
 	  case 1:            // output to file
811 855
 		 $rc = fwrite($this->outputFileHandle, $s);
812
-		 if ($rc === false) $this->outputError = true;
856
+		 if ($rc === false) {
857
+		 	$this->outputError = true;
858
+		 }
813 859
 		 break;
814 860
 	  case 2:            // output to string
815 861
 		 $this->outputString .= $s;
@@ -824,7 +870,9 @@  discard block
 block discarded – undo
824 870
 */
825 871
 function lookupVariableName($varName, &$varNo) {
826 872
    $x = & $this->varNameToNoMap[strtoupper($varName)];
827
-   if (!isset($x)) return false;
873
+   if (!isset($x)) {
874
+   	return false;
875
+   }
828 876
    $varNo = $x;
829 877
    return true; }
830 878
 
@@ -837,7 +885,9 @@  discard block
 block discarded – undo
837 885
 */
838 886
 function lookupBlockName($blockName, &$blockNo) {
839 887
    $x = & $this->blockNameToNoMap[strtoupper($blockName)];
840
-   if (!isset($x)) return false;
888
+   if (!isset($x)) {
889
+   	return false;
890
+   }
841 891
    $blockNo = $x;
842 892
    return true; }
843 893
 
@@ -851,15 +901,21 @@  discard block
 block discarded – undo
851 901
 function readFileIntoString ($fileName, &$s) {
852 902
    if (function_exists('version_compare') && version_compare(phpversion(),"4.3.0",">=")) {
853 903
 	  $s = file_get_contents($fileName);
854
-	  if ($s === false) return false;
904
+	  if ($s === false) {
905
+	  	return false;
906
+	  }
855 907
 	  return true; }
856 908
    $fh = fopen($fileName,"rb");
857
-   if ($fh === false) return false;
909
+   if ($fh === false) {
910
+   	return false;
911
+   }
858 912
    $fileSize = filesize($fileName);
859 913
    if ($fileSize === false) {fclose ($fh); return false; }
860 914
    $s = fread($fh,$fileSize);
861 915
    fclose ($fh);
862
-   if (strlen($s) != $fileSize) return false;
916
+   if (strlen($s) != $fileSize) {
917
+   	return false;
918
+   }
863 919
    return true; }
864 920
 
865 921
 /**
@@ -887,12 +943,22 @@  discard block
 block discarded – undo
887 943
 */
888 944
 function parseQuotedString($s, &$p, &$w) {
889 945
    $sLen = strlen($s);
890
-   while ($p < $sLen && ord($s{$p}) <= 32) $p++;
891
-   if ($p >= $sLen) return false;
892
-   if (substr($s, $p, 1) != '"') return false;
946
+   while ($p < $sLen && ord($s{$p}) <= 32) {
947
+   	$p++;
948
+   }
949
+   if ($p >= $sLen) {
950
+   	return false;
951
+   }
952
+   if (substr($s, $p, 1) != '"') {
953
+   	return false;
954
+   }
893 955
    $p++; $p0 = $p;
894
-   while ($p < $sLen && $s{$p} != '"') $p++;
895
-   if ($p >= $sLen) return false;
956
+   while ($p < $sLen && $s{$p} != '"') {
957
+   	$p++;
958
+   }
959
+   if ($p >= $sLen) {
960
+   	return false;
961
+   }
896 962
    $w = substr($s, $p0, $p - $p0);
897 963
    $p++;
898 964
    return true; }
@@ -903,25 +969,36 @@  discard block
 block discarded – undo
903 969
 */
904 970
 function parseWordOrQuotedString ($s, &$p, &$w) {
905 971
    $sLen = strlen($s);
906
-   while ($p < $sLen && ord($s{$p}) <= 32) $p++;
907
-   if ($p >= $sLen) return false;
908
-   if (substr($s,$p,1) == '"')
909
-	  return $this->parseQuotedString($s,$p,$w);
910
-	else
911
-	  return $this->parseWord($s,$p,$w); }
972
+   while ($p < $sLen && ord($s{$p}) <= 32) {
973
+   	$p++;
974
+   }
975
+   if ($p >= $sLen) {
976
+   	return false;
977
+   }
978
+   if (substr($s,$p,1) == '"') {
979
+   	  return $this->parseQuotedString($s,$p,$w);
980
+   } else {
981
+		  return $this->parseWord($s,$p,$w);
982
+	}
983
+	}
912 984
 
913 985
 /**
914 986
 * Combine two file system paths.
915 987
 * @access private
916 988
 */
917 989
 function combineFileSystemPath ($path1, $path2) {
918
-   if ($path1 == '' || $path2 == '') return $path2;
990
+   if ($path1 == '' || $path2 == '') {
991
+   	return $path2;
992
+   }
919 993
    $s = $path1;
920
-   if (substr($s,-1) != '\\' && substr($s,-1) != '/') $s = $s . "/";
921
-   if (substr($path2,0,1) == '\\' || substr($path2,0,1) == '/')
922
-	  $s = $s . substr($path2,1);
923
-	else
924
-	  $s = $s . $path2;
994
+   if (substr($s,-1) != '\\' && substr($s,-1) != '/') {
995
+   	$s = $s . "/";
996
+   }
997
+   if (substr($path2,0,1) == '\\' || substr($path2,0,1) == '/') {
998
+   	  $s = $s . substr($path2,1);
999
+   } else {
1000
+		  $s = $s . $path2;
1001
+	}
925 1002
    return $s; }
926 1003
 
927 1004
 /**
Please login to merge, or discard this patch.
classes/article.php 1 patch
Braces   +21 added lines, -16 removed lines patch added patch discarded remove patch
@@ -445,10 +445,12 @@  discard block
 block discarded – undo
445 445
 
446 446
 								if (!$hide_images) {
447 447
 									$encsize = '';
448
-									if ($entry['height'] > 0)
449
-										$encsize .= ' height="'.intval($entry['height']).'"';
450
-									if ($entry['width'] > 0)
451
-										$encsize .= ' width="'.intval($entry['width']).'"';
448
+									if ($entry['height'] > 0) {
449
+																			$encsize .= ' height="'.intval($entry['height']).'"';
450
+									}
451
+									if ($entry['width'] > 0) {
452
+																			$encsize .= ' width="'.intval($entry['width']).'"';
453
+									}
452 454
 									$rv .= "<p><img
453 455
 										alt=\"".htmlspecialchars($entry["filename"])."\"
454 456
 										src=\"" .htmlspecialchars($entry["url"])."\"
@@ -480,15 +482,17 @@  discard block
 block discarded – undo
480 482
 			$rv .= "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
481 483
 
482 484
 			foreach ($entries as $entry) {
483
-				if ($entry["title"])
484
-					$title = " &mdash; ".truncate_string($entry["title"], 30);
485
-				else
486
-					$title = "";
485
+				if ($entry["title"]) {
486
+									$title = " &mdash; ".truncate_string($entry["title"], 30);
487
+				} else {
488
+									$title = "";
489
+				}
487 490
 
488
-				if ($entry["filename"])
489
-					$filename = truncate_middle(htmlspecialchars($entry["filename"]), 60);
490
-				else
491
-					$filename = "";
491
+				if ($entry["filename"]) {
492
+									$filename = truncate_middle(htmlspecialchars($entry["filename"]), 60);
493
+				} else {
494
+									$filename = "";
495
+				}
492 496
 
493 497
 				$rv .= "<div onclick='popupOpenUrl(\"".htmlspecialchars($entry["url"])."\")'
494 498
 					dojoType=\"dijit.MenuItem\">".$filename.$title."</div>";
@@ -639,10 +643,11 @@  discard block
 block discarded – undo
639 643
 
640 644
 		// purge orphaned posts in main content table
641 645
 
642
-		if (DB_TYPE == "mysql")
643
-			$limit_qpart = "LIMIT 5000";
644
-		else
645
-			$limit_qpart = "";
646
+		if (DB_TYPE == "mysql") {
647
+					$limit_qpart = "LIMIT 5000";
648
+		} else {
649
+					$limit_qpart = "";
650
+		}
646 651
 
647 652
 		$pdo = Db::pdo();
648 653
 		$res = $pdo->query("DELETE FROM ttrss_entries WHERE
Please login to merge, or discard this patch.
classes/feedparser.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,8 +26,10 @@
 block discarded – undo
26 26
 		if ($error) {
27 27
 			foreach (libxml_get_errors() as $error) {
28 28
 				if ($error->level == LIBXML_ERR_FATAL) {
29
-					if (!isset($this->error)) //currently only the first error is reported
29
+					if (!isset($this->error)) {
30
+						//currently only the first error is reported
30 31
 						$this->error = $this->format_error($error);
32
+					}
31 33
 					$this->libxml_errors [] = $this->format_error($error);
32 34
 				}
33 35
 			}
Please login to merge, or discard this patch.
classes/feeds.php 1 patch
Braces   +54 added lines, -33 removed lines patch added patch discarded remove patch
@@ -50,8 +50,9 @@  discard block
 block discarded – undo
50 50
 			$reply .= strip_tags($feed_title);
51 51
 		}
52 52
 
53
-		if ($error)
54
-			$reply .= " <i title=\"".htmlspecialchars($error)."\" class='material-icons icon-error'>error</i>";
53
+		if ($error) {
54
+					$reply .= " <i title=\"".htmlspecialchars($error)."\" class='material-icons icon-error'>error</i>";
55
+		}
55 56
 
56 57
 		$reply .= "</span>";
57 58
 		$reply .= "<span id='feed_current_unread' style='display: none'></span>";
@@ -325,10 +326,11 @@  discard block
 block discarded – undo
325 326
 
326 327
 				$line['content'] = DiskCache::rewriteUrls($line['content']);
327 328
 
328
-				if ($line['note'])
329
-					$line['note'] = Article::format_article_note($id, $line['note']);
330
-				else
331
-					$line['note'] = "";
329
+				if ($line['note']) {
330
+									$line['note'] = Article::format_article_note($id, $line['note']);
331
+				} else {
332
+									$line['note'] = "";
333
+				}
332 334
 
333 335
 				if (!get_pref("CDM_EXPANDED")) {
334 336
 					$line["cdm_excerpt"] = "<span class='collapse'>
@@ -395,8 +397,9 @@  discard block
 block discarded – undo
395 397
 				/* we don't need those */
396 398
 
397 399
 				foreach (["date_entered", "guid", "last_published", "last_marked", "tag_cache", "favicon_avg_color",
398
-							 "uuid", "label_cache", "yyiw"] as $k)
399
-					unset($line[$k]);
400
+							 "uuid", "label_cache", "yyiw"] as $k) {
401
+									unset($line[$k]);
402
+				}
400 403
 
401 404
 				array_push($reply['content'], $line);
402 405
 			}
@@ -1310,13 +1313,17 @@  discard block
 block discarded – undo
1310 1313
 
1311 1314
 	public static function getCategoryUnread($cat, $owner_uid = false) {
1312 1315
 
1313
-		if (!$owner_uid) $owner_uid = $_SESSION["uid"];
1316
+		if (!$owner_uid) {
1317
+			$owner_uid = $_SESSION["uid"];
1318
+		}
1314 1319
 
1315 1320
 		$pdo = Db::pdo();
1316 1321
 
1317 1322
 		if ($cat >= 0) {
1318 1323
 
1319
-			if (!$cat) $cat = null;
1324
+			if (!$cat) {
1325
+				$cat = null;
1326
+			}
1320 1327
 
1321 1328
 			$sth = $pdo->prepare("SELECT id FROM ttrss_feeds
1322 1329
                     WHERE (cat_id = :cat OR (:cat IS NULL AND cat_id IS NULL))
@@ -2279,56 +2286,68 @@  discard block
 block discarded – undo
2279 2286
 				break;
2280 2287
 			case "note":
2281 2288
 				if ($commandpair[1]) {
2282
-					if ($commandpair[1] == "true")
2283
-						array_push($query_keywords, "($not (note IS NOT NULL AND note != ''))");
2284
-					else if ($commandpair[1] == "false")
2285
-						array_push($query_keywords, "($not (note IS NULL OR note = ''))");
2286
-					else
2287
-						array_push($query_keywords, "($not (LOWER(note) LIKE ".
2289
+					if ($commandpair[1] == "true") {
2290
+											array_push($query_keywords, "($not (note IS NOT NULL AND note != ''))");
2291
+					} else if ($commandpair[1] == "false") {
2292
+											array_push($query_keywords, "($not (note IS NULL OR note = ''))");
2293
+					} else {
2294
+											array_push($query_keywords, "($not (LOWER(note) LIKE ".
2288 2295
 							$pdo->quote('%' . mb_strtolower($commandpair[1]) . '%')."))");
2296
+					}
2289 2297
 				} else {
2290 2298
 					array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").")
2291 2299
 								OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))");
2292
-					if (!$not) array_push($search_words, $k);
2300
+					if (!$not) {
2301
+						array_push($search_words, $k);
2302
+					}
2293 2303
 				}
2294 2304
 				break;
2295 2305
 			case "star":
2296 2306
 
2297 2307
 				if ($commandpair[1]) {
2298
-					if ($commandpair[1] == "true")
2299
-						array_push($query_keywords, "($not (marked = true))");
2300
-					else
2301
-						array_push($query_keywords, "($not (marked = false))");
2308
+					if ($commandpair[1] == "true") {
2309
+											array_push($query_keywords, "($not (marked = true))");
2310
+					} else {
2311
+											array_push($query_keywords, "($not (marked = false))");
2312
+					}
2302 2313
 				} else {
2303 2314
 					array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").")
2304 2315
 								OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))");
2305
-					if (!$not) array_push($search_words, $k);
2316
+					if (!$not) {
2317
+						array_push($search_words, $k);
2318
+					}
2306 2319
 				}
2307 2320
 				break;
2308 2321
 			case "pub":
2309 2322
 				if ($commandpair[1]) {
2310
-					if ($commandpair[1] == "true")
2311
-						array_push($query_keywords, "($not (published = true))");
2312
-					else
2313
-						array_push($query_keywords, "($not (published = false))");
2323
+					if ($commandpair[1] == "true") {
2324
+											array_push($query_keywords, "($not (published = true))");
2325
+					} else {
2326
+											array_push($query_keywords, "($not (published = false))");
2327
+					}
2314 2328
 
2315 2329
 				} else {
2316 2330
 					array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%')
2317 2331
 								OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))");
2318
-					if (!$not) array_push($search_words, $k);
2332
+					if (!$not) {
2333
+						array_push($search_words, $k);
2334
+					}
2319 2335
 				}
2320 2336
 				break;
2321 2337
 			case "unread":
2322 2338
 				if ($commandpair[1]) {
2323
-					if ($commandpair[1] == "true")
2324
-						array_push($query_keywords, "($not (unread = true))");
2325
-					else
2326
-						array_push($query_keywords, "($not (unread = false))");
2339
+					if ($commandpair[1] == "true") {
2340
+											array_push($query_keywords, "($not (unread = true))");
2341
+					} else {
2342
+											array_push($query_keywords, "($not (unread = false))");
2343
+					}
2327 2344
 
2328 2345
 				} else {
2329 2346
 					array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").")
2330 2347
 								OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))");
2331
-					if (!$not) array_push($search_words, $k);
2348
+					if (!$not) {
2349
+						array_push($search_words, $k);
2350
+					}
2332 2351
 				}
2333 2352
 				break;
2334 2353
 			default:
@@ -2351,7 +2370,9 @@  discard block
 block discarded – undo
2351 2370
 								OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))");
2352 2371
 					}
2353 2372
 
2354
-					if (!$not) array_push($search_words, $k);
2373
+					if (!$not) {
2374
+						array_push($search_words, $k);
2375
+					}
2355 2376
 				}
2356 2377
 			}
2357 2378
 		}
Please login to merge, or discard this patch.