-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathphpstan-magento2-bootstrap.php
More file actions
36 lines (28 loc) · 1005 Bytes
/
Copy pathphpstan-magento2-bootstrap.php
File metadata and controls
36 lines (28 loc) · 1005 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
25
26
27
28
29
30
31
32
33
34
35
<?php
/* Find bootstrap path */
$rootPath = realpath(dirname(__FILE__));
while (!file_exists($rootPath . '/app/bootstrap.php') && $rootPath !== '/') {
$rootPath = realpath(dirname($rootPath));
}
/* Include Magento bootstrap file */
require_once $rootPath . '/app/bootstrap.php';
/* Create git hook class autoloader */
$_git_hook_loaded_class = [];
function phpstan_magento2_autoloader($class)
{
global $_git_hook_loaded_class;
if (isset($_git_hook_loaded_class[$class])) {
return $_git_hook_loaded_class[$class];
}
try {
/* Get Magento ObjectManager */
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
$objectManager->get($class);
$_git_hook_loaded_class[$class] = true;
} catch (\Exception $e) {
$_git_hook_loaded_class[$class] = false;
}
return $_git_hook_loaded_class[$class];
}
spl_autoload_register('phpstan_magento2_autoloader');