Skip to content

Commit 885f273

Browse files
committed
Some fixes
1 parent 925f863 commit 885f273

File tree

5 files changed

+15
-19
lines changed

5 files changed

+15
-19
lines changed

Zend/tests/type_declarations/typed_class_constants_type_error8.phpt

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
11
--TEST--
2-
Typed class constants (declaration; enums)
2+
Typed enum constants (self/static)
33
--FILE--
44
<?php
55
enum E {
6-
const E FooConst = E::Foo;
6+
public const E CONST1 = E::Foo;
7+
public const self CONST2 = E::Foo;
8+
public const static CONST3 = E::Foo;
79

810
case Foo;
911
}
1012

1113
class A {
12-
public const E CONST1 = E::Foo;
13-
public const E CONST2 = E::FooConst;
14+
public const E ENUM_CONST = E::Foo;
15+
public const E CONST1 = E::CONST1;
16+
public const E CONST2 = E::CONST2;
17+
public const E CONST3 = E::CONST3;
1418
}
1519

16-
var_dump(E::FooConst);
20+
var_dump(A::ENUM_CONST);
1721
var_dump(A::CONST1);
1822
var_dump(A::CONST2);
23+
var_dump(A::CONST3);
1924
?>
20-
--EXPECTF--
25+
--EXPECT--
26+
enum(E::Foo)
2127
enum(E::Foo)
2228
enum(E::Foo)
2329
enum(E::Foo)

Zend/zend_compile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7715,7 +7715,7 @@ static void zend_compile_class_const_decl(zend_ast *ast, uint32_t flags, zend_as
77157715

77167716
uint32_t type_mask = ZEND_TYPE_PURE_MASK(type);
77177717

7718-
if (type_mask != MAY_BE_ANY && (type_mask & (MAY_BE_CALLABLE|MAY_BE_VOID|MAY_BE_NEVER|MAY_BE_STATIC))) {
7718+
if (type_mask != MAY_BE_ANY && (type_mask & (MAY_BE_CALLABLE|MAY_BE_VOID|MAY_BE_NEVER))) {
77197719
zend_string *type_str = zend_type_to_string(type);
77207720

77217721
zend_error_noreturn(E_COMPILE_ERROR, "Class constant %s::%s cannot have type %s",

Zend/zend_execute.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,7 @@ static ZEND_COLD void zend_verify_missing_return_type(const zend_function *zf)
14731473
zend_verify_return_error(zf, NULL);
14741474
}
14751475

1476-
zend_bool zend_never_inline zend_verify_class_constant_type(const zend_class_constant *c, zval *constant)
1476+
bool zend_never_inline zend_verify_class_constant_type(const zend_class_constant *c, zval *constant)
14771477
{
14781478
if (zend_check_type((zend_type *) &c->type, constant, NULL, NULL, /* is_return_type */ 1, /* is_internal_arg */ 0)) {
14791479
return 1;

Zend/zend_execute.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ ZEND_API int ZEND_FASTCALL zend_handle_undef_args(zend_execute_data *call);
466466
#define ZEND_CLASS_HAS_READONLY_PROPS(ce) ((ce->ce_flags & ZEND_ACC_HAS_READONLY_PROPS) == ZEND_ACC_HAS_READONLY_PROPS)
467467

468468

469-
zend_bool zend_verify_class_constant_type(const zend_class_constant *c, zval *constant);
469+
bool zend_verify_class_constant_type(const zend_class_constant *c, zval *constant);
470470
ZEND_COLD void zend_verify_class_constant_type_error(const zend_class_constant *c, const zval *constant);
471471

472472
ZEND_API bool zend_verify_property_type(const zend_property_info *info, zval *property, bool strict);

0 commit comments

Comments
 (0)