diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Context.php | 2 | ||||
-rw-r--r-- | src/Fragments/DataTypeFragment.php | 2 | ||||
-rw-r--r-- | src/Fragments/FieldListFragment.php | 5 | ||||
-rw-r--r-- | src/TokensList.php | 3 | ||||
-rw-r--r-- | src/Utils/Misc.php | 9 | ||||
-rw-r--r-- | src/Utils/Query.php | 9 |
6 files changed, 18 insertions, 12 deletions
diff --git a/src/Context.php b/src/Context.php index d42211f..03fc0d1 100644 --- a/src/Context.php +++ b/src/Context.php @@ -426,6 +426,8 @@ abstract class Context * Sets the SQL mode. * * @param string $mode The list of modes. If empty, the mode is reset. + * + * @return void */ public static function setMode($mode = '') { diff --git a/src/Fragments/DataTypeFragment.php b/src/Fragments/DataTypeFragment.php index 6a44b78..6ef4fde 100644 --- a/src/Fragments/DataTypeFragment.php +++ b/src/Fragments/DataTypeFragment.php @@ -157,7 +157,7 @@ class DataTypeFragment extends Fragment { $tmp = ''; if (!empty($fragment->parameters)) { - $tmp = '('. implode(', ', $fragment->parameters) . ')'; + $tmp = '(' . implode(', ', $fragment->parameters) . ')'; } return trim( $fragment->name . ' ' . $tmp . ' ' diff --git a/src/Fragments/FieldListFragment.php b/src/Fragments/FieldListFragment.php index cc769e0..cc070c1 100644 --- a/src/Fragments/FieldListFragment.php +++ b/src/Fragments/FieldListFragment.php @@ -80,6 +80,11 @@ class FieldListFragment extends Fragment return $ret; } + /** + * @param FieldFragment[] $fragment The fragment to be built. + * + * @return string + */ public static function build($fragment) { $ret = array(); diff --git a/src/TokensList.php b/src/TokensList.php index be9124c..93fb7c0 100644 --- a/src/TokensList.php +++ b/src/TokensList.php @@ -43,6 +43,7 @@ class TokensList implements \ArrayAccess * Constructor. * * @param array $tokens The initial array of tokens. + * @param int $count The count of tokens in the initial array. */ public function __construct(array $tokens = array(), $count = -1) { @@ -57,7 +58,7 @@ class TokensList implements \ArrayAccess /** * Builds an array of tokens by merging their raw value. * - * @param string|array|TokensList $tokens + * @param string|Token[]|TokensList $list * * @return string */ diff --git a/src/Utils/Misc.php b/src/Utils/Misc.php index 85c2399..41c62ed 100644 --- a/src/Utils/Misc.php +++ b/src/Utils/Misc.php @@ -26,14 +26,17 @@ class Misc /** * Gets a list of all aliases and their original names. * - * @param SelectStatement $statement The statement to be processed. - * @param string $database The name of the database. + * @param Statement $statement The statement to be processed. + * @param string $database The name of the database. * * @return array */ public static function getAliases($statement, $database) { - if ((empty($statement->from)) || (empty($statement->expr))) { + if (!($statement instanceof SelectStatement) + || (empty($statement->from)) + || (empty($statement->expr)) + ) { return array(); } diff --git a/src/Utils/Query.php b/src/Utils/Query.php index d4c01af..1f05711 100644 --- a/src/Utils/Query.php +++ b/src/Utils/Query.php @@ -12,6 +12,7 @@ use SqlParser\Lexer; use SqlParser\Parser; use SqlParser\Statement; use SqlParser\Token; +use SqlParser\TokensList; use SqlParser\Fragments\FieldFragment; use SqlParser\Statements\AlterStatement; use SqlParser\Statements\AnalyzeStatement; @@ -672,12 +673,6 @@ class Query */ $ret = ''; - /** - * The clauses of this type of statement and their index. - * @var array - */ - $clauses = array_keys($statement::$CLAUSES); - // If there is only one clause, `replaceClause()` should be used. if ($count === 1) { return static::replaceClause( @@ -697,7 +692,7 @@ class Query // Adding everything between this and next replacement. if ($i + 1 !== $count) { - $ret .= static::getClause($statement, $list, $ops[$i][0], $ops[$i + 1][0], -1) . ' '; + $ret .= static::getClause($statement, $list, $ops[$i][0], $ops[$i + 1][0]) . ' '; } } |