forked from PrestaShop/PrestaShop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautoload.php
More file actions
175 lines (166 loc) · 6.36 KB
/
Copy pathautoload.php
File metadata and controls
175 lines (166 loc) · 6.36 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php
declare(strict_types = 1);
define('_PS_ROOT_DIR_', __DIR__. '/../../../');
// Add module composer autoloader
require_once _PS_ROOT_DIR_ . 'vendor/autoload.php';
// Add PrestaShop composer autoload
define('_PS_ADMIN_DIR_', _PS_ROOT_DIR_ . '/admin-dev/');
define('PS_ADMIN_DIR', _PS_ADMIN_DIR_);
require_once _PS_ROOT_DIR_ . '/config/defines.inc.php';
require_once _PS_ROOT_DIR_ . '/config/autoload.php';
require_once _PS_ROOT_DIR_ . '/config/bootstrap.php';
require_once _PS_ROOT_DIR_ . '/install-dev/classes/exception.php';
require_once _PS_ROOT_DIR_ . '/install-dev/classes/session.php';
require_once _PS_ROOT_DIR_ . '/var/SymfonyRequirements.php';
include_once _PS_TOOL_DIR_ . 'profiling/Profiler.php';
include_once _PS_TOOL_DIR_ . 'profiling/Controller.php';
include_once _PS_TOOL_DIR_ . 'profiling/ObjectModel.php';
include_once _PS_TOOL_DIR_ . 'profiling/Db.php';
include_once _PS_TOOL_DIR_ . 'profiling/Hook.php';
include_once _PS_TOOL_DIR_ . 'profiling/Module.php';
include_once _PS_TOOL_DIR_ . 'profiling/Tools.php';
// Make sure loader php-parser is coming from php stan composer
// 1- Use module vendors
$loader = new \Composer\Autoload\ClassLoader();
$loader->setPsr4('PhpParser\\', ['vendor/nikic/php-parser/lib/PhpParser']);
$loader->register(true);
// 2- Use with Docker container
$loader = new \Composer\Autoload\ClassLoader();
$loader->setPsr4('PhpParser\\', ['/composer/vendor/nikic/php-parser/lib/PhpParser']);
$loader->register(true);
// 3- Use with PHPStan phar
$loader = new \Composer\Autoload\ClassLoader();
// Contains the vendor in phar, like "phar://phpstan.phar/vendor"
$loader->setPsr4('PhpParser\\', ['phar://' . dirname($_SERVER['PATH_TRANSLATED']) . '/../phpstan/phpstan-shim/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/']);
$loader->register(true);
// 4- Use phpstan phar with sym link
$loader = new \Composer\Autoload\ClassLoader();
$loader->setPsr4('PhpParser\\', ['phar://' . realpath($_SERVER['PATH_TRANSLATED']) . '/vendor/nikic/php-parser/lib/PhpParser/']);
$loader->register(true);
// We must declare these constant in this bootstrap script.
// Ignoring the error pattern with this value will throw another error if not found
// during the checks.
$constantsToDefine = [
'_LEGACY_PS_CREATION_DATE_' => 'string',
'_LEGACY_PS_CACHE_ENABLED_' => 'bool',
'_LEGACY_PS_CACHING_SYSTEM_' => 'string',
'_LEGACY_COOKIE_KEY_' => 'string',
'_LEGACY_COOKIE_IV_' => 'string',
'_LEGACY_DB_PREFIX_' => 'string',
'_LEGACY_DB_SERVER_' => 'string',
'_LEGACY_DB_USER_' => 'string',
'_LEGACY_DB_PASSWD_' => 'string',
'_LEGACY_DB_NAME_' => 'string',
'_LEGACY_MYSQL_ENGINE_' => 'string',
'_DB_SERVER_' => 'string',
'_DB_NAME_' => 'string',
'_DB_USER_' => 'string',
'_DB_PASSWD_' => 'string',
'_MYSQL_ENGINE_' => 'string',
'_COOKIE_KEY_' => 'string',
'_COOKIE_IV_' => 'string',
'_DB_PREFIX_' => 'string',
'_PS_SSL_PORT_' => 'int',
'_THEME_NAME_' => 'string',
'_THEME_COL_DIR_' => 'string',
'_PARENT_THEME_NAME_' => 'string',
'__PS_BASE_URI__' => 'string',
'_PS_API_URL_' => 'string',
'_PS_CACHE_ENABLED_' => 'int',
'_PS_CACHING_SYSTEM_' => 'string',
'_PS_CREATION_DATE_' => 'string',
'_PS_INSTALL_PATH_' => 'string',
'_PS_INSTALL_DATA_PATH_' => 'string',
'_PS_INSTALL_LANGS_PATH_' => 'string',
'_PS_INSTALL_FIXTURES_PATH_' => 'string',
'_PS_INSTALL_VERSION_' => 'string',
'_PS_OS_CHEQUE_' => 'int',
'_PS_OS_PAYMENT_' => 'int',
'_PS_OS_PREPARATION_' => 'int',
'_PS_OS_SHIPPING_' => 'int',
'_PS_OS_DELIVERED_' => 'int',
'_PS_OS_CANCELED_' => 'int',
'_PS_OS_REFUND_' => 'int',
'_PS_OS_ERROR_' => 'int',
'_PS_OS_OUTOFSTOCK_' => 'int',
'_PS_OS_OUTOFSTOCK_PAID_' => 'int',
'_PS_OS_OUTOFSTOCK_UNPAID_' => 'int',
'_PS_OS_BANKWIRE_' => 'int',
'_PS_OS_PAYPAL_' => 'int',
'_PS_OS_WS_PAYMENT_' => 'int',
'_PS_OS_COD_VALIDATION_' => 'int',
'_PS_THEME_DIR_' => 'string',
'_PS_BASE_URL_' => 'string',
'_MODULE_DIR_' => 'string',
'_THEME_PROD_DIR_' => 'string',
'_THEME_PROD_PIC_DIR_' => 'string',
'_NEW_COOKIE_KEY_' => 'string',
'_MAIL_DIR_' => 'string',
'_PS_IMG_' => 'string',
'_PS_PARENT_THEME_DIR_' => 'string',
'_PS_API_MODULES_LIST_16_' => 'string',
'_PS_CURRENCY_FEED_URL_' => 'string',
'_PS_DEFAULT_THEME_NAME_' => 'string',
'_PS_INSTALL_CONTROLLERS_PATH_' => 'string',
'_PS_INSTALL_MAXIMUM_PHP_VERSION_' => 'string',
'_PS_INSTALL_MAXIMUM_PHP_VERSION_ID_' => 'int',
'_PS_INSTALL_MINIMUM_PHP_VERSION_' => 'string',
'_PS_INSTALL_MINIMUM_PHP_VERSION_ID_' => 'int',
'_PS_JS_DIR_' => 'string',
'_PS_PARENT_THEME_URI_' => 'string',
'_PS_TAB_MODULE_LIST_URL_' => 'string',
'_PS_THEME_SELECTED_DIR_' => 'string',
'_PS_THEME_URI_' => 'string',
'_PS_TMP_IMG_' => 'string',
'_THEME_CAT_DIR_' => 'string',
'_THEME_CSS_DIR_' => 'string',
'_THEME_DIR_' => 'string',
'_THEME_EMPLOYEE_DIR_' => 'string',
'_THEME_GENDERS_DIR_' => 'string',
'_THEME_IMG_DIR_' => 'string',
'_THEME_JS_DIR_' => 'string',
'_THEME_LANG_DIR_' => 'string',
'_THEME_MANU_DIR_' => 'string',
'_THEME_SHIP_DIR_' => 'string',
'_THEME_STORE_DIR_' => 'string',
'_THEME_SUP_DIR_' => 'string',
'_THEME_PROFILE_DIR_' => 'string',
'_THEMES_DIR_' => 'string',
'PS_INSTALLATION_LOCK_FILE' => 'string',
];
foreach ($constantsToDefine as $key => $value) {
if (!defined($key)) {
switch ($value) {
case 'bool':
define($key, false);
break;
case 'int':
define($key, 1);
break;
case 'string':
default:
define($key, 'DUMMY_VALUE');
break;
}
}
}
/*
* At this time if _PS_VERSION_ is still undefined, this is likely because
* - we are on a old PrestaShop (below 1.7.0.0),
* - the shop hasn't been installed yet.
*
* In that case, the constant can be set from another one in the installation folder.
*/
if (!defined('_PS_VERSION_')) {
$legacyInstallationFileDefiningConstant = [
'/install-dev/install_version.php',
'/install/install_version.php',
];
foreach ($legacyInstallationFileDefiningConstant as $file) {
if (file_exists(_PS_ROOT_DIR_ . $file)) {
require_once _PS_ROOT_DIR_ . $file;
define('_PS_VERSION_', _PS_INSTALL_VERSION_);
break;
}
}
}