55 - [ Class aliases] ( #class-aliases )
66 - [ Function aliases] ( #function-aliases )
77- [ Symfony support] ( #symfony-support )
8+ - [ Wordpress support] ( #wordpress-support )
89
910
1011### How to deal with unknown third-party symbols
@@ -111,6 +112,44 @@ return [
111112Note that the path is the "regular path(s)" that can be passed to patchers.
112113
113114
115+ ### Wordpress Support
116+
117+ When writing a Wordpress plugin, you need to [ exclude Wordpress' symbols] ( #excluded-symbols ) . To facilitate
118+ this task, [ Snicco] created a third-party CLI tool [ php-scoper-excludes] that can be used to generate
119+ PHP-Scoper compatible symbol lists for any PHP codebase you point it.
120+
121+ ### Example for WordPress Core
122+
123+ ``` shell
124+ composer require sniccowp/php-scoper-wordpress-excludes
125+ ```
126+
127+ ``` php
128+ // scoper.inc.php
129+
130+ function getWpExcludedSymbols(string $fileName): array
131+ {
132+ $filePath = __DIR__.'/vendor/sniccowp/php-scoper-wordpress-excludes/generated/'.$fileName;
133+
134+ return json_decode(
135+ file_get_contents($filePath),
136+ true,
137+ );
138+ }
139+
140+ $wp_classes = getWpExcludedSymbols('exclude-wordpress-classes.json');
141+ $wp_functions = getWpExcludedSymbols('exclude-wordpress-functions.json');
142+ $wp_constants = getWpExcludedSymbols('exclude-wordpress-constants.json');
143+
144+ return [
145+ 'exclude-classes' => $wp_classes,
146+ 'exclude-constants' => $wp_functions,
147+ 'exclude-functions' => $wp_constants,
148+ // ...
149+ ];
150+ ```
151+
152+
114153<br />
115154<hr />
116155
@@ -123,5 +162,7 @@ Note that the path is the "regular path(s)" that can be passed to patchers.
123162[ exposing a class ] : configuration.md#exposing-classes
124163[ exposing a function ] : configuration.md#exposing-functions
125164[ #706 ] : https://github.com/humbug/php-scoper/pull/706
126- [ patchers ] : ./configuration.md#patchers
165+ [ Snicco ] : https://github.com/snicco
127166[ symfony-php-config ] : https://symfony.com/doc/current/service_container.html#explicitly-configuring-services-and-arguments
167+ [ patchers ] : ./configuration.md#patchers
168+ [ php-scoper-excludes ] : https://github.com/snicco/php-scoper-excludes
0 commit comments