Skip to content

Lack of support for nullable types #49

@more7dev

Description

@more7dev

PHP 7.1 and above has nullable types.

Parser doesn`t recognize them.

Example:
Change the example function declaration at the bottom of demo.php and add nullable type:

function foo(?array $a) {

Effect:

PHP Fatal error: Uncaught RuntimeException: Unknown Expr Type NullableType in .../vendor/ircmaxell/php-cfg/lib/PHPCfg/Parser.php:799
Stack trace:
#0 .../vendor/ircmaxell/php-cfg/lib/PHPCfg/Parser.php(1253): PHPCfg\Parser->parseExprNode(Object(PhpParser\Node\NullableType))
#1 .../vendor/ircmaxell/php-cfg/lib/PHPCfg/Parser.php(95): PHPCfg\Parser->parseParameterList(Object(PHPCfg\Func), Array)
#2 .../vendor/ircmaxell/php-cfg/lib/PHPCfg/Parser.php(332): PHPCfg\Parser->parseFunc(Object(PHPCfg\Func), Array, Array, NULL)
#3 .../vendor/ircmaxell/php-cfg/lib/PHPCfg/Parser.php(146): PHPCfg\Parser->parseStmt_Function(Object(PhpParser\Node\Stmt\Function_))
#4 .../vendor/ircmaxell/php-cfg/lib/PHPCfg/Parser.php(132): PHPCfg\Parser->parseNode(Object(PhpParser\Node\Stmt\Function_))
#5 .../vendor/ircmaxell/php-cfg/lib/PHPCfg/Parser.php(100): PHPCfg\Parser-> in .../vendor/ircmaxell/php-cfg/lib/PHPCfg/Parser.php on line 799

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions