-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscoper.inc.php
More file actions
84 lines (76 loc) · 2.9 KB
/
scoper.inc.php
File metadata and controls
84 lines (76 loc) · 2.9 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
<?php declare(strict_types=1);
use Isolated\Symfony\Component\Finder\Finder;
function getWpExcludedSymbols(string $fileName): array
{
$filePath = __DIR__ . '/vendor/sniccowp/php-scoper-wordpress-excludes/generated/' . $fileName;
return json_decode(
file_get_contents($filePath),
true,
);
}
$wpConstants = getWpExcludedSymbols('exclude-wordpress-constants.json');
$wpClasses = getWpExcludedSymbols('exclude-wordpress-classes.json');
$wpFunctions = getWpExcludedSymbols('exclude-wordpress-functions.json');
return [
'prefix' => 'OTWSystems\WpOidcLogin\Vendor',
'finders' => [
Finder::create()
->files()
->ignoreVCS(true)
->notName('/.*\.dist|Makefile|scoper.inc.php|build.sh|public-signing-key.pub|composer.json|composer.lock/')
->exclude([
'doc',
'test',
'test_old',
'tests',
'Tests',
'vendor-bin',
])
->in(['vendor', '.']),
Finder::create()->append([
'composer.json',
]),
],
'exclude-constants' => array_merge([
'ABSPATH',
'WP_OIDC_LOGIN_VERSION',
], $wpConstants),
'exclude-classes' => $wpClasses,
'exclude-functions' => $wpFunctions,
'exclude-namespaces' => [
'/^OTWSystems\\\\WpOidcLogin\\\\/',
'/^OTWSystems\\\\WpOidcLogin/',
'/^Psr\\\\/',
],
'expose-global-constants' => false,
'expose-global-classes' => false,
'expose-global-functions' => false,
'patchers' => [
static function (string $filePath, string $prefix, string $content): string {
// Fix the string reference of a scoped dependency in the Math lib
$escapedPrefix = str_replace('\\', '\\\\', $prefix);
if (
str_ends_with($filePath, 'vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger.php') ||
str_ends_with($filePath, 'vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/Engine.php')
) {
$content = str_replace(
'phpseclib3\Math\BigInteger\Engines\\\\',
"{$escapedPrefix}\\\\phpseclib3\\\\Math\\\\BigInteger\\\\Engines\\\\",
$content
);
}
if (str_ends_with($filePath, 'vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/AsymmetricKey.php')) {
$content = str_replace(
'phpseclib3\Crypt\\\\',
"{$escapedPrefix}\\\\phpseclib3\\\\Crypt\\\\",
$content
);
}
// Remove the newly added namespace for the bcmath functions
if (str_ends_with($filePath, 'vendor/phpseclib/bcmath_compat/lib/bcmath.php')) {
$content = str_replace("namespace {$prefix};", '', $content);
}
return $content;
}
],
];