Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tokenizer/PHP: fix ? tokenization after attribute #3446

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/Standards/PSR12/Tests/Operators/OperatorSpacingUnitTest.inc
Expand Up @@ -63,3 +63,15 @@ $fn = fn(array & $one) => 1;
$fn = static fn(DateTime $a, DateTime $b): int => -($a->getTimestamp() <=> $b->getTimestamp());

function issue3267(string|int ...$values) {}

function setDefault(#[ImportValue(
constraints: [
[
Assert\Type::class,
['type' => 'bool'],
],
]
)] ?bool $value = null): void
{
// Do something
}
Expand Up @@ -63,3 +63,15 @@ $fn = fn(array & $one) => 1;
$fn = static fn(DateTime $a, DateTime $b): int => -($a->getTimestamp() <=> $b->getTimestamp());

function issue3267(string|int ...$values) {}

function setDefault(#[ImportValue(
constraints: [
[
Assert\Type::class,
['type' => 'bool'],
],
]
)] ?bool $value = null): void
{
// Do something
}
2 changes: 1 addition & 1 deletion src/Tokenizers/PHP.php
Expand Up @@ -1576,7 +1576,7 @@ protected function tokenize($string)
&& isset(Util\Tokens::$emptyTokens[$tokenType]) === false
) {
// Found the previous non-empty token.
if ($tokenType === ':' || $tokenType === ',') {
if ($tokenType === ':' || $tokenType === ',' || $tokenType === T_ATTRIBUTE_END) {
$newToken['code'] = T_NULLABLE;
$newToken['type'] = 'T_NULLABLE';

Expand Down