D
D
Donald_Duck2018-09-29 10:40:08
phpDocumentor
Donald_Duck, 2018-09-29 10:40:08

How to set the type of an array element in phpdoc?

Hello! Is it possible to specify in phpdoc that an array element has a specific type, otherwise autocomplete does not work in phpstorm? Tried like this:

$post = factory(\App\Post::class)->raw();
/** @var Carbon $post[date] */
$post['date']->setTimezone('Europe/Moscow');

But that doesn't work :(

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
UksusoFF, 2018-09-29
@UksusoFF

You specify that $post \App\Post
And for its properties you use ide helper generator.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question