Bug #72920 [Opn->Csd]: Accessing a private constant using constant() creates an exception AND warning
| From: | laruence@php.net | Date: | Mon, 22 Aug 2016 15:45:02 +0000 |
| Subject: | Bug #72920 [Opn->Csd]: Accessing a private constant using constant() creates an exception AND warning | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-203494@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72920&edit=1
ID: 72920
Updated by: laruence@php.net
Reported by: suralc dot github at gmail dot com
Summary: Accessing a private constant using constant()
creates an exception AND warning
-Status: Open
+Status: Closed
Type: Bug
Package: *General Issues
PHP Version: 7.1.0beta3
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=434ae90e852ed2b39432baf30d928e26b834c03e
Log: Fixed bug #72920 (Accessing a private constant using constant() creates an exception AND
warning)
Previous Comments:
------------------------------------------------------------------------
[2016-08-22 11:27:47] suralc dot github at gmail dot com
Description:
------------
Accessing a private class constant using constant() triggers an exception (as expected) and a
warning.
The function should only use one way to report the inaccessible constant; prefferably the
Error/Exception. Removing the warning from the constant() function would result in the same
behaviour as accessing the constant directly.
A small test script is attached, a slightly larger version is linked here:
https://3v4l.org/JY1AO
Test script:
---------------
<?php
class Foo {
private const C1 = "a";
}
try {
var_dump(constant('Foo::C1'));
} catch(Error $e) {
echo 'Caught';
}
Expected result:
----------------
Caught
Actual result:
--------------
Warning: constant(): Couldn't find constant Foo::C1 in ??? on line 8
Caught
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72920&edit=1