Skip to content

Commit a8a4283

Browse files
committed
Fix code style and PHP 8.2 dynamic-property deprecation in identity test
1 parent 61a00fa commit a8a4283

3 files changed

Lines changed: 13 additions & 10 deletions

File tree

packages/mysql-on-sqlite/src/mysql/native/class-wp-mysql-native-parser-node.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ private function intern( $value ) {
223223
if ( isset( $cache->nodes[ $index ] ) ) {
224224
return $cache->nodes[ $index ];
225225
}
226-
$value->cache = $cache;
226+
$value->cache = $cache;
227227
$cache->nodes[ $index ] = $value;
228228
return $value;
229229
}

packages/mysql-on-sqlite/tests/mysql/native/WP_MySQL_Native_Parser_Node_Identity_Tests.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

packages/mysql-on-sqlite/tests/tools/run-native-ast-walk-benchmark.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ function ( $severity, $message, $file, $line ) {
3939
}
4040
fclose( $handle );
4141

42-
$total = 0;
43-
$walked = 0;
42+
$total = 0;
43+
$walked = 0;
4444
$identity_ok = true;
45-
$failures = 0;
45+
$failures = 0;
4646

4747
if ( function_exists( 'memory_reset_peak_usage' ) ) {
4848
memory_reset_peak_usage();

0 commit comments

Comments
 (0)