-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathphpstan-bootstrap.php
More file actions
24 lines (19 loc) · 933 Bytes
/
Copy pathphpstan-bootstrap.php
File metadata and controls
24 lines (19 loc) · 933 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
declare(strict_types=1);
// Testbench's workbench.discovers.views config is not applied during Larastan's analysis-time app boot,
// so we must register the view path manually for PHPStan's view-string validation to find fixtures.
// If a future Larastan/Testbench version applies workbench.discovers.views during PHPStan's own app boot,
// this manual registration becomes redundant and can be deleted along with the `bootstrapFiles` entry
// in phpstan-tests.neon.dist.
if (function_exists('app')) {
$app = app();
$viewFactory = $app->make('view');
$finder = $viewFactory->getFinder();
$currentPaths = $finder->getPaths();
$workbenchViewPath = realpath(__DIR__.'/workbench/resources/views');
if ($workbenchViewPath && ! in_array($workbenchViewPath, $currentPaths, true)) {
$newPaths = $currentPaths;
$newPaths[] = $workbenchViewPath;
$finder->setPaths($newPaths);
}
}