mirror of
https://github.com/php/php-src.git
synced 2025-08-16 22:18:50 +02:00
Merge branch 'PHP-7.3' into PHP-7.4
This commit is contained in:
commit
aaebf3b653
5 changed files with 21 additions and 18 deletions
|
@ -378,7 +378,9 @@ ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope,
|
||||||
ret_constant = NULL;
|
ret_constant = NULL;
|
||||||
} else {
|
} else {
|
||||||
if (!zend_verify_const_access(c, scope)) {
|
if (!zend_verify_const_access(c, scope)) {
|
||||||
|
if ((flags & ZEND_FETCH_CLASS_SILENT) == 0) {
|
||||||
zend_throw_error(NULL, "Cannot access %s const %s::%s", zend_visibility_string(Z_ACCESS_FLAGS(c->value)), ZSTR_VAL(class_name), ZSTR_VAL(constant_name));
|
zend_throw_error(NULL, "Cannot access %s const %s::%s", zend_visibility_string(Z_ACCESS_FLAGS(c->value)), ZSTR_VAL(class_name), ZSTR_VAL(constant_name));
|
||||||
|
}
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
ret_constant = &c->value;
|
ret_constant = &c->value;
|
||||||
|
|
|
@ -6,10 +6,7 @@ class Foo {
|
||||||
private const C1 = "a";
|
private const C1 = "a";
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
var_dump(constant('Foo::C1'));
|
||||||
var_dump(constant('Foo::C1'));
|
--EXPECTF--
|
||||||
} catch (Error $e) {
|
Warning: constant(): Couldn't find constant Foo::C1 in %s on line %d
|
||||||
var_dump($e->getMessage());
|
NULL
|
||||||
}
|
|
||||||
--EXPECT--
|
|
||||||
string(35) "Cannot access private const Foo::C1"
|
|
||||||
|
|
|
@ -21,8 +21,4 @@ constant('A::protectedConst');
|
||||||
string(14) "protectedConst"
|
string(14) "protectedConst"
|
||||||
string(14) "protectedConst"
|
string(14) "protectedConst"
|
||||||
|
|
||||||
Fatal error: Uncaught Error: Cannot access protected const A::protectedConst in %s:14
|
Warning: constant(): Couldn't find constant A::protectedConst in %s on line %d
|
||||||
Stack trace:
|
|
||||||
#0 %s(14): constant('A::protectedCon...')
|
|
||||||
#1 {main}
|
|
||||||
thrown in %s on line 14
|
|
||||||
|
|
|
@ -21,8 +21,4 @@ constant('A::privateConst');
|
||||||
string(12) "privateConst"
|
string(12) "privateConst"
|
||||||
string(12) "privateConst"
|
string(12) "privateConst"
|
||||||
|
|
||||||
Fatal error: Uncaught Error: Cannot access private const A::privateConst in %s:14
|
Warning: constant(): Couldn't find constant A::privateConst in %s on line %d
|
||||||
Stack trace:
|
|
||||||
#0 %s(14): constant('A::privateConst')
|
|
||||||
#1 {main}
|
|
||||||
thrown in %s on line 14
|
|
||||||
|
|
12
tests/classes/constants_visibility_008.phpt
Normal file
12
tests/classes/constants_visibility_008.phpt
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
--TEST--
|
||||||
|
Defined on private constant should not raise exception
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class Foo
|
||||||
|
{
|
||||||
|
private const BAR = 1;
|
||||||
|
}
|
||||||
|
echo (int)defined('Foo::BAR');
|
||||||
|
--EXPECTF--
|
||||||
|
0
|
Loading…
Add table
Add a link
Reference in a new issue