Bug->Doc #80766 [Opn->Ver]: assert() can be imported via use statement

From: Date: Thu, 18 Feb 2021 10:49:24 +0000
Subject: Bug->Doc #80766 [Opn->Ver]: assert() can be imported via use statement
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-18562@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80766&edit=1 ID: 80766 Updated by: cmb@php.net Reported by: smokey101stair at gmail dot com Summary: assert() can be imported via use statement -Status: Open +Status: Verified -Type: Bug +Type: Documentation Problem Package: Unknown/Other Function Operating System: Ubuntu 20.04 PHP Version: 7.3.27 Block user comment: N Private report: N New Comment: 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] <https://wiki.php.net/rfc/expectations#namespaced_assert> Previous Comments: ------------------------------------------------------------------------ [2021-02-18 00:24:45] smokey101stair at gmail dot com Description: ------------ 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; } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80766&edit=1

« previous php.doc.bugs (#18562) next »