Force PhpStorm to not treat a string as SQL

As a WordPress developer, I have had this issue come up repeatedly when coding a custom post type. See the example code block below. Where it says "Insert into document", PhpStorm interprets this string as a SQL string and performs syntax checking on it, and of course it always complains that it's an incomplete command. If I do "Reformat Code", it applies SQL formatting to it (i.e., it surrounds "document" with backticks as if it were a table name). Is there a comment I can enter that will force PhpStorm to not treat that string as SQL, or what is suggested? I don't want to turn off SQL syntax checking and formatting entirely.

register_post_type( 'document', [
'labels' => [
'name' => _x( 'Documents', 'post type general name', 'mydomain' ),
'singular_name' => _x( 'Document', 'post type singular name', 'mydomain' ),
'add_new' => _x( 'Add New', 'document', 'mydomain' ),
'add_new_item' => __( 'Add New Document', 'mydomain' ),
'edit_item' => __( 'Edit Document', 'mydomain' ),
'new_item' => __( 'New Document', 'mydomain' ),
'view_item' => __( 'View Document', 'mydomain' ),
'view_items' => __( 'View Documents', 'mydomain' ),
'search_items' => __( 'Search Documents', 'mydomain' ),
'not_found' => __( 'No documents found.', 'mydomain' ),
'not_found_in_trash' => __( 'No documents found in Trash.', 'mydomain' ),
'parent_item_colon' => __( 'Parent Document:', 'mydomain' ),
'all_items' => __( 'All Documents', 'mydomain' ),
'archives' => __( 'Document Archives', 'mydomain' ),
'attributes' => __( 'Document Attributes', 'mydomain' ),
'insert_into_item' => __( 'Insert into document', 'mydomain' ),
'uploaded_to_this_item' => __( 'Uploaded to this document', 'mydomain' ),
'featured_image' => _x( 'Featured Image', 'document', 'mydomain' ),
'set_featured_image' => _x( 'Set featured image', 'document', 'mydomain' ),
'remove_featured_image' => _x( 'Remove featured image', 'document', 'mydomain' ),
'use_featured_image' => _x( 'Use as featured image', 'document', 'mydomain' ),
'filter_items_list' => __( 'Filter documents list', 'mydomain' ),
'items_list_navigation' => __( 'Documents list navigation', 'mydomain' ),
'items_list' => __( 'Documents list', 'mydomain' )
],
'public' => true,
'hierarchical' => true,
'menu_icon' => 'dashicons-media-default'
] );

 

1 comment

Hi there,

Try adding /** @lang Text */ just before the string.

2

Please sign in to leave a comment.