From 14b5d8c2a7f2b621d92399f678a02a4a66aacc06 Mon Sep 17 00:00:00 2001 From: Ollie Read Date: Tue, 16 Aug 2022 14:19:05 +0100 Subject: [PATCH 01/17] Updated magic method error message, updated existing tests, and added missing magic method tests --- Zend/tests/enum/__clone.phpt | 15 +++++++++++++++ Zend/tests/enum/__construct.phpt | 15 +++++++++++++++ Zend/tests/enum/__debugInfo.phpt | 16 ++++++++++++++++ Zend/tests/enum/__destruct.phpt | 15 +++++++++++++++ Zend/tests/enum/__get.phpt | 2 +- Zend/tests/enum/__serialize.phpt | 16 ++++++++++++++++ Zend/tests/enum/__set.phpt | 17 +++++++++++++++++ Zend/tests/enum/__set_state.phpt | 16 ++++++++++++++++ Zend/tests/enum/__sleep.phpt | 16 ++++++++++++++++ Zend/tests/enum/__toString.phpt | 16 ++++++++++++++++ Zend/tests/enum/__unserialize.phpt | 16 ++++++++++++++++ Zend/tests/enum/__unset.phpt | 16 ++++++++++++++++ Zend/tests/enum/__wakeup.phpt | 16 ++++++++++++++++ Zend/zend_enum.c | 2 +- 14 files changed, 192 insertions(+), 2 deletions(-) create mode 100644 Zend/tests/enum/__clone.phpt create mode 100644 Zend/tests/enum/__construct.phpt create mode 100644 Zend/tests/enum/__debugInfo.phpt create mode 100644 Zend/tests/enum/__destruct.phpt create mode 100644 Zend/tests/enum/__serialize.phpt create mode 100644 Zend/tests/enum/__set.phpt create mode 100644 Zend/tests/enum/__set_state.phpt create mode 100644 Zend/tests/enum/__sleep.phpt create mode 100644 Zend/tests/enum/__toString.phpt create mode 100644 Zend/tests/enum/__unserialize.phpt create mode 100644 Zend/tests/enum/__unset.phpt create mode 100644 Zend/tests/enum/__wakeup.phpt diff --git a/Zend/tests/enum/__clone.phpt b/Zend/tests/enum/__clone.phpt new file mode 100644 index 0000000000000..257788ed0fe4a --- /dev/null +++ b/Zend/tests/enum/__clone.phpt @@ -0,0 +1,15 @@ +--TEST-- +Enum __clone +--FILE-- + +--EXPECTF-- +Fatal error: Enum may not include magic method __clone in %s on line %d diff --git a/Zend/tests/enum/__construct.phpt b/Zend/tests/enum/__construct.phpt new file mode 100644 index 0000000000000..ec617a3729516 --- /dev/null +++ b/Zend/tests/enum/__construct.phpt @@ -0,0 +1,15 @@ +--TEST-- +Enum __construct +--FILE-- + +--EXPECTF-- +Fatal error: Enum may not include magic method __construct in %s on line %d diff --git a/Zend/tests/enum/__debugInfo.phpt b/Zend/tests/enum/__debugInfo.phpt new file mode 100644 index 0000000000000..27ef4be075f77 --- /dev/null +++ b/Zend/tests/enum/__debugInfo.phpt @@ -0,0 +1,16 @@ +--TEST-- +Enum __debugInfo +--FILE-- +cases(); + } +} + +?> +--EXPECTF-- +Fatal error: Enum may not include magic method __debugInfo in %s on line %d diff --git a/Zend/tests/enum/__destruct.phpt b/Zend/tests/enum/__destruct.phpt new file mode 100644 index 0000000000000..9533902a52830 --- /dev/null +++ b/Zend/tests/enum/__destruct.phpt @@ -0,0 +1,15 @@ +--TEST-- +Enum __destruct +--FILE-- + +--EXPECTF-- +Fatal error: Enum may not include magic method __destruct in %s on line %d diff --git a/Zend/tests/enum/__get.phpt b/Zend/tests/enum/__get.phpt index 885cc2f2c8302..4083ba7ed6bb5 100644 --- a/Zend/tests/enum/__get.phpt +++ b/Zend/tests/enum/__get.phpt @@ -14,4 +14,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum may not include __get in %s on line %d +Fatal error: Enum may not include magic method __get in %s on line %d diff --git a/Zend/tests/enum/__serialize.phpt b/Zend/tests/enum/__serialize.phpt new file mode 100644 index 0000000000000..893cf59255653 --- /dev/null +++ b/Zend/tests/enum/__serialize.phpt @@ -0,0 +1,16 @@ +--TEST-- +Enum __serialize +--FILE-- +cases(); + } +} + +?> +--EXPECTF-- +Fatal error: Enum may not include magic method __serialize in %s on line %d diff --git a/Zend/tests/enum/__set.phpt b/Zend/tests/enum/__set.phpt new file mode 100644 index 0000000000000..8f62fb8033497 --- /dev/null +++ b/Zend/tests/enum/__set.phpt @@ -0,0 +1,17 @@ +--TEST-- +Enum __set +--FILE-- + +--EXPECTF-- +Fatal error: Enum may not include magic method __set in %s on line %d diff --git a/Zend/tests/enum/__set_state.phpt b/Zend/tests/enum/__set_state.phpt new file mode 100644 index 0000000000000..e6f46e080ff0c --- /dev/null +++ b/Zend/tests/enum/__set_state.phpt @@ -0,0 +1,16 @@ +--TEST-- +Enum __set_state +--FILE-- + +--EXPECTF-- +Fatal error: Enum may not include magic method __set_state in %s on line %d diff --git a/Zend/tests/enum/__sleep.phpt b/Zend/tests/enum/__sleep.phpt new file mode 100644 index 0000000000000..db5f75bad59b7 --- /dev/null +++ b/Zend/tests/enum/__sleep.phpt @@ -0,0 +1,16 @@ +--TEST-- +Enum __sleep +--FILE-- + +--EXPECTF-- +Fatal error: Enum may not include magic method __sleep in %s on line %d diff --git a/Zend/tests/enum/__toString.phpt b/Zend/tests/enum/__toString.phpt new file mode 100644 index 0000000000000..6eb137a0c5a91 --- /dev/null +++ b/Zend/tests/enum/__toString.phpt @@ -0,0 +1,16 @@ +--TEST-- +Enum __toString +--FILE-- +name; + } +} + +?> +--EXPECTF-- +Fatal error: Enum may not include magic method __toString in %s on line %d diff --git a/Zend/tests/enum/__unserialize.phpt b/Zend/tests/enum/__unserialize.phpt new file mode 100644 index 0000000000000..c35af0917949f --- /dev/null +++ b/Zend/tests/enum/__unserialize.phpt @@ -0,0 +1,16 @@ +--TEST-- +Enum __unserialize +--FILE-- + +--EXPECTF-- +Fatal error: Enum may not include magic method __unserialize in %s on line %d diff --git a/Zend/tests/enum/__unset.phpt b/Zend/tests/enum/__unset.phpt new file mode 100644 index 0000000000000..f5bc1131e7e3e --- /dev/null +++ b/Zend/tests/enum/__unset.phpt @@ -0,0 +1,16 @@ +--TEST-- +Enum __unset +--FILE-- + +--EXPECTF-- +Fatal error: Enum may not include magic method __unset in %s on line %d diff --git a/Zend/tests/enum/__wakeup.phpt b/Zend/tests/enum/__wakeup.phpt new file mode 100644 index 0000000000000..afaca220816a0 --- /dev/null +++ b/Zend/tests/enum/__wakeup.phpt @@ -0,0 +1,16 @@ +--TEST-- +Enum __wakeup +--FILE-- + +--EXPECTF-- +Fatal error: Enum may not include magic method __wakeup in %s on line %d diff --git a/Zend/zend_enum.c b/Zend/zend_enum.c index 16c3753e7c94a..d441538d51e58 100644 --- a/Zend/zend_enum.c +++ b/Zend/zend_enum.c @@ -28,7 +28,7 @@ #define ZEND_ENUM_DISALLOW_MAGIC_METHOD(propertyName, methodName) \ do { \ if (ce->propertyName) { \ - zend_error_noreturn(E_COMPILE_ERROR, "Enum may not include %s", methodName); \ + zend_error_noreturn(E_COMPILE_ERROR, "Enum may not include magic method %s", methodName); \ } \ } while (0); From d0b5deaaf3e786ea7b3bc5243ee10458d0359601 Mon Sep 17 00:00:00 2001 From: Ollie Read Date: Tue, 16 Aug 2022 14:19:24 +0100 Subject: [PATCH 02/17] Updated __isset enum tests --- Zend/tests/enum/__isset.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/tests/enum/__isset.phpt b/Zend/tests/enum/__isset.phpt index 76409f075b27d..9f9d7b95ef20a 100644 --- a/Zend/tests/enum/__isset.phpt +++ b/Zend/tests/enum/__isset.phpt @@ -13,4 +13,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum may not include __isset in %s on line %d +Fatal error: Enum may not include magic method __isset in %s on line %d From fa3244b8e72c1c6e9d94e0130350a47f554444ee Mon Sep 17 00:00:00 2001 From: Ollie Read Date: Tue, 16 Aug 2022 14:57:00 +0100 Subject: [PATCH 03/17] Remove __construct and __destruct tests in favour of existing ones --- Zend/tests/enum/__construct.phpt | 15 --------------- Zend/tests/enum/__destruct.phpt | 15 --------------- 2 files changed, 30 deletions(-) delete mode 100644 Zend/tests/enum/__construct.phpt delete mode 100644 Zend/tests/enum/__destruct.phpt diff --git a/Zend/tests/enum/__construct.phpt b/Zend/tests/enum/__construct.phpt deleted file mode 100644 index ec617a3729516..0000000000000 --- a/Zend/tests/enum/__construct.phpt +++ /dev/null @@ -1,15 +0,0 @@ ---TEST-- -Enum __construct ---FILE-- - ---EXPECTF-- -Fatal error: Enum may not include magic method __construct in %s on line %d diff --git a/Zend/tests/enum/__destruct.phpt b/Zend/tests/enum/__destruct.phpt deleted file mode 100644 index 9533902a52830..0000000000000 --- a/Zend/tests/enum/__destruct.phpt +++ /dev/null @@ -1,15 +0,0 @@ ---TEST-- -Enum __destruct ---FILE-- - ---EXPECTF-- -Fatal error: Enum may not include magic method __destruct in %s on line %d From c90fa623515192b6dcb6bd88210fb6148c2b6a99 Mon Sep 17 00:00:00 2001 From: Ollie Read Date: Tue, 16 Aug 2022 14:57:23 +0100 Subject: [PATCH 04/17] Fix existing enum tests to include new magic method error message --- Zend/tests/enum/no-constructors.phpt | 2 +- Zend/tests/enum/no-destruct.phpt | 2 +- Zend/tests/enum/traits-no-__construct.phpt | 2 +- Zend/tests/enum/traits-no-forbidden-methods.phpt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Zend/tests/enum/no-constructors.phpt b/Zend/tests/enum/no-constructors.phpt index 70504e14eb381..865ea57e75903 100644 --- a/Zend/tests/enum/no-constructors.phpt +++ b/Zend/tests/enum/no-constructors.phpt @@ -9,4 +9,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum may not include __construct in %s on line %d +Fatal error: Enum may not include magic method __construct in %s on line %d diff --git a/Zend/tests/enum/no-destruct.phpt b/Zend/tests/enum/no-destruct.phpt index 730c29f8476c7..99595d2c2168b 100644 --- a/Zend/tests/enum/no-destruct.phpt +++ b/Zend/tests/enum/no-destruct.phpt @@ -9,4 +9,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum may not include __destruct in %s on line %d +Fatal error: Enum may not include magic method __destruct in %s on line %d diff --git a/Zend/tests/enum/traits-no-__construct.phpt b/Zend/tests/enum/traits-no-__construct.phpt index 0529a2a989013..24075492b0a7c 100644 --- a/Zend/tests/enum/traits-no-__construct.phpt +++ b/Zend/tests/enum/traits-no-__construct.phpt @@ -18,4 +18,4 @@ var_dump(Bar::Baz); ?> --EXPECTF-- -Fatal error: Enum may not include __construct in %s on line %d +Fatal error: Enum may not include magic method __construct in %s on line %d diff --git a/Zend/tests/enum/traits-no-forbidden-methods.phpt b/Zend/tests/enum/traits-no-forbidden-methods.phpt index 1f310f48cd0c6..44b159589f1f8 100644 --- a/Zend/tests/enum/traits-no-forbidden-methods.phpt +++ b/Zend/tests/enum/traits-no-forbidden-methods.phpt @@ -18,4 +18,4 @@ enum Suit { ?> --EXPECTF-- -Fatal error: Enum may not include __construct in %s on line %d +Fatal error: Enum may not include magic method __construct in %s on line %d From 0f0f39da18a83cbe554ff2e70bc7ae36358b51eb Mon Sep 17 00:00:00 2001 From: Ollie Read Date: Tue, 16 Aug 2022 15:06:51 +0100 Subject: [PATCH 05/17] Updated enum exception messages to be consistent, and not wrap enum name in quotes, and updated tests --- Zend/tests/enum/backed-from-invalid-int.phpt | 2 +- Zend/tests/enum/backed-from-invalid-string.phpt | 2 +- Zend/tests/enum/backed-from-invalid-type.phpt | 2 +- Zend/zend_enum.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Zend/tests/enum/backed-from-invalid-int.phpt b/Zend/tests/enum/backed-from-invalid-int.phpt index d976f3d0fbd39..92cf988c6eb86 100644 --- a/Zend/tests/enum/backed-from-invalid-int.phpt +++ b/Zend/tests/enum/backed-from-invalid-int.phpt @@ -16,4 +16,4 @@ try { ?> --EXPECT-- -2 is not a valid backing value for enum "Foo" +"2" is not a valid backing value for enum Foo diff --git a/Zend/tests/enum/backed-from-invalid-string.phpt b/Zend/tests/enum/backed-from-invalid-string.phpt index db8b791d8bea1..c6d784872ef0d 100644 --- a/Zend/tests/enum/backed-from-invalid-string.phpt +++ b/Zend/tests/enum/backed-from-invalid-string.phpt @@ -18,4 +18,4 @@ try { ?> --EXPECT-- -"A" is not a valid backing value for enum "Suit" +"A" is not a valid backing value for enum Suit diff --git a/Zend/tests/enum/backed-from-invalid-type.phpt b/Zend/tests/enum/backed-from-invalid-type.phpt index 3f35bef64f55a..b4e0e6d6164f1 100644 --- a/Zend/tests/enum/backed-from-invalid-type.phpt +++ b/Zend/tests/enum/backed-from-invalid-type.phpt @@ -30,5 +30,5 @@ try { ?> --EXPECT-- -"42" is not a valid backing value for enum "Suit" +"42" is not a valid backing value for enum Suit Foo::from(): Argument #1 ($value) must be of type int, string given diff --git a/Zend/zend_enum.c b/Zend/zend_enum.c index d441538d51e58..5c0228ab3164d 100644 --- a/Zend/zend_enum.c +++ b/Zend/zend_enum.c @@ -307,10 +307,10 @@ ZEND_API zend_result zend_enum_get_case_by_value(zend_object **result, zend_clas } if (ce->enum_backing_type == IS_LONG) { - zend_value_error(ZEND_LONG_FMT " is not a valid backing value for enum \"%s\"", long_key, ZSTR_VAL(ce->name)); + zend_value_error("\"" ZEND_LONG_FMT "\" is not a valid backing value for enum %s", long_key, ZSTR_VAL(ce->name)); } else { ZEND_ASSERT(ce->enum_backing_type == IS_STRING); - zend_value_error("\"%s\" is not a valid backing value for enum \"%s\"", ZSTR_VAL(string_key), ZSTR_VAL(ce->name)); + zend_value_error("\"%s\" is not a valid backing value for enum %s", ZSTR_VAL(string_key), ZSTR_VAL(ce->name)); } return FAILURE; } From bee31869c701be09ed0359662ab77dd1eb7251c0 Mon Sep 17 00:00:00 2001 From: Ollie Read Date: Tue, 16 Aug 2022 15:18:51 +0100 Subject: [PATCH 06/17] Normalise enum property error message to not quote enum name --- Zend/tests/enum/traits-no-properties.phpt | 2 +- Zend/zend_enum.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Zend/tests/enum/traits-no-properties.phpt b/Zend/tests/enum/traits-no-properties.phpt index 5a6faf9deac4e..44428ccff76f2 100644 --- a/Zend/tests/enum/traits-no-properties.phpt +++ b/Zend/tests/enum/traits-no-properties.phpt @@ -22,4 +22,4 @@ enum Suit { ?> --EXPECTF-- -Fatal error: Enum "Suit" may not include properties in %s on line %d +Fatal error: Enum Suit may not include properties in %s on line %d diff --git a/Zend/zend_enum.c b/Zend/zend_enum.c index 5c0228ab3164d..a4a4e4a2256b6 100644 --- a/Zend/zend_enum.c +++ b/Zend/zend_enum.c @@ -67,7 +67,7 @@ static void zend_verify_enum_properties(zend_class_entry *ce) continue; } // FIXME: File/line number for traits? - zend_error_noreturn(E_COMPILE_ERROR, "Enum \"%s\" may not include properties", + zend_error_noreturn(E_COMPILE_ERROR, "Enum %s may not include properties", ZSTR_VAL(ce->name)); } ZEND_HASH_FOREACH_END(); } From 533f0f8c72e22dc89098efee70922ec50257c42d Mon Sep 17 00:00:00 2001 From: Ollie Read Date: Tue, 16 Aug 2022 15:45:56 +0100 Subject: [PATCH 07/17] Fixed internal enums test --- Zend/tests/enum/internal_enums.phpt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Zend/tests/enum/internal_enums.phpt b/Zend/tests/enum/internal_enums.phpt index 5e36baae302cc..768aa8f4163d1 100644 --- a/Zend/tests/enum/internal_enums.phpt +++ b/Zend/tests/enum/internal_enums.phpt @@ -86,9 +86,9 @@ enum(ZendTestIntEnum::Foo) enum(ZendTestIntEnum::Foo) enum(ZendTestIntEnum::Foo) enum(ZendTestIntEnum::Foo) -ValueError: 2 is not a valid backing value for enum "ZendTestIntEnum" +ValueError: "2" is not a valid backing value for enum ZendTestIntEnum NULL -ValueError: 2 is not a valid backing value for enum "ZendTestIntEnum" +ValueError: "2" is not a valid backing value for enum ZendTestIntEnum NULL enum(ZendTestIntEnum::Baz) enum(ZendTestIntEnum::Baz) From 2d07685017776f34e2fa3334120e7e3c370c6768 Mon Sep 17 00:00:00 2001 From: Ollie Read Date: Fri, 19 Aug 2022 14:45:11 +0100 Subject: [PATCH 08/17] Unquote the integer value for invalid enum backing value error message --- Zend/zend_enum.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/zend_enum.c b/Zend/zend_enum.c index a4a4e4a2256b6..a737cb2e293ab 100644 --- a/Zend/zend_enum.c +++ b/Zend/zend_enum.c @@ -307,7 +307,7 @@ ZEND_API zend_result zend_enum_get_case_by_value(zend_object **result, zend_clas } if (ce->enum_backing_type == IS_LONG) { - zend_value_error("\"" ZEND_LONG_FMT "\" is not a valid backing value for enum %s", long_key, ZSTR_VAL(ce->name)); + zend_value_error(ZEND_LONG_FMT " is not a valid backing value for enum %s", long_key, ZSTR_VAL(ce->name)); } else { ZEND_ASSERT(ce->enum_backing_type == IS_STRING); zend_value_error("\"%s\" is not a valid backing value for enum %s", ZSTR_VAL(string_key), ZSTR_VAL(ce->name)); From fd3dbad91f86cdfd724961ea5587dc24a2939233 Mon Sep 17 00:00:00 2001 From: Ollie Read Date: Fri, 19 Aug 2022 14:57:01 +0100 Subject: [PATCH 09/17] Fixed expected error message for invalid int on enum backing test --- Zend/tests/enum/backed-from-invalid-int.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/tests/enum/backed-from-invalid-int.phpt b/Zend/tests/enum/backed-from-invalid-int.phpt index 92cf988c6eb86..d40cae30e6c8e 100644 --- a/Zend/tests/enum/backed-from-invalid-int.phpt +++ b/Zend/tests/enum/backed-from-invalid-int.phpt @@ -16,4 +16,4 @@ try { ?> --EXPECT-- -"2" is not a valid backing value for enum Foo +2 is not a valid backing value for enum Foo From 40542844cdbbd66be7609d72268d42b1084e9ae7 Mon Sep 17 00:00:00 2001 From: Ollie Read Date: Sat, 20 Aug 2022 00:24:29 +0100 Subject: [PATCH 10/17] Fix internal enum tests with correct error message --- Zend/tests/enum/internal_enums.phpt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Zend/tests/enum/internal_enums.phpt b/Zend/tests/enum/internal_enums.phpt index 768aa8f4163d1..ae26e24cd7eaf 100644 --- a/Zend/tests/enum/internal_enums.phpt +++ b/Zend/tests/enum/internal_enums.phpt @@ -86,9 +86,9 @@ enum(ZendTestIntEnum::Foo) enum(ZendTestIntEnum::Foo) enum(ZendTestIntEnum::Foo) enum(ZendTestIntEnum::Foo) -ValueError: "2" is not a valid backing value for enum ZendTestIntEnum +ValueError: 2 is not a valid backing value for enum ZendTestIntEnum NULL -ValueError: "2" is not a valid backing value for enum ZendTestIntEnum +ValueError: 2 is not a valid backing value for enum ZendTestIntEnum NULL enum(ZendTestIntEnum::Baz) enum(ZendTestIntEnum::Baz) From 320344b785a1c15d4b26e1a0366fac21c7dd43be Mon Sep 17 00:00:00 2001 From: Ollie Read Date: Mon, 22 Aug 2022 13:10:41 +0100 Subject: [PATCH 11/17] Change "may not" to "cannot" within the enum error messages --- Zend/tests/enum/__clone.phpt | 2 +- Zend/tests/enum/__debugInfo.phpt | 2 +- Zend/tests/enum/__get.phpt | 2 +- Zend/tests/enum/__isset.phpt | 2 +- Zend/tests/enum/__serialize.phpt | 2 +- Zend/tests/enum/__set.phpt | 2 +- Zend/tests/enum/__set_state.phpt | 2 +- Zend/tests/enum/__sleep.phpt | 2 +- Zend/tests/enum/__toString.phpt | 2 +- Zend/tests/enum/__unserialize.phpt | 2 +- Zend/tests/enum/__unset.phpt | 2 +- Zend/tests/enum/__wakeup.phpt | 2 +- Zend/tests/enum/no-constructors.phpt | 2 +- Zend/tests/enum/no-destruct.phpt | 2 +- Zend/tests/enum/no-implement-serializable-indirect.phpt | 2 +- Zend/tests/enum/no-implement-serializable.phpt | 2 +- Zend/tests/enum/no-name-property.phpt | 2 +- Zend/tests/enum/no-properties.phpt | 2 +- Zend/tests/enum/no-static-properties.phpt | 2 +- Zend/tests/enum/no-value-property.phpt | 2 +- Zend/tests/enum/traits-no-__construct.phpt | 2 +- Zend/tests/enum/traits-no-forbidden-methods.phpt | 2 +- Zend/tests/enum/traits-no-properties.phpt | 2 +- Zend/zend_enum.c | 8 ++++---- 24 files changed, 27 insertions(+), 27 deletions(-) diff --git a/Zend/tests/enum/__clone.phpt b/Zend/tests/enum/__clone.phpt index 257788ed0fe4a..c33e748eafeed 100644 --- a/Zend/tests/enum/__clone.phpt +++ b/Zend/tests/enum/__clone.phpt @@ -12,4 +12,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum may not include magic method __clone in %s on line %d +Fatal error: Enum cannot include magic method __clone in %s on line %d diff --git a/Zend/tests/enum/__debugInfo.phpt b/Zend/tests/enum/__debugInfo.phpt index 27ef4be075f77..d080818257b14 100644 --- a/Zend/tests/enum/__debugInfo.phpt +++ b/Zend/tests/enum/__debugInfo.phpt @@ -13,4 +13,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum may not include magic method __debugInfo in %s on line %d +Fatal error: Enum cannot include magic method __debugInfo in %s on line %d diff --git a/Zend/tests/enum/__get.phpt b/Zend/tests/enum/__get.phpt index 4083ba7ed6bb5..72d2341dcac16 100644 --- a/Zend/tests/enum/__get.phpt +++ b/Zend/tests/enum/__get.phpt @@ -14,4 +14,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum may not include magic method __get in %s on line %d +Fatal error: Enum cannot include magic method __get in %s on line %d diff --git a/Zend/tests/enum/__isset.phpt b/Zend/tests/enum/__isset.phpt index 9f9d7b95ef20a..a82330155aa4f 100644 --- a/Zend/tests/enum/__isset.phpt +++ b/Zend/tests/enum/__isset.phpt @@ -13,4 +13,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum may not include magic method __isset in %s on line %d +Fatal error: Enum cannot include magic method __isset in %s on line %d diff --git a/Zend/tests/enum/__serialize.phpt b/Zend/tests/enum/__serialize.phpt index 893cf59255653..24afc84f9305a 100644 --- a/Zend/tests/enum/__serialize.phpt +++ b/Zend/tests/enum/__serialize.phpt @@ -13,4 +13,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum may not include magic method __serialize in %s on line %d +Fatal error: Enum cannot include magic method __serialize in %s on line %d diff --git a/Zend/tests/enum/__set.phpt b/Zend/tests/enum/__set.phpt index 8f62fb8033497..053e85388d5c5 100644 --- a/Zend/tests/enum/__set.phpt +++ b/Zend/tests/enum/__set.phpt @@ -14,4 +14,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum may not include magic method __set in %s on line %d +Fatal error: Enum cannot include magic method __set in %s on line %d diff --git a/Zend/tests/enum/__set_state.phpt b/Zend/tests/enum/__set_state.phpt index e6f46e080ff0c..4e91ca11075b2 100644 --- a/Zend/tests/enum/__set_state.phpt +++ b/Zend/tests/enum/__set_state.phpt @@ -13,4 +13,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum may not include magic method __set_state in %s on line %d +Fatal error: Enum cannot include magic method __set_state in %s on line %d diff --git a/Zend/tests/enum/__sleep.phpt b/Zend/tests/enum/__sleep.phpt index db5f75bad59b7..68b518df7b61d 100644 --- a/Zend/tests/enum/__sleep.phpt +++ b/Zend/tests/enum/__sleep.phpt @@ -13,4 +13,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum may not include magic method __sleep in %s on line %d +Fatal error: Enum cannot include magic method __sleep in %s on line %d diff --git a/Zend/tests/enum/__toString.phpt b/Zend/tests/enum/__toString.phpt index 6eb137a0c5a91..9d4a68acd7af5 100644 --- a/Zend/tests/enum/__toString.phpt +++ b/Zend/tests/enum/__toString.phpt @@ -13,4 +13,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum may not include magic method __toString in %s on line %d +Fatal error: Enum cannot include magic method __toString in %s on line %d diff --git a/Zend/tests/enum/__unserialize.phpt b/Zend/tests/enum/__unserialize.phpt index c35af0917949f..a57d9c818dac9 100644 --- a/Zend/tests/enum/__unserialize.phpt +++ b/Zend/tests/enum/__unserialize.phpt @@ -13,4 +13,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum may not include magic method __unserialize in %s on line %d +Fatal error: Enum cannot include magic method __unserialize in %s on line %d diff --git a/Zend/tests/enum/__unset.phpt b/Zend/tests/enum/__unset.phpt index f5bc1131e7e3e..f8ed9edd0e095 100644 --- a/Zend/tests/enum/__unset.phpt +++ b/Zend/tests/enum/__unset.phpt @@ -13,4 +13,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum may not include magic method __unset in %s on line %d +Fatal error: Enum cannot include magic method __unset in %s on line %d diff --git a/Zend/tests/enum/__wakeup.phpt b/Zend/tests/enum/__wakeup.phpt index afaca220816a0..1f8b558f32552 100644 --- a/Zend/tests/enum/__wakeup.phpt +++ b/Zend/tests/enum/__wakeup.phpt @@ -13,4 +13,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum may not include magic method __wakeup in %s on line %d +Fatal error: Enum cannot include magic method __wakeup in %s on line %d diff --git a/Zend/tests/enum/no-constructors.phpt b/Zend/tests/enum/no-constructors.phpt index 865ea57e75903..4096894cd9bdc 100644 --- a/Zend/tests/enum/no-constructors.phpt +++ b/Zend/tests/enum/no-constructors.phpt @@ -9,4 +9,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum may not include magic method __construct in %s on line %d +Fatal error: Enum cannot include magic method __construct in %s on line %d diff --git a/Zend/tests/enum/no-destruct.phpt b/Zend/tests/enum/no-destruct.phpt index 99595d2c2168b..33b34feee3463 100644 --- a/Zend/tests/enum/no-destruct.phpt +++ b/Zend/tests/enum/no-destruct.phpt @@ -9,4 +9,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum may not include magic method __destruct in %s on line %d +Fatal error: Enum cannot include magic method __destruct in %s on line %d diff --git a/Zend/tests/enum/no-implement-serializable-indirect.phpt b/Zend/tests/enum/no-implement-serializable-indirect.phpt index efd9229d9edc9..fff4d4ab03bb4 100644 --- a/Zend/tests/enum/no-implement-serializable-indirect.phpt +++ b/Zend/tests/enum/no-implement-serializable-indirect.phpt @@ -23,4 +23,4 @@ var_dump(unserialize(serialize(Foo::Bar))); --EXPECTF-- Deprecated: %s implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d -Fatal error: Enums may not implement the Serializable interface in %s on line %d +Fatal error: Enums cannot implement the Serializable interface in %s on line %d diff --git a/Zend/tests/enum/no-implement-serializable.phpt b/Zend/tests/enum/no-implement-serializable.phpt index 355d62b71ba53..151bd5c972e18 100644 --- a/Zend/tests/enum/no-implement-serializable.phpt +++ b/Zend/tests/enum/no-implement-serializable.phpt @@ -21,4 +21,4 @@ var_dump(unserialize(serialize(Foo::Bar))); --EXPECTF-- Deprecated: %s implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d -Fatal error: Enums may not implement the Serializable interface in %s on line %d +Fatal error: Enums cannot implement the Serializable interface in %s on line %d diff --git a/Zend/tests/enum/no-name-property.phpt b/Zend/tests/enum/no-name-property.phpt index a565c08e83005..e684dfaf3bbb4 100644 --- a/Zend/tests/enum/no-name-property.phpt +++ b/Zend/tests/enum/no-name-property.phpt @@ -9,4 +9,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enums may not include properties in %s on line %d +Fatal error: Enums cannot include properties in %s on line %d diff --git a/Zend/tests/enum/no-properties.phpt b/Zend/tests/enum/no-properties.phpt index e846845d22270..7aee06a1dd4ac 100644 --- a/Zend/tests/enum/no-properties.phpt +++ b/Zend/tests/enum/no-properties.phpt @@ -9,4 +9,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enums may not include properties in %s on line %d +Fatal error: Enums cannot include properties in %s on line %d diff --git a/Zend/tests/enum/no-static-properties.phpt b/Zend/tests/enum/no-static-properties.phpt index 4b823e98e9ffd..d2d03a1d5b34e 100644 --- a/Zend/tests/enum/no-static-properties.phpt +++ b/Zend/tests/enum/no-static-properties.phpt @@ -9,4 +9,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enums may not include properties in %s on line %d +Fatal error: Enums cannot include properties in %s on line %d diff --git a/Zend/tests/enum/no-value-property.phpt b/Zend/tests/enum/no-value-property.phpt index d8b12f2ca8a23..0f39619f6b2c9 100644 --- a/Zend/tests/enum/no-value-property.phpt +++ b/Zend/tests/enum/no-value-property.phpt @@ -9,4 +9,4 @@ enum Foo: int { ?> --EXPECTF-- -Fatal error: Enums may not include properties in %s on line %d +Fatal error: Enums cannot include properties in %s on line %d diff --git a/Zend/tests/enum/traits-no-__construct.phpt b/Zend/tests/enum/traits-no-__construct.phpt index 24075492b0a7c..e6e1b9e63eb52 100644 --- a/Zend/tests/enum/traits-no-__construct.phpt +++ b/Zend/tests/enum/traits-no-__construct.phpt @@ -18,4 +18,4 @@ var_dump(Bar::Baz); ?> --EXPECTF-- -Fatal error: Enum may not include magic method __construct in %s on line %d +Fatal error: Enum cannot include magic method __construct in %s on line %d diff --git a/Zend/tests/enum/traits-no-forbidden-methods.phpt b/Zend/tests/enum/traits-no-forbidden-methods.phpt index 44b159589f1f8..dac78cdf06ac1 100644 --- a/Zend/tests/enum/traits-no-forbidden-methods.phpt +++ b/Zend/tests/enum/traits-no-forbidden-methods.phpt @@ -18,4 +18,4 @@ enum Suit { ?> --EXPECTF-- -Fatal error: Enum may not include magic method __construct in %s on line %d +Fatal error: Enum cannot include magic method __construct in %s on line %d diff --git a/Zend/tests/enum/traits-no-properties.phpt b/Zend/tests/enum/traits-no-properties.phpt index 44428ccff76f2..0cc3c9cf3872b 100644 --- a/Zend/tests/enum/traits-no-properties.phpt +++ b/Zend/tests/enum/traits-no-properties.phpt @@ -22,4 +22,4 @@ enum Suit { ?> --EXPECTF-- -Fatal error: Enum Suit may not include properties in %s on line %d +Fatal error: Enum Suit cannot include properties in %s on line %d diff --git a/Zend/zend_enum.c b/Zend/zend_enum.c index a737cb2e293ab..f86adbdf18677 100644 --- a/Zend/zend_enum.c +++ b/Zend/zend_enum.c @@ -28,7 +28,7 @@ #define ZEND_ENUM_DISALLOW_MAGIC_METHOD(propertyName, methodName) \ do { \ if (ce->propertyName) { \ - zend_error_noreturn(E_COMPILE_ERROR, "Enum may not include magic method %s", methodName); \ + zend_error_noreturn(E_COMPILE_ERROR, "Enum cannot include magic method %s", methodName); \ } \ } while (0); @@ -67,7 +67,7 @@ static void zend_verify_enum_properties(zend_class_entry *ce) continue; } // FIXME: File/line number for traits? - zend_error_noreturn(E_COMPILE_ERROR, "Enum %s may not include properties", + zend_error_noreturn(E_COMPILE_ERROR, "Enum %s cannot include properties", ZSTR_VAL(ce->name)); } ZEND_HASH_FOREACH_END(); } @@ -99,7 +99,7 @@ static void zend_verify_enum_magic_methods(zend_class_entry *ce) const char *forbidden_method = forbidden_methods[i]; if (zend_hash_str_exists(&ce->function_table, forbidden_method, strlen(forbidden_method))) { - zend_error_noreturn(E_COMPILE_ERROR, "Enum may not include magic method %s", forbidden_method); + zend_error_noreturn(E_COMPILE_ERROR, "Enum cannot include magic method %s", forbidden_method); } } } @@ -108,7 +108,7 @@ static void zend_verify_enum_interfaces(zend_class_entry *ce) { if (zend_class_implements_interface(ce, zend_ce_serializable)) { zend_error_noreturn(E_COMPILE_ERROR, - "Enums may not implement the Serializable interface"); + "Enums cannot implement the Serializable interface"); } } From 1b2a8cb2c87bbd8faa31a81e43fd46aec4ddd304 Mon Sep 17 00:00:00 2001 From: Ollie Read Date: Mon, 22 Aug 2022 13:34:43 +0100 Subject: [PATCH 12/17] Added the enum class name to the enum error messages --- Zend/zend_enum.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Zend/zend_enum.c b/Zend/zend_enum.c index f86adbdf18677..35e0cb6df1e22 100644 --- a/Zend/zend_enum.c +++ b/Zend/zend_enum.c @@ -28,7 +28,7 @@ #define ZEND_ENUM_DISALLOW_MAGIC_METHOD(propertyName, methodName) \ do { \ if (ce->propertyName) { \ - zend_error_noreturn(E_COMPILE_ERROR, "Enum cannot include magic method %s", methodName); \ + zend_error_noreturn(E_COMPILE_ERROR, "Enum %s cannot include magic method %s", ZSTR_VAL(ce->name), methodName); \ } \ } while (0); @@ -99,7 +99,7 @@ static void zend_verify_enum_magic_methods(zend_class_entry *ce) const char *forbidden_method = forbidden_methods[i]; if (zend_hash_str_exists(&ce->function_table, forbidden_method, strlen(forbidden_method))) { - zend_error_noreturn(E_COMPILE_ERROR, "Enum cannot include magic method %s", forbidden_method); + zend_error_noreturn(E_COMPILE_ERROR, "Enum %s cannot include magic method %s", ZSTR_VAL(ce->name), forbidden_method); } } } @@ -108,7 +108,7 @@ static void zend_verify_enum_interfaces(zend_class_entry *ce) { if (zend_class_implements_interface(ce, zend_ce_serializable)) { zend_error_noreturn(E_COMPILE_ERROR, - "Enums cannot implement the Serializable interface"); + "Enums %s cannot implement the Serializable interface", ZSTR_VAL(ce->name)); } } From 0e3c8a3f1878cfef0f1fb319ba29a8623711013e Mon Sep 17 00:00:00 2001 From: Ollie Read Date: Mon, 22 Aug 2022 13:42:14 +0100 Subject: [PATCH 13/17] Updated enum error messages in enum tests --- Zend/tests/enum/__clone.phpt | 2 +- Zend/tests/enum/__debugInfo.phpt | 2 +- Zend/tests/enum/__get.phpt | 2 +- Zend/tests/enum/__isset.phpt | 2 +- Zend/tests/enum/__serialize.phpt | 2 +- Zend/tests/enum/__set.phpt | 2 +- Zend/tests/enum/__set_state.phpt | 2 +- Zend/tests/enum/__sleep.phpt | 2 +- Zend/tests/enum/__toString.phpt | 2 +- Zend/tests/enum/__unserialize.phpt | 2 +- Zend/tests/enum/__unset.phpt | 2 +- Zend/tests/enum/__wakeup.phpt | 2 +- Zend/tests/enum/no-constructors.phpt | 2 +- Zend/tests/enum/no-destruct.phpt | 2 +- Zend/tests/enum/no-implement-serializable-indirect.phpt | 2 +- Zend/tests/enum/no-implement-serializable.phpt | 2 +- Zend/tests/enum/no-name-property.phpt | 2 +- Zend/tests/enum/no-properties.phpt | 2 +- Zend/tests/enum/no-static-properties.phpt | 2 +- Zend/tests/enum/no-value-property.phpt | 2 +- Zend/tests/enum/traits-no-__construct.phpt | 2 +- Zend/tests/enum/traits-no-forbidden-methods.phpt | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Zend/tests/enum/__clone.phpt b/Zend/tests/enum/__clone.phpt index c33e748eafeed..fd4b4c43173b6 100644 --- a/Zend/tests/enum/__clone.phpt +++ b/Zend/tests/enum/__clone.phpt @@ -12,4 +12,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum cannot include magic method __clone in %s on line %d +Fatal error: Enum Foo cannot include magic method __clone in %s on line %d diff --git a/Zend/tests/enum/__debugInfo.phpt b/Zend/tests/enum/__debugInfo.phpt index d080818257b14..33e0f49851f9c 100644 --- a/Zend/tests/enum/__debugInfo.phpt +++ b/Zend/tests/enum/__debugInfo.phpt @@ -13,4 +13,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum cannot include magic method __debugInfo in %s on line %d +Fatal error: Enum Foo cannot include magic method __debugInfo in %s on line %d diff --git a/Zend/tests/enum/__get.phpt b/Zend/tests/enum/__get.phpt index 72d2341dcac16..6c77d119b7c71 100644 --- a/Zend/tests/enum/__get.phpt +++ b/Zend/tests/enum/__get.phpt @@ -14,4 +14,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum cannot include magic method __get in %s on line %d +Fatal error: Enum Foo cannot include magic method __get in %s on line %d diff --git a/Zend/tests/enum/__isset.phpt b/Zend/tests/enum/__isset.phpt index a82330155aa4f..087d7d0b17275 100644 --- a/Zend/tests/enum/__isset.phpt +++ b/Zend/tests/enum/__isset.phpt @@ -13,4 +13,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum cannot include magic method __isset in %s on line %d +Fatal error: Enum Foo cannot include magic method __isset in %s on line %d diff --git a/Zend/tests/enum/__serialize.phpt b/Zend/tests/enum/__serialize.phpt index 24afc84f9305a..635bd43964284 100644 --- a/Zend/tests/enum/__serialize.phpt +++ b/Zend/tests/enum/__serialize.phpt @@ -13,4 +13,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum cannot include magic method __serialize in %s on line %d +Fatal error: Enum Foo cannot include magic method __serialize in %s on line %d diff --git a/Zend/tests/enum/__set.phpt b/Zend/tests/enum/__set.phpt index 053e85388d5c5..bfed3df80559b 100644 --- a/Zend/tests/enum/__set.phpt +++ b/Zend/tests/enum/__set.phpt @@ -14,4 +14,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum cannot include magic method __set in %s on line %d +Fatal error: Enum Foo cannot include magic method __set in %s on line %d diff --git a/Zend/tests/enum/__set_state.phpt b/Zend/tests/enum/__set_state.phpt index 4e91ca11075b2..b2bf071743091 100644 --- a/Zend/tests/enum/__set_state.phpt +++ b/Zend/tests/enum/__set_state.phpt @@ -13,4 +13,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum cannot include magic method __set_state in %s on line %d +Fatal error: Enum Foo cannot include magic method __set_state in %s on line %d diff --git a/Zend/tests/enum/__sleep.phpt b/Zend/tests/enum/__sleep.phpt index 68b518df7b61d..4da08e6a4d3f2 100644 --- a/Zend/tests/enum/__sleep.phpt +++ b/Zend/tests/enum/__sleep.phpt @@ -13,4 +13,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum cannot include magic method __sleep in %s on line %d +Fatal error: Enum Foo cannot include magic method __sleep in %s on line %d diff --git a/Zend/tests/enum/__toString.phpt b/Zend/tests/enum/__toString.phpt index 9d4a68acd7af5..9407e482fb727 100644 --- a/Zend/tests/enum/__toString.phpt +++ b/Zend/tests/enum/__toString.phpt @@ -13,4 +13,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum cannot include magic method __toString in %s on line %d +Fatal error: Enum Foo cannot include magic method __toString in %s on line %d diff --git a/Zend/tests/enum/__unserialize.phpt b/Zend/tests/enum/__unserialize.phpt index a57d9c818dac9..f9d594176851b 100644 --- a/Zend/tests/enum/__unserialize.phpt +++ b/Zend/tests/enum/__unserialize.phpt @@ -13,4 +13,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum cannot include magic method __unserialize in %s on line %d +Fatal error: Enum Foo cannot include magic method __unserialize in %s on line %d diff --git a/Zend/tests/enum/__unset.phpt b/Zend/tests/enum/__unset.phpt index f8ed9edd0e095..e2ada98688e63 100644 --- a/Zend/tests/enum/__unset.phpt +++ b/Zend/tests/enum/__unset.phpt @@ -13,4 +13,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum cannot include magic method __unset in %s on line %d +Fatal error: Enum Foo cannot include magic method __unset in %s on line %d diff --git a/Zend/tests/enum/__wakeup.phpt b/Zend/tests/enum/__wakeup.phpt index 1f8b558f32552..8aea17ae53fd3 100644 --- a/Zend/tests/enum/__wakeup.phpt +++ b/Zend/tests/enum/__wakeup.phpt @@ -13,4 +13,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum cannot include magic method __wakeup in %s on line %d +Fatal error: Enum Foo cannot include magic method __wakeup in %s on line %d diff --git a/Zend/tests/enum/no-constructors.phpt b/Zend/tests/enum/no-constructors.phpt index 4096894cd9bdc..862c9ebb7b2f1 100644 --- a/Zend/tests/enum/no-constructors.phpt +++ b/Zend/tests/enum/no-constructors.phpt @@ -9,4 +9,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum cannot include magic method __construct in %s on line %d +Fatal error: Enum Foo cannot include magic method __construct in %s on line %d diff --git a/Zend/tests/enum/no-destruct.phpt b/Zend/tests/enum/no-destruct.phpt index 33b34feee3463..107478b9762c9 100644 --- a/Zend/tests/enum/no-destruct.phpt +++ b/Zend/tests/enum/no-destruct.phpt @@ -9,4 +9,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum cannot include magic method __destruct in %s on line %d +Fatal error: Enum Foo cannot include magic method __destruct in %s on line %d diff --git a/Zend/tests/enum/no-implement-serializable-indirect.phpt b/Zend/tests/enum/no-implement-serializable-indirect.phpt index fff4d4ab03bb4..7f11e34027b8e 100644 --- a/Zend/tests/enum/no-implement-serializable-indirect.phpt +++ b/Zend/tests/enum/no-implement-serializable-indirect.phpt @@ -23,4 +23,4 @@ var_dump(unserialize(serialize(Foo::Bar))); --EXPECTF-- Deprecated: %s implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d -Fatal error: Enums cannot implement the Serializable interface in %s on line %d +Fatal error: Enums Foo cannot implement the Serializable interface in %s on line %d diff --git a/Zend/tests/enum/no-implement-serializable.phpt b/Zend/tests/enum/no-implement-serializable.phpt index 151bd5c972e18..da2a42579b841 100644 --- a/Zend/tests/enum/no-implement-serializable.phpt +++ b/Zend/tests/enum/no-implement-serializable.phpt @@ -21,4 +21,4 @@ var_dump(unserialize(serialize(Foo::Bar))); --EXPECTF-- Deprecated: %s implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d -Fatal error: Enums cannot implement the Serializable interface in %s on line %d +Fatal error: Enums Foo cannot implement the Serializable interface in %s on line %d diff --git a/Zend/tests/enum/no-name-property.phpt b/Zend/tests/enum/no-name-property.phpt index e684dfaf3bbb4..a565c08e83005 100644 --- a/Zend/tests/enum/no-name-property.phpt +++ b/Zend/tests/enum/no-name-property.phpt @@ -9,4 +9,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enums cannot include properties in %s on line %d +Fatal error: Enums may not include properties in %s on line %d diff --git a/Zend/tests/enum/no-properties.phpt b/Zend/tests/enum/no-properties.phpt index 7aee06a1dd4ac..e846845d22270 100644 --- a/Zend/tests/enum/no-properties.phpt +++ b/Zend/tests/enum/no-properties.phpt @@ -9,4 +9,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enums cannot include properties in %s on line %d +Fatal error: Enums may not include properties in %s on line %d diff --git a/Zend/tests/enum/no-static-properties.phpt b/Zend/tests/enum/no-static-properties.phpt index d2d03a1d5b34e..4b823e98e9ffd 100644 --- a/Zend/tests/enum/no-static-properties.phpt +++ b/Zend/tests/enum/no-static-properties.phpt @@ -9,4 +9,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enums cannot include properties in %s on line %d +Fatal error: Enums may not include properties in %s on line %d diff --git a/Zend/tests/enum/no-value-property.phpt b/Zend/tests/enum/no-value-property.phpt index 0f39619f6b2c9..d8b12f2ca8a23 100644 --- a/Zend/tests/enum/no-value-property.phpt +++ b/Zend/tests/enum/no-value-property.phpt @@ -9,4 +9,4 @@ enum Foo: int { ?> --EXPECTF-- -Fatal error: Enums cannot include properties in %s on line %d +Fatal error: Enums may not include properties in %s on line %d diff --git a/Zend/tests/enum/traits-no-__construct.phpt b/Zend/tests/enum/traits-no-__construct.phpt index e6e1b9e63eb52..4bac34295b8fa 100644 --- a/Zend/tests/enum/traits-no-__construct.phpt +++ b/Zend/tests/enum/traits-no-__construct.phpt @@ -18,4 +18,4 @@ var_dump(Bar::Baz); ?> --EXPECTF-- -Fatal error: Enum cannot include magic method __construct in %s on line %d +Fatal error: Enum Bar cannot include magic method __construct in %s on line %d diff --git a/Zend/tests/enum/traits-no-forbidden-methods.phpt b/Zend/tests/enum/traits-no-forbidden-methods.phpt index dac78cdf06ac1..36e4ce780e3e1 100644 --- a/Zend/tests/enum/traits-no-forbidden-methods.phpt +++ b/Zend/tests/enum/traits-no-forbidden-methods.phpt @@ -18,4 +18,4 @@ enum Suit { ?> --EXPECTF-- -Fatal error: Enum cannot include magic method __construct in %s on line %d +Fatal error: Enum Suit cannot include magic method __construct in %s on line %d From 3a90c2b1e9c2d9182ebfaa3ed4f6b42c6e8fc3f3 Mon Sep 17 00:00:00 2001 From: Ollie Read Date: Mon, 22 Aug 2022 13:50:54 +0100 Subject: [PATCH 14/17] Remove return statement for enum __set test --- Zend/tests/enum/__set.phpt | 1 - 1 file changed, 1 deletion(-) diff --git a/Zend/tests/enum/__set.phpt b/Zend/tests/enum/__set.phpt index bfed3df80559b..7fa0fcfb3a499 100644 --- a/Zend/tests/enum/__set.phpt +++ b/Zend/tests/enum/__set.phpt @@ -8,7 +8,6 @@ enum Foo { public function __set(string $name, mixed $value) { - return '__set'; } } From 44d0066f8cb5609db1b4fafb66efbcf58a17d04f Mon Sep 17 00:00:00 2001 From: Ollie Read Date: Mon, 22 Aug 2022 13:53:30 +0100 Subject: [PATCH 15/17] Correct plurality of "enum" in enum error messages --- Zend/tests/enum/no-implement-serializable-indirect.phpt | 2 +- Zend/tests/enum/no-implement-serializable.phpt | 2 +- Zend/zend_enum.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Zend/tests/enum/no-implement-serializable-indirect.phpt b/Zend/tests/enum/no-implement-serializable-indirect.phpt index 7f11e34027b8e..43231b60da845 100644 --- a/Zend/tests/enum/no-implement-serializable-indirect.phpt +++ b/Zend/tests/enum/no-implement-serializable-indirect.phpt @@ -23,4 +23,4 @@ var_dump(unserialize(serialize(Foo::Bar))); --EXPECTF-- Deprecated: %s implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d -Fatal error: Enums Foo cannot implement the Serializable interface in %s on line %d +Fatal error: Enum Foo cannot implement the Serializable interface in %s on line %d diff --git a/Zend/tests/enum/no-implement-serializable.phpt b/Zend/tests/enum/no-implement-serializable.phpt index da2a42579b841..1099cc725c810 100644 --- a/Zend/tests/enum/no-implement-serializable.phpt +++ b/Zend/tests/enum/no-implement-serializable.phpt @@ -21,4 +21,4 @@ var_dump(unserialize(serialize(Foo::Bar))); --EXPECTF-- Deprecated: %s implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d -Fatal error: Enums Foo cannot implement the Serializable interface in %s on line %d +Fatal error: Enum Foo cannot implement the Serializable interface in %s on line %d diff --git a/Zend/zend_enum.c b/Zend/zend_enum.c index 35e0cb6df1e22..59befde732194 100644 --- a/Zend/zend_enum.c +++ b/Zend/zend_enum.c @@ -108,7 +108,7 @@ static void zend_verify_enum_interfaces(zend_class_entry *ce) { if (zend_class_implements_interface(ce, zend_ce_serializable)) { zend_error_noreturn(E_COMPILE_ERROR, - "Enums %s cannot implement the Serializable interface", ZSTR_VAL(ce->name)); + "Enum %s cannot implement the Serializable interface", ZSTR_VAL(ce->name)); } } From a9852518ff33b9cf1ffbdb67a0aeb8e4100f4493 Mon Sep 17 00:00:00 2001 From: Ollie Read Date: Mon, 22 Aug 2022 13:53:53 +0100 Subject: [PATCH 16/17] Update enum static property error messages to include enum class anme --- Zend/tests/enum/no-name-property.phpt | 2 +- Zend/tests/enum/no-properties.phpt | 2 +- Zend/tests/enum/no-static-properties.phpt | 2 +- Zend/tests/enum/no-value-property.phpt | 2 +- Zend/zend_compile.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Zend/tests/enum/no-name-property.phpt b/Zend/tests/enum/no-name-property.phpt index a565c08e83005..93dd4813411f1 100644 --- a/Zend/tests/enum/no-name-property.phpt +++ b/Zend/tests/enum/no-name-property.phpt @@ -9,4 +9,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enums may not include properties in %s on line %d +Fatal error: Enum Foo may not include properties in %s on line %d diff --git a/Zend/tests/enum/no-properties.phpt b/Zend/tests/enum/no-properties.phpt index e846845d22270..7717efbbfe0e5 100644 --- a/Zend/tests/enum/no-properties.phpt +++ b/Zend/tests/enum/no-properties.phpt @@ -9,4 +9,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enums may not include properties in %s on line %d +Fatal error: Enum Foo may not include properties in %s on line %d diff --git a/Zend/tests/enum/no-static-properties.phpt b/Zend/tests/enum/no-static-properties.phpt index 4b823e98e9ffd..468671f5c87a4 100644 --- a/Zend/tests/enum/no-static-properties.phpt +++ b/Zend/tests/enum/no-static-properties.phpt @@ -9,4 +9,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enums may not include properties in %s on line %d +Fatal error: Enum Foo may not include properties in %s on line %d diff --git a/Zend/tests/enum/no-value-property.phpt b/Zend/tests/enum/no-value-property.phpt index d8b12f2ca8a23..e9f68253185e8 100644 --- a/Zend/tests/enum/no-value-property.phpt +++ b/Zend/tests/enum/no-value-property.phpt @@ -9,4 +9,4 @@ enum Foo: int { ?> --EXPECTF-- -Fatal error: Enums may not include properties in %s on line %d +Fatal error: Enum Foo may not include properties in %s on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index ee983e675cd2c..44a467179ce72 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -7405,7 +7405,7 @@ static void zend_compile_prop_decl(zend_ast *ast, zend_ast *type_ast, uint32_t f } if (ce->ce_flags & ZEND_ACC_ENUM) { - zend_error_noreturn(E_COMPILE_ERROR, "Enums may not include properties"); + zend_error_noreturn(E_COMPILE_ERROR, "Enum %s may not include properties", ZSTR_VAL(ce->name)); } if (flags & ZEND_ACC_ABSTRACT) { From 688084d7a5baf547a1e228f9e61501e8b0ef2e40 Mon Sep 17 00:00:00 2001 From: Ollie Read Date: Tue, 23 Aug 2022 11:43:34 +0100 Subject: [PATCH 17/17] Change enum error message when an enum has properties --- Zend/tests/enum/no-name-property.phpt | 2 +- Zend/tests/enum/no-properties.phpt | 2 +- Zend/tests/enum/no-static-properties.phpt | 2 +- Zend/tests/enum/no-value-property.phpt | 2 +- Zend/zend_compile.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Zend/tests/enum/no-name-property.phpt b/Zend/tests/enum/no-name-property.phpt index 93dd4813411f1..6ea1e1a0b0023 100644 --- a/Zend/tests/enum/no-name-property.phpt +++ b/Zend/tests/enum/no-name-property.phpt @@ -9,4 +9,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum Foo may not include properties in %s on line %d +Fatal error: Enum Foo cannot include properties in %s on line %d diff --git a/Zend/tests/enum/no-properties.phpt b/Zend/tests/enum/no-properties.phpt index 7717efbbfe0e5..fb396b403e370 100644 --- a/Zend/tests/enum/no-properties.phpt +++ b/Zend/tests/enum/no-properties.phpt @@ -9,4 +9,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum Foo may not include properties in %s on line %d +Fatal error: Enum Foo cannot include properties in %s on line %d diff --git a/Zend/tests/enum/no-static-properties.phpt b/Zend/tests/enum/no-static-properties.phpt index 468671f5c87a4..873582637789a 100644 --- a/Zend/tests/enum/no-static-properties.phpt +++ b/Zend/tests/enum/no-static-properties.phpt @@ -9,4 +9,4 @@ enum Foo { ?> --EXPECTF-- -Fatal error: Enum Foo may not include properties in %s on line %d +Fatal error: Enum Foo cannot include properties in %s on line %d diff --git a/Zend/tests/enum/no-value-property.phpt b/Zend/tests/enum/no-value-property.phpt index e9f68253185e8..efa8a7d3420bd 100644 --- a/Zend/tests/enum/no-value-property.phpt +++ b/Zend/tests/enum/no-value-property.phpt @@ -9,4 +9,4 @@ enum Foo: int { ?> --EXPECTF-- -Fatal error: Enum Foo may not include properties in %s on line %d +Fatal error: Enum Foo cannot include properties in %s on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 44a467179ce72..8492f1b684cd3 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -7405,7 +7405,7 @@ static void zend_compile_prop_decl(zend_ast *ast, zend_ast *type_ast, uint32_t f } if (ce->ce_flags & ZEND_ACC_ENUM) { - zend_error_noreturn(E_COMPILE_ERROR, "Enum %s may not include properties", ZSTR_VAL(ce->name)); + zend_error_noreturn(E_COMPILE_ERROR, "Enum %s cannot include properties", ZSTR_VAL(ce->name)); } if (flags & ZEND_ACC_ABSTRACT) {