Description
PHPantom reports false-positive missing_view_variable diagnostics for Laravel Blade @include calls when no explicit data array is passed.
The actual case involves nested includes:
View A includes View B
View B includes View C (`scripts.apps.wp`)
View C declares or expects these variables:
$server: \\App\\Models\\Server
$VERSION: string
$data: array
However, PHPantom reports:
View 'scripts.apps.wp' expects $server of type \\App\\Models\\Server, which is not passed phpantom(missing_view_variable)
View 'scripts.apps.wp' expects $VERSION of type string, which is not passed phpantom(missing_view_variable)
View 'scripts.apps.wp' expects $data of type array, which is not passed phpantom(missing_view_variable)
Expected behavior
In Laravel Blade, an include without an explicit data array automatically inherits all variables available in the current parent view scope. That inherited scope should continue through nested includes, so View C should receive $server, $VERSION, and $data when they are available in View A or View B.
The data array parameter of @include is optional. PHPantom should only report a missing variable when it is unavailable from both the explicitly passed data and the inherited parent scope.
Proposed fix
Update Blade include analysis so that:
- omitting the explicit
$data argument does not by itself produce missing_view_variable diagnostics;
- available variables are propagated through nested include chains;
- explicit data arrays continue to be checked when provided;
- genuinely unavailable variables can still be reported.
Description
PHPantom reports false-positive
missing_view_variablediagnostics for Laravel Blade@includecalls when no explicit data array is passed.The actual case involves nested includes:
View C declares or expects these variables:
However, PHPantom reports:
Expected behavior
In Laravel Blade, an include without an explicit data array automatically inherits all variables available in the current parent view scope. That inherited scope should continue through nested includes, so View C should receive
$server,$VERSION, and$datawhen they are available in View A or View B.The data array parameter of
@includeis optional. PHPantom should only report a missing variable when it is unavailable from both the explicitly passed data and the inherited parent scope.Proposed fix
Update Blade include analysis so that:
$dataargument does not by itself producemissing_view_variablediagnostics;