File Included By & Special PHPDoc Comments

I've got one file that declares some variables and then includes a second file. The second file, when opened, marks these variables as unknown. Is there a PHPDoc directive or some other way to let PhpStorm know that the second file is included by the first, so go to the first to resolve those variables?

Also... Just as a side note, is there a list of all of the PhpStorm-specific PHPDoc comments that control inspections, etc? Thanks.

2 comments
Comment actions Permalink

Hi Robert,

1) If these variables are global -- then they should be picked up with no issues (at least it works for me). If you have include used inside some function & these variables are local variables (like in the example below) then IDE will not pick those variables up and the only way known to me how to inform IDE about this fact is to use PHPDoc comment in included file for each of such variable:

main.php

<?php
function some_function()
{
    $someVar = "meow";
    $anotherVar = 123;
    
    include "include.php";
}

include.php

<?php
/** @var $someVar string */
/** @var $anotherVar int */


echo $someVar;



2) I will just refer to already existing thread, especially these posts by Alexey: http://devnet.jetbrains.net/message/5277218#5277218 and http://devnet.jetbrains.net/message/5277328#5277328

0
Comment actions Permalink

Thanks, that'll have to do. And thanks for the links too.

0

Please sign in to leave a comment.