title: How to set PHPStorm to check for variable usage in required/included files? How to check variable definition in required/included files?
body: <p>When I <code>require</code> or <code>include</code> a file in PHPStorm, it's not being able to detect that a variable defined in the main file is being used in that file that is being required/included. Same thing with the variable in the included/required file, it shows as not defined.</p>
  
  <p>Here's an example for clarity:</p>
  
  <p>Main file (let's say <code>main.php</code>):</p>
  
  <pre><code>&lt;?php
  $var1 = "hi";
  require "next.php";
  </code></pre>
  
  <p>While here is the "required" <code>next.php</code> file:</p>
  
  <pre><code>&lt;?php
  echo "&lt;p&gt;".$var1."&lt;/p&gt;";
  </code></pre>
  
  <p>The code works fine but on PHPStorm, <code>$var1</code> shows as unused in the <code>main.php</code> file while it shows as undefined in the <code>next.php</code> file.</p>
  
  <p>I've seen several answers on SO on how to disable the warnings but that's not what I want. I want PHPStorm to recognize this variable as used and defined in the called and calling modules respectively.</p>
  
  <p>Is this possible? Or am I asking the wrong questions?</p>
  
  <p>If anyone's wondering why I'm doing this, I'm trying to separate logic from structure ala-MVC.</p>