E
E
evilelf2019-07-26 13:13:14
PHP
evilelf, 2019-07-26 13:13:14

How to get rid of duplication when describing an array structure?

Now I have to describe it like this:

/**
 * @var array $items = [
 *    'left' => [
 *     'id' => 1,
 *     'date_create' => '2019-07-23 11:47:35',
 *     'date_update' => '2019-07-23 11:47:35',
 *     'url' => '/sdsd/sdsdsd/',
 *     'active' => 1,
 *     'lang' => [
 *         'id' => 1,
 *         'news_id' => 1,
 *         'lang_id' => 1,
 *         'title' => '',
 *         'preview_text' => '<html>',
 *         'detail_text' => '<html>',
 *     ],
 *    ],
 *    'right' => [
 *      'id' => 1,
 *      'date_create' => '2019-07-23 11:47:35',
 *      'date_update' => '2019-07-23 11:47:35',
 *      'url' => '/sdsd/sdsdsd/',
 *      'active' => 1,
 *      'lang' => [
 *           'id' => 1,
 *           'news_id' => 1,
 *           'lang_id' => 1,
 *           'title' => '',
 *           'preview_text' => '<html>',
 *           'detail_text' => '<html>',
 *      ],
 *    ],
 * ];
 */

As you can see, there is a duplication here.
What is the best way to get rid of it so that phpstorm shows the structure and nesting?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Igor Vorotnev, 2019-07-26
@HeadOnFire

If it's just for hints in PhpStorm, then I would recommend using the deep-assoc-completion plugin and not bother with docblock.

K
Konata Izumi, 2019-07-26
@Konata69lol

As option to describe structure through a class.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question