Bug #75543 [Com]: function "defined" should ignore class constant visibility
| From: | spam2 at rhsoft dot net | Date: | Mon, 20 Nov 2017 13:59:58 +0000 |
| Subject: | Bug #75543 [Com]: function "defined" should ignore class constant visibility | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-212639@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75543&edit=1
ID: 75543
Comment by: spam2 at rhsoft dot net
Reported by: matej21 at matej21 dot cz
Summary: function "defined" should ignore class constant
visibility
Status: Open
Type: Bug
Package: Scripting Engine problem
PHP Version: 7.1.11
Block user comment: N
Private report: N
New Comment:
it should return false but not raise a fatal error at all, but there is no valid reason to return
true because you can't access it outside the class
Previous Comments:
------------------------------------------------------------------------
[2017-11-20 13:55:38] matej21 at matej21 dot cz
Description:
------------
When you check if private/protected constant is defined on a class, it currently triggers a fatal
error.
For a consistency with method_exists and property_exists it should probably ignore visibility and
return true
Test script:
---------------
<?php
class Foo
{
private const BAR = 1;
}
var_dump(defined('Foo::BAR'));
Expected result:
----------------
bool(true)
Actual result:
--------------
Fatal error: Uncaught Error: Cannot access private const Foo::BAR
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75543&edit=1