|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80225 broken namespace usage in eval code
Submitted: 2020-10-12 13:47 UTC Modified: 2020-10-12 14:51 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: Assigned: nikic (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 8.0.0rc1 OS: GNU/Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
27 - 15 = ?
Subscribe to this entry?

 [2020-10-12 13:47 UTC]
Looks like a regression in 8.0.0rc1

Was working in previous versions (7.2, 7.3, 7.4 and up to 8.0.0beta4)

Test script:

eval("echo \"One\n\";\n");
eval("namespace Bar;\n\necho \"Two\n\";\n");
eval("?><?php\necho \"Three\n\";\n");
eval("?><?php\nnamespace Bar;\n\necho \"Four\n\";\n");

Expected result:

Actual result:

Fatal error: Namespace declaration statement has to be the very first statement or after any declare call in the script in /in/gWW0K(6) : eval()'d code on line 2


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-10-12 14:30 UTC]
-Status: Open +Status: Verified
 [2020-10-12 14:30 UTC]
Basically same as No idea if that's "right", but I guess we can just match the previous behavior.
 [2020-10-12 14:35 UTC]
Automatic comment on behalf of
Log: Fixed bug #80225
 [2020-10-12 14:35 UTC]
-Status: Verified +Status: Closed
 [2020-10-12 14:40 UTC]
Thanks for the quick fix.

(for memory was affecting mockery/mockery).
 [2020-10-12 14:42 UTC]
-Assigned To: +Assigned To: nikic
 [2020-10-12 14:42 UTC]
It makes me wonder if we shouldn't also lift this restriction for declare(strict_types)... That is allow `<?php ; declare(strict_types=1);` or `?><?php declare(strict_types=1);` in eval.
 [2020-10-12 14:51 UTC]
> It makes me wonder if we shouldn't also lift this restriction for declare(strict_types)... 

I think it make sense
 [2020-10-12 14:56 UTC]
Well, NOOP before declare was not allowed in previous versions, so can also stay like now.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 03:01:27 2024 UTC