diff --git a/Zend/tests/enum/__clone.phpt b/Zend/tests/enum/__clone.phpt new file mode 100644 index 0000000000000..fd4b4c43173b6 --- /dev/null +++ b/Zend/tests/enum/__clone.phpt @@ -0,0 +1,15 @@ +--TEST-- +Enum __clone +--FILE-- + +--EXPECTF-- +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 new file mode 100644 index 0000000000000..33e0f49851f9c --- /dev/null +++ b/Zend/tests/enum/__debugInfo.phpt @@ -0,0 +1,16 @@ +--TEST-- +Enum __debugInfo +--FILE-- +cases(); + } +} + +?> +--EXPECTF-- +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 885cc2f2c8302..6c77d119b7c71 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 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 76409f075b27d..087d7d0b17275 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 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 new file mode 100644 index 0000000000000..635bd43964284 --- /dev/null +++ b/Zend/tests/enum/__serialize.phpt @@ -0,0 +1,16 @@ +--TEST-- +Enum __serialize +--FILE-- +cases(); + } +} + +?> +--EXPECTF-- +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 new file mode 100644 index 0000000000000..7fa0fcfb3a499 --- /dev/null +++ b/Zend/tests/enum/__set.phpt @@ -0,0 +1,16 @@ +--TEST-- +Enum __set +--FILE-- + +--EXPECTF-- +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 new file mode 100644 index 0000000000000..b2bf071743091 --- /dev/null +++ b/Zend/tests/enum/__set_state.phpt @@ -0,0 +1,16 @@ +--TEST-- +Enum __set_state +--FILE-- + +--EXPECTF-- +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 new file mode 100644 index 0000000000000..4da08e6a4d3f2 --- /dev/null +++ b/Zend/tests/enum/__sleep.phpt @@ -0,0 +1,16 @@ +--TEST-- +Enum __sleep +--FILE-- + +--EXPECTF-- +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 new file mode 100644 index 0000000000000..9407e482fb727 --- /dev/null +++ b/Zend/tests/enum/__toString.phpt @@ -0,0 +1,16 @@ +--TEST-- +Enum __toString +--FILE-- +name; + } +} + +?> +--EXPECTF-- +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 new file mode 100644 index 0000000000000..f9d594176851b --- /dev/null +++ b/Zend/tests/enum/__unserialize.phpt @@ -0,0 +1,16 @@ +--TEST-- +Enum __unserialize +--FILE-- + +--EXPECTF-- +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 new file mode 100644 index 0000000000000..e2ada98688e63 --- /dev/null +++ b/Zend/tests/enum/__unset.phpt @@ -0,0 +1,16 @@ +--TEST-- +Enum __unset +--FILE-- + +--EXPECTF-- +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 new file mode 100644 index 0000000000000..8aea17ae53fd3 --- /dev/null +++ b/Zend/tests/enum/__wakeup.phpt @@ -0,0 +1,16 @@ +--TEST-- +Enum __wakeup +--FILE-- + +--EXPECTF-- +Fatal error: Enum Foo cannot include magic method __wakeup in %s on line %d diff --git a/Zend/tests/enum/backed-from-invalid-int.phpt b/Zend/tests/enum/backed-from-invalid-int.phpt index d976f3d0fbd39..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 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/tests/enum/internal_enums.phpt b/Zend/tests/enum/internal_enums.phpt index 5e36baae302cc..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) diff --git a/Zend/tests/enum/no-constructors.phpt b/Zend/tests/enum/no-constructors.phpt index 70504e14eb381..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 may not include __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 730c29f8476c7..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 may not include __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 efd9229d9edc9..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 may not 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 355d62b71ba53..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 may not 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-name-property.phpt b/Zend/tests/enum/no-name-property.phpt index a565c08e83005..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: Enums 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 e846845d22270..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: Enums 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 4b823e98e9ffd..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: Enums 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 d8b12f2ca8a23..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: Enums 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/traits-no-__construct.phpt b/Zend/tests/enum/traits-no-__construct.phpt index 0529a2a989013..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 may not include __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 1f310f48cd0c6..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 may not include __construct in %s on line %d +Fatal error: Enum Suit 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 5a6faf9deac4e..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_compile.c b/Zend/zend_compile.c index ee983e675cd2c..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, "Enums may not include properties"); + zend_error_noreturn(E_COMPILE_ERROR, "Enum %s cannot include properties", ZSTR_VAL(ce->name)); } if (flags & ZEND_ACC_ABSTRACT) { diff --git a/Zend/zend_enum.c b/Zend/zend_enum.c index 16c3753e7c94a..59befde732194 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 %s cannot include magic method %s", ZSTR_VAL(ce->name), 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 %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 may not implement the Serializable interface"); + "Enum %s cannot implement the Serializable interface", ZSTR_VAL(ce->name)); } } @@ -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; }