php include() question, variable & function autocompletion

I am the beginner of PHP, while i am using INCLUDE() in  PHPSTOREM, i found a question,

for example,
I create a file   "abc.php",  and inside it , there is    "  $abc = 10;    function abcFunction(){};"

and in the "123.php", i include  "abc.php" into it ,

i can get the abcFunction() from the auto completion, but $abc does not,

does there is anyone can tell me  which part i have made a mistake

thanks :)

0
3 comments
Avatar
Permanently deleted user

That is common in IDE's.

If varibles were included in the code completion it would be an awful big mess of options to choose.

Consider working on a big application like WordPress or a framework like CodeIgniter where there are a huge amount of varibles.

But now if it is something that is important that will be re-used throughout the app, then it should be a property or object.
Then it will show under the code completion.

icnlude file

/**
*
*/
class a
{
     /**
      * @var int
      */
     public $abc = 10;

     public function foo()
     {
          echo 'Bar';
     }
}



test file

include 'include_test.php';

$test = new a;
echo $test->abc;
echo '<br />';

$test->foo();



Should out put
10
Bar

0
Avatar
Permanently deleted user

Hello jacky,

It is possible to obtain 'global variants' in completion also:

local_variants.png

At this point invoke completion manually('ctrl'+'space' is default shortcut for Windows\Linux):

global_variants.png

Thank you for feedback!

0
Avatar
Permanently deleted user

Jeff,

Thanks for the help!

0

Please sign in to leave a comment.