Skip to content

Commit

Permalink
Merge pull request #36 from Defender32/improves-parser
Browse files Browse the repository at this point in the history
improves parser multi byte string
  • Loading branch information
guilhermeblanco authored Oct 30, 2019
2 parents 29ed26d + 2f59289 commit 5242d66
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/Doctrine/Common/Lexer/AbstractLexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public function getLiteral($token)
*/
protected function getModifiers()
{
return 'i';
return 'iu';
}

/**
Expand Down
29 changes: 29 additions & 0 deletions tests/Doctrine/Common/Lexer/AbstractLexerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
namespace Doctrine\Tests\Common\Lexer;

use PHPUnit\Framework\TestCase;
use const LC_ALL;
use function array_map;
use function count;
use function setlocale;

class AbstractLexerTest extends TestCase
{
Expand All @@ -18,6 +20,14 @@ public function setUp() : void
$this->concreteLexer = new ConcreteLexer();
}

/**
* {@inheritdoc}
*/
public function tearDown() : void
{
setlocale(LC_ALL, null);
}

public function dataProvider()
{
return [
Expand Down Expand Up @@ -286,4 +296,23 @@ public function testAddCatchablePatternsToMutableLexer()

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

public function testMarkerAnnotationLocaleTr() : void
{
setlocale(LC_ALL, 'tr_TR.utf8', 'tr_TR');
$mutableLexer = new MutableLexer();
$mutableLexer->addCatchablePattern('[a-z_\\\][a-z0-9_\:\\\]*[a-z_][a-z0-9_]*');
$mutableLexer->addCatchablePattern('(?:[+-]?[0-9]+(?:[\.][0-9]+)*)(?:[eE][+-]?[0-9]+)?');
$mutableLexer->addCatchablePattern('"(?:""|[^"])*+"');
$mutableLexer->setInput('@ODM\Id');

self::assertNull($mutableLexer->token);
self::assertNull($mutableLexer->lookahead);
self::assertTrue($mutableLexer->moveNext());
self::assertNull($mutableLexer->token);
self::assertEquals('@', $mutableLexer->lookahead['value']);
self::assertTrue($mutableLexer->moveNext());
self::assertEquals('@', $mutableLexer->token['value']);
self::assertEquals('ODM\Id', $mutableLexer->lookahead['value']);
}
}
5 changes: 0 additions & 5 deletions tests/Doctrine/Common/Lexer/ConcreteLexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,4 @@ protected function getType(&$value)

return null;
}

protected function getModifiers()
{
return parent::getModifiers() . 'u';
}
}

0 comments on commit 5242d66

Please sign in to comment.