PHPStorm: undefined variables caused by include/require

All above answers removes or suppress warnings which imho is not good solution.

Best solution is to add header with doc block with used variables.

Example:

<?php
/**
 * @var string $name
 * @var FormData $form
 */
?>

This will not only prevent from showing “Undefined variable” warning, but also document your code and makes autocomplete working as expected.

Leave a Comment