Skip to content

Commit

Permalink
Drop php7 and drop doctrine/mongodb
Browse files Browse the repository at this point in the history
  • Loading branch information
instabledesign committed Dec 8, 2023
1 parent 65c123d commit 4a699f4
Show file tree
Hide file tree
Showing 26 changed files with 1,754 additions and 2,754 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
vendor
composer.lock
.phpunit.result.cache
31 changes: 22 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,37 @@
],
"type": "library",
"description": "Xpression is a simple PHP implementation of Specification pattern",
"keywords": ["dsl", "doctrine", "orm", "mongodb", "collections", "specification", "expression", "parser", "lexer", "query", "builder", "query builder"],
"keywords": [
"dsl",
"doctrine",
"orm",
"mongodb",
"collections",
"specification",
"expression",
"parser",
"lexer",
"query",
"builder",
"query builder"
],
"homepage": "https://github.com/symftony/Xpression",
"require": {
"php": ">=7.0",
"php": "^8.0",
"doctrine/lexer": "^1.0"
},
"scripts": {
"test": "vendor/bin/phpunit"
},
"require-dev": {
"phpunit/phpunit": "^5",
"doctrine/collections": "^1.0",
"doctrine/orm": "^2.4.0"
"doctrine/orm": "^2.4.0",
"phpspec/prophecy": "^1.18",
"phpunit/phpunit": "^9.6"
},
"scripts": {
"test": "vendor/bin/phpunit"
},
"suggest": {
"doctrine/collections": "If you want filter an ArrayCollection",
"doctrine/orm": "If you want filter an ORM query builder",
"doctrine/mongodb": "If you want filter an Mongodb query builder"
"doctrine/orm": "If you want filter an ORM query builder"
},
"license": "MIT",
"autoload": {
Expand Down
37 changes: 17 additions & 20 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
convertNoticesToExceptions="true"
>
<php>
<ini name="error_reporting" value="-1" />
</php>

<testsuites>
<testsuite name="Xpression Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>src</directory>
<exclude>
<directory>src/Exception</directory>
</exclude>
</whitelist>
</filter>
<coverage>
<include>
<directory>src</directory>
</include>
<exclude>
<directory>src/Exception</directory>
</exclude>
</coverage>
<php>
<ini name="error_reporting" value="-1"/>
</php>
<testsuites>
<testsuite name="Xpression Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
133 changes: 17 additions & 116 deletions src/Bridge/Doctrine/Common/ExpressionBuilderAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,160 +2,84 @@

namespace Symftony\Xpression\Bridge\Doctrine\Common;

use Doctrine\Common\Collections\Expr\Comparison;
use Doctrine\Common\Collections\Expr\CompositeExpression;
use Doctrine\Common\Collections\ExpressionBuilder;
use Symftony\Xpression\Expr\ExpressionBuilderInterface;
use Symftony\Xpression\Exception\Expr\UnsupportedExpressionTypeException;
use Symftony\Xpression\Lexer;

class ExpressionBuilderAdapter implements ExpressionBuilderInterface
{
/**
* @var ExpressionBuilder
*/
private $expressionBuilder;
private ExpressionBuilder $expressionBuilder;

public function __construct(ExpressionBuilder $expressionBuilder)
{
$this->expressionBuilder = $expressionBuilder;
}

/**
* @return int
*/
public function getSupportedTokenType()
public function getSupportedTokenType(): int
{
return Lexer::T_ALL - Lexer::T_NOT_AND - Lexer::T_NOT_OR - Lexer::T_XOR - Lexer::T_NOT_DOUBLE_OPEN_CURLY_BRACKET;
}

/**
* @param $value
* @param bool $isValue
*
* @return mixed
*/
public function parameter($value, $isValue = false)
public function parameter(mixed $value, bool $isValue = false): mixed
{
return $value;
}

/**
* @param $value
* @return mixed
*/
public function string($value)
public function string($value): mixed
{
return $value;
}

/**
* @param string $field
*
* @return Comparison
*/
public function isNull($field)
public function isNull(string $field)
{
return $this->expressionBuilder->isNull($field);
}

/**
* @param string $field
* @param mixed $value
*
* @return Comparison
*/
public function eq($field, $value)
public function eq(string $field, mixed $value)
{
return $this->expressionBuilder->eq($field, $value);
}

/**
* @param string $field
* @param mixed $value
*
* @return Comparison
*/
public function neq($field, $value)
public function neq(string $field, mixed $value)
{
return $this->expressionBuilder->neq($field, $value);
}

/**
* @param string $field
* @param mixed $value
*
* @return Comparison
*/
public function gt($field, $value)
public function gt(string $field, mixed $value)
{
return $this->expressionBuilder->gt($field, $value);
}

/**
* @param string $field
* @param mixed $value
*
* @return Comparison
*/
public function gte($field, $value)
public function gte(string $field, mixed $value)
{
return $this->expressionBuilder->gte($field, $value);
}

/**
* @param string $field
* @param mixed $value
*
* @return Comparison
*/
public function lt($field, $value)
public function lt(string $field, mixed $value)
{
return $this->expressionBuilder->lt($field, $value);
}

/**
* @param string $field
* @param mixed $value
*
* @return Comparison
*/
public function lte($field, $value)
public function lte(string $field, mixed $value)
{
return $this->expressionBuilder->lte($field, $value);
}

/**
* @param string $field
* @param mixed $values
*
* @return Comparison
*/
public function in($field, array $values)
public function in(string $field, array $values)
{
return $this->expressionBuilder->in($field, $values);
}

/**
* @param string $field
* @param mixed $values
*
* @return Comparison
*/
public function notIn($field, array $values)
public function notIn(string $field, array $values)
{
return $this->expressionBuilder->notIn($field, $values);
}

/**
* /!\ Contains operator appear only in doctrine/common v1.1 /!\
*
* @param string $field
* @param mixed $value
*
* @return Comparison
*/
public function contains($field, $value)
public function contains(string $field, mixed $value)
{
if (!method_exists($this->expressionBuilder, 'contains')) {
throw new UnsupportedExpressionTypeException('contains');
Expand All @@ -164,54 +88,31 @@ public function contains($field, $value)
return $this->expressionBuilder->contains($field, $value);
}

/**
* @param string $field
* @param mixed $value
*/
public function notContains($field, $value)
public function notContains(string $field, mixed $value)
{
throw new UnsupportedExpressionTypeException('notContains');
}

/**
* @param array $expressions
*
* @return CompositeExpression
*/
public function andX(array $expressions)
{
return call_user_func_array(array($this->expressionBuilder, 'andX'), $expressions);
return call_user_func_array([$this->expressionBuilder, 'andX'], $expressions);
}

/**
* @param array $expressions
*/
public function nandX(array $expressions)
{
throw new UnsupportedExpressionTypeException('nandX');
}

/**
* @param array $expressions
*
* @return CompositeExpression
*/
public function orX(array $expressions)
{
return call_user_func_array(array($this->expressionBuilder, 'orX'), $expressions);
return call_user_func_array([$this->expressionBuilder, 'orX'], $expressions);
}

/**
* @param array $expressions
*/
public function norX(array $expressions)
{
throw new UnsupportedExpressionTypeException('norX');
}

/**
* @param array $expressions
*/
public function xorX(array $expressions)
{
throw new UnsupportedExpressionTypeException('xorX');
Expand Down
Loading

0 comments on commit 4a699f4

Please sign in to comment.