-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce NAMED_ARGUMENT_OPERATOR_TYPE
- Loading branch information
1 parent
10bdf19
commit 3081cdc
Showing
8 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -579,6 +579,9 @@ private function lexArrowFunction(): void | |
$this->pushToken(Token::ARROW_TYPE, '=>'); | ||
} | ||
|
||
/** | ||
* @throws CannotTokenizeException | ||
*/ | ||
private function lexOperator(string $operator): void | ||
Check failure on line 585 in src/Token/Tokenizer.php GitHub Actions / PHPStan
|
||
{ | ||
if ('?' === $operator) { | ||
|
@@ -587,6 +590,17 @@ private function lexOperator(string $operator): void | |
} elseif (':' === $operator && $this->isInTernary()) { | ||
$bracket = array_pop($this->bracketsAndTernary); | ||
$this->pushToken(Token::OPERATOR_TYPE, $operator, $bracket); | ||
} elseif ('=' === $operator) { | ||
$bracket = end($this->bracketsAndTernary); | ||
if (false !== $bracket && '(' === $bracket->getValue()) { | ||
// This is a named argument operator instead | ||
$this->pushToken(Token::NAMED_ARGUMENT_OPERATOR_TYPE, $operator); | ||
|
||
return; | ||
} | ||
|
||
|
||
$this->pushToken(Token::OPERATOR_TYPE, $operator); | ||
} else { | ||
$this->pushToken(Token::OPERATOR_TYPE, $operator); | ||
} | ||
|
@@ -681,6 +695,12 @@ private function lexPunctuation(): void | |
|
||
return; | ||
} | ||
if ('(' === $bracket->getValue()) { | ||
// This is a named argument operator instead | ||
$this->pushToken(Token::NAMED_ARGUMENT_OPERATOR_TYPE, $currentCode); | ||
|
||
return; | ||
} | ||
|
||
$this->pushToken(Token::PUNCTUATION_TYPE, $currentCode); | ||
} else { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{% set foo=1 %} | ||
{{ foo(foo=1) }} | ||
{{ foo(foo:1) }} | ||
{{ foo({foo:1}) }} | ||
{{ (foo==1) }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters