Drop else-statements, remove debug statement.

This commit is contained in:
James Cole
2025-01-05 07:45:29 +01:00
parent fd6560bdd0
commit 10a284848b
4 changed files with 20 additions and 15 deletions

View File

@@ -54,7 +54,6 @@ class GdbotsQueryParser implements QueryParserInterface
return new NodeGroup($nodes);
} catch (\LogicException|\TypeError $e) {
fwrite(STDERR, "Setting up GdbotsQueryParserTest\n");
dd('Creating GdbotsQueryParser');
app('log')->error($e->getMessage());
app('log')->error(sprintf('Could not parse search: "%s".', $query));

View File

@@ -35,18 +35,19 @@ abstract class Node
/**
* Returns the prohibited status of the node, optionally inverted based on flipFlag
*
* Flipping is used when a node is inside a NodeGroup that has a prohibited status itself, causing inversion of the query parts inside
* Flipping is used when a node is inside a NodeGroup that has a prohibited status itself, causing inversion of the
* query parts inside
*
* @param bool $flipFlag When true, inverts the prohibited status
*
* @return bool The (potentially inverted) prohibited status
*/
public function isProhibited(bool $flipFlag): bool
{
if ($flipFlag === true) {
if ($flipFlag) {
return !$this->prohibited;
} else {
return $this->prohibited;
}
return $this->prohibited;
}
}

View File

@@ -92,13 +92,12 @@ class QueryParser implements QueryParserInterface
$tokenUnderConstruction .= $char;
$this->position++;
continue;
} else {
}
$this->position++;
return new NodeResult(
$this->createNode($tokenUnderConstruction, $fieldName, $prohibited),
false
);
}
}
switch ($char) {
@@ -106,7 +105,8 @@ class QueryParser implements QueryParserInterface
if ($tokenUnderConstruction === '') {
// A minus sign at the beginning of a token indicates prohibition
$prohibited = true;
} else {
}
if ($tokenUnderConstruction !== '') {
// In any other location, it's just a normal character
$tokenUnderConstruction .= $char;
}
@@ -116,7 +116,8 @@ class QueryParser implements QueryParserInterface
if ($tokenUnderConstruction === '') {
// A quote sign at the beginning of a token indicates the start of a quoted string
$inQuotes = true;
} else {
}
if ($tokenUnderConstruction !== '') {
// In any other location, it's just a normal character
$tokenUnderConstruction .= $char;
}
@@ -129,10 +130,9 @@ class QueryParser implements QueryParserInterface
return new NodeResult($this->buildNodeGroup(true, $prohibited),
false
);
} else {
}
// In any other location, it's just a normal character
$tokenUnderConstruction .= $char;
}
break;
case ')':
@@ -157,7 +157,8 @@ class QueryParser implements QueryParserInterface
// If we meet a colon with a left-hand side string, we know we're in a field and are about to set up the value
$fieldName = $tokenUnderConstruction;
$tokenUnderConstruction = '';
} else {
}
if ($tokenUnderConstruction === '') {
// In any other location, it's just a normal character
$tokenUnderConstruction .= $char;
}