ircmaxell / ircmaxell/php-cfg

Lack of support for nullable types

Open
#49 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
247
Forks
45
Avg merge
1m
Merged PRs (30d)
1

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lib/PHPCfg/Parser.php around the reported failure at line 799, then reproduce the issue by updating the example function declaration in demo.php to use ?array. Done means the parser accepts that nullable type without the reported Unknown Expr Type NullableType fatal when demo.php is run.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.