-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
1,050 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/tests export-ignore | ||
.gitattributes export-ignore | ||
.github/ export-ignore | ||
.gitignore export-ignore | ||
.travis.yml export-ignore | ||
phpunit.xml.dist export-ignore | ||
* text=auto eol=lf | ||
*.php text whitespace=blank-at-eol,blank-at-eof,space-before-tab,tab-in-indent,tabwidth=4 diff=php | ||
*.json text whitespace=blank-at-eol,blank-at-eof,space-before-tab,tab-in-indent,tabwidth=4 | ||
*.yml text whitespace=blank-at-eol,blank-at-eof,space-before-tab,tab-in-indent,tabwidth=4 | ||
*.md text whitespace=blank-at-eol,blank-at-eof | ||
*.rst text whitespace=blank-at-eol,blank-at-eof |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
composer.phar | ||
/vendor/ | ||
|
||
# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file | ||
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file | ||
# composer.lock | ||
/composer.lock | ||
/build/logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
$finder = PhpCsFixer\Finder::create() | ||
->in('src') | ||
; | ||
|
||
$header = <<<EOT | ||
This file is part of the tmilos/scim-filter-parser package. | ||
(c) Milos Tomic <[email protected]> | ||
This source file is subject to the MIT license that is bundled | ||
with this source code in the file LICENSE. | ||
EOT; | ||
|
||
return PhpCsFixer\Config::create() | ||
->setRules(array( | ||
'@Symfony' => true, | ||
'simplified_null_return' => false, | ||
'phpdoc_no_empty_return' => false, | ||
'no_mixed_echo_print' => ['use' => 'print'], | ||
'header_comment' => ['header' => $header], | ||
)) | ||
->setUsingCache(false) | ||
->setFinder($finder) | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
language: php | ||
|
||
php: | ||
- 5.6 | ||
- 7.0 | ||
- 7.1 | ||
|
||
before_install: | ||
- composer self-update | ||
- composer --version | ||
- wget http://get.sensiolabs.org/php-cs-fixer.phar -O php-cs-fixer.phar | ||
- php php-cs-fixer.phar --version | ||
|
||
install: | ||
- COMPOSER_ROOT_VERSION=dev-master composer update --prefer-source | ||
|
||
script: | ||
- if [ "$TRAVIS_PHP_VERSION" == "7.0" ]; then php php-cs-fixer.phar fix --dry-run -v; fi | ||
- vendor/bin/phpunit --coverage-clover build/logs/clover.xml | ||
|
||
after_script: | ||
- if [ "$TRAVIS_PHP_VERSION" == "7.0" ]; then vendor/bin/coveralls -v; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
// if library is in dev environement with its own vendor, include its autoload | ||
if(file_exists(__DIR__ . '/vendor')) | ||
require_once __DIR__ . '/vendor/autoload.php'; | ||
// if library is in vendor of another project, include the global autolaod | ||
else | ||
require_once __DIR__ . '/../../autoload.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "tmilos/scim-filter-parser", | ||
"description": "SCIM AST filter parser library", | ||
"keywords": ["SCIM", "AST", "parser", "SCIM parser", "SCIM filter parser", "SCIM AST"], | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Milos Tomic", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"autoload": { | ||
"psr-4": { | ||
"Tmilos\\ScimFilterParser\\": "src/", | ||
"Tests\\Tmilos\\ScimFilterParser\\": "tests/" | ||
} | ||
}, | ||
"minimum-stability": "stable", | ||
"require": { | ||
"tmilos/lexer": "^1.0" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^5.7", | ||
"satooshi/php-coveralls": "^1.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html --> | ||
<phpunit | ||
backupGlobals = "false" | ||
backupStaticAttributes = "false" | ||
colors = "false" | ||
convertErrorsToExceptions = "true" | ||
convertNoticesToExceptions = "true" | ||
convertWarningsToExceptions = "true" | ||
processIsolation = "false" | ||
stopOnFailure = "false" | ||
syntaxCheck = "false" | ||
bootstrap = "autoload.php" | ||
> | ||
|
||
<logging> | ||
<log type="junit" target="build/logs/junit.xml" logIncompleteSkipped="false"/> | ||
</logging> | ||
|
||
<testsuites> | ||
<testsuite name="Project Test Suite"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<!-- | ||
<php> | ||
<server name="KERNEL_DIR" value="/path/to/your/app/" /> | ||
</php> | ||
--> | ||
|
||
<filter> | ||
<whitelist> | ||
<directory>src</directory> | ||
</whitelist> | ||
</filter> | ||
|
||
|
||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the tmilos/scim-filter-parser package. | ||
* | ||
* (c) Milos Tomic <[email protected]> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Tmilos\ScimFilterParser\Ast; | ||
|
||
class AttributePath extends Node | ||
{ | ||
/** @var string[] */ | ||
public $attributeNames = []; | ||
|
||
public function add($attributeName) | ||
{ | ||
$this->attributeNames[] = $attributeName; | ||
} | ||
|
||
public function __toString() | ||
{ | ||
return implode('.', $this->attributeNames); | ||
} | ||
|
||
public function dump() | ||
{ | ||
return [ | ||
'AttributePath: '.implode('.', $this->attributeNames), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the tmilos/scim-filter-parser package. | ||
* | ||
* (c) Milos Tomic <[email protected]> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Tmilos\ScimFilterParser\Ast; | ||
|
||
class ComparisonExpression extends Factor | ||
{ | ||
/** @var AttributePath */ | ||
public $attributePath; | ||
|
||
/** @var string */ | ||
public $operator; | ||
|
||
/** @var mixed */ | ||
public $compareValue; | ||
|
||
/** | ||
* @param AttributePath $attributePath | ||
* @param string $operator | ||
* @param mixed $compareValue | ||
*/ | ||
public function __construct(AttributePath $attributePath, $operator, $compareValue = null) | ||
{ | ||
$this->attributePath = $attributePath; | ||
$this->operator = $operator; | ||
$this->compareValue = $compareValue; | ||
} | ||
|
||
public function __toString() | ||
{ | ||
if ($this->operator === 'pr') { | ||
return sprintf('%s %s', $this->attributePath, $this->operator); | ||
} else { | ||
return sprintf('%s %s %s', $this->attributePath, $this->operator, $this->compareValue instanceof \DateTime ? $this->compareValue->format('Y-m-d\TH:i:s\Z') : $this->compareValue); | ||
} | ||
} | ||
|
||
public function dump() | ||
{ | ||
return [ | ||
'ComparisonExpression' => (string) $this, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the tmilos/scim-filter-parser package. | ||
* | ||
* (c) Milos Tomic <[email protected]> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Tmilos\ScimFilterParser\Ast; | ||
|
||
class Conjunction extends Term | ||
{ | ||
/** @var Filter[] */ | ||
private $factors = []; | ||
|
||
/** | ||
* @param Filter[] $factors | ||
*/ | ||
public function __construct(array $factors = []) | ||
{ | ||
foreach ($factors as $factor) { | ||
$this->add($factor); | ||
} | ||
} | ||
|
||
/** | ||
* @param Filter $factor | ||
*/ | ||
public function add(Filter $factor) | ||
{ | ||
$this->factors[] = $factor; | ||
} | ||
|
||
/** | ||
* @return Filter[] | ||
*/ | ||
public function getFactors() | ||
{ | ||
return $this->factors; | ||
} | ||
|
||
public function dump() | ||
{ | ||
$arr = []; | ||
foreach ($this->factors as $factor) { | ||
$arr[] = $factor->dump(); | ||
} | ||
|
||
return [ | ||
'Conjunction' => $arr, | ||
]; | ||
} | ||
|
||
public function __toString() | ||
{ | ||
return implode(' and ', $this->factors); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the tmilos/scim-filter-parser package. | ||
* | ||
* (c) Milos Tomic <[email protected]> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Tmilos\ScimFilterParser\Ast; | ||
|
||
class Disjunction extends Filter | ||
{ | ||
/** @var Term[] */ | ||
private $terms = []; | ||
|
||
/** | ||
* @param Term[] $terms | ||
*/ | ||
public function __construct(array $terms = []) | ||
{ | ||
foreach ($terms as $term) { | ||
$this->add($term); | ||
} | ||
} | ||
|
||
/** | ||
* @param Term $term | ||
*/ | ||
public function add(Term $term) | ||
{ | ||
$this->terms[] = $term; | ||
} | ||
|
||
/** | ||
* @return Term[] | ||
*/ | ||
public function getTerms() | ||
{ | ||
return $this->terms; | ||
} | ||
|
||
public function __toString() | ||
{ | ||
return implode(' or ', $this->terms); | ||
} | ||
|
||
public function dump() | ||
{ | ||
$arr = []; | ||
foreach ($this->terms as $term) { | ||
$arr[] = $term->dump(); | ||
} | ||
|
||
return [ | ||
'Disjunction' => $arr, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the tmilos/scim-filter-parser package. | ||
* | ||
* (c) Milos Tomic <[email protected]> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Tmilos\ScimFilterParser\Ast; | ||
|
||
abstract class Factor extends Term | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the tmilos/scim-filter-parser package. | ||
* | ||
* (c) Milos Tomic <[email protected]> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Tmilos\ScimFilterParser\Ast; | ||
|
||
abstract class Filter extends Node | ||
{ | ||
} |
Oops, something went wrong.