Skip to content

Incorrect return type for esc_sql(), wp_slash() and wp_unslash() #154

@IanDelMar

Description

@IanDelMar

StringOrArrayDynamicFunctionReturnTypeExtension narrows the return type to strings. While this is true for esc_sql(), wp_slash() and wp_unslash() do not change the type of the values.

wp_slash([true]); // gives [true]
wp_unslash(1); // gives 1
esc_sql([true]); // gives ['1']
esc_sql(1); // gives '1'

For Array[] also the return type for esc_sql() is incorrect.

esc_sql([[1]]); // gives array<int,array<int,string>>
esc_sql([['key' => 1]]); // gives array<int,array<string,string>>
esc_sql(['key' => [1]]); // gives array<string,array<int,string>>
esc_sql(['key1' => ['key2' => 1]]); // gives array<string,array<string,string>>
// the extension gives either array<int,string> or array<string,string>

Currently the extension also lacks a maybe array case, ie string|array<int|string,mixed>, and a maybe string array key case, ie array<int|string,mixed>.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions