Skip to content

Commit

Permalink
fixup coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
instabledesign committed Dec 20, 2023
1 parent 4786426 commit 52d74bb
Show file tree
Hide file tree
Showing 18 changed files with 862 additions and 80 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
vendor
coverage
composer.lock
.phpunit.cache
.phpunit.result.cache
.php-cs-fixer.cache
.clover.xml
691 changes: 691 additions & 0 deletions clover.xml

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheResultFile=".phpunit.cache/test-results"
executionOrder="depends,defects"
forceCoversAnnotation="true"
beStrictAboutCoversAnnotation="false"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
convertDeprecationsToExceptions="true"
failOnRisky="true"
failOnWarning="true"
verbose="true">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>

<coverage cacheDirectory=".phpunit.cache/code-coverage"
processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
<exclude>
<directory>src/Exception</directory>
</exclude>
<report>
<clover outputFile="clover.xml" />
</report>
</coverage>
</phpunit>
25 changes: 0 additions & 25 deletions phpunit.xml.dist

This file was deleted.

17 changes: 9 additions & 8 deletions src/Lexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ protected function getCatchablePatterns()
'≤|≥|≠|<=|>=|!=|<|>|=|\[|!\[|\]|!{{|{{|}}', // Comparison operator
'[a-z_][a-z0-9_\.\-]*', // identifier or qualified name
'(?:[+-]?[0-9]*(?:[\.][0-9]+)*)', // numbers
// '(?:[+-]?(?:(?:(?:[0-9]+|(?:[0-9]*[\.][0-9]+)|(?:[0-9]+[\.][0-9]*))[eE][+-]?[0-9]+)|(?:[0-9]*[\.][0-9]+)|(?:[0-9]+[\.][0-9]*)))', // number extended all float (.5 / 1.5 / -1.2e3)
];
}

Expand Down Expand Up @@ -184,21 +185,21 @@ protected function getType(&$value)

break;

// Recognize numeric values
// Recognize numeric values
case is_numeric($value):
if (str_contains($value, '.') || false !== stripos($value, 'e')) {
$value = (float) $value;
$value = (float)$value;
$type = self::T_FLOAT;

break;
}

$value = (int) $value;
$value = (int)$value;
$type = self::T_INTEGER;

break;

// Recognize quoted strings
// Recognize quoted strings
case '"' === $value[0]:
$value = str_replace('""', '"', substr($value, 1, \strlen($value) - 2));

Expand All @@ -218,7 +219,7 @@ protected function getType(&$value)

break;

// Comparison operator
// Comparison operator
case '=' === $value:
$type = self::T_EQUALS;

Expand Down Expand Up @@ -255,7 +256,7 @@ protected function getType(&$value)

break;

// Composite operator
// Composite operator
case '&' === $value:
$type = self::T_AND;

Expand Down Expand Up @@ -283,7 +284,7 @@ protected function getType(&$value)

break;

// Brace
// Brace
case '(' === $value:
$type = self::T_OPEN_PARENTHESIS;

Expand Down Expand Up @@ -324,7 +325,7 @@ protected function getType(&$value)

break;

// Default
// Default
default:
throw new UnknownTokenTypeException($value);
}
Expand Down
11 changes: 3 additions & 8 deletions src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,12 @@ public function __construct(ExpressionBuilderInterface $expressionBuilder)
$this->expressionBuilder = $expressionBuilder;
}

public function getAllowedTokenType(): int
{
return $this->allowedTokenType;
}

/**
* @throws InvalidExpressionException
*/
public function parse(string $input, ?int $allowedTokenType = null): mixed
{
$this->allowedTokenType = $allowedTokenType ?: Lexer::T_ALL;
$this->allowedTokenType = null !== $allowedTokenType ? $allowedTokenType : Lexer::T_ALL;
$this->supportedTokenType = $this->expressionBuilder->getSupportedTokenType();

try {
Expand Down Expand Up @@ -143,13 +138,13 @@ private function getExpression(mixed $previousExpression = null): mixed
case Lexer::T_INPUT_PARAMETER:
$currentTokenValue = $this->expressionBuilder->parameter($currentToken['value'], null !== $comparisonFirstOperande);

// no break
// no break
case Lexer::T_STRING:
if (!isset($currentTokenValue)) {
$currentTokenValue = $this->expressionBuilder->string($currentToken['value']);
}

// no break
// no break
case Lexer::T_INTEGER:
case Lexer::T_FLOAT:
if (!isset($currentTokenValue)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
use Symftony\Xpression\Exception\Expr\UnsupportedExpressionTypeException;

/**
* @internal
*
* @coversNothing
* @covers \Symftony\Xpression\Bridge\Doctrine\Common\ExpressionBuilderAdapter
*/
final class ExpressionBuilderAdapterTest extends TestCase
{
Expand Down
5 changes: 2 additions & 3 deletions tests/Bridge/Doctrine/Common/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
use Symftony\Xpression\Parser;

/**
* @internal
*
* @coversNothing
* @covers \Symftony\Xpression\Parser
* @covers \Symftony\Xpression\Bridge\Doctrine\Common\ExpressionBuilderAdapter
*/
final class ParserTest extends TestCase
{
Expand Down
4 changes: 1 addition & 3 deletions tests/Bridge/Doctrine/ORM/ExprAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
use Symftony\Xpression\Exception\Expr\UnsupportedExpressionTypeException;

/**
* @internal
*
* @coversNothing
* @covers \Symftony\Xpression\Bridge\Doctrine\ORM\ExprAdapter
*/
final class ExprAdapterTest extends TestCase
{
Expand Down
5 changes: 2 additions & 3 deletions tests/Bridge/Doctrine/ORM/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
use Symftony\Xpression\Parser;

/**
* @internal
*
* @coversNothing
* @covers \Symftony\Xpression\Parser
* @covers \Symftony\Xpression\Bridge\Doctrine\ORM\ExprAdapter
*/
final class ParserTest extends TestCase
{
Expand Down
4 changes: 1 addition & 3 deletions tests/Bridge/MongoDB/ExprBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
use Symftony\Xpression\Lexer;

/**
* @internal
*
* @coversNothing
* @covers \Symftony\Xpression\Bridge\MongoDB\ExprBuilder
*/
final class ExprBuilderTest extends TestCase
{
Expand Down
9 changes: 3 additions & 6 deletions tests/Bridge/MongoDB/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
use Symftony\Xpression\Parser;

/**
* @internal
*
* @coversNothing
* @covers \Symftony\Xpression\Parser
* @covers \Symftony\Xpression\Bridge\MongoDB\ExprBuilder
*/
final class ParserTest extends TestCase
{
Expand Down Expand Up @@ -202,10 +201,8 @@ public static function provideParserCases(): iterable

/**
* @dataProvider provideParserCases
*
* @param mixed $expectedExpression
*/
public function testParser(string $input, $expectedExpression): void
public function testParser(string $input, array $expectedExpression): void
{
self::assertSame($expectedExpression, $this->parser->parse($input));
}
Expand Down
4 changes: 1 addition & 3 deletions tests/Expr/ClosureExpressionBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
use Symftony\Xpression\Lexer;

/**
* @internal
*
* @coversNothing
* @covers \Symftony\Xpression\Expr\ClosureExpressionBuilder
*/
final class ClosureExpressionBuilderTest extends TestCase
{
Expand Down
4 changes: 1 addition & 3 deletions tests/Expr/HtmlExpressionBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
use Symftony\Xpression\Lexer;

/**
* @internal
*
* @coversNothing
* @covers \Symftony\Xpression\Expr\HtmlExpressionBuilder
*/
final class HtmlExpressionBuilderTest extends TestCase
{
Expand Down
4 changes: 1 addition & 3 deletions tests/Expr/MapperExpressionBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
use Symftony\Xpression\Expr\MapperExpressionBuilder;

/**
* @internal
*
* @coversNothing
* @covers \Symftony\Xpression\Expr\MapperExpressionBuilder
*/
final class MapperExpressionBuilderTest extends TestCase
{
Expand Down
Loading

0 comments on commit 52d74bb

Please sign in to comment.