summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Components/AlterOperation.php5
-rw-r--r--src/Components/Array2d.php11
-rw-r--r--src/Components/ArrayObj.php6
-rw-r--r--src/Components/Condition.php5
-rw-r--r--src/Components/CreateDefinition.php4
-rw-r--r--src/Components/DataType.php4
-rw-r--r--src/Components/Expression.php7
-rw-r--r--src/Components/ExpressionArray.php6
-rw-r--r--src/Components/FunctionCall.php6
-rw-r--r--src/Components/IntoKeyword.php6
-rw-r--r--src/Components/JoinKeyword.php4
-rw-r--r--src/Components/Key.php4
-rw-r--r--src/Components/Limit.php2
-rw-r--r--src/Components/OptionsArray.php8
-rw-r--r--src/Components/OrderKeyword.php4
-rw-r--r--src/Components/ParameterDefinition.php6
-rw-r--r--src/Components/Reference.php6
-rw-r--r--src/Components/RenameOperation.php6
-rw-r--r--src/Components/SetOperation.php4
-rw-r--r--src/Context.php1
-rw-r--r--src/Lexer.php11
-rw-r--r--src/Parser.php11
-rw-r--r--src/Statement.php14
-rw-r--r--src/Statements/AlterStatement.php4
-rw-r--r--src/Statements/CreateStatement.php3
-rw-r--r--src/Utils/BufferedQuery.php5
-rw-r--r--src/Utils/Formatter.php24
-rw-r--r--src/Utils/Misc.php3
-rw-r--r--src/Utils/Query.php14
-rw-r--r--tests/TestGenerator.php14
-rw-r--r--tests/Utils/BufferedQueryTest.php2
-rw-r--r--tests/bootstrap.php3
32 files changed, 172 insertions, 41 deletions
diff --git a/src/Components/AlterOperation.php b/src/Components/AlterOperation.php
index d704f25..6b81a46 100644
--- a/src/Components/AlterOperation.php
+++ b/src/Components/AlterOperation.php
@@ -108,6 +108,7 @@ class AlterOperation extends Component
/**
* Counts brackets.
+ *
* @var int $brackets
*/
$brackets = 0;
@@ -123,13 +124,15 @@ class AlterOperation extends Component
*
* 2 -------------------------[ , ]-----------------------> 0
*
- * @var int
+ * @var int $state
*/
$state = 0;
for (; $list->idx < $list->count; ++$list->idx) {
+
/**
* Token parsed at this moment.
+ *
* @var Token $token
*/
$token = $list->tokens[$list->idx];
diff --git a/src/Components/Array2d.php b/src/Components/Array2d.php
index c616fdb..268dcea 100644
--- a/src/Components/Array2d.php
+++ b/src/Components/Array2d.php
@@ -38,7 +38,8 @@ class Array2d extends Component
/**
* The number of values in each set.
- * @var int
+ *
+ * @var int $count
*/
$count = -1;
@@ -47,18 +48,20 @@ class Array2d extends Component
*
* Below are the states of the parser.
*
- * 0 ----------------------[ array ]---------------------> 1
+ * 0 ----------------------[ array ]----------------------> 1
*
* 1 ------------------------[ , ]------------------------> 0
- * 1 -----------------------[ else ]----------------------> -1
+ * 1 -----------------------[ else ]----------------------> (END)
*
- * @var int
+ * @var int $state
*/
$state = 0;
for (; $list->idx < $list->count; ++$list->idx) {
+
/**
* Token parsed at this moment.
+ *
* @var Token $token
*/
$token = $list->tokens[$list->idx];
diff --git a/src/Components/ArrayObj.php b/src/Components/ArrayObj.php
index 422c81c..431ed6d 100644
--- a/src/Components/ArrayObj.php
+++ b/src/Components/ArrayObj.php
@@ -72,15 +72,17 @@ class ArrayObj extends Component
* 1 ------------------[ array element ]-----------------> 2
*
* 2 ------------------------[ , ]-----------------------> 1
- * 2 ------------------------[ ) ]-----------------------> -1
+ * 2 ------------------------[ ) ]-----------------------> (END)
*
- * @var int
+ * @var int $state
*/
$state = 0;
for (; $list->idx < $list->count; ++$list->idx) {
+
/**
* Token parsed at this moment.
+ *
* @var Token $token
*/
$token = $list->tokens[$list->idx];
diff --git a/src/Components/Condition.php b/src/Components/Condition.php
index 46cab2a..1f515dc 100644
--- a/src/Components/Condition.php
+++ b/src/Components/Condition.php
@@ -95,6 +95,7 @@ class Condition extends Component
/**
* Counts brackets.
+ *
* @var int $brackets
*/
$brackets = 0;
@@ -104,7 +105,8 @@ class Condition extends Component
* It is required to keep track of them because their structure contains
* the keyword `AND`, which is also an operator that delimits
* expressions.
- * @var bool
+ *
+ * @var bool $betweenBefore
*/
$betweenBefore = false;
@@ -112,6 +114,7 @@ class Condition extends Component
/**
* Token parsed at this moment.
+ *
* @var Token $token
*/
$token = $list->tokens[$list->idx];
diff --git a/src/Components/CreateDefinition.php b/src/Components/CreateDefinition.php
index 4dfbb7a..5671801 100644
--- a/src/Components/CreateDefinition.php
+++ b/src/Components/CreateDefinition.php
@@ -173,13 +173,15 @@ class CreateDefinition extends Component
* 5 ------------------------[ , ]-----------------------> 1
* 5 ------------------------[ ) ]-----------------------> 6 (-1)
*
- * @var int
+ * @var int $state
*/
$state = 0;
for (; $list->idx < $list->count; ++$list->idx) {
+
/**
* Token parsed at this moment.
+ *
* @var Token $token
*/
$token = $list->tokens[$list->idx];
diff --git a/src/Components/DataType.php b/src/Components/DataType.php
index 99c3918..48ce5b7 100644
--- a/src/Components/DataType.php
+++ b/src/Components/DataType.php
@@ -103,13 +103,15 @@ class DataType extends Component
*
* 1 ----------------[ size and options ]----------------> 2
*
- * @var int
+ * @var int $state
*/
$state = 0;
for (; $list->idx < $list->count; ++$list->idx) {
+
/**
* Token parsed at this moment.
+ *
* @var Token $token
*/
$token = $list->tokens[$list->idx];
diff --git a/src/Components/Expression.php b/src/Components/Expression.php
index 60f8554..11e7132 100644
--- a/src/Components/Expression.php
+++ b/src/Components/Expression.php
@@ -122,24 +122,28 @@ class Expression extends Component
/**
* Whether current tokens make an expression or a table reference.
+ *
* @var bool $isExpr
*/
$isExpr = false;
/**
* Whether a period was previously found.
+ *
* @var bool $dot
*/
$dot = false;
/**
* Whether an alias is expected. Is 2 if `AS` keyword was found.
+ *
* @var int $alias
*/
$alias = 0;
/**
* Counts brackets.
+ *
* @var int $brackets
*/
$brackets = 0;
@@ -150,13 +154,16 @@ class Expression extends Component
* string, if function was previously found;
* true, if opening bracket was previously found;
* null, in any other case.
+ *
* @var string|bool $prev
*/
$prev = null;
for (; $list->idx < $list->count; ++$list->idx) {
+
/**
* Token parsed at this moment.
+ *
* @var Token $token
*/
$token = $list->tokens[$list->idx];
diff --git a/src/Components/ExpressionArray.php b/src/Components/ExpressionArray.php
index 309972a..82e67c9 100644
--- a/src/Components/ExpressionArray.php
+++ b/src/Components/ExpressionArray.php
@@ -44,15 +44,17 @@ class ExpressionArray extends Component
* 0 ----------------------[ array ]---------------------> 1
*
* 1 ------------------------[ , ]------------------------> 0
- * 1 -----------------------[ else ]----------------------> -1
+ * 1 -----------------------[ else ]----------------------> (END)
*
- * @var int
+ * @var int $state
*/
$state = 0;
for (; $list->idx < $list->count; ++$list->idx) {
+
/**
* Token parsed at this moment.
+ *
* @var Token $token
*/
$token = $list->tokens[$list->idx];
diff --git a/src/Components/FunctionCall.php b/src/Components/FunctionCall.php
index b86eeb8..43eb082 100644
--- a/src/Components/FunctionCall.php
+++ b/src/Components/FunctionCall.php
@@ -73,15 +73,17 @@ class FunctionCall extends Component
*
* 0 ----------------------[ name ]-----------------------> 1
*
- * 1 --------------------[ parameters ]-------------------> -1
+ * 1 --------------------[ parameters ]-------------------> (END)
*
- * @var int
+ * @var int $state
*/
$state = 0;
for (; $list->idx < $list->count; ++$list->idx) {
+
/**
* Token parsed at this moment.
+ *
* @var Token $token
*/
$token = $list->tokens[$list->idx];
diff --git a/src/Components/IntoKeyword.php b/src/Components/IntoKeyword.php
index 9b52c7c..7a91064 100644
--- a/src/Components/IntoKeyword.php
+++ b/src/Components/IntoKeyword.php
@@ -65,17 +65,19 @@ class IntoKeyword extends Component
* 0 -----------------------[ name ]----------------------> 1
* 0 ---------------------[ OUTFILE ]---------------------> 2
*
- * 1 ------------------------[ ( ]------------------------> -1
+ * 1 ------------------------[ ( ]------------------------> (END)
*
* 2 ---------------------[ filename ]--------------------> 1
*
- * @var int
+ * @var int $state
*/
$state = 0;
for (; $list->idx < $list->count; ++$list->idx) {
+
/**
* Token parsed at this moment.
+ *
* @var Token $token
*/
$token = $list->tokens[$list->idx];
diff --git a/src/Components/JoinKeyword.php b/src/Components/JoinKeyword.php
index 171ad98..237022a 100644
--- a/src/Components/JoinKeyword.php
+++ b/src/Components/JoinKeyword.php
@@ -86,7 +86,7 @@ class JoinKeyword extends Component
*
* 3 --------------------[ conditions ]-------------------> 0
*
- * @var int
+ * @var int $state
*/
$state = 0;
@@ -98,8 +98,10 @@ class JoinKeyword extends Component
}
for (; $list->idx < $list->count; ++$list->idx) {
+
/**
* Token parsed at this moment.
+ *
* @var Token $token
*/
$token = $list->tokens[$list->idx];
diff --git a/src/Components/Key.php b/src/Components/Key.php
index bb8bbf0..1364a8c 100644
--- a/src/Components/Key.php
+++ b/src/Components/Key.php
@@ -107,13 +107,15 @@ class Key extends Component
*
* 2 ---------------------[ options ]---------------------> 3
*
- * @var int
+ * @var int $state
*/
$state = 0;
for (; $list->idx < $list->count; ++$list->idx) {
+
/**
* Token parsed at this moment.
+ *
* @var Token $token
*/
$token = $list->tokens[$list->idx];
diff --git a/src/Components/Limit.php b/src/Components/Limit.php
index a821b9f..8622c96 100644
--- a/src/Components/Limit.php
+++ b/src/Components/Limit.php
@@ -65,8 +65,10 @@ class Limit extends Component
$offset = false;
for (; $list->idx < $list->count; ++$list->idx) {
+
/**
* Token parsed at this moment.
+ *
* @var Token $token
*/
$token = $list->tokens[$list->idx];
diff --git a/src/Components/OptionsArray.php b/src/Components/OptionsArray.php
index da2ec8d..6b43844 100644
--- a/src/Components/OptionsArray.php
+++ b/src/Components/OptionsArray.php
@@ -57,24 +57,28 @@ class OptionsArray extends Component
/**
* The ID that will be assigned to duplicate options.
+ *
* @var int $lastAssignedId
*/
$lastAssignedId = count($options) + 1;
/**
* The option that was processed last time.
+ *
* @var array $lastOption
*/
$lastOption = null;
/**
* The index of the option that was processed last time.
+ *
* @var int $lastOptionId
*/
$lastOptionId = 0;
/**
* Counts brackets.
+ *
* @var int $brackets
*/
$brackets = 0;
@@ -90,13 +94,15 @@ class OptionsArray extends Component
*
* 2 ----------------------[ value ]----------------------> 0
*
- * @var int
+ * @var int $state
*/
$state = 0;
for (; $list->idx < $list->count; ++$list->idx) {
+
/**
* Token parsed at this moment.
+ *
* @var Token $token
*/
$token = $list->tokens[$list->idx];
diff --git a/src/Components/OrderKeyword.php b/src/Components/OrderKeyword.php
index b8b05c1..81bff2f 100644
--- a/src/Components/OrderKeyword.php
+++ b/src/Components/OrderKeyword.php
@@ -74,13 +74,15 @@ class OrderKeyword extends Component
* 1 ------------------------[ , ]------------------------> 0
* 1 -------------------[ ASC / DESC ]--------------------> 1
*
- * @var int
+ * @var int $state
*/
$state = 0;
for (; $list->idx < $list->count; ++$list->idx) {
+
/**
* Token parsed at this moment.
+ *
* @var Token $token
*/
$token = $list->tokens[$list->idx];
diff --git a/src/Components/ParameterDefinition.php b/src/Components/ParameterDefinition.php
index d10a460..79b4845 100644
--- a/src/Components/ParameterDefinition.php
+++ b/src/Components/ParameterDefinition.php
@@ -73,15 +73,17 @@ class ParameterDefinition extends Component
* 2 -------------------[ data type ]--------------------> 3
*
* 3 ------------------------[ , ]-----------------------> 1
- * 3 ------------------------[ ) ]-----------------------> -1
+ * 3 ------------------------[ ) ]-----------------------> (END)
*
- * @var int
+ * @var int $state
*/
$state = 0;
for (; $list->idx < $list->count; ++$list->idx) {
+
/**
* Token parsed at this moment.
+ *
* @var Token $token
*/
$token = $list->tokens[$list->idx];
diff --git a/src/Components/Reference.php b/src/Components/Reference.php
index fa46887..36d3971 100644
--- a/src/Components/Reference.php
+++ b/src/Components/Reference.php
@@ -92,15 +92,17 @@ class Reference extends Component
*
* 1 ---------------------[ columns ]--------------------> 2
*
- * 2 ---------------------[ options ]--------------------> -1
+ * 2 ---------------------[ options ]--------------------> (END)
*
- * @var int
+ * @var int $state
*/
$state = 0;
for (; $list->idx < $list->count; ++$list->idx) {
+
/**
* Token parsed at this moment.
+ *
* @var Token $token
*/
$token = $list->tokens[$list->idx];
diff --git a/src/Components/RenameOperation.php b/src/Components/RenameOperation.php
index cc9630c..34c62bb 100644
--- a/src/Components/RenameOperation.php
+++ b/src/Components/RenameOperation.php
@@ -64,15 +64,17 @@ class RenameOperation extends Component
* 2 ---------------------[ old name ]--------------------> 3
*
* 3 ------------------------[ , ]------------------------> 0
- * 3 -----------------------[ else ]----------------------> -1
+ * 3 -----------------------[ else ]----------------------> (END)
*
- * @var int
+ * @var int $state
*/
$state = 0;
for (; $list->idx < $list->count; ++$list->idx) {
+
/**
* Token parsed at this moment.
+ *
* @var Token $token
*/
$token = $list->tokens[$list->idx];
diff --git a/src/Components/SetOperation.php b/src/Components/SetOperation.php
index 25bb9e4..8b6af87 100644
--- a/src/Components/SetOperation.php
+++ b/src/Components/SetOperation.php
@@ -62,13 +62,15 @@ class SetOperation extends Component
* 1 ------------------------[ , ]------------------------> 0
* 1 ----------------------[ value ]----------------------> 1
*
- * @var int
+ * @var int $state
*/
$state = 0;
for (; $list->idx < $list->count; ++$list->idx) {
+
/**
* Token parsed at this moment.
+ *
* @var Token $token
*/
$token = $list->tokens[$list->idx];
diff --git a/src/Context.php b/src/Context.php
index c355534..d6602ce 100644
--- a/src/Context.php
+++ b/src/Context.php
@@ -450,6 +450,7 @@ abstract class Context
/**
* The number of replaces done by `preg_replace`.
* This actually represents whether a new context was generated or not.
+ *
* @var int $count
*/
$count = 0;
diff --git a/src/Lexer.php b/src/Lexer.php
index e11d5a2..1d18399 100644
--- a/src/Lexer.php
+++ b/src/Lexer.php
@@ -42,6 +42,7 @@ namespace SqlParser {
/**
* Forces usage of `UtfString` if the string is multibyte.
* `UtfString` may be slower, but it gives better results.
+ *
* @var bool
*/
define('USE_UTF_STRINGS', true);
@@ -242,13 +243,16 @@ namespace SqlParser {
/**
* Last processed token.
+ *
* @var Token $lastToken
*/
$lastToken = null;
for ($this->last = 0, $lastIdx = 0; $this->last < $this->len; $lastIdx = ++$this->last) {
+
/**
* The new token.
+ *
* @var Token $token
*/
$token = null;
@@ -392,23 +396,27 @@ namespace SqlParser {
/**
* Value to be returned.
+ *
* @var Token $ret
*/
$ret = null;
/**
* The value of `$this->last` where `$token` ends in `$this->str`.
+ *
* @var int $iEnd
*/
$iEnd = $this->last;
/**
* Whether last parsed character is a whitespace.
+ *
* @var bool $lastSpace
*/
$lastSpace = false;
for ($j = 1; $j < Context::KEYWORD_MAX_LENGTH && $this->last < $this->len; ++$j, ++$this->last) {
+
// Composed keywords shouldn't have more than one whitespace between
// keywords.
if (Context::isWhitespace($this->str[$this->last])) {
@@ -426,6 +434,7 @@ namespace SqlParser {
if (($flags = Context::isKeyword($token))) {
$ret = new Token($token, Token::TYPE_KEYWORD, $flags);
$iEnd = $this->last;
+
// We don't break so we find longest keyword.
// For example, `OR` and `ORDER` have a common prefix `OR`.
// If we stopped at `OR`, the parsing would be invalid.
@@ -448,12 +457,14 @@ namespace SqlParser {
/**
* Value to be returned.
+ *
* @var Token $ret
*/
$ret = null;
/**
* The value of `$this->last` where `$token` ends in `$this->str`.
+ *
* @var int $iEnd
*/
$iEnd = $this->last;
diff --git a/src/Parser.php b/src/Parser.php
index 11c83f3..d3a639c 100644
--- a/src/Parser.php
+++ b/src/Parser.php
@@ -332,30 +332,35 @@ namespace SqlParser {
/**
* Last transaction.
+ *
* @var TransactionStatement $lastTransaction
*/
$lastTransaction = null;
/**
* Last parsed statement.
+ *
* @var Statement $lastStatement
*/
$lastStatement = null;
/**
* Whether a union is parsed or not.
+ *
* @var bool $inUnion
*/
$inUnion = false;
/**
* The index of the last token from the last statement.
+ *
* @var int $prevLastIdx
*/
$prevLastIdx = -1;
/**
* The list of tokens.
+ *
* @var TokensList $list
*/
$list = &$this->list;
@@ -364,6 +369,7 @@ namespace SqlParser {
/**
* Token parsed at this moment.
+ *
* @var Token $token
*/
$token = $list->tokens[$list->idx];
@@ -419,12 +425,14 @@ namespace SqlParser {
/**
* The name of the class that is used for parsing.
+ *
* @var string $class
*/
$class = static::$STATEMENT_PARSERS[$token->value];
/**
* Processed statement.
+ *
* @var Statement $statement
*/
$statement = new $class($this, $this->list);
@@ -445,13 +453,16 @@ namespace SqlParser {
&& ($lastStatement instanceof SelectStatement)
&& ($statement instanceof SelectStatement)
) {
+
/**
* This SELECT statement.
+ *
* @var SelectStatement $statement
*/
/**
* Last SELECT statement.
+ *
* @var SelectStatement $lastStatement
*/
$lastStatement->union[] = $statement;
diff --git a/src/Statement.php b/src/Statement.php
index 8bf3d24..0568d93 100644
--- a/src/Statement.php
+++ b/src/Statement.php
@@ -103,6 +103,7 @@ abstract class Statement
{
/**
* Query to be returned.
+ *
* @var string $query
*/
$query = '';
@@ -111,12 +112,14 @@ abstract class Statement
/**
* The name of the clause.
+ *
* @var string $name
*/
$name = $clause[0];
/**
* The type of the clause.
+ *
* @see self::$CLAUSES
* @var int $type
*/
@@ -124,6 +127,7 @@ abstract class Statement
/**
* The builder (parser) of this clause.
+ *
* @var Component $class
*/
$class = Parser::$KEYWORD_PARSERS[$name]['class'];
@@ -131,6 +135,7 @@ abstract class Statement
/**
* The name of the field that is used as source for the builder.
* Same field is used to store the result of parsing.
+ *
* @var string $field
*/
$field = Parser::$KEYWORD_PARSERS[$name]['field'];
@@ -167,7 +172,8 @@ abstract class Statement
/**
* Array containing all list of clauses parsed.
* This is used to check for duplicates.
- * @var array
+ *
+ * @var array $parsedClauses
*/
$parsedClauses = array();
@@ -178,13 +184,16 @@ abstract class Statement
* Whether options were parsed or not.
* For statements that do not have any options this is set to `true` by
* default.
+ *
* @var bool $parsedOptions
*/
$parsedOptions = empty(static::$OPTIONS);
for (; $list->idx < $list->count; ++$list->idx) {
+
/**
* Token parsed at this moment.
+ *
* @var Token $token
*/
$token = $list->tokens[$list->idx];
@@ -213,18 +222,21 @@ abstract class Statement
/**
* The name of the class that is used for parsing.
+ *
* @var Component $class
*/
$class = null;
/**
* The name of the field where the result of the parsing is stored.
+ *
* @var string $field
*/
$field = null;
/**
* Parser's options.
+ *
* @var array $options
*/
$options = array();
diff --git a/src/Statements/AlterStatement.php b/src/Statements/AlterStatement.php
index 2c48181..31bbcb4 100644
--- a/src/Statements/AlterStatement.php
+++ b/src/Statements/AlterStatement.php
@@ -89,13 +89,15 @@ class AlterStatement extends Statement
*
* 1 -------------------------[ , ]-----------------------> 0
*
- * @var int
+ * @var int $state
*/
$state = 0;
for (; $list->idx < $list->count; ++$list->idx) {
+
/**
* Token parsed at this moment.
+ *
* @var Token $token
*/
$token = $list->tokens[$list->idx];
diff --git a/src/Statements/CreateStatement.php b/src/Statements/CreateStatement.php
index 2dd5775..03379ee 100644
--- a/src/Statements/CreateStatement.php
+++ b/src/Statements/CreateStatement.php
@@ -348,7 +348,7 @@ class CreateStatement extends Statement
* previously. At least one bracket is required to validate the
* expression.
*
- * @var int|bool
+ * @var int|bool $brackets
*/
$brackets = false;
@@ -359,6 +359,7 @@ class CreateStatement extends Statement
/**
* Token parsed at this moment.
+ *
* @var Token $token
*/
$token = $list->tokens[$list->idx];
diff --git a/src/Utils/BufferedQuery.php b/src/Utils/BufferedQuery.php
index e308fb2..e58165a 100644
--- a/src/Utils/BufferedQuery.php
+++ b/src/Utils/BufferedQuery.php
@@ -91,14 +91,17 @@ class BufferedQuery
// Merges specified options with defaults.
$this->options = array_merge(
array(
+
/**
* The starting delimiter.
+ *
* @var string
*/
'delimiter' => ';',
/**
* Whether `DELIMITER` statements should be parsed.
+ *
* @var bool
*/
'parse_delimiter' => false,
@@ -106,6 +109,7 @@ class BufferedQuery
/**
* Whether a delimiter should be added at the end of the
* statement.
+ *
* @var bool
*/
'add_delimiter' => false,
@@ -156,6 +160,7 @@ class BufferedQuery
/**
* The length of the buffer.
+ *
* @var int $len
*/
$len = strlen($this->query);
diff --git a/src/Utils/Formatter.php b/src/Utils/Formatter.php
index dc8c3af..aba215a 100644
--- a/src/Utils/Formatter.php
+++ b/src/Utils/Formatter.php
@@ -58,6 +58,7 @@ class Formatter
/**
* The format of the result.
+ *
* @var string The type ('text', 'cli' or 'html')
*/
'type' => php_sapi_name() == 'cli' ? 'cli' : 'text',
@@ -65,24 +66,28 @@ class Formatter
/**
* The line ending used.
* By default, for text this is "\n" and for HTML this is "<br/>".
+ *
* @var string
*/
'line_ending' => $this->options['type'] == 'html' ? '<br/>' : "\n",
/**
* The string used for indentation.
+ *
* @var string
*/
'indentation' => " ",
/**
* Whether comments should be removed or not.
+ *
* @var bool
*/
'remove_comments' => false,
/**
* Whether each clause should be on a new line.
+ *
* @var bool
*/
'clause_newline' => true,
@@ -90,12 +95,14 @@ class Formatter
/**
* Whether each part should be on a new line.
* Parts are delimited by brackets and commas.
+ *
* @var bool
*/
'parts_newline' => true,
/**
* Whether each part of each clause should be indented.
+ *
* @var bool
*/
'indent_parts' => true,
@@ -103,6 +110,7 @@ class Formatter
/**
* The styles used for HTML formatting.
* array($type, $flags, $span, $callback)
+ *
* @var array[]
*/
'formats' => array(
@@ -176,24 +184,28 @@ class Formatter
/**
* The query to be returned.
+ *
* @var string $ret
*/
$ret = '';
/**
* The indentation level.
+ *
* @var int $indent
*/
$indent = 0;
/**
* Whether the line ended.
+ *
* @var bool $lineEnded
*/
$lineEnded = false;
/**
* The name of the last clause.
+ *
* @var string $lastClause
*/
$lastClause = '';
@@ -201,6 +213,7 @@ class Formatter
/**
* A stack that keeps track of the indentation level every time a new
* block is found.
+ *
* @var array $blocksIndentation
*/
$blocksIndentation = array();
@@ -208,18 +221,21 @@ class Formatter
/**
* A stack that keeps track of the line endings every time a new block
* is found.
+ *
* @var array $blocksLineEndings
*/
$blocksLineEndings = array();
/**
* Whether clause's options were formatted.
+ *
* @var bool $formattedOptions
*/
$formattedOptions = false;
/**
* Previously parsed token.
+ *
* @var Token $prev
*/
$prev = null;
@@ -227,6 +243,7 @@ class Formatter
/**
* Comments are being formatted separately to maintain the whitespaces
* before and after them.
+ *
* @var string $comment
*/
$comment = '';
@@ -239,6 +256,7 @@ class Formatter
/**
* Token parsed at this moment.
+ *
* @var Token $curr
*/
$curr = $list->tokens[$list->idx];
@@ -461,13 +479,15 @@ class Formatter
* This counter starts at one because by the time this function called,
* the list already advanced one position and the opening bracket was
* already parsed.
- * @var int
+ *
+ * @var int $count
*/
$count = 1;
/**
* The length of this group.
- * @var int
+ *
+ * @var int $length
*/
$length = 0;
diff --git a/src/Utils/Misc.php b/src/Utils/Misc.php
index 2107172..1597648 100644
--- a/src/Utils/Misc.php
+++ b/src/Utils/Misc.php
@@ -47,7 +47,8 @@ class Misc
/**
* Expressions that may contain aliases.
* These are extracted from `FROM` and `JOIN` keywords.
- * @var Expression[]
+ *
+ * @var Expression[] $expressions
*/
$expressions = $statement->from;
diff --git a/src/Utils/Query.php b/src/Utils/Query.php
index 6aff11d..5723ec6 100644
--- a/src/Utils/Query.php
+++ b/src/Utils/Query.php
@@ -510,6 +510,7 @@ class Query
/**
* The index of the current clause.
+ *
* @var int $currIdx
*/
$currIdx = 0;
@@ -517,18 +518,21 @@ class Query
/**
* The count of brackets.
* We keep track of them so we won't insert the clause in a subquery.
+ *
* @var int $brackets
*/
$brackets = 0;
/**
* The string to be returned.
+ *
* @var string $ret
*/
$ret = '';
/**
* The clauses of this type of statement and their index.
+ *
* @var array $clauses
*/
$clauses = array_flip(array_keys($statement::$CLAUSES));
@@ -543,18 +547,21 @@ class Query
/**
* Lexer used for lexing the clause.
+ *
* @var Lexer $lexer
*/
$lexer = new Lexer($clause);
/**
* The type of this clause.
+ *
* @var string $clauseType
*/
$clauseType = $lexer->list->getNextOfType(Token::TYPE_KEYWORD)->value;
/**
* The index of this clause.
+ *
* @var int $clauseIdx
*/
$clauseIdx = $clauses[$clauseType];
@@ -680,6 +687,7 @@ class Query
/**
* Value to be returned.
+ *
* @var string $ret
*/
$ret = '';
@@ -730,13 +738,15 @@ class Query
/**
* Whether a full statement was found.
- * @var bool
+ *
+ * @var bool $fullStatement
*/
$fullStatement = false;
/**
* The first full statement.
- * @var string
+ *
+ * @var string $statement
*/
$statement = '';
diff --git a/tests/TestGenerator.php b/tests/TestGenerator.php
index 234c693..f8a176a 100644
--- a/tests/TestGenerator.php
+++ b/tests/TestGenerator.php
@@ -32,26 +32,30 @@ class TestGenerator
/**
* Lexer used for tokenizing the query.
- * @var Lexer
+ *
+ * @var Lexer $lexer
*/
$lexer = new Lexer($query);
/**
* Parsed used for analyzing the query.
* A new instance of parser is generated only if the test requires.
- * @var Parser
+ *
+ * @var Parser $parser
*/
$parser = ($type === 'parser') ? new Parser($lexer->list) : null;
/**
* Lexer's errors.
- * @var array
+ *
+ * @var array $lexerErrors
*/
$lexerErrors = array();
/**
* Parser's errors.
- * @var array
+ *
+ * @var array $parserErrors
*/
$parserErrors = array();
@@ -109,7 +113,7 @@ class TestGenerator
/**
* The query that is used to generate the test.
*
- * @var string
+ * @var string $query
*/
$query = file_get_contents($input);
diff --git a/tests/Utils/BufferedQueryTest.php b/tests/Utils/BufferedQueryTest.php
index fe2b0c8..3f74429 100644
--- a/tests/Utils/BufferedQueryTest.php
+++ b/tests/Utils/BufferedQueryTest.php
@@ -20,12 +20,14 @@ class BufferedQueryTest extends TestCase
/**
* The array of extracted statements.
+ *
* @var array $statements
*/
$statements = array();
/**
* The `BufferedQuery` instance used for extraction.
+ *
* @var BufferedQuery $bq
*/
$bq = new BufferedQuery('', $options);
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index adbe10b..6c36088 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -82,7 +82,8 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase
{
/**
* Test's data.
- * @var array
+ *
+ * @var array $data
*/
$data = $this->getData($name);