Turn some returns into exceptions

This commit is contained in:
Dennis Eichhorn 2018-07-18 00:12:53 +02:00
parent 46465207a7
commit b82213d97f
4 changed files with 10 additions and 10 deletions

View File

@ -95,7 +95,7 @@ abstract class GrammarAbstract
{ {
return trim( return trim(
implode(' ', implode(' ',
array_filter( \array_filter(
$this->compileComponents($query), $this->compileComponents($query),
function ($value) { function ($value) {
return (string) $value !== ''; return (string) $value !== '';
@ -169,13 +169,13 @@ abstract class GrammarAbstract
$expression = ''; $expression = '';
foreach ($elements as $key => $element) { foreach ($elements as $key => $element) {
if (is_string($element) && $element !== '*') { if (\is_string($element) && $element !== '*') {
if (strpos($element, '.') === false) { if (\strpos($element, '.') === false) {
$prefix = ''; $prefix = '';
} }
$expression .= $this->compileSystem($element, $prefix) . ', '; $expression .= $this->compileSystem($element, $prefix) . ', ';
} elseif (is_string($element) && $element === '*') { } elseif (\is_string($element) && $element === '*') {
$expression .= '*, '; $expression .= '*, ';
} elseif ($element instanceof \Closure) { } elseif ($element instanceof \Closure) {
$expression .= $element() . ', '; $expression .= $element() . ', ';
@ -204,9 +204,9 @@ abstract class GrammarAbstract
$expression = ''; $expression = '';
foreach ($elements as $key => $element) { foreach ($elements as $key => $element) {
if (is_string($element) && $element !== '*') { if (\is_string($element) && $element !== '*') {
$expression .= $this->compileSystem($element, $prefix) . ', '; $expression .= $this->compileSystem($element, $prefix) . ', ';
} elseif (is_string($element) && $element === '*') { } elseif (\is_string($element) && $element === '*') {
$expression .= '*, '; $expression .= '*, ';
} elseif ($element instanceof \Closure) { } elseif ($element instanceof \Closure) {
$expression .= $element() . ', '; $expression .= $element() . ', ';

View File

@ -63,6 +63,6 @@ class TableException extends \PDOException
$table = \substr($message, $pos1 + 1, $pos2 - $pos1 - 1); $table = \substr($message, $pos1 + 1, $pos2 - $pos1 - 1);
return $table === false ? '' : $table; return $table === false ? $message : $table;
} }
} }

View File

@ -122,7 +122,7 @@ final class Money implements \Serializable
$right = \substr($right, 0, self::MAX_DECIMALS); $right = \substr($right, 0, self::MAX_DECIMALS);
if ($right === false) { if ($right === false) {
return 0; throw new \Exception();
} }
return ((int) $left) * 10 ** self::MAX_DECIMALS + (int) \str_pad($right, self::MAX_DECIMALS, '0'); return ((int) $left) * 10 ** self::MAX_DECIMALS + (int) \str_pad($right, self::MAX_DECIMALS, '0');
@ -196,7 +196,7 @@ final class Money implements \Serializable
$left = \substr($value, 0, -self::MAX_DECIMALS); $left = \substr($value, 0, -self::MAX_DECIMALS);
$right = \substr($value, -self::MAX_DECIMALS); $right = \substr($value, -self::MAX_DECIMALS);
if ($left === false || $right === false) { if ($left === false || $right === false) {
return '0'; throw new \Exception();
} }
return ($decimals > 0) ? number_format((float) $left, 0, $this->decimal, $this->thousands) . $this->decimal . \substr($right, 0, $decimals) : $left; return ($decimals > 0) ? number_format((float) $left, 0, $this->decimal, $this->thousands) . $this->decimal . \substr($right, 0, $decimals) : $left;

View File

@ -158,7 +158,7 @@ final class Http implements UriInterface
$path = \substr($this->path, 0, -4); $path = \substr($this->path, 0, -4);
if ($path === false) { if ($path === false) {
return; throw new \Exception();
} }
$this->path = $path; $this->path = $path;