@@ -125,14 +125,36 @@ $driver = new WP_PDO_MySQL_On_SQLite( 'mysql-on-sqlite:path=:memory:;dbname=wp;'
125125$parser = $driver->create_parser( 'SELECT 1' );
126126$parser->next_query();
127127$ast = $parser->get_query_ast();
128- $property = ( new ReflectionClass( $ast ) )->getProperty( 'native_ast' );
129- $property->setAccessible( true );
130- $native_ast = $property->getValue( $ast );
131128
132- if ( ! is_object ( $native_ast ) || 'WP_MySQL_Native_Ast' !== get_class( $native_ast ) ) {
129+ if ( ! ( $ast instanceof WP_MySQL_Native_Parser_Node ) ) {
133130 fwrite( STDERR, "WordPress PHP test container did not select the native-backed AST.\n" );
134131 exit( 1 );
135132}
133+
134+ $reflection = new ReflectionObject( $ast );
135+ if ( $reflection->hasProperty( 'native_ast' ) || $reflection->hasProperty( 'native_node_index' ) ) {
136+ fwrite( STDERR, "Native wrapper still stores Rust AST handle properties.\n" );
137+ exit( 1 );
138+ }
139+
140+ $first = $ast->get_first_child_node();
141+ if ( ! ( $first instanceof WP_MySQL_Native_Parser_Node ) ) {
142+ fwrite( STDERR, "Native wrapper did not return a native-backed child node.\n" );
143+ exit( 1 );
144+ }
145+
146+ if ( $first !== $ast->get_first_child_node() ) {
147+ fwrite( STDERR, "Native wrapper identity is not stable across reads.\n" );
148+ exit( 1 );
149+ }
150+
151+ $synthetic = new WP_Parser_Node( 0, 'synthetic' );
152+ $first->append_child( $synthetic );
153+ $same_first = $ast->get_first_child_node();
154+ if ( $same_first !== $first || ! in_array( $synthetic, $same_first->get_children(), true ) ) {
155+ fwrite( STDERR, "Materialized native wrapper was lost from the parent cache.\n" );
156+ exit( 1 );
157+ }
136158EOF
137159
138160node tools/local-env/scripts/docker.js run --rm php php -m | grep -qx ' wp_mysql_parser'
0 commit comments