| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
use Isolated\Symfony\Component\Finder\Finder; |
| 6 |
|
| 7 |
return [ |
| 8 |
'prefix' => 'BerqWP_Deps', |
| 9 |
|
| 10 |
'finders' => [ |
| 11 |
// Third-party vendor packages |
| 12 |
Finder::create() |
| 13 |
->files() |
| 14 |
->in(__DIR__ . '/vendor') |
| 15 |
->name('*.php'), |
| 16 |
|
| 17 |
// SDK source — so GuzzleHttp/voku use statements get rewritten automatically |
| 18 |
Finder::create() |
| 19 |
->files() |
| 20 |
->in(__DIR__ . '/src') |
| 21 |
->name('*.php'), |
| 22 |
], |
| 23 |
|
| 24 |
'exclude-namespaces' => [ |
| 25 |
'BerqWP', // plugin's own namespace — never prefix |
| 26 |
'Composer', // composer internals |
| 27 |
], |
| 28 |
|
| 29 |
'exclude-classes' => [ |
| 30 |
// polyfill-php80 global stubs |
| 31 |
'Attribute', |
| 32 |
'PhpToken', |
| 33 |
'Stringable', |
| 34 |
'UnhandledMatchError', |
| 35 |
'ValueError', |
| 36 |
], |
| 37 |
|
| 38 |
'exclude-functions' => [ |
| 39 |
'getallheaders', // ralouphie/getallheaders |
| 40 |
'fdiv', |
| 41 |
'preg_last_error_msg', |
| 42 |
'str_contains', |
| 43 |
'str_starts_with', |
| 44 |
'str_ends_with', |
| 45 |
'get_debug_type', |
| 46 |
'get_resource_id', // symfony/polyfill-php80 |
| 47 |
'trigger_deprecation', // symfony/deprecation-contracts |
| 48 |
], |
| 49 |
|
| 50 |
'exclude-constants' => [ |
| 51 |
'ABSPATH', |
| 52 |
'WP_CONTENT_DIR', |
| 53 |
], |
| 54 |
|
| 55 |
'patchers' => [ |
| 56 |
// Composer\InstalledVersions is declared by many plugins without a class_exists |
| 57 |
// guard, causing "cannot redeclare class" fatals. Wrap our copy in a guard. |
| 58 |
// Note: autoload_static.php is generated output by php-scoper, not an input file, |
| 59 |
// so it cannot be patched here — it is fixed by fix-autoload-static.php in Makefile. |
| 60 |
static function (string $filePath, string $prefix, string $content): string { |
| 61 |
if (!str_ends_with($filePath, 'composer/InstalledVersions.php')) { |
| 62 |
return $content; |
| 63 |
} |
| 64 |
$content = str_replace( |
| 65 |
"class InstalledVersions\n{", |
| 66 |
"if (!class_exists('Composer\\\\InstalledVersions', false)) {\nclass InstalledVersions\n{", |
| 67 |
$content |
| 68 |
); |
| 69 |
$content = rtrim($content) . "\n} // end class_exists check\n"; |
| 70 |
return $content; |
| 71 |
}, |
| 72 |
], |
| 73 |
]; |
| 74 |
|