Skip to content

Commit ec15210

Browse files
committed
Merge branch 'PHP-8.4'
* PHP-8.4: Disallow asymmetric visibility on static properties
2 parents 1083872 + a8bbc84 commit ec15210

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Asymmetric visibility on static props
3+
--FILE--
4+
<?php
5+
6+
class C {
7+
public private(set) static int $prop;
8+
}
9+
10+
?>
11+
--EXPECTF--
12+
Fatal error: Static property may not have asymmetric visibility in %s on line %d

Zend/zend_compile.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8598,6 +8598,10 @@ static void zend_compile_prop_decl(zend_ast *ast, zend_ast *type_ast, uint32_t f
85988598
zend_error_noreturn(E_COMPILE_ERROR, "Property cannot be both final and private");
85998599
}
86008600

8601+
if ((flags & ZEND_ACC_STATIC) && (flags & ZEND_ACC_PPP_SET_MASK)) {
8602+
zend_error_noreturn(E_COMPILE_ERROR, "Static property may not have asymmetric visibility");
8603+
}
8604+
86018605
if (ce->ce_flags & ZEND_ACC_INTERFACE) {
86028606
if (flags & ZEND_ACC_FINAL) {
86038607
zend_error_noreturn(E_COMPILE_ERROR, "Property in interface cannot be final");

0 commit comments

Comments
 (0)