Bug #75562 [Opn->Nab]: token_get_all() errors should be catchable
Edit report at https://bugs.php.net/bug.php?id=75562&edit=1
ID: 75562
Updated by: nikic@php.net
Reported by: software at nano dot net dot tr
Summary: token_get_all() errors should be catchable
-Status: Open
+Status: Not a bug
Type: Bug
Package: Reproducible crash
Operating System: Ubuntu 16.04.3 LTS
PHP Version: 7.1.11
Block user comment: N
Private report: N
New Comment:
token_get_all() errors are catchable using catch(ParseError $e).
Previous Comments:
------------------------------------------------------------------------
[2017-11-23 15:58:41] software at nano dot net dot tr
Description:
------------
OS is Ubuntu 16.04.3 LTS
PHP package is 7.1.11-1+ubuntu16.04.1+deb.sury.org+1 installed from http://ppa.launchpad.net/ondrej/php/ubuntu
While using token_get_all() with TOKEN_PARSE flag; if tested code block has syntax error, then
process killed with "Parse error: syntax error".
Example: https://3v4l.org/05lUI
Test script:
---------------
<?php
// Syntax error: tested code has a space between equal signs
$tokens=token_get_all('<?php if($foo= =$bar) {}', TOKEN_PARSE);
var_dump($tokens); // not printed on error
Expected result:
----------------
function returns (FALSE) or throws a catchable error. script continues to run. error could be
checked/catched with if, try-catch or error handler.
Actual result:
--------------
script dies with error: (Parse error: syntax error, unexpected '=' in on line 1)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75562&edit=1
Thread (4 messages)