-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathscoper.inc.php
More file actions
75 lines (63 loc) · 2.09 KB
/
scoper.inc.php
File metadata and controls
75 lines (63 loc) · 2.09 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
<?php
declare(strict_types=1);
use Isolated\Symfony\Component\Finder\Finder;
return [
'prefix' => 'Monei\\Internal',
// Don't prefix the SDK's own namespace
'exclude-namespaces' => [
'Monei',
'Symfony\Polyfill',
],
'exclude-classes' => [
'Composer\Autoload\ClassLoader',
],
'exclude-functions' => [],
'exclude-constants' => [],
'expose-global-constants' => true,
'expose-global-classes' => true,
'expose-global-functions' => true,
'finders' => [
// Process vendor dependencies to scope them
Finder::create()
->files()
->ignoreVCS(true)
->notName('/LICENSE|.*\.md|.*\.dist|Makefile|composer\.json|composer\.lock/')
->exclude([
'doc',
'test',
'test_old',
'tests',
'Tests',
'vendor-bin',
'bin',
])
->in('vendor/guzzlehttp')
->in('vendor/psr/http-message')
->in('vendor/psr/http-client')
->in('vendor/psr/http-factory')
->in('vendor/ralouphie')
->name('*.php'),
// ALSO process the SDK files to update their imports
// Since 'Monei' namespace is excluded, these files won't be prefixed
// but their imports WILL be updated to use scoped versions
Finder::create()
->files()
->in('lib')
->notPath('Internal')
->name('*.php'),
],
'patchers' => [
function (string $filePath, string $prefix, string $content): string {
// Fix Utils::jsonEncode calls to use the function instead
// After PHP-Scoper has already updated namespaces
if (str_contains($content, 'Utils::jsonEncode')) {
$content = str_replace(
'\\' . $prefix . '\\GuzzleHttp\\Utils::jsonEncode',
'\\' . $prefix . '\\GuzzleHttp\\json_encode',
$content
);
}
return $content;
},
],
];