-
Notifications
You must be signed in to change notification settings - Fork 178
/
scoper.inc.php
199 lines (183 loc) · 5.44 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
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<?php
/**
* PHP-Scoper configuration file.
*
* @link https://github.com/googleforcreators/web-stories-wp
*
* @copyright 2020 Google LLC
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
*/
declare(strict_types = 1);
use Isolated\Symfony\Component\Finder\Finder;
$wp_classes = json_decode( file_get_contents( 'vendor/sniccowp/php-scoper-wordpress-excludes/generated/exclude-wordpress-classes.json' ), true );
$wp_functions = json_decode( file_get_contents( 'vendor/sniccowp/php-scoper-wordpress-excludes/generated/exclude-wordpress-functions.json' ), true );
$wp_constants = json_decode( file_get_contents( 'vendor/sniccowp/php-scoper-wordpress-excludes/generated/exclude-wordpress-constants.json' ), true );
return [
'prefix' => 'Google\\Web_Stories_Dependencies',
// See: https://github.com/humbug/php-scoper#finders-and-paths.
'finders' => [
// Main AMP PHP Library.
Finder::create()
->files()
->ignoreVCS( true )
->ignoreDotFiles( true )
->name( '*.php' )
->name( 'class-amp-base-sanitizer.php' )
->notName(
[
'amp.php',
'amp-enabled-classic-editor-toggle.php',
'amp-frontend-actions.php',
'amp-helper-functions.php',
'amp-paired-browsing.php',
'amp-post-template-functions.php',
'class-amp-autoloader.php',
'class-amp-comment-walker.php',
'class-amp-content.php',
'class-amp-html-utils.php',
'class-amp-http.php',
'class-amp-post-template.php',
'class-amp-post-type-support.php',
'class-amp-service-worker.php',
'class-amp-theme-support.php',
'class-amp-validated-url-post-type.php',
'class-amp-validation-callback-wrapper.php',
'deprecated.php',
'reader-template-loader.php',
]
)
->exclude(
[
'admin',
'assets',
'back-compat',
'bin',
'cli',
'docs',
'embeds',
'includes/admin',
'includes/cli',
'includes/embeds',
'includes/options',
'includes/settings',
'includes/validation',
'includes/widgets',
'options',
'patches',
'sanitizers',
'settings',
'src',
'templates',
'tests',
'vendor',
'widgets',
'wp-assets',
'tests',
]
)
->in(
[
'vendor/ampproject/amp-wp/includes',
'vendor/ampproject/amp-wp/src/RemoteRequest',
]
)
->append(
[
'vendor/ampproject/amp-wp/includes/sanitizers/class-amp-allowed-tags-generated.php',
'vendor/ampproject/amp-wp/includes/sanitizers/class-amp-base-sanitizer.php',
'vendor/ampproject/amp-wp/includes/sanitizers/class-amp-dev-mode-sanitizer.php',
'vendor/ampproject/amp-wp/includes/sanitizers/class-amp-layout-sanitizer.php',
'vendor/ampproject/amp-wp/includes/sanitizers/class-amp-meta-sanitizer.php',
'vendor/ampproject/amp-wp/includes/sanitizers/class-amp-rule-spec.php',
'vendor/ampproject/amp-wp/includes/sanitizers/class-amp-script-sanitizer.php',
'vendor/ampproject/amp-wp/includes/sanitizers/class-amp-style-sanitizer.php',
'vendor/ampproject/amp-wp/includes/sanitizers/class-amp-tag-and-attribute-sanitizer.php',
'vendor/ampproject/amp-wp/includes/sanitizers/trait-amp-noscript-fallback.php',
'vendor/ampproject/amp-wp/includes/templates/class-amp-content-sanitizer.php',
'vendor/ampproject/amp-wp/src/ValidationExemption.php',
]
)
->append( [ 'vendor/ampproject/amp-wp/composer.json' ] ),
// AMP PHP Toolbox (Common + Optimizer).
// Not just including /src folder because we also need the /resources folder.
Finder::create()
->files()
->ignoreVCS( true )
->ignoreDotFiles( true )
->in(
[
'vendor/ampproject/amp-toolbox/src',
'vendor/ampproject/amp-toolbox/resources',
]
)
->append( [ 'vendor/ampproject/amp-toolbox/composer.json' ] ),
// FasterImage (used by AMP_Img_Sanitizer).
Finder::create()
->files()
->ignoreVCS( true )
->ignoreDotFiles( true )
->name( '*.php' )
->exclude(
[
'tests',
]
)
->in( 'vendor/fasterimage/fasterimage' )
->append( [ 'vendor/fasterimage/fasterimage/composer.json' ] ),
// PHP-CSS-Parser (used by AMP_Style_Sanitizer).
Finder::create()
->files()
->ignoreVCS( true )
->ignoreDotFiles( true )
->name( '*.php' )
->exclude(
[
'tests',
]
)
->in( 'vendor/sabberworm/php-css-parser' )
->append( [ 'vendor/sabberworm/php-css-parser/composer.json' ] ),
Finder::create()
->files()
->ignoreVCS( true )
->ignoreDotFiles( true )
->name( '*.php' )
->exclude(
[
'tests',
]
)
->in( 'vendor/enshrined/svg-sanitize/src' )
->append( [ 'vendor/enshrined/svg-sanitize/composer.json' ] ),
// Symfony mbstring polyfill.
Finder::create()
->files()
->ignoreVCS( true )
->ignoreDotFiles( true )
->name( '/\.*.php8?/' )
->in( 'vendor/symfony/polyfill-mbstring/Resources' )
->append(
[
'vendor/symfony/polyfill-mbstring/Mbstring.php',
'vendor/symfony/polyfill-mbstring/composer.json',
]
),
// Main composer.json file so that we can build a classmap.
Finder::create()
->append( [ 'composer.json' ] ),
],
// See: https://github.com/humbug/php-scoper#patchers.
'patchers' => [],
// See https://github.com/humbug/php-scoper#whitelist.
'whitelist' => [],
'exclude-classes' => $wp_classes,
'exclude-functions' => $wp_functions,
'exclude-constants' => array_merge(
$wp_constants,
[
'AMP__FILE__',
'AMP__DIR__',
'AMP__VERSION',
]
),
];