diff options
author | Dan Ungureanu <udan1107@gmail.com> | 2015-09-25 11:01:45 +0300 |
---|---|---|
committer | Dan Ungureanu <udan1107@gmail.com> | 2015-09-25 11:01:45 +0300 |
commit | 8f19b8f15e098b06587cc67ce02ecc204fd201c7 (patch) | |
tree | 4219e5576893acc5edf7035218114ce2dbd39ffc | |
parent | 1415469b34b1fc33189e2c801302597b5b50f704 (diff) | |
download | sql-parser-8f19b8f15e098b06587cc67ce02ecc204fd201c7.zip sql-parser-8f19b8f15e098b06587cc67ce02ecc204fd201c7.tar.gz sql-parser-8f19b8f15e098b06587cc67ce02ecc204fd201c7.tar.bz2 |
Updated coding style to follow PSR-2 coding standards.
38 files changed, 99 insertions, 120 deletions
diff --git a/src/Component.php b/src/Component.php index cb2a33c..2e406c5 100644 --- a/src/Component.php +++ b/src/Component.php @@ -39,7 +39,9 @@ abstract class Component * @return mixed */ public static function parse( - Parser $parser, TokensList $list, array $options = array() + Parser $parser, + TokensList $list, + array $options = array() ) { // This method should be abstract, but it can't be both static and // abstract. diff --git a/src/Components/AlterOperation.php b/src/Components/AlterOperation.php index ee9302c..8dad8e8 100644 --- a/src/Components/AlterOperation.php +++ b/src/Components/AlterOperation.php @@ -137,7 +137,6 @@ class AlterOperation extends Component $state = 0; for (; $list->idx < $list->count; ++$list->idx) { - /** * Token parsed at this moment. * diff --git a/src/Components/Array2d.php b/src/Components/Array2d.php index e4c0ed7..a46813b 100644 --- a/src/Components/Array2d.php +++ b/src/Components/Array2d.php @@ -58,7 +58,6 @@ class Array2d extends Component $state = 0; for (; $list->idx < $list->count; ++$list->idx) { - /** * Token parsed at this moment. * diff --git a/src/Components/ArrayObj.php b/src/Components/ArrayObj.php index 01d79cc..fb199ea 100644 --- a/src/Components/ArrayObj.php +++ b/src/Components/ArrayObj.php @@ -79,7 +79,6 @@ class ArrayObj extends Component $state = 0; for (; $list->idx < $list->count; ++$list->idx) { - /** * Token parsed at this moment. * diff --git a/src/Components/Condition.php b/src/Components/Condition.php index 43347a8..30be971 100644 --- a/src/Components/Condition.php +++ b/src/Components/Condition.php @@ -111,7 +111,6 @@ class Condition extends Component $betweenBefore = false; for (; $list->idx < $list->count; ++$list->idx) { - /** * Token parsed at this moment. * diff --git a/src/Components/CreateDefinition.php b/src/Components/CreateDefinition.php index 0ef7c4a..21f44fe 100644 --- a/src/Components/CreateDefinition.php +++ b/src/Components/CreateDefinition.php @@ -126,8 +126,12 @@ class CreateDefinition extends Component * @param bool $isConstraint Whether this field is a constraint or not. * @param Reference $references References. */ - public function __construct($name = null, $options = null, $type = null, - $isConstraint = false, $references = null + public function __construct( + $name = null, + $options = null, + $type = null, + $isConstraint = false, + $references = null ) { $this->name = $name; $this->options = $options; @@ -178,7 +182,6 @@ class CreateDefinition extends Component $state = 0; for (; $list->idx < $list->count; ++$list->idx) { - /** * Token parsed at this moment. * diff --git a/src/Components/DataType.php b/src/Components/DataType.php index a3aca73..aac40ee 100644 --- a/src/Components/DataType.php +++ b/src/Components/DataType.php @@ -75,7 +75,9 @@ class DataType extends Component * @param array $parameters The parameters (size or possible values). * @param OptionsArray $options The options of this data type. */ - public function __construct($name = null, array $parameters = array(), + public function __construct( + $name = null, + array $parameters = array(), $options = null ) { $this->name = $name; @@ -108,7 +110,6 @@ class DataType extends Component $state = 0; for (; $list->idx < $list->count; ++$list->idx) { - /** * Token parsed at this moment. * diff --git a/src/Components/Expression.php b/src/Components/Expression.php index 1f8752e..22cd23f 100644 --- a/src/Components/Expression.php +++ b/src/Components/Expression.php @@ -160,7 +160,6 @@ class Expression extends Component $prev = null; for (; $list->idx < $list->count; ++$list->idx) { - /** * Token parsed at this moment. * @@ -274,7 +273,6 @@ class Expression extends Component // field should be skipped; used to parse table names). $field = (!empty($options['skipColumn'])) ? 'table' : 'column'; if (!empty($ret->$field)) { - // No alias is expected. if (!empty($options['noAlias'])) { break; diff --git a/src/Components/ExpressionArray.php b/src/Components/ExpressionArray.php index 8327296..5c84dcd 100644 --- a/src/Components/ExpressionArray.php +++ b/src/Components/ExpressionArray.php @@ -51,7 +51,6 @@ class ExpressionArray extends Component $state = 0; for (; $list->idx < $list->count; ++$list->idx) { - /** * Token parsed at this moment. * diff --git a/src/Components/FunctionCall.php b/src/Components/FunctionCall.php index 54e95ac..9d2dfed 100644 --- a/src/Components/FunctionCall.php +++ b/src/Components/FunctionCall.php @@ -80,7 +80,6 @@ class FunctionCall extends Component $state = 0; for (; $list->idx < $list->count; ++$list->idx) { - /** * Token parsed at this moment. * diff --git a/src/Components/IntoKeyword.php b/src/Components/IntoKeyword.php index b230308..1ac7be8 100644 --- a/src/Components/IntoKeyword.php +++ b/src/Components/IntoKeyword.php @@ -74,7 +74,6 @@ class IntoKeyword extends Component $state = 0; for (; $list->idx < $list->count; ++$list->idx) { - /** * Token parsed at this moment. * diff --git a/src/Components/JoinKeyword.php b/src/Components/JoinKeyword.php index 28756ab..ac2fa02 100644 --- a/src/Components/JoinKeyword.php +++ b/src/Components/JoinKeyword.php @@ -98,7 +98,6 @@ class JoinKeyword extends Component } for (; $list->idx < $list->count; ++$list->idx) { - /** * Token parsed at this moment. * @@ -132,7 +131,7 @@ class JoinKeyword extends Component if (($token->type === Token::TYPE_KEYWORD) && ($token->value === 'ON')) { $state = 3; } - } else if ($state === 3) { + } elseif ($state === 3) { $expr->on = Condition::parse($parser, $list); $ret[] = $expr; $expr = new JoinKeyword(); diff --git a/src/Components/Key.php b/src/Components/Key.php index 70b2b93..490d067 100644 --- a/src/Components/Key.php +++ b/src/Components/Key.php @@ -75,8 +75,11 @@ class Key extends Component * @param string $type The type of this key. * @param OptionsArray $options The options of this key. */ - public function __construct($name = null, array $columns = array(), - $type = null, $options = null + public function __construct( + $name = null, + array $columns = array(), + $type = null, + $options = null ) { $this->name = $name; $this->columns = $columns; @@ -119,7 +122,6 @@ class Key extends Component $state = 0; for (; $list->idx < $list->count; ++$list->idx) { - /** * Token parsed at this moment. * diff --git a/src/Components/Limit.php b/src/Components/Limit.php index edf663a..c6b3290 100644 --- a/src/Components/Limit.php +++ b/src/Components/Limit.php @@ -65,7 +65,6 @@ class Limit extends Component $offset = false; for (; $list->idx < $list->count; ++$list->idx) { - /** * Token parsed at this moment. * diff --git a/src/Components/OptionsArray.php b/src/Components/OptionsArray.php index f24635a..a7fbf41 100644 --- a/src/Components/OptionsArray.php +++ b/src/Components/OptionsArray.php @@ -99,7 +99,6 @@ class OptionsArray extends Component $state = 0; for (; $list->idx < $list->count; ++$list->idx) { - /** * Token parsed at this moment. * diff --git a/src/Components/OrderKeyword.php b/src/Components/OrderKeyword.php index 9c1ad59..fc226f0 100644 --- a/src/Components/OrderKeyword.php +++ b/src/Components/OrderKeyword.php @@ -79,7 +79,6 @@ class OrderKeyword extends Component $state = 0; for (; $list->idx < $list->count; ++$list->idx) { - /** * Token parsed at this moment. * diff --git a/src/Components/ParameterDefinition.php b/src/Components/ParameterDefinition.php index 9ed9cfc..aea8f9c 100644 --- a/src/Components/ParameterDefinition.php +++ b/src/Components/ParameterDefinition.php @@ -80,7 +80,6 @@ class ParameterDefinition extends Component $state = 0; for (; $list->idx < $list->count; ++$list->idx) { - /** * Token parsed at this moment. * diff --git a/src/Components/PartitionDefinition.php b/src/Components/PartitionDefinition.php index 34acbb8..766d58d 100644 --- a/src/Components/PartitionDefinition.php +++ b/src/Components/PartitionDefinition.php @@ -125,7 +125,6 @@ class PartitionDefinition extends Component $state = 0; for (; $list->idx < $list->count; ++$list->idx) { - /** * Token parsed at this moment. * diff --git a/src/Components/Reference.php b/src/Components/Reference.php index 6826f7f..037499a 100644 --- a/src/Components/Reference.php +++ b/src/Components/Reference.php @@ -99,7 +99,6 @@ class Reference extends Component $state = 0; for (; $list->idx < $list->count; ++$list->idx) { - /** * Token parsed at this moment. * diff --git a/src/Components/RenameOperation.php b/src/Components/RenameOperation.php index 5f7c9a5..8776963 100644 --- a/src/Components/RenameOperation.php +++ b/src/Components/RenameOperation.php @@ -71,7 +71,6 @@ class RenameOperation extends Component $state = 0; for (; $list->idx < $list->count; ++$list->idx) { - /** * Token parsed at this moment. * diff --git a/src/Components/SetOperation.php b/src/Components/SetOperation.php index 3d04320..9281902 100644 --- a/src/Components/SetOperation.php +++ b/src/Components/SetOperation.php @@ -67,7 +67,6 @@ class SetOperation extends Component $state = 0; for (; $list->idx < $list->count; ++$list->idx) { - /** * Token parsed at this moment. * diff --git a/src/Context.php b/src/Context.php index d6602ce..5cbf6a1 100644 --- a/src/Context.php +++ b/src/Context.php @@ -464,7 +464,11 @@ abstract class Context // If it didn't work, we are looking for a new one and skipping // over to the next generation that will try the new context. $context = preg_replace( - '/[1-9](0*)$/', '0$1', $context, -1, $count + '/[1-9](0*)$/', + '0$1', + $context, + -1, + $count ); continue; } diff --git a/src/Lexer.php b/src/Lexer.php index 111148b..5ba613d 100644 --- a/src/Lexer.php +++ b/src/Lexer.php @@ -16,7 +16,6 @@ require_once 'common.php'; use SqlParser\Exceptions\LexerException; if (!defined('USE_UTF_STRINGS')) { - // NOTE: In previous versions of PHP (5.5 and older) the default // internal encoding is "ISO-8859-1". // All `mb_` functions must specify the correct encoding, which is @@ -232,7 +231,6 @@ class Lexer $lastToken = null; for ($this->last = 0, $lastIdx = 0; $this->last < $this->len; $lastIdx = ++$this->last) { - /** * The new token. * @@ -399,7 +397,6 @@ class Lexer $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])) { diff --git a/src/Parser.php b/src/Parser.php index 1148331..1859ae0 100644 --- a/src/Parser.php +++ b/src/Parser.php @@ -354,7 +354,6 @@ class Parser $list = &$this->list; for (; $list->idx < $list->count; ++$list->idx) { - /** * Token parsed at this moment. * @@ -441,7 +440,6 @@ class Parser && ($lastStatement instanceof SelectStatement) && ($statement instanceof SelectStatement) ) { - /** * This SELECT statement. * @@ -472,7 +470,6 @@ class Parser // Handles transactions. if ($statement instanceof TransactionStatement) { - /** * @var TransactionStatement $statement */ diff --git a/src/Statement.php b/src/Statement.php index 0568d93..3fe3f42 100644 --- a/src/Statement.php +++ b/src/Statement.php @@ -109,7 +109,6 @@ abstract class Statement $query = ''; foreach (static::$CLAUSES as $clause) { - /** * The name of the clause. * @@ -190,7 +189,6 @@ abstract class Statement $parsedOptions = empty(static::$OPTIONS); for (; $list->idx < $list->count; ++$list->idx) { - /** * Token parsed at this moment. * @@ -247,7 +245,8 @@ abstract class Statement ) { if (!empty($parsedClauses[$token->value])) { $parser->error( - __('This type of clause was previously parsed.'), $token + __('This type of clause was previously parsed.'), + $token ); break; } diff --git a/src/Statements/AlterStatement.php b/src/Statements/AlterStatement.php index 31bbcb4..4da360a 100644 --- a/src/Statements/AlterStatement.php +++ b/src/Statements/AlterStatement.php @@ -73,7 +73,9 @@ class AlterStatement extends Statement // Parsing affected table. $this->table = Expression::parse( - $parser, $list, array( + $parser, + $list, + array( 'noAlias' => true, 'noBrackets' => true, ) @@ -94,7 +96,6 @@ class AlterStatement extends Statement $state = 0; for (; $list->idx < $list->count; ++$list->idx) { - /** * Token parsed at this moment. * @@ -115,7 +116,7 @@ class AlterStatement extends Statement if ($state === 0) { $this->altered[] = AlterOperation::parse($parser, $list); $state = 1; - } else if ($state === 1) { + } elseif ($state === 1) { if (($token->type === Token::TYPE_OPERATOR) && ($token->value === ',')) { $state = 0; } diff --git a/src/Statements/CreateStatement.php b/src/Statements/CreateStatement.php index 9b07737..1a46b56 100644 --- a/src/Statements/CreateStatement.php +++ b/src/Statements/CreateStatement.php @@ -395,7 +395,6 @@ class CreateStatement extends Statement * Handles partitions. */ for (; $list->idx < $list->count; ++$list->idx) { - /** * Token parsed at this moment. * @@ -428,7 +427,6 @@ class CreateStatement extends Statement --$list->idx; // `getNextOfType` also advances one position. $this->subpartitionsNum = $token->value; } elseif (!empty($field)) { - /* * Handling the content of `PARTITION BY` and `SUBPARTITION BY`. */ @@ -499,7 +497,7 @@ class CreateStatement extends Statement $token = $list->tokens[$list->idx]; $this->body[] = $token; } - } else if ($this->options->has('VIEW')) { + } elseif ($this->options->has('VIEW')) { $token = $list->getNext(); // Skipping whitespaces and comments. // Parsing columns list. @@ -518,7 +516,7 @@ class CreateStatement extends Statement } $this->body[] = $token; } - } else if ($this->options->has('TRIGGER')) { + } elseif ($this->options->has('TRIGGER')) { // Parsing the time and the event. $this->entityOptions = OptionsArray::parse( $parser, diff --git a/src/Token.php b/src/Token.php index d534321..9659672 100644 --- a/src/Token.php +++ b/src/Token.php @@ -219,59 +219,59 @@ class Token public function extract() { switch ($this->type) { - case Token::TYPE_KEYWORD: - if (!($this->flags & Token::FLAG_KEYWORD_RESERVED)) { - // Unreserved keywords should stay the way they are because they - // might represent field names. - return $this->token; - } - return strtoupper($this->token); - case Token::TYPE_WHITESPACE: - return ' '; - case Token::TYPE_BOOL: - return strtoupper($this->token) === 'TRUE'; - case Token::TYPE_NUMBER: - $ret = str_replace('--', '', $this->token); // e.g. ---42 === -42 - if ($this->flags & Token::FLAG_NUMBER_HEX) { - if ($this->flags & Token::FLAG_NUMBER_NEGATIVE) { - $ret = str_replace('-', '', $this->token); - sscanf($ret, "%x", $ret); - $ret = -$ret; - } else { - sscanf($ret, "%x", $ret); + case Token::TYPE_KEYWORD: + if (!($this->flags & Token::FLAG_KEYWORD_RESERVED)) { + // Unreserved keywords should stay the way they are because they + // might represent field names. + return $this->token; } - } elseif (($this->flags & Token::FLAG_NUMBER_APPROXIMATE) + return strtoupper($this->token); + case Token::TYPE_WHITESPACE: + return ' '; + case Token::TYPE_BOOL: + return strtoupper($this->token) === 'TRUE'; + case Token::TYPE_NUMBER: + $ret = str_replace('--', '', $this->token); // e.g. ---42 === -42 + if ($this->flags & Token::FLAG_NUMBER_HEX) { + if ($this->flags & Token::FLAG_NUMBER_NEGATIVE) { + $ret = str_replace('-', '', $this->token); + sscanf($ret, "%x", $ret); + $ret = -$ret; + } else { + sscanf($ret, "%x", $ret); + } + } elseif (($this->flags & Token::FLAG_NUMBER_APPROXIMATE) || ($this->flags & Token::FLAG_NUMBER_FLOAT) - ) { - sscanf($ret, "%f", $ret); - } else { - sscanf($ret, "%d", $ret); - } - return $ret; - case Token::TYPE_STRING: - $quote = $this->token[0]; - $str = str_replace($quote . $quote, $quote, $this->token); - return mb_substr($str, 1, -1, 'UTF-8'); // trims quotes - case Token::TYPE_SYMBOL: - $str = $this->token; - if ((isset($str[0])) && ($str[0] === '@')) { - // `mb_strlen($str)` must be used instead of `null` because - // in PHP 5.3- the `null` parameter isn't handled correctly. - $str = mb_substr( - $str, - ((!empty($str[1])) && ($str[1] === '@')) ? 2 : 1, - mb_strlen($str), - 'UTF-8' - ); - } - if ((isset($str[0])) && (($str[0] === '`') + ) { + sscanf($ret, "%f", $ret); + } else { + sscanf($ret, "%d", $ret); + } + return $ret; + case Token::TYPE_STRING: + $quote = $this->token[0]; + $str = str_replace($quote . $quote, $quote, $this->token); + return mb_substr($str, 1, -1, 'UTF-8'); // trims quotes + case Token::TYPE_SYMBOL: + $str = $this->token; + if ((isset($str[0])) && ($str[0] === '@')) { + // `mb_strlen($str)` must be used instead of `null` because + // in PHP 5.3- the `null` parameter isn't handled correctly. + $str = mb_substr( + $str, + ((!empty($str[1])) && ($str[1] === '@')) ? 2 : 1, + mb_strlen($str), + 'UTF-8' + ); + } + if ((isset($str[0])) && (($str[0] === '`') || ($str[0] === '"') || ($str[0] === '\'')) - ) { - $quote = $str[0]; - $str = str_replace($quote . $quote, $quote, $str); - $str = mb_substr($str, 1, -1, 'UTF-8'); - } - return $str; + ) { + $quote = $str[0]; + $str = str_replace($quote . $quote, $quote, $str); + $str = mb_substr($str, 1, -1, 'UTF-8'); + } + return $str; } return $this->token; } diff --git a/src/Utils/BufferedQuery.php b/src/Utils/BufferedQuery.php index e58165a..1da0b81 100644 --- a/src/Utils/BufferedQuery.php +++ b/src/Utils/BufferedQuery.php @@ -186,7 +186,6 @@ class BufferedQuery $loopLen = $end ? $len : $len - 16; for (; $i < $loopLen; ++$i) { - /* * Handling special parses statuses. */ @@ -285,7 +284,6 @@ class BufferedQuery && (($this->query[$i + 8] === 'R') || ($this->query[$i + 8] === 'r')) && (Context::isWhitespace($this->query[$i + 9])) ) { - // Saving the current index to be able to revert any parsing // done in this block. $iBak = $i; @@ -307,14 +305,12 @@ class BufferedQuery && ((($i < $len) && (Context::isWhitespace($this->query[$i]))) || (($i === $len) && ($end))) ) { - // Saving the delimiter. $this->setDelimiter($delimiter); // Whether this statement should be returned or not. $ret = ''; if (!empty($this->options['parse_delimiter'])) { - // Appending the `DELIMITER` statement that was just // found to the current statement. $ret = trim( @@ -351,7 +347,6 @@ class BufferedQuery && (($this->delimiterLen === 1) || (substr($this->query, $i, $this->delimiterLen) === $this->delimiter)) ) { - // Saving the statement that just ended. $ret = $this->current; diff --git a/src/Utils/Error.php b/src/Utils/Error.php index df6d513..a9c0814 100644 --- a/src/Utils/Error.php +++ b/src/Utils/Error.php @@ -78,14 +78,20 @@ class Error * @return array */ public static function format( - $errors, $format = '#%1$d: %2$s (near "%4$s" at position %5$d)' + $errors, + $format = '#%1$d: %2$s (near "%4$s" at position %5$d)' ) { $ret = array(); $i = 0; foreach ($errors as $key => $err) { $ret[$key] = sprintf( - $format, ++$i, $err[0], $err[1], $err[2], $err[3] + $format, + ++$i, + $err[0], + $err[1], + $err[2], + $err[3] ); } diff --git a/src/Utils/Formatter.php b/src/Utils/Formatter.php index ebdea42..ea4b419 100644 --- a/src/Utils/Formatter.php +++ b/src/Utils/Formatter.php @@ -257,7 +257,6 @@ class Formatter // `$prev` and `$curr` which store two consecutive tokens. // Actually, at every iteration the previous token is being used. for ($list->idx = 0; $list->idx < $list->count; ++$list->idx) { - /** * Token parsed at this moment. * @@ -266,11 +265,9 @@ class Formatter $curr = $list->tokens[$list->idx]; if ($curr->type === Token::TYPE_WHITESPACE) { - // Whitespaces are skipped because the formatter adds its own. continue; } elseif ($curr->type === Token::TYPE_COMMENT) { - // Whether the comments should be parsed. if (!empty($this->options['remove_comments'])) { continue; @@ -297,7 +294,6 @@ class Formatter // Checking if pointers were initialized. if ($prev !== null) { - // Checking if a new clause started. if (static::isClause($prev) !== false) { $lastClause = $prev->value; @@ -428,7 +424,6 @@ class Formatter if (($token->type === $format['type']) && (($token->flags & $format['flags']) === $format['flags']) ) { - // Running transformation function. if (!empty($format['function'])) { $func = $format['function']; diff --git a/src/common.php b/src/common.php index a594b6d..3575c24 100644 --- a/src/common.php +++ b/src/common.php @@ -7,7 +7,6 @@ */ if (!function_exists('__')) { - /** * Translates the given string. * diff --git a/tests/Components/Array2dTest.php b/tests/Components/Array2dTest.php index b268d99..a1c9786 100644 --- a/tests/Components/Array2dTest.php +++ b/tests/Components/Array2dTest.php @@ -69,5 +69,4 @@ class Array2dTest extends TestCase $parser->errors[0]->getMessage() ); } - } diff --git a/tests/Lexer/LexerTest.php b/tests/Lexer/LexerTest.php index c17e78d..9c22768 100644 --- a/tests/Lexer/LexerTest.php +++ b/tests/Lexer/LexerTest.php @@ -20,7 +20,10 @@ class LexerTest extends TestCase $lexer->error(__('error #1'), 'foo', 1, 2); $lexer->error( - sprintf(__('%2$s #%1$d'), 2, 'error'), 'bar', 3, 4 + sprintf(__('%2$s #%1$d'), 2, 'error'), + 'bar', + 3, + 4 ); $this->assertEquals( diff --git a/tests/Utils/BufferedQueryTest.php b/tests/Utils/BufferedQueryTest.php index 3f74429..185e9d2 100644 --- a/tests/Utils/BufferedQueryTest.php +++ b/tests/Utils/BufferedQueryTest.php @@ -13,7 +13,10 @@ class BufferedQueryTest extends TestCase * @dataProvider testExtractProvider */ public function testExtract( - $query, $chunkSize, array $options = array(), array $expected + $query, + $chunkSize, + array $options = array(), + array $expected ) { $chunks = str_split($query, $chunkSize); $count = count($chunks); diff --git a/tests/Utils/QueryTest.php b/tests/Utils/QueryTest.php index 9929da1..8455dee 100644 --- a/tests/Utils/QueryTest.php +++ b/tests/Utils/QueryTest.php @@ -369,7 +369,8 @@ class QueryTest extends TestCase Query::getClause( $parser->statements[0], $parser->list, - 'LIMIT', 'FROM' + 'LIMIT', + 'FROM' ) ); } diff --git a/tools/ContextGenerator.php b/tools/ContextGenerator.php index 7720c02..c1bce26 100644 --- a/tools/ContextGenerator.php +++ b/tools/ContextGenerator.php @@ -131,7 +131,6 @@ class ContextGenerator $types = array(); for ($i = 0, $count = count($words); $i != $count; ++$i) { - $type = 1; $value = trim($words[$i]); @@ -191,7 +190,6 @@ class ContextGenerator $ret = ''; foreach ($words as $type => $wordsByType) { - foreach ($wordsByType as $len => $wordsByLen) { $count = round(($line - $spaces) / ($len + 9)); // strlen("'' => 1, ") = 9 $i = 0; @@ -327,7 +325,6 @@ class ContextGenerator $files = scandir($input); foreach ($files as $file) { - // Skipping current and parent directories. if (($file === '.') || ($file === '..') || ($file[0] === '_')) { continue; @@ -350,7 +347,6 @@ class ContextGenerator // The output will be generated in the same `data` folder. // if (count($argv) >= 3) { - // Extracting directories' name from command line and trimming unnecessary // slashes at the end. $input = rtrim($argv[1], '/'); diff --git a/tools/TestGenerator.php b/tools/TestGenerator.php index e705f9e..07c8612 100644 --- a/tools/TestGenerator.php +++ b/tools/TestGenerator.php @@ -146,7 +146,6 @@ class TestGenerator $files = scandir($input); foreach ($files as $file) { - // Skipping current and parent directories. if (($file === '.') || ($file === '..')) { continue; @@ -158,7 +157,6 @@ class TestGenerator $debugFile = ($debug !== null) ? $debug . '/' . $file : null; if (is_dir($inputFile)) { - // Creating required directories to maintain the structure. // Ignoring errors if the folder structure exists already. if (!is_dir($outputFile)) { @@ -171,7 +169,6 @@ class TestGenerator // Generating tests recursively. static::buildAll($inputFile, $outputFile, $debugFile); } elseif (substr($inputFile, -3) === '.in') { - // Generating file names by replacing `.in` with `.out` and // `.debug`. $outputFile = substr($outputFile, 0, -3) . '.out'; @@ -206,7 +203,6 @@ class TestGenerator // The output will be generated in the same `../tests/data` folder. // if (count($argv) >= 3) { - // Extracting directories' name from command line and trimming unnecessary // slashes at the end. $input = rtrim($argv[1], '/'); |