Code hinting not working
I get no code hints for this code ( https://www.evernote.com/l/AALUb2sMnRRKpqJpoYffIlajRZ6Vf4vqS8o ):
$recipes = self::get_indexes('amd_zlrecipe_recipes');
$post_ids = array_map(function ($recipe) {
return $recipe->;
}, $recipes);
The PHPDoc for `get_indexes` is done properly and if I change it by removing `[]` after Recipe, for example, PHPStorm warns me:
/**
* Get Index
*
* @global object $wpdb
* @param String $extension_table_name
* @return \ZRDN\Recipe[]
*/
public static function get_indexes($extension_table_name) {
global $wpdb;
$db_name = $wpdb->prefix . $extension_table_name;
$selectStatement = "SELECT * FROM `{$db_name}`";
$recipe_indexes = $wpdb->get_results($selectStatement);
return $recipe_indexes;
}
Recipe is defined in the same file under same namespace:
class Recipe {
/**
* @var int
*/
public $recipe_id;
/**
* @var int
*/
public $post_id;
...
Any ideas what the issue might be?
Please sign in to leave a comment.
Hi there,
PhpStorm does not cover such usage case yet. https://youtrack.jetbrains.com/issue/WI-18347 I guess -- watch it (star/vote/comment) to get notified on any progress.
Right now you may typehint your $recipe manually with inline PHPDoc (place it somewhere before the usage place -- e.g. before return statement in your case), e.g.
You may also use PHP's own typehinting mechanism here (never tried it myself for lambdas though). I mean:
array_map(function(\ZRDN\Recipe $recipe) {P.S. Same on StackOverflow: https://stackoverflow.com/q/48040747/783119