FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Key should be quoted when it contains spaces in ArrayShapeItemNode · Issue #251 · phpstan/phpdoc-parser · GitHub

Key should be quoted when it contains spaces in ArrayShapeItemNode #251

Description

I noticed something odd.

$input = "array{states: array{'Hello World': int}}";
$expected = "array{states: array{'Hello World': int}}";
$lexer = new Lexer();
$constExprParser = new ConstExprParser(true, true);
$typeParser = new TypeParser($constExprParser);
$phpDocParser = new PhpDocParser($typeParser, $constExprParser);

$tokens = new TokenIterator($lexer->tokenize($input));
$phpDocNode = $phpDocParser->parseTagValue($tokens, '@var');

$this->assertInstanceOf(VarTagValueNode::class, $phpDocNode);
$this->assertInstanceOf(ArrayShapeNode::class, $phpDocNode->type);

$printer = new Printer();
$this->assertSame($expected, $printer->print($phpDocNode));

Failed asserting that two strings are identical.
Expected :'array{states: array{'Hello World': int}}'
Actual :'array{states: array{Hello World: int}}'

As you can see, the key Hello World is not quoted, while it should.

When I try to feed the wrong PHPDoc into parseTagValue it returns InvalidTagValueNode.

Am I doing something wrong, or is this a bug that I can try to fix 😊 ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL