-
Notifications
You must be signed in to change notification settings - Fork 338
Expand file tree
/
Copy pathscoper.inc.php
More file actions
81 lines (75 loc) · 2.83 KB
/
scoper.inc.php
File metadata and controls
81 lines (75 loc) · 2.83 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
<?php
/**
* PHP-Scoper configuration file.
*
* @package Google\Site_Kit
* @copyright 2021 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://sitekit.withgoogle.com
*/
use Symfony\Component\Finder\Finder;
$installed = include __DIR__ . '/vendor/composer/installed.php';
$non_dev_packages = array_filter(
$installed['versions'],
fn ( $pkg ) => ! $pkg['dev_requirement']
);
return array(
'prefix' => 'Google\\Site_Kit_Dependencies',
'finders' => array(
// All non-dev dependency package files.
Finder::create()
->files()
->in( __DIR__ . '/vendor' )
->path( array_keys( $non_dev_packages ) )
->ignoreVCS( true )
->notName( '/LICENSE|.*\\.md|.*\\.dist|Makefile|composer\\.(json|lock)/' )
->exclude(
array(
'doc',
'test',
'test_old',
'tests',
'Tests',
'vendor-bin',
'.github',
)
),
),
'exclude-files' => array(
// This dependency is a global function which should remain global.
'vendor/ralouphie/getallheaders/src/getallheaders.php',
),
'patchers' => array(
function ( $file_path, $prefix, $contents ) {
// Avoid prefixing the `static` keyword in some places.
$contents = str_replace( "\\$prefix\\static", 'static', $contents );
// Use double backslashes for class names in strings.
$doubled_backslash_prefix = str_replace( '\\', '\\\\', $prefix );
if ( false !== strpos( $file_path, 'vendor/google/apiclient/' ) ) {
$contents = str_replace( "'\\\\GuzzleHttp\\\\ClientInterface", "'\\\\" . $doubled_backslash_prefix . '\\\\GuzzleHttp\\\\ClientInterface', $contents );
$contents = str_replace( "'Google_", "'" . $prefix . '\Google_', $contents );
}
if ( false !== strpos( $file_path, 'vendor/google/auth/' ) ) {
$contents = str_replace( "'GuzzleHttp\\\\ClientInterface", "'" . $doubled_backslash_prefix . '\\\\GuzzleHttp\\\\ClientInterface', $contents );
}
if ( false !== strpos( $file_path, 'apiclient-services-analyticsadmin.v1alpha' ) ) {
// Put v1alpha library in alternate namespace to avoid collision with v1beta for some things.
$contents = preg_replace(
// Use a regular expression to avoid prefixing those that have V1alpha already.
'/GoogleAnalyticsAdmin(V1alpha)?/',
'GoogleAnalyticsAdminV1alpha',
$contents
);
}
if ( false !== strpos( $file_path, 'phpseclib' ) ) {
$contents = str_replace( "'phpseclib3\\\\", "'\\\\" . $doubled_backslash_prefix . '\\\\phpseclib3\\\\', $contents );
$contents = str_replace( "'\\\\phpseclib3", "'\\\\" . $doubled_backslash_prefix . '\\\\phpseclib3', $contents );
}
return $contents;
},
),
'expose-namespaces' => array(),
'expose-global-constants' => false,
'expose-global-classes' => false,
'expose-global-functions' => false,
);