forked from TomasVotruba/class-leak
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scoper.php
34 lines (29 loc) · 1.32 KB
/
scoper.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
<?php
declare(strict_types=1);
require __DIR__ . '/vendor/autoload.php';
$nowDateTime = new DateTime('now');
$timestamp = $nowDateTime->format('Ym');
// see https://github.com/humbug/php-scoper
return [
'prefix' => 'ClassLeak' . $timestamp,
'expose-constants' => ['#^SYMFONY\_[\p{L}_]+$#'],
'exclude-namespaces' => ['#^TomasVotruba\\\\ClassLeak#', '#^Symfony\\\\Polyfill#'],
'exclude-files' => [
// do not prefix "trigger_deprecation" from symfony - https://github.com/symfony/symfony/commit/0032b2a2893d3be592d4312b7b098fb9d71aca03
// these paths are relative to this file location, so it should be in the root directory
'vendor/symfony/deprecation-contracts/function.php',
],
'patchers' => [
function (string $filePath, string $prefix, string $content): string {
if (! str_ends_with($filePath, 'app/Filtering/PossiblyUnusedClassesFilter.php')) {
return $content;
}
return preg_replace_callback('#DEFAULT_TYPES_TO_SKIP = (?<content>.*?)\;#ms', function (array $match) use (
$prefix
) {
$unprefixedValue = preg_replace('#' . $prefix . '\\\\#', '', $match['content']);
return 'DEFAULT_TYPES_TO_SKIP = ' . $unprefixedValue . ';';
}, $content);
},
],
];