Passed
Branch php-cs-fixer (b9836a)
by Fabio
15:02
created
framework/Caching/TEtcdCache.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     */
80 80
 	public function init($config)
81 81
 	{
82
-		if (!function_exists('curl_version')) throw new TConfigurationException('curl_extension_required');
82
+		if(!function_exists('curl_version')) throw new TConfigurationException('curl_extension_required');
83 83
 		parent::init($config);
84 84
 	}
85 85
   
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	protected function setValue($key, $value, $expire)
156 156
 	{
157 157
 	$value = ['value' => serialize($value)];
158
-	if ($expire > 0) $value['ttl'] = $expire;
158
+	if($expire > 0) $value['ttl'] = $expire;
159 159
 		$result = $this->request('PUT', $this->_dir . '/' . $key, $value);
160 160
 	return !property_exists($result, 'errorCode');
161 161
 	}
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	protected function addValue($key, $value, $expire)
173 173
 	{
174 174
 	$value = ['value' => serialize($value), 'prevExist' => 'false'];
175
-	if ($expire > 0) $value['ttl'] = $expire;
175
+	if($expire > 0) $value['ttl'] = $expire;
176 176
 		$result = $this->request('PUT', $this->_dir . '/' . $key, $value);
177 177
 	return !property_exists($result, 'errorCode');
178 178
 	}
Please login to merge, or discard this patch.
framework/I18N/core/MessageSource_XLIFF.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	public function __construct($source)
60 60
 	{
61
-		$this->source = (string)$source;
61
+		$this->source = (string) $source;
62 62
 	}
63 63
 
64 64
 	/**
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
 
80 80
 		foreach($translationUnit as $unit)
81 81
 		{
82
-			$source = (string)$unit->source;
83
-			$translations[$source][] = (string)$unit->target;
84
-			$translations[$source][] = (string)$unit['id'];
85
-			$translations[$source][] = (string)$unit->note;
82
+			$source = (string) $unit->source;
83
+			$translations[$source][] = (string) $unit->target;
84
+			$translations[$source][] = (string) $unit['id'];
85
+			$translations[$source][] = (string) $unit->note;
86 86
 		}
87 87
 
88 88
 		return $translations;
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 		{
137 137
 			if(isset($variants[$i]{0}))
138 138
 			{
139
-				$variant .= ($variant)?'_' . $variants[$i]:$variants[$i];
139
+				$variant .= ($variant) ? '_' . $variants[$i] : $variants[$i];
140 140
 				$catalogues[] = $catalogue . $this->dataSeparator . $variant . $this->dataExt;
141 141
 			}
142 142
 		}
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 		{
172 172
 			if(isset($variants[$i]{0}))
173 173
 			{
174
-				$variant .= ($variant)?'_' . $variants[$i]:$variants[$i];
174
+				$variant .= ($variant) ? '_' . $variants[$i] : $variants[$i];
175 175
 				$catalogues[] = $variant . '/' . $catalogue . $this->dataExt;
176 176
 			}
177 177
 		}
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	 */
199 199
 	protected function getCatalogues($dir = null, $variant = null)
200 200
 	{
201
-		$dir = $dir?$dir:$this->source;
201
+		$dir = $dir ? $dir : $this->source;
202 202
 		$files = scandir($dir);
203 203
 		$catalogue = [];
204 204
 
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 
295 295
 		$lastNodes = $xpath->query('//trans-unit[last()]');
296 296
 		if(($last = $lastNodes->item(0)) !== null) {
297
-			$count = (int)$last->getAttribute('id');
297
+			$count = (int) $last->getAttribute('id');
298 298
 		} else {
299 299
 			$count = 0;
300 300
 		}
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -523,7 +523,7 @@
 block discarded – undo
523 523
   </body>
524 524
  </file>
525 525
 </xliff>
526
-EOD;
526
+eod;
527 527
 		return $xml;
528 528
 	}
529 529
 }
Please login to merge, or discard this patch.
framework/I18N/core/Gettext/TGettext.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -125,19 +125,19 @@  discard block
 block discarded – undo
125 125
 	 */
126 126
 	public static function poFile2moFile($pofile, $mofile)
127 127
 	{
128
-		if (!is_file($pofile)) {
128
+		if(!is_file($pofile)) {
129 129
 			throw new Exception("File $pofile doesn't exist.");
130 130
 		}
131 131
 
132 132
 		include_once dirname(__FILE__) . '/PO.php';
133 133
 
134 134
 		$PO = new TGettext_PO($pofile);
135
-		if (true !== ($e = $PO->load())) {
135
+		if(true !== ($e = $PO->load())) {
136 136
 			return $e;
137 137
 		}
138 138
 
139 139
 		$MO = $PO->toMO();
140
-		if (true !== ($e = $MO->save($mofile))) {
140
+		if(true !== ($e = $MO->save($mofile))) {
141 141
 			return $e;
142 142
 		}
143 143
 		unset($PO, $MO);
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	 */
157 157
 	public static function prepare($string, $reverse = false)
158 158
 	{
159
-		if ($reverse) {
159
+		if($reverse) {
160 160
 			$smap = ['"', "\n", "\t", "\r"];
161 161
 			$rmap = ['\"', '\\n"' . "\n" . '"', '\\t', '\\r'];
162 162
 			return (string) str_replace($smap, $rmap, $string);
@@ -179,8 +179,8 @@  discard block
 block discarded – undo
179 179
 	public static function meta2array($meta)
180 180
 	{
181 181
 		$array = [];
182
-		foreach (explode("\n", $meta) as $info) {
183
-			if ($info = trim($info)) {
182
+		foreach(explode("\n", $meta) as $info) {
183
+			if($info = trim($info)) {
184 184
 				list($key, $value) = explode(':', $info, 2);
185 185
 				$array[trim($key)] = trim($value);
186 186
 			}
@@ -244,8 +244,8 @@  discard block
 block discarded – undo
244 244
 	 */
245 245
 	public function fromArray($array)
246 246
 	{
247
-		if (!array_key_exists('strings', $array)) {
248
-			if (count($array) != 2) {
247
+		if(!array_key_exists('strings', $array)) {
248
+			if(count($array) != 2) {
249 249
 				return false;
250 250
 			} else {
251 251
 				list($this->meta, $this->strings) = $array;
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@
 block discarded – undo
126 126
 	public static function poFile2moFile($pofile, $mofile)
127 127
 	{
128 128
 		if (!is_file($pofile)) {
129
-			throw new Exception("File $pofile doesn't exist.");
129
+			throw new Exception("file $pofile doesn't exist.");
130 130
 		}
131 131
 
132 132
 		include_once dirname(__FILE__) . '/PO.php';
Please login to merge, or discard this patch.
framework/I18N/core/Gettext/TGettext_PO.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -72,12 +72,12 @@  discard block
 block discarded – undo
72 72
 	 */
73 73
 	public function load($file = null)
74 74
 	{
75
-		if (!isset($file)) {
75
+		if(!isset($file)) {
76 76
 			$file = $this->file;
77 77
 		}
78 78
 
79 79
 		// load file
80
-		if (!$contents = @file($file)) {
80
+		if(!$contents = @file($file)) {
81 81
 			return false;
82 82
 		}
83 83
 		$contents = implode('', $contents);
@@ -90,12 +90,12 @@  discard block
 block discarded – undo
90 90
 		);
91 91
 		unset($contents);
92 92
 
93
-		if (!$matched) {
93
+		if(!$matched) {
94 94
 			return false;
95 95
 		}
96 96
 
97 97
 		// get all msgids and msgtrs
98
-		for ($i = 0; $i < $matched; $i++) {
98
+		for($i = 0; $i < $matched; $i++) {
99 99
 			$msgid = preg_replace(
100 100
 				'/\s*msgid\s*"(.*)"\s*/s', '\\1', $matches[1][$i]);
101 101
 			$msgstr = preg_replace(
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 		}
105 105
 
106 106
 		// check for meta info
107
-		if (isset($this->strings[''])) {
107
+		if(isset($this->strings[''])) {
108 108
 			$this->meta = parent::meta2array($this->strings['']);
109 109
 			unset($this->strings['']);
110 110
 		}
@@ -121,30 +121,30 @@  discard block
 block discarded – undo
121 121
 	 */
122 122
 	public function save($file = null)
123 123
 	{
124
-		if (!isset($file)) {
124
+		if(!isset($file)) {
125 125
 			$file = $this->file;
126 126
 		}
127 127
 
128 128
 		// open PO file
129
-		if (!is_resource($fh = @fopen($file, 'w'))) {
129
+		if(!is_resource($fh = @fopen($file, 'w'))) {
130 130
 			return false;
131 131
 		}
132 132
 
133 133
 		// lock PO file exclusively
134
-		if (!flock($fh, LOCK_EX)) {
134
+		if(!flock($fh, LOCK_EX)) {
135 135
 			fclose($fh);
136 136
 			return false;
137 137
 		}
138 138
 		// write meta info
139
-		if (count($this->meta)) {
139
+		if(count($this->meta)) {
140 140
 			$meta = 'msgid ""' . "\nmsgstr " . '""' . "\n";
141
-			foreach ($this->meta as $k => $v) {
141
+			foreach($this->meta as $k => $v) {
142 142
 				$meta .= '"' . $k . ': ' . $v . '\n"' . "\n";
143 143
 			}
144 144
 			fwrite($fh, $meta . "\n");
145 145
 		}
146 146
 		// write strings
147
-		foreach ($this->strings as $o => $t) {
147
+		foreach($this->strings as $o => $t) {
148 148
 			fwrite($fh,
149 149
 				'msgid "' . parent::prepare($o, true) . '"' . "\n" .
150 150
 				'msgstr "' . parent::prepare($t, true) . '"' . "\n\n"
Please login to merge, or discard this patch.
framework/I18N/core/Gettext/TGettext_MO.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 */
91 91
 	public function _read($bytes = 1)
92 92
 	{
93
-		if (0 < $bytes = abs($bytes)) {
93
+		if(0 < $bytes = abs($bytes)) {
94 94
 			return fread($this->_handle, $bytes);
95 95
 		}
96 96
 		return null;
@@ -169,16 +169,16 @@  discard block
 block discarded – undo
169 169
 	 */
170 170
 	public function load($file = null)
171 171
 	{
172
-		if (!isset($file)) {
172
+		if(!isset($file)) {
173 173
 			$file = $this->file;
174 174
 		}
175 175
 
176 176
 		// open MO file
177
-		if (!is_resource($this->_handle = @fopen($file, 'rb'))) {
177
+		if(!is_resource($this->_handle = @fopen($file, 'rb'))) {
178 178
 			return false;
179 179
 		}
180 180
 		// lock MO file shared
181
-		if (!@flock($this->_handle, LOCK_SH)) {
181
+		if(!@flock($this->_handle, LOCK_SH)) {
182 182
 			@fclose($this->_handle);
183 183
 			return false;
184 184
 		}
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 
188 188
 		//unpack returns a reference????
189 189
 		$unpacked = unpack('c', $this->_read(4));
190
-		switch ($magic = array_shift($unpacked))
190
+		switch($magic = array_shift($unpacked))
191 191
 		{
192 192
 			case -34:
193 193
 				$be = false;
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 		}
203 203
 
204 204
 		// check file format revision - we currently only support 0
205
-		if (0 !== ($_rev = $this->_readInt($be))) {
205
+		if(0 !== ($_rev = $this->_readInt($be))) {
206 206
 			return false;
207 207
 		}
208 208
 
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 		fseek($this->_handle, $offset_original);
219 219
 		// read lengths and offsets of msgids
220 220
 		$original = [];
221
-		for ($i = 0; $i < $count; $i++) {
221
+		for($i = 0; $i < $count; $i++) {
222 222
 			$original[$i] = [
223 223
 				'length' => $this->_readInt($be),
224 224
 				'offset' => $this->_readInt($be)
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 		fseek($this->_handle, $offset_translat);
230 230
 		// read lengths and offsets of msgstrs
231 231
 		$translat = [];
232
-		for ($i = 0; $i < $count; $i++) {
232
+		for($i = 0; $i < $count; $i++) {
233 233
 			$translat[$i] = [
234 234
 				'length' => $this->_readInt($be),
235 235
 				'offset' => $this->_readInt($be)
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 		}
238 238
 
239 239
 		// read all
240
-		for ($i = 0; $i < $count; $i++) {
240
+		for($i = 0; $i < $count; $i++) {
241 241
 			$this->strings[$this->_readStr($original[$i])] =
242 242
 				$this->_readStr($translat[$i]);
243 243
 		}
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 		$this->_handle = null;
249 249
 
250 250
 		// check for meta info
251
-		if (isset($this->strings[''])) {
251
+		if(isset($this->strings[''])) {
252 252
 			$this->meta = parent::meta2array($this->strings['']);
253 253
 			unset($this->strings['']);
254 254
 		}
@@ -265,22 +265,22 @@  discard block
 block discarded – undo
265 265
 	 */
266 266
 	public function save($file = null)
267 267
 	{
268
-		if (!isset($file)) {
268
+		if(!isset($file)) {
269 269
 			$file = $this->file;
270 270
 		}
271 271
 
272 272
 		// open MO file
273
-		if (!is_resource($this->_handle = @fopen($file, 'wb'))) {
273
+		if(!is_resource($this->_handle = @fopen($file, 'wb'))) {
274 274
 			return false;
275 275
 		}
276 276
 		// lock MO file exclusively
277
-		if (!@flock($this->_handle, LOCK_EX)) {
277
+		if(!@flock($this->_handle, LOCK_EX)) {
278 278
 			@fclose($this->_handle);
279 279
 			return false;
280 280
 		}
281 281
 
282 282
 		// write magic number
283
-		if ($this->writeBigEndian) {
283
+		if($this->writeBigEndian) {
284 284
 			$this->_write(pack('c*', 0x95, 0x04, 0x12, 0xde));
285 285
 		} else {
286 286
 			$this->_write(pack('c*', 0xde, 0x12, 0x04, 0x95));
@@ -309,9 +309,9 @@  discard block
 block discarded – undo
309 309
 		$this->_writeInt($offset);
310 310
 
311 311
 		// unshift meta info
312
-		if ($this->meta) {
312
+		if($this->meta) {
313 313
 			$meta = '';
314
-			foreach ($this->meta as $key => $val) {
314
+			foreach($this->meta as $key => $val) {
315 315
 				$meta .= $key . ': ' . $val . "\n";
316 316
 			}
317 317
 			$strings = ['' => $meta] + $this->strings;
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 		}
321 321
 
322 322
 		// write offsets for original strings
323
-		foreach (array_keys($strings) as $o) {
323
+		foreach(array_keys($strings) as $o) {
324 324
 			$len = strlen($o);
325 325
 			$this->_writeInt($len);
326 326
 			$this->_writeInt($offset);
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 		}
329 329
 
330 330
 		// write offsets for translated strings
331
-		foreach ($strings as $t) {
331
+		foreach($strings as $t) {
332 332
 			$len = strlen($t);
333 333
 			$this->_writeInt($len);
334 334
 			$this->_writeInt($offset);
@@ -336,12 +336,12 @@  discard block
 block discarded – undo
336 336
 		}
337 337
 
338 338
 		// write original strings
339
-		foreach (array_keys($strings) as $o) {
339
+		foreach(array_keys($strings) as $o) {
340 340
 			$this->_writeStr($o);
341 341
 		}
342 342
 
343 343
 		// write translated strings
344
-		foreach ($strings as $t) {
344
+		foreach($strings as $t) {
345 345
 			$this->_writeStr($t);
346 346
 		}
347 347
 
Please login to merge, or discard this patch.
framework/I18N/core/MessageCache.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 */
77 77
 	public function setLifeTime($time)
78 78
 	{
79
-		$this->lifetime = (int)$time;
79
+		$this->lifetime = (int) $time;
80 80
 	}
81 81
 
82 82
 	/**
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 			return false;
122 122
 
123 123
 
124
-		$lastmodified = (int)$lastmodified;
124
+		$lastmodified = (int) $lastmodified;
125 125
 
126 126
 		if($lastmodified <= 0 || $lastmodified > filemtime($cache))
127 127
 			return false;
Please login to merge, or discard this patch.
framework/I18N/core/MessageSource_PHP.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 */
56 56
 	public function __construct($source)
57 57
 	{
58
-		$this->source = (string)$source;
58
+		$this->source = (string) $source;
59 59
 	}
60 60
 
61 61
 	/**
@@ -76,10 +76,10 @@  discard block
 block discarded – undo
76 76
 
77 77
 		foreach($translationUnit as $k => $unit)
78 78
 		{
79
-			$source = (string)$unit['source'];
80
-			$translations[$source][] = (string)$unit['target'];
81
-			$translations[$source][] = (string)$k;
82
-			$translations[$source][] = array_key_exists('note', $unit) ? (string)$unit['note'] : '';
79
+			$source = (string) $unit['source'];
80
+			$translations[$source][] = (string) $unit['target'];
81
+			$translations[$source][] = (string) $k;
82
+			$translations[$source][] = array_key_exists('note', $unit) ? (string) $unit['note'] : '';
83 83
 		}
84 84
 
85 85
 		return $translations;
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 		{
134 134
 			if(isset($variants[$i]{0}))
135 135
 			{
136
-				$variant .= ($variant)?'_' . $variants[$i]:$variants[$i];
136
+				$variant .= ($variant) ? '_' . $variants[$i] : $variants[$i];
137 137
 				$catalogues[] = $catalogue . $this->dataSeparator . $variant . $this->dataExt;
138 138
 			}
139 139
 		}
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		{
160 160
 			if(isset($variants[$i]{0}))
161 161
 			{
162
-				$variant .= ($variant)?'_' . $variants[$i]:$variants[$i];
162
+				$variant .= ($variant) ? '_' . $variants[$i] : $variants[$i];
163 163
 				$catalogues[] = $variant . '/' . $catalogue . $this->dataExt;
164 164
 			}
165 165
 		}
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 	 */
187 187
 	protected function getCatalogues($dir = null, $variant = null)
188 188
 	{
189
-		$dir = $dir?$dir:$this->source;
189
+		$dir = $dir ? $dir : $this->source;
190 190
 		$files = scandir($dir);
191 191
 		$catalogue = [];
192 192
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -418,7 +418,7 @@
 block discarded – undo
418 418
 	'trans-unit' => array(
419 419
 	)
420 420
 );
421
-EOD;
421
+eod;
422 422
 		return $php;
423 423
 	}
424 424
 }
Please login to merge, or discard this patch.
framework/I18N/core/MessageSource.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@
 block discarded – undo
126 126
 	 */
127 127
 	public static function &factory($type, $source = '.', $filename = '')
128 128
 	{
129
-		$types = ['XLIFF','PHP','gettext','Database'];
129
+		$types = ['XLIFF', 'PHP', 'gettext', 'Database'];
130 130
 
131 131
 		if(empty($filename) && !in_array($type, $types))
132 132
 			throw new Exception('Invalid type "' . $type . '", valid types are ' .
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -138,7 +138,7 @@
 block discarded – undo
138 138
 			$filename = dirname(__FILE__) . '/' . $class . '.php';
139 139
 						
140 140
 		if(is_file($filename) == false)
141
-			throw new Exception("File $filename not found");
141
+			throw new Exception("file $filename not found");
142 142
 						
143 143
 		include_once $filename;
144 144
 		
Please login to merge, or discard this patch.
framework/I18N/core/CultureInfo.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 	{
238 238
 		if(!empty($culture))
239 239
 		{
240
-			if (!preg_match('/^[_\\w]+$/', $culture))
240
+			if(!preg_match('/^[_\\w]+$/', $culture))
241 241
 				throw new Exception('Invalid culture supplied: ' . $culture);
242 242
 		}
243 243
 
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 			$value = $index[$i];
356 356
 			if($i < $k - 1 && isset($array[$value]))
357 357
 				$array = $array[$value];
358
-			elseif ($i == $k - 1 && isset($array[$value]))
358
+			elseif($i == $k - 1 && isset($array[$value]))
359 359
 				return $array[$value];
360 360
 		}
361 361
 	}
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 			$elements = $this->findInfo('NumberElements');
486 486
 			$patterns = $this->findInfo('NumberPatterns');
487 487
 			$currencies = $this->getCurrencies();
488
-			$data = [	'NumberElements' => $elements,
488
+			$data = ['NumberElements' => $elements,
489 489
 							'NumberPatterns' => $patterns,
490 490
 							'Currencies' => $currencies];
491 491
 
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
 		$neutral = [];
536 536
 		$specific = [];
537 537
 
538
-		while (false !== ($entry = $dir->read()))
538
+		while(false !== ($entry = $dir->read()))
539 539
 		{
540 540
 			if(is_file($dataDir . $entry)
541 541
 				&& substr($entry, -4) == $dataExt
Please login to merge, or discard this patch.