1--TEST-- 2Property hooks in php 8.4 constructor property promotion 3--SKIPIF-- 4<?php if (PHP_VERSION_ID < 80400) die('skip PHP >=8.4 only'); ?> 5--FILE-- 6<?php 7require __DIR__ . '/../util.php'; 8$code = <<<'PHP' 9<?php 10class User 11{ 12 public function __construct( 13 public string $username { set => strtolower($value); } 14 ) {} 15} 16PHP; 17$node = ast\parse_code($code, $version=110); 18echo ast_dump($node), "\n"; 19--EXPECTF-- 20AST_STMT_LIST 21 0: AST_CLASS 22 name: "User" 23 docComment: null 24 extends: null 25 implements: null 26 stmts: AST_STMT_LIST 27 0: AST_METHOD 28 flags: MODIFIER_PUBLIC (%d) 29 name: "__construct" 30 docComment: null 31 params: AST_PARAM_LIST 32 0: AST_PARAM 33 flags: PARAM_MODIFIER_PUBLIC (%d) 34 type: AST_TYPE 35 flags: TYPE_STRING (%d) 36 name: "username" 37 default: null 38 attributes: null 39 docComment: null 40 hooks: AST_STMT_LIST 41 0: AST_PROPERTY_HOOK 42 name: "set" 43 docComment: null 44 params: null 45 stmts: AST_PROPERTY_HOOK_SHORT_BODY 46 expr: AST_CALL 47 expr: AST_NAME 48 flags: NAME_NOT_FQ (%d) 49 name: "strtolower" 50 args: AST_ARG_LIST 51 0: AST_VAR 52 name: "value" 53 attributes: null 54 __declId: 0 55 stmts: AST_STMT_LIST 56 returnType: null 57 attributes: null 58 __declId: 1 59 attributes: null 60 type: null 61 __declId: 2 62