I get no code hints for this code:

The PHPDoc for get_indexes I think is done properly and NetBeans seems to understand it and show hints properly:
/**
* 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?
If you know that $recipes always contains objects of type Recipe then use it as the type of the $recipe argument of the map function:
$post_ids = array_map(function(Recipe $recipe) {
return $recipe->recipe_id;
}, $recipes);
This way PhpStorm (and other IDEs) can help you with the autocomplete and also the PHP interpreter triggers a fatal error when it encounters a value in $recipes of the wrong type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With