-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscoper.inc.php
More file actions
63 lines (56 loc) · 1.87 KB
/
scoper.inc.php
File metadata and controls
63 lines (56 loc) · 1.87 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
<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
use Isolated\Symfony\Component\Finder\Finder;
$dependenciesToPrefix = json_decode(getenv('MATOMO_DEPENDENCIES_TO_PREFIX'), true);
$namespacesToPrefix = json_decode(getenv('MATOMO_NAMESPACES_TO_PREFIX'), true);
$isRenamingReferences = getenv('MATOMO_RENAME_REFERENCES') == 1;
$pluginName = getenv('MATOMO_PLUGIN');
$namespacesToExclude = [];
$forceNoGlobalAlias = false;
if ($isRenamingReferences) {
$finders = [
Finder::create()
->files()
->in(__DIR__)
->exclude('vendor')
->notName(['scoper.inc.php'])
->filter(function (\SplFileInfo $file) {
return !($file->isLink() && $file->isDir());
})
->filter(function (\SplFileInfo $file) {
return !($file->isLink() && !$file->getRealPath());
}),
];
} else {
$finders = array_map(function ($dependency) {
return Finder::create()
->files()
->in($dependency);
}, $dependenciesToPrefix);
}
$namespacesToIncludeRegexes = array_map(function ($n) {
$n = rtrim($n, '\\');
return '/^' . preg_quote($n) . '(?:\\\\|$)/';
}, $namespacesToPrefix);
return [
'expose-global-constants' => false,
'expose-global-classes' => false,
'expose-global-functions' => false,
'force-no-global-alias' => $forceNoGlobalAlias,
'prefix' => 'Matomo\\Dependencies\\' . $pluginName,
'finders' => $finders,
'patchers' => [],
'include-namespaces' => $namespacesToIncludeRegexes,
'exclude-namespaces' => $namespacesToExclude,
'exclude-constants' => [
'PIWIK_TEST_MODE',
'/^self::/', // work around php-scoper bug
],
'exclude-functions' => ['Piwik_ShouldPrintBackTraceWithMessage'],
];