Skip to content

Chain multiple comparision expressions#6

Open
andreigorgan wants to merge 9 commits into
tmilos:masterfrom
webchainro:chain_multiple_comparisions
Open

Chain multiple comparision expressions#6
andreigorgan wants to merge 9 commits into
tmilos:masterfrom
webchainro:chain_multiple_comparisions

Conversation

@andreigorgan
Copy link
Copy Markdown
Contributor

Added the possiblity to chain multiple comparision expression in a single Disjunction/Conjunction

@coveralls
Copy link
Copy Markdown

coveralls commented Feb 4, 2020

Coverage Status

Coverage decreased (-1.0%) to 90.4% when pulling 4ce3dce on webchainro:chain_multiple_comparisions into c022625 on tmilos:master.

Comment thread src/Ast/Disjunction.php
* @return Term[]
* @return Filter[]
*/
public function getTerms()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming changing this from Term[] to Filter[] doesn't break anything, I would suggest renaming this to getFilters().

Comment thread src/Ast/Disjunction.php
{
/** @var Term[] */
/** @var Filter[] */
private $terms = [];
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rename this to $filters.

Comment thread src/Ast/Disjunction.php

/**
* @param Term[] $terms
* @param Filter[] $terms
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same goes for this one, I would rename to $filters

Comment thread src/Ast/Disjunction.php
* @param Filter $term
*/
public function add(Term $term)
public function add(Filter $term)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same goes for this one, I would rename to $filter

Comment thread src/Ast/Path.php
Comment on lines +67 to +82

/**
* @return AttributePath
*/
public function getAttributePath()
{
return $this->attributePath;
}

/**
* @return ValuePath
*/
public function getValuePath()
{
return $this->valuePath;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's already a pending PR for this one: #7

Comment thread src/Parser.php
Comment on lines 130 to 141

if ($this->lexer->isNextToken(Tokens::T_SP)) {
$isNextTokenOr = true;
while($this->lexer->isNextToken(Tokens::T_SP) && $isNextTokenOr) {
$nextToken = $this->lexer->glimpse();
if ($this->isName('or', $nextToken)) {
$this->match(Tokens::T_SP);
$this->match(Tokens::T_NAME);
$this->match(Tokens::T_SP);
$terms[] = $this->conjunction();
} else {
$isNextTokenOr = false;
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using a variable to break the while loop, simply use the break statement instead.

while ($this->lexer->isNextToken(Tokens::T_SP)) {
    $nextToken = $this->lexer->glimpse();
    
    if ($this->isName('or', $nextToken) === false) {
        break;
    }
    
    $this->match(Tokens::T_SP);
    $this->match(Tokens::T_NAME);
    $this->match(Tokens::T_SP);
    $terms[] = $this->conjunction();
}

Comment thread src/Parser.php
Comment on lines 155 to 169

if ($this->lexer->isNextToken(Tokens::T_SP)) {
$isNextTokenAnd = true;
while($this->lexer->isNextToken(Tokens::T_SP) && $isNextTokenAnd) {
$nextToken = $this->lexer->glimpse();
if ($this->isName('and', $nextToken)) {
$this->match(Tokens::T_SP);
$this->match(Tokens::T_NAME);
$this->match(Tokens::T_SP);
$factors[] = $this->factor();
} else {
$isNextTokenAnd = false;
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same goes for this one:

while ($this->lexer->isNextToken(Tokens::T_SP)) {
    $nextToken = $this->lexer->glimpse();
    
    if ($this->isName('and', $nextToken) === false) {
        break;
    }
    
    $this->match(Tokens::T_SP);
    $this->match(Tokens::T_NAME);
    $this->match(Tokens::T_SP);
    $factors[] = $this->factor();
}

@dbollaer
Copy link
Copy Markdown

dbollaer commented Aug 12, 2022

Hello @mdeboer / @tmilos any hope of merging this PR? I am running against this issue. Thank you in advance!

@mdeboer
Copy link
Copy Markdown

mdeboer commented Aug 12, 2022

@dbollaer Well this repository isn't mine so don't ask me haha. Given the last release was in 2017, I doubt it though. Shameless plug but you could try mine if you like: https://github.com/Cloudstek/scim-filter-parser

@stevebauman
Copy link
Copy Markdown

Noice, thanks @mdeboer! Appreciate that you've taken the helm of this 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants