Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a8bbc84

Browse files
Disallow asymmetric visibility on static properties
This check was forgotten in the original implementation. Relaxing this restriction shouldn't be hard, but needs some work. We either need to prevent merging of cache slots for R/RW/W, or we need to introduce an additional check when writing to the property indirectly. This check is currently present only for direct writes. Closes GH-16462
1 parent d70f3ba commit a8bbc84

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

‎NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ PHP NEWS
1515
. Fixed bug GH-16168 (php 8.1 and earlier crash immediately when compiled
1616
with Xcode 16 clang on macOS 15). (nielsdos)
1717
. Fixed bug GH-16371 (Assertion failure in Zend/zend_weakrefs.c:646). (Arnaud)
18+
. Fixed missing error when adding asymmetric visibility to static properties.
19+
(ilutov)
1820

1921
- Curl:
2022
. Fixed bug GH-16302 (CurlMultiHandle holds a reference to CurlHandle if
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)

AltStyle によって変換されたページ (->オリジナル) /