|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #80766 assert() can be imported via use statement
Submitted: 2021-02-18 00:24 UTC Modified: 2021-02-22 09:30 UTC
From: smokey101stair at gmail dot com Assigned:
Status: Closed Package: Unknown/Other Function
PHP Version: 7.3.27 OS: Ubuntu 20.04
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:
12 + 12 = ?
Subscribe to this entry?

 [2021-02-18 00:24 UTC] smokey101stair at gmail dot com
In PHP 7, `assert` became a language construct and cannot be redefined as a user function. Typically language constructs can't be imported via use statements, however, it seems that `assert` can be imported via a use statement. I'm not sure if this is intentional or not for BC purposes. PHP throws a ParseError when trying to import other language constructs, such as `isset`, so I would expect importing `assert` to throw as well.

Test script:
// Works, unexpectedly
namespace Foo {
    use function assert;

// Doesn't work, as expected
namespace Foo {
    use function isset;


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-02-18 10:49 UTC]
-Status: Open +Status: Verified -Type: Bug +Type: Documentation Problem
 [2021-02-18 10:49 UTC]
While `isset` is a keyword, `assert` is not.  This is by design,
and allows to define a namespace assert() function[1].  This is
apparently not yet documented in the manual.

[1] <>
 [2021-02-22 09:18 UTC]
Defining a namespaced assert is not allowed:

Nothing wrong with an explicit import though. assert() is still considered a normal function, albeit one that is specially handled to respect zend.assertions.
 [2021-02-22 09:30 UTC]
> Defining a namespaced assert is not allowed

Ah, right!   However, it was allowed[1].  All that should be

[1] <>
 [2021-04-19 17:54 UTC]
Automatic comment on behalf of jhdxr (author) and web-flow (committer)
Log: fix #80766  namespaced assert is no longer allowed
 [2021-04-19 17:54 UTC]
-Status: Verified +Status: Closed
 [2021-04-20 02:04 UTC]
Automatic comment on behalf of mumumu
Log: fix #80766 namespaced assert is no longer allowed
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat May 15 12:01:23 2021 UTC