summaryrefslogtreecommitdiffstats
path: root/src/Fragments
diff options
context:
space:
mode:
Diffstat (limited to 'src/Fragments')
-rw-r--r--src/Fragments/ArrayFragment.php2
-rw-r--r--src/Fragments/CallKeyword.php2
-rw-r--r--src/Fragments/FieldFragment.php2
-rw-r--r--src/Fragments/LimitKeyword.php2
-rw-r--r--src/Fragments/OptionsFragment.php2
-rw-r--r--src/Fragments/WhereKeyword.php31
6 files changed, 20 insertions, 21 deletions
diff --git a/src/Fragments/ArrayFragment.php b/src/Fragments/ArrayFragment.php
index db12622..8c91fc2 100644
--- a/src/Fragments/ArrayFragment.php
+++ b/src/Fragments/ArrayFragment.php
@@ -131,7 +131,7 @@ class ArrayFragment extends Fragment
*
* @return string
*/
- public static function build(ArrayFragment $fragment)
+ public static function build($fragment)
{
$values = array();
if (!empty($fragment->raw)) {
diff --git a/src/Fragments/CallKeyword.php b/src/Fragments/CallKeyword.php
index 3b8cc80..e56940b 100644
--- a/src/Fragments/CallKeyword.php
+++ b/src/Fragments/CallKeyword.php
@@ -116,7 +116,7 @@ class CallKeyword extends Fragment
*
* @return string
*/
- public static function build(CallKeyword $fragment)
+ public static function build($fragment)
{
return $fragment->name . ArrayFragment::build($fragment->parameters);
}
diff --git a/src/Fragments/FieldFragment.php b/src/Fragments/FieldFragment.php
index 8b0f0ef..a6c5777 100644
--- a/src/Fragments/FieldFragment.php
+++ b/src/Fragments/FieldFragment.php
@@ -299,8 +299,6 @@ class FieldFragment extends Fragment
*/
public static function build($fragment)
{
- $ret = '';
-
if (!empty($fragment->expr)) {
$ret = $fragment->expr;
} else {
diff --git a/src/Fragments/LimitKeyword.php b/src/Fragments/LimitKeyword.php
index af8d92d..36efa02 100644
--- a/src/Fragments/LimitKeyword.php
+++ b/src/Fragments/LimitKeyword.php
@@ -45,7 +45,7 @@ class LimitKeyword extends Fragment
* @param int $rowCount The row count.
* @param int $offset The offset.
*/
- public function __construct($rowCount = null, $offset = null)
+ public function __construct($rowCount = 0, $offset = 0)
{
$this->rowCount = $rowCount;
$this->offset = $offset;
diff --git a/src/Fragments/OptionsFragment.php b/src/Fragments/OptionsFragment.php
index 16459cc..00ac282 100644
--- a/src/Fragments/OptionsFragment.php
+++ b/src/Fragments/OptionsFragment.php
@@ -142,7 +142,7 @@ class OptionsFragment extends Fragment
*
* @return string
*/
- public static function build(OptionsFragment $fragment)
+ public static function build($fragment)
{
$options = array();
foreach ($fragment->options as $option) {
diff --git a/src/Fragments/WhereKeyword.php b/src/Fragments/WhereKeyword.php
index d2143f3..0710738 100644
--- a/src/Fragments/WhereKeyword.php
+++ b/src/Fragments/WhereKeyword.php
@@ -44,16 +44,16 @@ class WhereKeyword extends Fragment
*
* @var string
*/
- public $condition;
+ public $expr;
/**
* Constructor.
*
- * @param string $condition The condition or the operator.
+ * @param string $expr The condition or the operator.
*/
- public function __construct($condition = null)
+ public function __construct($expr = null)
{
- $this->condition = trim($condition);
+ $this->expr = trim($expr);
}
/**
@@ -71,9 +71,10 @@ class WhereKeyword extends Fragment
* The condition that was parsed so far.
* @var string
*/
- $condition = '';
+ $tmp = '';
for (; $list->idx < $list->count; ++$list->idx) {
+
/**
* Token parsed at this moment.
* @var Token
@@ -92,10 +93,10 @@ class WhereKeyword extends Fragment
// Conditions are delimited by logical operators.
if (in_array($token->value, static::$OPERATORS, true)) {
- if (!empty(trim($condition))) {
+ if (!empty(trim($tmp))) {
// Adding the condition that is delimited by this operator.
- $ret[] = new WhereKeyword($condition);
- $condition = '';
+ $ret[] = new WhereKeyword($tmp);
+ $tmp = '';
}
// Adding the operator.
@@ -111,13 +112,13 @@ class WhereKeyword extends Fragment
break;
}
- $condition .= $token->token;
+ $tmp .= $token->token;
}
// Last iteration was not processed.
- if (!empty(trim($condition))) {
- $ret[] = new WhereKeyword($condition);
+ if (!empty(trim($tmp))) {
+ $ret[] = new WhereKeyword($tmp);
}
--$list->idx;
@@ -125,16 +126,16 @@ class WhereKeyword extends Fragment
}
/**
- * @param WhereKeyword $fragment The fragment to be built.
+ * @param WhereKeyword[] $fragment The fragment to be built.
*
* @return string
*/
public static function build($fragment)
{
- $conditions = array();
+ $ret = array();
foreach ($fragment as $f) {
- $conditions[] = $f->condition;
+ $ret[] = $f->expr;
}
- return implode(' ', $conditions);
+ return implode(' ', $ret);
}
}