z7zmey / php-parser

PHP parser written in Go

Home Page:https://php-parser.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

crash with incomplete blocks

imuli opened this issue · comments

When dealing with truncated or otherwise incomplete php files, sometimes the file ends inside a block.

function incomplete() {
    return something();

for some block types - class, switch - it comes out fine, just a syntax error and dropping the entry. For the majority though, - do, foreach, function, if, namespace, while - the parser returns nil and php-parser crashes.

I haven't yet seen an unclosed parenthetical break the parser, but that seems like a possibility too.