@@ -180,8 +180,7 @@ |
||
180 | 180 | { |
181 | 181 | $this->_row = $this->_statement->fetch(); |
182 | 182 | $this->_index = 0; |
183 | - } |
|
184 | - else |
|
183 | + } else |
|
185 | 184 | throw new TDbException('dbdatareader_rewind_invalid'); |
186 | 185 | } |
187 | 186 |
@@ -135,28 +135,24 @@ |
||
135 | 135 | { |
136 | 136 | $param->setData($data); |
137 | 137 | $this->_nextPageList = null; |
138 | - } |
|
139 | - else |
|
138 | + } else |
|
140 | 139 | { |
141 | 140 | $param->setData(array_slice($data, 0, $pageSize)); |
142 | 141 | $this->_nextPageList = array_slice($data, $pageSize - 1, $total); |
143 | 142 | } |
144 | - } |
|
145 | - else |
|
143 | + } else |
|
146 | 144 | { |
147 | 145 | if($total <= $pageSize) |
148 | 146 | { |
149 | 147 | $this->_prevPageList = array_slice($data, 0, $total); |
150 | 148 | $param->setData([]); |
151 | 149 | $this->_nextPageList = null; |
152 | - } |
|
153 | - elseif($total <= $pageSize * 2) |
|
150 | + } elseif($total <= $pageSize * 2) |
|
154 | 151 | { |
155 | 152 | $this->_prevPageList = array_slice($data, 0, $pageSize); |
156 | 153 | $param->setData(array_slice($data, $pageSize, $total)); |
157 | 154 | $this->_nextPageList = null; |
158 | - } |
|
159 | - else |
|
155 | + } else |
|
160 | 156 | { |
161 | 157 | $this->_prevPageList = array_slice($data, 0, $pageSize); |
162 | 158 | $param->setData(array_slice($data, $pageSize, $pageSize)); |
@@ -196,8 +196,7 @@ discard block |
||
196 | 196 | $this->_pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
197 | 197 | $this->_active = true; |
198 | 198 | $this->setConnectionCharset(); |
199 | - } |
|
200 | - catch(PDOException $e) |
|
199 | + } catch(PDOException $e) |
|
201 | 200 | { |
202 | 201 | throw new TDbException('dbconnection_open_failed', $e->getMessage()); |
203 | 202 | } |
@@ -350,8 +349,7 @@ discard block |
||
350 | 349 | { |
351 | 350 | $this->_pdo->beginTransaction(); |
352 | 351 | return $this->_transaction = Prado::createComponent($this->getTransactionClass(), $this); |
353 | - } |
|
354 | - else |
|
352 | + } else |
|
355 | 353 | throw new TDbException('dbconnection_connection_inactive'); |
356 | 354 | } |
357 | 355 |
@@ -51,9 +51,10 @@ |
||
51 | 51 | { |
52 | 52 | if($this->_dependencies !== null) |
53 | 53 | { |
54 | - foreach($this->_dependencies as $dependency) |
|
55 | - if($dependency->getHasChanged()) |
|
54 | + foreach($this->_dependencies as $dependency) { |
|
55 | + if($dependency->getHasChanged()) |
|
56 | 56 | return true; |
57 | + } |
|
57 | 58 | } |
58 | 59 | return false; |
59 | 60 | } |
@@ -160,8 +160,7 @@ discard block |
||
160 | 160 | { |
161 | 161 | $am = self::$_application->getAssetManager(); |
162 | 162 | $url = $am->publishFilePath(self::getPathOfNamespace('Prado\\' . $logoName, '.gif')); |
163 | - } |
|
164 | - else |
|
163 | + } else |
|
165 | 164 | $url = 'http://pradosoft.github.io/docs/' . $logoName . '.gif'; |
166 | 165 | return '<a title="Powered by PRADO" href="https://github.com/pradosoft/prado" target="_blank"><img src="' . $url . '" style="border-width:0px;" alt="Powered by PRADO" /></a>'; |
167 | 166 | } |
@@ -213,8 +212,7 @@ discard block |
||
213 | 212 | if(self::$_application !== null && ($errorHandler = self::$_application->getErrorHandler()) !== null) |
214 | 213 | { |
215 | 214 | $errorHandler->handleError(null, $exception); |
216 | - } |
|
217 | - else |
|
215 | + } else |
|
218 | 216 | { |
219 | 217 | echo $exception; |
220 | 218 | } |
@@ -322,14 +320,14 @@ discard block |
||
322 | 320 | break; |
323 | 321 | default: |
324 | 322 | $s = '$args[1]'; |
325 | - for($i = 2;$i < $n;++$i) |
|
326 | - $s .= ",\$args[$i]"; |
|
323 | + for($i = 2;$i < $n;++$i) { |
|
324 | + $s .= ",\$args[$i]"; |
|
325 | + } |
|
327 | 326 | eval("\$component=new $type($s);"); |
328 | 327 | return $component; |
329 | 328 | break; |
330 | 329 | } |
331 | - } |
|
332 | - else |
|
330 | + } else |
|
333 | 331 | return new $type; |
334 | 332 | } |
335 | 333 | |
@@ -383,8 +381,7 @@ discard block |
||
383 | 381 | if($className === '*') // a directory |
384 | 382 | { |
385 | 383 | self::$_usings[substr($namespace, 0, $pos)] = $path; |
386 | - } |
|
387 | - else // a file |
|
384 | + } else // a file |
|
388 | 385 | { |
389 | 386 | //self::$_usings[$namespace]=$path; |
390 | 387 | if(!$checkClassExistence || (!class_exists($className, false) && !interface_exists($className, false))) |
@@ -394,8 +391,7 @@ discard block |
||
394 | 391 | include_once($path); |
395 | 392 | if(class_exists($namespace, false) || interface_exists($namespace, false)) |
396 | 393 | class_alias($namespace, $className); |
397 | - } |
|
398 | - catch(\Exception $e) |
|
394 | + } catch(\Exception $e) |
|
399 | 395 | { |
400 | 396 | if($checkClassExistence && !class_exists($className, false)) |
401 | 397 | throw new TInvalidOperationException('prado_component_unknown', $className, $e->getMessage()); |
@@ -471,8 +467,7 @@ discard block |
||
471 | 467 | self::$_aliases[$alias] = $rp; |
472 | 468 | else |
473 | 469 | throw new TInvalidDataValueException('prado_aliasname_invalid', $alias); |
474 | - } |
|
475 | - else |
|
470 | + } else |
|
476 | 471 | throw new TInvalidDataValueException('prado_alias_invalid', $alias, $path); |
477 | 472 | } |
478 | 473 | |
@@ -517,8 +512,7 @@ discard block |
||
517 | 512 | echo "'" . substr($str, 0, 70) . "...'"; |
518 | 513 | else |
519 | 514 | echo "'" . $str . "'"; |
520 | - } |
|
521 | - elseif (is_int($item) || is_float($item)) |
|
515 | + } elseif (is_int($item) || is_float($item)) |
|
522 | 516 | echo $item; |
523 | 517 | elseif (is_object($item)) |
524 | 518 | echo get_class($item); |
@@ -613,8 +607,7 @@ discard block |
||
613 | 607 | if(isset($trace[0]['file']) && isset($trace[0]['line'])) |
614 | 608 | $msg .= " (line {$trace[0]['line']}, {$trace[0]['file']})"; |
615 | 609 | $level = TLogger::DEBUG; |
616 | - } |
|
617 | - else |
|
610 | + } else |
|
618 | 611 | $level = TLogger::INFO; |
619 | 612 | self::log($msg, $level, $category, $ctl); |
620 | 613 | } |
@@ -677,8 +670,9 @@ discard block |
||
677 | 670 | $app = Prado::getApplication()->getGlobalization(false); |
678 | 671 | |
679 | 672 | $params = []; |
680 | - foreach($parameters as $key => $value) |
|
681 | - $params['{' . $key . '}'] = $value; |
|
673 | + foreach($parameters as $key => $value) { |
|
674 | + $params['{' . $key . '}'] = $value; |
|
675 | + } |
|
682 | 676 | |
683 | 677 | //no translation handler provided |
684 | 678 | if($app === null || ($config = $app->getTranslationConfiguration()) === null) |
@@ -46,8 +46,9 @@ |
||
46 | 46 | array_shift($args); |
47 | 47 | $n = count($args); |
48 | 48 | $tokens = []; |
49 | - for($i = 0;$i < $n;++$i) |
|
50 | - $tokens['{' . $i . '}'] = TPropertyValue::ensureString($args[$i]); |
|
49 | + for($i = 0;$i < $n;++$i) { |
|
50 | + $tokens['{' . $i . '}'] = TPropertyValue::ensureString($args[$i]); |
|
51 | + } |
|
51 | 52 | parent::__construct(strtr($errorMessage, $tokens)); |
52 | 53 | } |
53 | 54 |
@@ -132,9 +132,10 @@ |
||
132 | 132 | */ |
133 | 133 | public function isInRole($role) |
134 | 134 | { |
135 | - foreach($this->getRoles() as $r) |
|
136 | - if(strcasecmp($role, $r) === 0) |
|
135 | + foreach($this->getRoles() as $r) { |
|
136 | + if(strcasecmp($role, $r) === 0) |
|
137 | 137 | return true; |
138 | + } |
|
138 | 139 | return false; |
139 | 140 | } |
140 | 141 |
@@ -190,8 +190,9 @@ discard block |
||
190 | 190 | |
191 | 191 | $this->sortPriorities(); |
192 | 192 | $this->_fd = []; |
193 | - foreach($this->_d as $priority => $itemsatpriority) |
|
194 | - $this->_fd = array_merge($this->_fd, $itemsatpriority); |
|
193 | + foreach($this->_d as $priority => $itemsatpriority) { |
|
194 | + $this->_fd = array_merge($this->_fd, $itemsatpriority); |
|
195 | + } |
|
195 | 196 | return $this->_fd; |
196 | 197 | } |
197 | 198 | |
@@ -313,9 +314,10 @@ discard block |
||
313 | 314 | public function priorityOf($item) |
314 | 315 | { |
315 | 316 | $this->sortPriorities(); |
316 | - foreach($this->_d as $priority => $items) |
|
317 | - if(($index = array_search($item, $items, true)) !== false) |
|
317 | + foreach($this->_d as $priority => $items) { |
|
318 | + if(($index = array_search($item, $items, true)) !== false) |
|
318 | 319 | return $priority; |
320 | + } |
|
319 | 321 | return false; |
320 | 322 | } |
321 | 323 | |
@@ -327,9 +329,10 @@ discard block |
||
327 | 329 | public function priorityAt($key) |
328 | 330 | { |
329 | 331 | $this->sortPriorities(); |
330 | - foreach($this->_d as $priority => $items) |
|
331 | - if(array_key_exists($key, $items)) |
|
332 | + foreach($this->_d as $priority => $items) { |
|
333 | + if(array_key_exists($key, $items)) |
|
332 | 334 | return $priority; |
335 | + } |
|
333 | 336 | return false; |
334 | 337 | } |
335 | 338 | |
@@ -354,10 +357,11 @@ discard block |
||
354 | 357 | |
355 | 358 | if(!$this->_r) |
356 | 359 | { |
357 | - foreach($this->_d as $innerpriority => $items) |
|
358 | - if(array_key_exists($key, $items)) |
|
360 | + foreach($this->_d as $innerpriority => $items) { |
|
361 | + if(array_key_exists($key, $items)) |
|
359 | 362 | { |
360 | 363 | unset($this->_d[$innerpriority][$key]); |
364 | + } |
|
361 | 365 | $this->_c--; |
362 | 366 | if(count($this->_d[$innerpriority]) === 0) |
363 | 367 | unset($this->_d[$innerpriority]); |
@@ -365,13 +369,11 @@ discard block |
||
365 | 369 | if(!isset($this->_d[$priority])) { |
366 | 370 | $this->_d[$priority] = [$key => $value]; |
367 | 371 | $this->_o = false; |
368 | - } |
|
369 | - else |
|
372 | + } else |
|
370 | 373 | $this->_d[$priority][$key] = $value; |
371 | 374 | $this->_c++; |
372 | 375 | $this->_fd = null; |
373 | - } |
|
374 | - else |
|
376 | + } else |
|
375 | 377 | throw new TInvalidOperationException('map_readonly', get_class($this)); |
376 | 378 | return $priority; |
377 | 379 | } |
@@ -398,10 +400,11 @@ discard block |
||
398 | 400 | if($priority === false) |
399 | 401 | { |
400 | 402 | $this->sortPriorities(); |
401 | - foreach($this->_d as $priority => $items) |
|
402 | - if(array_key_exists($key, $items)) |
|
403 | + foreach($this->_d as $priority => $items) { |
|
404 | + if(array_key_exists($key, $items)) |
|
403 | 405 | { |
404 | 406 | $value = $this->_d[$priority][$key]; |
407 | + } |
|
405 | 408 | unset($this->_d[$priority][$key]); |
406 | 409 | $this->_c--; |
407 | 410 | if(count($this->_d[$priority]) === 0) |
@@ -413,8 +416,7 @@ discard block |
||
413 | 416 | return $value; |
414 | 417 | } |
415 | 418 | return null; |
416 | - } |
|
417 | - else |
|
419 | + } else |
|
418 | 420 | { |
419 | 421 | $priority = (string)round(TPropertyValue::ensureFloat($priority), $this->_p); |
420 | 422 | if(isset($this->_d[$priority]) && (isset($this->_d[$priority][$key]) || array_key_exists($key, $this->_d[$priority]))) |
@@ -428,12 +430,10 @@ discard block |
||
428 | 430 | } |
429 | 431 | $this->_fd = null; |
430 | 432 | return $value; |
431 | - } |
|
432 | - else |
|
433 | + } else |
|
433 | 434 | return null; |
434 | 435 | } |
435 | - } |
|
436 | - else |
|
436 | + } else |
|
437 | 437 | throw new TInvalidOperationException('map_readonly', get_class($this)); |
438 | 438 | } |
439 | 439 | |
@@ -442,9 +442,10 @@ discard block |
||
442 | 442 | */ |
443 | 443 | public function clear() |
444 | 444 | { |
445 | - foreach($this->_d as $priority => $items) |
|
446 | - foreach(array_keys($items) as $key) |
|
445 | + foreach($this->_d as $priority => $items) { |
|
446 | + foreach(array_keys($items) as $key) |
|
447 | 447 | $this->remove($key); |
448 | + } |
|
448 | 449 | } |
449 | 450 | |
450 | 451 | /** |
@@ -526,15 +527,14 @@ discard block |
||
526 | 527 | $this->add($key, $value, $priority); |
527 | 528 | } |
528 | 529 | } |
529 | - } |
|
530 | - elseif(is_array($data) || $data instanceof \Traversable) |
|
530 | + } elseif(is_array($data) || $data instanceof \Traversable) |
|
531 | 531 | { |
532 | 532 | if($this->getCount() > 0) |
533 | 533 | $this->clear(); |
534 | - foreach($data as $key => $value) |
|
535 | - $this->add($key, $value); |
|
536 | - } |
|
537 | - elseif($data !== null) |
|
534 | + foreach($data as $key => $value) { |
|
535 | + $this->add($key, $value); |
|
536 | + } |
|
537 | + } elseif($data !== null) |
|
538 | 538 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
539 | 539 | } |
540 | 540 | |
@@ -551,16 +551,16 @@ discard block |
||
551 | 551 | { |
552 | 552 | foreach($data->getPriorities() as $priority) |
553 | 553 | { |
554 | - foreach($data->itemsAtPriority($priority) as $key => $value) |
|
555 | - $this->add($key, $value, $priority); |
|
554 | + foreach($data->itemsAtPriority($priority) as $key => $value) { |
|
555 | + $this->add($key, $value, $priority); |
|
556 | + } |
|
556 | 557 | } |
557 | - } |
|
558 | - elseif(is_array($data) || $data instanceof \Traversable) |
|
558 | + } elseif(is_array($data) || $data instanceof \Traversable) |
|
559 | 559 | { |
560 | - foreach($data as $key => $value) |
|
561 | - $this->add($key, $value); |
|
562 | - } |
|
563 | - elseif($data !== null) |
|
560 | + foreach($data as $key => $value) { |
|
561 | + $this->add($key, $value); |
|
562 | + } |
|
563 | + } elseif($data !== null) |
|
564 | 564 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
565 | 565 | } |
566 | 566 |
@@ -208,8 +208,9 @@ discard block |
||
208 | 208 | |
209 | 209 | $this->sortPriorities(); |
210 | 210 | $this->_fd = []; |
211 | - foreach($this->_d as $priority => $itemsatpriority) |
|
212 | - $this->_fd = array_merge($this->_fd, $itemsatpriority); |
|
211 | + foreach($this->_d as $priority => $itemsatpriority) { |
|
212 | + $this->_fd = array_merge($this->_fd, $itemsatpriority); |
|
213 | + } |
|
213 | 214 | return $this->_fd; |
214 | 215 | } |
215 | 216 | |
@@ -318,9 +319,10 @@ discard block |
||
318 | 319 | if($preserveCache) { |
319 | 320 | $this->sortPriorities(); |
320 | 321 | $cc = 0; |
321 | - foreach($this->_d as $prioritykey => $items) |
|
322 | - if($prioritykey >= $priority) |
|
322 | + foreach($this->_d as $prioritykey => $items) { |
|
323 | + if($prioritykey >= $priority) |
|
323 | 324 | break; |
325 | + } |
|
324 | 326 | else |
325 | 327 | $cc += count($items); |
326 | 328 | |
@@ -391,8 +393,7 @@ discard block |
||
391 | 393 | } |
392 | 394 | $this->removeAtIndexInPriority($p[1], $p[0]); |
393 | 395 | return $p[2]; |
394 | - } |
|
395 | - else |
|
396 | + } else |
|
396 | 397 | throw new TInvalidDataValueException('list_item_inexistent'); |
397 | 398 | } |
398 | 399 | |
@@ -454,8 +455,9 @@ discard block |
||
454 | 455 | throw new TInvalidOperationException('list_readonly', get_class($this)); |
455 | 456 | |
456 | 457 | foreach($this->_d as $priority => $items) { |
457 | - for($index = count($items) - 1;$index >= 0;$index--) |
|
458 | - $this->removeAtIndexInPriority($index, $priority); |
|
458 | + for($index = count($items) - 1;$index >= 0;$index--) { |
|
459 | + $this->removeAtIndexInPriority($index, $priority); |
|
460 | + } |
|
459 | 461 | unset($this->_d[$priority]); |
460 | 462 | } |
461 | 463 | } |
@@ -647,14 +649,16 @@ discard block |
||
647 | 649 | $this->clear(); |
648 | 650 | foreach($data->getPriorities() as $priority) |
649 | 651 | { |
650 | - foreach($data->itemsAtPriority($priority) as $index => $item) |
|
651 | - $this->insertAtIndexInPriority($item, $index, $priority); |
|
652 | + foreach($data->itemsAtPriority($priority) as $index => $item) { |
|
653 | + $this->insertAtIndexInPriority($item, $index, $priority); |
|
654 | + } |
|
652 | 655 | } |
653 | 656 | } elseif(is_array($data) || $data instanceof \Traversable) { |
654 | 657 | if($this->getCount() > 0) |
655 | 658 | $this->clear(); |
656 | - foreach($data as $key => $item) |
|
657 | - $this->add($item); |
|
659 | + foreach($data as $key => $item) { |
|
660 | + $this->add($item); |
|
661 | + } |
|
658 | 662 | } elseif($data !== null) |
659 | 663 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
660 | 664 | } |
@@ -673,17 +677,17 @@ discard block |
||
673 | 677 | { |
674 | 678 | foreach($data->getPriorities() as $priority) |
675 | 679 | { |
676 | - foreach($data->itemsAtPriority($priority) as $index => $item) |
|
677 | - $this->insertAtIndexInPriority($item, false, $priority); |
|
680 | + foreach($data->itemsAtPriority($priority) as $index => $item) { |
|
681 | + $this->insertAtIndexInPriority($item, false, $priority); |
|
682 | + } |
|
678 | 683 | } |
679 | - } |
|
680 | - elseif(is_array($data) || $data instanceof \Traversable) |
|
684 | + } elseif(is_array($data) || $data instanceof \Traversable) |
|
681 | 685 | { |
682 | - foreach($data as $priority => $item) |
|
683 | - $this->add($item); |
|
686 | + foreach($data as $priority => $item) { |
|
687 | + $this->add($item); |
|
688 | + } |
|
684 | 689 | |
685 | - } |
|
686 | - elseif($data !== null) |
|
690 | + } elseif($data !== null) |
|
687 | 691 | throw new TInvalidDataTypeException('map_data_not_iterable'); |
688 | 692 | } |
689 | 693 |