| 1 |
<?php |
| 2 |
|
| 3 |
declare( strict_types=1 ); |
| 4 |
|
| 5 |
use Isolated\Symfony\Component\Finder\Finder; |
| 6 |
|
| 7 |
// You can do your own things here, e.g. collecting symbols to expose dynamically |
| 8 |
// or files to exclude. |
| 9 |
// However beware that this file is executed by PHP-Scoper, hence if you are using |
| 10 |
// the PHAR it will be loaded by the PHAR. So it is highly recommended to avoid |
| 11 |
// to auto-load any code here: it can result in a conflict or even corrupt |
| 12 |
// the PHP-Scoper analysis. |
| 13 |
|
| 14 |
return [ |
| 15 |
// The prefix configuration. If a non null value is be used, a random prefix |
| 16 |
// will be generated instead. |
| 17 |
// |
| 18 |
// For more see: https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#prefix |
| 19 |
'prefix' => 'WPMUDEV_Analytics_Vendor', |
| 20 |
|
| 21 |
// By default when running php-scoper add-prefix, it will prefix all relevant code found in the current working |
| 22 |
// directory. You can however define which files should be scoped by defining a collection of Finders in the |
| 23 |
// following configuration key. |
| 24 |
// |
| 25 |
// This configuration entry is completely ignored when using Box. |
| 26 |
// |
| 27 |
// For more see: https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#finders-and-paths |
| 28 |
'finders' => [ |
| 29 |
Finder::create() |
| 30 |
->files() |
| 31 |
->ignoreVCS( true ) |
| 32 |
->notName( '/LICENSE|.*\\.md|.*\\.dist|.*\\.yml|Makefile|.gitignore|composer\\.json|MobileDetect\\.json|composer\\.lock/' ) |
| 33 |
->exclude( [ |
| 34 |
'doc', |
| 35 |
'docs', |
| 36 |
'test', |
| 37 |
'tests', |
| 38 |
'examples', |
| 39 |
] ) |
| 40 |
->in( [ |
| 41 |
'vendor/mixpanel/mixpanel-php', |
| 42 |
] ), |
| 43 |
], |
| 44 |
|
| 45 |
// List of excluded files, i.e. files for which the content will be left untouched. |
| 46 |
// Paths are relative to the configuration file unless if they are already absolute |
| 47 |
// |
| 48 |
// For more see: https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#patchers |
| 49 |
'exclude-files' => [ |
| 50 |
/*'src/a-whitelisted-file.php',*/ |
| 51 |
], |
| 52 |
|
| 53 |
// When scoping PHP files, there will be scenarios where some of the code being scoped indirectly references the |
| 54 |
// original namespace. These will include, for example, strings or string manipulations. PHP-Scoper has limited |
| 55 |
// support for prefixing such strings. To circumvent that, you can define patchers to manipulate the file to your |
| 56 |
// heart contents. |
| 57 |
// |
| 58 |
// For more see: https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#patchers |
| 59 |
'patchers' => [ |
| 60 |
static function ( string $filePath, string $prefix, string $content ): string { |
| 61 |
$class_names = array( |
| 62 |
'ConsumerStrategies_AbstractConsumer', |
| 63 |
'ConsumerStrategies_FileConsumer', |
| 64 |
'ConsumerStrategies_CurlConsumer', |
| 65 |
'ConsumerStrategies_SocketConsumer', |
| 66 |
'Producers_MixpanelBaseProducer', |
| 67 |
'Producers_MixpanelEvents', |
| 68 |
'Producers_MixpanelGroups', |
| 69 |
'Producers_MixpanelPeople', |
| 70 |
); |
| 71 |
$pattern = '~([\'"])(' . join( '|', $class_names ) . ')\1~'; |
| 72 |
|
| 73 |
return preg_replace( $pattern, '$1WPMUDEV_Analytics_Vendor\\\$2$1', $content ); |
| 74 |
}, |
| 75 |
], |
| 76 |
|
| 77 |
// List of symbols to consider internal i.e. to leave untouched. |
| 78 |
// |
| 79 |
// For more information see: https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#excluded-symbols |
| 80 |
'exclude-namespaces' => [ |
| 81 |
// 'Acme\Foo' // The Acme\Foo namespace (and sub-namespaces) |
| 82 |
// '~^PHPUnit\\\\Framework$~', // The whole namespace PHPUnit\Framework (but not sub-namespaces) |
| 83 |
// '~^$~', // The root namespace only |
| 84 |
// '', // Any namespace |
| 85 |
], |
| 86 |
'exclude-classes' => [ |
| 87 |
// 'ReflectionClassConstant', |
| 88 |
], |
| 89 |
'exclude-functions' => [ |
| 90 |
// 'mb_str_split', |
| 91 |
], |
| 92 |
'exclude-constants' => [ |
| 93 |
// 'STDIN', |
| 94 |
], |
| 95 |
|
| 96 |
// List of symbols to expose. |
| 97 |
// |
| 98 |
// For more information see: https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#exposed-symbols |
| 99 |
'expose-global-constants' => true, |
| 100 |
'expose-global-classes' => false, |
| 101 |
'expose-global-functions' => true, |
| 102 |
'expose-namespaces' => [ |
| 103 |
// 'Acme\Foo' // The Acme\Foo namespace (and sub-namespaces) |
| 104 |
// '~^PHPUnit\\\\Framework$~', // The whole namespace PHPUnit\Framework (but not sub-namespaces) |
| 105 |
// '~^$~', // The root namespace only |
| 106 |
// '', // Any namespace |
| 107 |
], |
| 108 |
'expose-classes' => [], |
| 109 |
'expose-functions' => [], |
| 110 |
'expose-constants' => [], |
| 111 |
]; |
| 112 |
|