-
-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathscoper.inc.php
55 lines (49 loc) · 1.95 KB
/
scoper.inc.php
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
<?php
declare (strict_types = 1);
use Isolated\Symfony\Component\Finder\Finder;
return [
'prefix' => 'Jacoby\Intervention',
// https://github.com/humbug/php-scoper#finders-and-paths
'finders' => [
Finder::create()
->files()
->ignoreVCS(true)
->notName('/LICENSE|.*\\.md|.*\\.dist|Makefile|composer\\.json|composer\\.lock/')
->exclude([
'doc',
'test',
'test_old',
'tests',
'Tests',
'vendor-bin',
])
->in('vendor'),
Finder::create()->append([
'composer.json',
]),
],
'exclude-namespaces' => [
'Jacoby\Intervention\*',
],
'patchers' => [
function ($file_path, $prefix, $contents) {
/**
* Illuminate includes some helper functions which are declared as
* globals. In order to namespace Intervention for WordPress, the
* helper functions are being namespaced. To avoid errors, we need
* to change the namespace of `helpers.php` to match the namespaces
* of `Arr.php` and `Str.php`. The function `data_get` is also being
* used under `Traits/` and should be namespaced correctly. This is
* not ideal but currently the best option for dealing with Illuminate
* collections and php-scoper.
*/
if (strpos($file_path, 'vendor/illuminate/collections/helpers.php')) {
$contents = str_replace('namespace Jacoby\\Intervention', 'namespace Jacoby\\Intervention\\Illuminate\\Support', $contents);
}
if (strpos($file_path, 'vendor/illuminate/collections/Traits/EnumeratesValues.php')) {
$contents = str_replace('data_get(', '\\Jacoby\\Intervention\\Illuminate\\Support\data_get(', $contents);
}
return $contents;
},
],
];