@@ -87,21 +87,24 @@ public function test_mutation_on_child_survives_re_read(): void {
8787 $ child = $ tree ->get_first_child_node ();
8888 $ this ->assertNotNull ( $ child );
8989
90- // Public dynamic property — the kind of state a caller might attach
91- // expecting WP_Parser_Node identity to keep it reachable.
92- $ child ->custom_marker = 'set-on-first-read ' ;
90+ // Mutate via the public WP_Parser_Node API — this is exactly the
91+ // kind of state the reviewer worried would be lost when accessors
92+ // hand back fresh wrappers. rule_name is a declared public property
93+ // that the parser itself sets, so PHP 8.2's dynamic-property
94+ // deprecation does not apply here.
95+ $ child ->rule_name = 'mutated-rule ' ;
9396
9497 $ same_child = $ tree ->get_first_child_node ();
9598 $ this ->assertSame ( $ child , $ same_child );
96- $ this ->assertSame ( 'set-on-first-read ' , $ same_child ->custom_marker );
99+ $ this ->assertSame ( 'mutated-rule ' , $ same_child ->rule_name );
97100 }
98101
99102 public function test_mutation_survives_parent_materialization (): void {
100103 $ tree = $ this ->parse ( 'SELECT 1 + 2 ' );
101104
102105 $ child = $ tree ->get_first_child_node ();
103106 $ this ->assertNotNull ( $ child );
104- $ child ->custom_marker = 'before-materialize ' ;
107+ $ child ->rule_name = 'before-materialize ' ;
105108
106109 // Force the parent to materialize its native children by appending
107110 // a sibling. After this, the parent walks $this->children directly.
@@ -110,6 +113,6 @@ public function test_mutation_survives_parent_materialization(): void {
110113
111114 $ children = $ tree ->get_children ();
112115 $ this ->assertContains ( $ child , $ children , 'Materialized children must include the previously-mutated wrapper. ' );
113- $ this ->assertSame ( 'before-materialize ' , $ child ->custom_marker );
116+ $ this ->assertSame ( 'before-materialize ' , $ child ->rule_name );
114117 }
115118}
0 commit comments