Skip to content
This repository has been archived by the owner on May 20, 2019. It is now read-only.

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
SerafimArts authored and StyleCIBot committed Jan 18, 2019
1 parent d64fb0b commit 37eb8f6
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/Lexer/Definition/MultistateTokenDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class MultistateTokenDefinition extends TokenDefinition
public function __construct(string $name, string $pcre, bool $keep = true, int $state = 0, int $nextState = 0)
{
parent::__construct($name, $pcre, $keep);
$this->state = $state;
$this->state = $state;
$this->nextState = $nextState;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Lexer/Driver/MultistateLexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ public function state(string $token, int $state, int $nextState = null): Multist
public function getTokenDefinitions(): iterable
{
foreach ($this->tokens as $name => $pcre) {
$keep = ! \in_array($name, $this->skipped, true);
$keep = ! \in_array($name, $this->skipped, true);
$state = $this->getTokenState($name);
$next = $this->getNextState($name);
$next = $this->getNextState($name);

yield new MultistateTokenDefinition($name, $pcre, $keep, $state, $next);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Lexer/Driver/NativeRegex.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class NativeRegex extends SimpleLexer
*/
public function __construct(array $tokens = [], array $skip = [])
{
$this->tokens = $tokens;
$this->tokens = $tokens;
$this->skipped = $skip;
}

Expand All @@ -42,7 +42,7 @@ public function __construct(array $tokens = [], array $skip = [])
protected function exec(Readable $file): \Traversable
{
$offset = 0;
$regex = new RegexNamedGroupsIterator($this->getPattern(), $file->getContents());
$regex = new RegexNamedGroupsIterator($this->getPattern(), $file->getContents());

$iterator = $regex->getIterator();

Expand Down
6 changes: 3 additions & 3 deletions src/Lexer/Driver/NativeStateful/PCRECompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class PCRECompiler
*/
protected const REGEX_DELIMITER = '/';

private const FLAG_UNICODE = 'u';
private const FLAG_DOT_ALL = 's';
private const FLAG_UNICODE = 'u';
private const FLAG_DOT_ALL = 's';
private const FLAG_ANALYZED = 'S';

/**
Expand Down Expand Up @@ -70,7 +70,7 @@ private function tokensToPattern(iterable $tokens): string
$tokensList = [];

foreach ($tokens as $name => $pcre) {
$name = $this->escapeTokenName($name);
$name = $this->escapeTokenName($name);
$value = $this->escapeTokenPattern($pcre);

$tokensList[] = \sprintf('(?P<%s>%s)', \trim($name), $value);
Expand Down
8 changes: 4 additions & 4 deletions src/Lexer/Driver/ParleLexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct(array $tokens = [], array $skip = [])
{
\assert(\class_exists(Parle::class, false));

$this->lexer = new Parle();
$this->lexer = new Parle();
$this->skipped = $skip;

foreach ($tokens as $name => $pcre) {
Expand All @@ -70,7 +70,7 @@ public function add(string $name, string $pcre): LexerInterface
try {
$this->lexer->push($pcre, $this->id);

$this->map[$this->id] = $name;
$this->map[$this->id] = $name;
$this->tokens[$this->id] = $pcre;
} catch (LexerException $e) {
$message = \preg_replace('/rule\h+id\h+\d+/iu', 'token ' . $name, $e->getMessage());
Expand Down Expand Up @@ -132,8 +132,8 @@ private function unknown(\Traversable $iterator): TokenInterface
{
/** @var InternalToken $current */
$current = $iterator->current();
$offset = $this->lexer->marker;
$body = '';
$offset = $this->lexer->marker;
$body = '';

while ($current->id === InternalToken::UNKNOWN) {
$body .= $current->value;
Expand Down
6 changes: 3 additions & 3 deletions src/Lexer/Iterator/RegexIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
*/
class RegexIterator implements \IteratorAggregate
{
public const PREG_PARSING_ERROR = 'The error occurs while compiling PCRE';
public const PREG_INTERNAL_ERROR = 'There was an internal PCRE error';
public const PREG_PARSING_ERROR = 'The error occurs while compiling PCRE';
public const PREG_INTERNAL_ERROR = 'There was an internal PCRE error';
public const PREG_BACKTRACK_LIMIT_ERROR = 'Backtrack limit was exhausted';
public const PREG_RECURSION_LIMIT_ERROR = 'Recursion limit was exhausted';
public const PREG_BAD_UTF8_ERROR = 'The offset didn\'t correspond to the begin of a valid UTF-8 code point';
public const PREG_BAD_UTF8_ERROR = 'The offset didn\'t correspond to the begin of a valid UTF-8 code point';
public const PREG_BAD_UTF8_OFFSET_ERROR = 'Malformed UTF-8 data';

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Lexer/Result/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class Token extends BaseToken
*/
public function __construct(string $name, $value, int $offset = 0)
{
$this->name = $name;
$this->value = (array)$value;
$this->name = $name;
$this->value = (array)$value;
$this->offset = $offset;
}

Expand Down
4 changes: 2 additions & 2 deletions tests/BenchTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function testParleLexer(int $samples, Readable $sources): void
}

$tokens = require __DIR__ . '/resources/graphql.lex.php';
$lexer = new ParleLexer();
$lexer = new ParleLexer();

foreach ($tokens as $token => $pcre) {
$lexer->add($token, $pcre);
Expand All @@ -73,7 +73,7 @@ public function testParleLexer(int $samples, Readable $sources): void
*/
private function execute(LexerInterface $lexer, int $samples, Readable $sources): void
{
$cnt = 0;
$cnt = 0;
$results = [];

for ($i = 0; $i < $samples; ++$i) {
Expand Down
2 changes: 1 addition & 1 deletion tests/LexerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function testDigitsWithSkipped(LexerInterface $lexer): void
*/
public function testUnknownLookahead(LexerInterface $lexer): void
{
$file = File::fromSources("23 \nunknown \n42");
$file = File::fromSources("23 \nunknown \n42");
$result = \iterator_to_array($lexer->lex($file));

$this->assertCount(4, $result);
Expand Down

0 comments on commit 37eb8f6

Please sign in to comment.