summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-01-10 12:01:42 +0100
committerNikita Popov <nikita.ppv@gmail.com>2020-01-10 13:39:56 +0100
commit7ce531f2c28dcfe4aeed271b55b82de65c3bca8a (patch)
tree201a845de42fa94daf2182cd90aeabec5b11088a /tests
parent0a2f6c55279c506dad65a6711567107d6aceec2d (diff)
downloadphp-git-7ce531f2c28dcfe4aeed271b55b82de65c3bca8a.tar.gz
Make constant() error handling consistent with plain const lookup
This means we get an Error exception and a much better error message indicating the root cause (e.g. accessing a private class constant).
Diffstat (limited to 'tests')
-rw-r--r--tests/classes/constants_visibility_002.phpt11
-rw-r--r--tests/classes/constants_visibility_003.phpt11
-rw-r--r--tests/lang/bug44827.phpt9
3 files changed, 20 insertions, 11 deletions
diff --git a/tests/classes/constants_visibility_002.phpt b/tests/classes/constants_visibility_002.phpt
index 4e0ecb1aa2..56c70a99a1 100644
--- a/tests/classes/constants_visibility_002.phpt
+++ b/tests/classes/constants_visibility_002.phpt
@@ -14,11 +14,14 @@ class A {
A::staticConstDump();
(new A())->constDump();
-constant('A::protectedConst');
+try {
+ constant('A::protectedConst');
+} catch (Error $e) {
+ echo $e->getMessage(), "\n";
+}
?>
---EXPECTF--
+--EXPECT--
string(14) "protectedConst"
string(14) "protectedConst"
-
-Warning: constant(): Couldn't find constant A::protectedConst in %s on line %d
+Cannot access protected const A::protectedConst
diff --git a/tests/classes/constants_visibility_003.phpt b/tests/classes/constants_visibility_003.phpt
index 7c961695ed..fe9bb6f6a1 100644
--- a/tests/classes/constants_visibility_003.phpt
+++ b/tests/classes/constants_visibility_003.phpt
@@ -14,11 +14,14 @@ class A {
A::staticConstDump();
(new A())->constDump();
-constant('A::privateConst');
+try {
+ constant('A::privateConst');
+} catch (Error $e) {
+ echo $e->getMessage(), "\n";
+}
?>
---EXPECTF--
+--EXPECT--
string(12) "privateConst"
string(12) "privateConst"
-
-Warning: constant(): Couldn't find constant A::privateConst in %s on line %d
+Cannot access private const A::privateConst
diff --git a/tests/lang/bug44827.phpt b/tests/lang/bug44827.phpt
index d871cfd2a8..9cb8c132e7 100644
--- a/tests/lang/bug44827.phpt
+++ b/tests/lang/bug44827.phpt
@@ -7,10 +7,13 @@ Testfest Munich 2009
--FILE--
<?php
define('::', true);
-var_dump(constant('::'));
+try {
+ var_dump(constant('::'));
+} catch (Error $e) {
+ echo $e->getMessage(), "\n";
+}
?>
--EXPECTF--
Warning: Class constants cannot be defined or redefined in %s on line %d
-Warning: constant(): Couldn't find constant :: in %s on line %d
-NULL
+Fatal error: Class '' not found in %s on line %d