Skip to content

Commit

Permalink
Merge pull request doctrine#86 from greg0ire/1.3.x
Browse files Browse the repository at this point in the history
Merge 1.2.x up into 1.3.x
  • Loading branch information
greg0ire authored Dec 10, 2022
2 parents 241097b + b8d0c3c commit 6b5a192
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 12 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"doctrine/coding-standard": "^9 || ^10",
"phpstan/phpstan": "^1.3",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
"vimeo/psalm": "^4.11"
"psalm/plugin-phpunit": "^0.18.3",
"vimeo/psalm": "^4.11 || ^5.0"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Common/Lexer/AbstractLexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public function skipUntil($type)
/**
* Checks if given value is identical to the given token.
*
* @param mixed $value
* @param string $value
* @param int|string $token
*
* @return bool
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
level: 7
level: max
paths:
- %rootDir%/../../../lib
- %rootDir%/../../../tests
17 changes: 14 additions & 3 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
<?xml version="1.0"?>
<psalm
errorLevel="5"
errorLevel="1"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="lib/Doctrine/Common/Lexer" />
<directory name="lib/Doctrine/Common/Lexer"/>
<directory name="tests/Doctrine/Common/Lexer"/>
<ignoreFiles>
<directory name="vendor" />
<directory name="vendor"/>
</ignoreFiles>
</projectFiles>
<plugins>
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
</plugins>
<issueHandlers>
<MixedAssignment>
<errorLevel type="suppress">
<file name="lib/Doctrine/Common/Lexer/AbstractLexer.php" />
</errorLevel>
</MixedAssignment>
</issueHandlers>
</psalm>
10 changes: 8 additions & 2 deletions tests/Doctrine/Common/Lexer/AbstractLexerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use PHPUnit\Framework\TestCase;

use function array_map;
use function assert;
use function count;
use function setlocale;

Expand Down Expand Up @@ -184,6 +185,7 @@ public function testPeek(string $input, array $expectedTokens): void
$this->concreteLexer->setInput($input);
foreach ($expectedTokens as $expectedToken) {
$actualToken = $this->concreteLexer->peek();
assert($actualToken !== null);
$this->assertEquals($expectedToken, $actualToken);
$this->assertSame($expectedToken['value'], $actualToken['value']);
$this->assertSame($expectedToken['type'], $actualToken['type']);
Expand All @@ -205,6 +207,8 @@ public function testGlimpse(string $input, array $expectedTokens): void

foreach ($expectedTokens as $expectedToken) {
$actualToken = $this->concreteLexer->glimpse();
assert($actualToken !== null);
$this->assertEquals($expectedToken, $actualToken);
$this->assertEquals($expectedToken, $this->concreteLexer->glimpse());
$this->assertSame($expectedToken['value'], $actualToken['value']);
$this->assertSame($expectedToken['type'], $actualToken['type']);
Expand Down Expand Up @@ -284,8 +288,8 @@ public function testGetLiteral(): void

public function testIsA(): void
{
$this->assertTrue($this->concreteLexer->isA(11, 'int'));
$this->assertTrue($this->concreteLexer->isA(1.1, 'int'));
$this->assertTrue($this->concreteLexer->isA('11', 'int'));
$this->assertTrue($this->concreteLexer->isA('1.1', 'int'));
$this->assertTrue($this->concreteLexer->isA('=', 'operator'));
$this->assertTrue($this->concreteLexer->isA('>', 'operator'));
$this->assertTrue($this->concreteLexer->isA('<', 'operator'));
Expand All @@ -299,13 +303,15 @@ public function testAddCatchablePatternsToMutableLexer(): void
$mutableLexer->setInput('one');
$token = $mutableLexer->glimpse();

$this->assertNotNull($token);
$this->assertEquals('o', $token['value']);

$mutableLexer = new MutableLexer();
$mutableLexer->addCatchablePattern('[a-z]+');
$mutableLexer->setInput('one');
$token = $mutableLexer->glimpse();

$this->assertNotNull($token);
$this->assertEquals('one', $token['value']);
}

Expand Down
5 changes: 1 addition & 4 deletions tests/Doctrine/Common/Lexer/ConcreteLexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

use function in_array;
use function is_numeric;
use function is_string;

class ConcreteLexer extends AbstractLexer
{
Expand Down Expand Up @@ -52,8 +51,6 @@ protected function getType(&$value): string
return 'operator';
}

if (is_string($value)) {
return 'string';
}
return 'string';
}
}

0 comments on commit 6b5a192

Please sign in to comment.