PluginProbe ʕ •ᴥ•ʔ
Presto Player / 4.3.1
Presto Player v4.3.1
4.3.1 4.3.0 4.2.4 4.2.3 4.2.2 4.2.0 4.2.1 trunk 1.10.0 1.10.1 1.10.2 1.11.0 1.12.0 1.13.0 1.14.0 1.14.1 1.5.10 1.5.11 1.5.12 1.5.13 1.5.14 1.5.15 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.10 1.6.11 1.6.12 1.6.13 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.9.0 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.14 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.2.0 2.2.1 2.2.2 2.2.3 2.2.3-beta1 2.3.0 2.3.1 2.3.2 2.3.3 3.0.0 3.0.0-beta1 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.1.0 3.1.1 3.1.2 3.1.3 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4
presto-player / vendor / typisttech / imposter / README.md
presto-player / vendor / typisttech / imposter Last commit date
src 5 years ago LICENSE 5 years ago README.md 5 years ago composer.json 5 years ago composer.lock 5 years ago
README.md
322 lines
1 <div align="center">
2
3 # Imposter
4
5 </div>
6
7 <div align="center">
8
9
10 [](https://packagist.org/packages/typisttech/imposter![Packagist Version](https://img.shields.io/packagist/v/typisttech/imposter.svg?style=flat-square)](https://packagist.org/packages/typisttech/imposter](https://packagist.org/packages/typisttech/imposter)
11 [](https://packagist.org/packages/typisttech/imposter![Packagist Downloads](https://img.shields.io/packagist/dt/typisttech/imposter.svg?style=flat-square)](https://packagist.org/packages/typisttech/imposter](https://packagist.org/packages/typisttech/imposter)
12 [](https://packagist.org/packages/typisttech/imposter![PHP from Packagist](https://img.shields.io/packagist/php-v/TypistTech/imposter?style=flat-square)](https://packagist.org/packages/typisttech/imposter](https://packagist.org/packages/typisttech/imposter)
13 [](https://circleci.com/gh/TypistTech/imposter![CircleCI](https://img.shields.io/circleci/build/gh/TypistTech/imposter?style=flat-square)](https://circleci.com/gh/TypistTech/imposter](https://circleci.com/gh/TypistTech/imposter)
14 [](https://codecov.io/gh/TypistTech/imposter![Codecov](https://img.shields.io/codecov/c/gh/typisttech/imposter?style=flat-square)](https://codecov.io/gh/TypistTech/imposter](https://codecov.io/gh/TypistTech/imposter)
15 [](https://github.com/TypistTech/imposter/blob/master/LICENSE![License](https://img.shields.io/github/license/TypistTech/imposter.svg?style=flat-square)](https://github.com/TypistTech/imposter/blob/master/LICENSE](https://github.com/TypistTech/imposter/blob/master/LICENSE)
16 [](https://twitter.com/tangrufus![Twitter Follow @TangRufus](https://img.shields.io/twitter/follow/TangRufus?style=flat-square&color=1da1f2&logo=twitter)](https://twitter.com/tangrufus](https://twitter.com/tangrufus)
17 [](https://www.typist.tech/contact/![Hire Typist Tech](https://img.shields.io/badge/Hire-Typist%20Tech-ff69b4.svg?style=flat-square)](https://www.typist.tech/contact/](https://www.typist.tech/contact/)
18
19 </div>
20
21 <p align="center">
22 <strong>Wrapping all composer vendor packages inside your own namespace. Intended for WordPress plugins.</strong>
23 <br />
24 <br />
25 Built with ♥ by <a href="https://www.typist.tech/">Typist Tech</a>
26 </p>
27
28 ---
29
30 **Imposter** is an open source project and completely free to use.
31
32 However, the amount of effort needed to maintain and develop new features is not sustainable without proper financial backing. If you have the capability, please consider donating using the links below:
33
34 <div align="center">
35
36 [](https://github.com/sponsors/TangRufus![GitHub via Sponsor](https://img.shields.io/badge/Sponsor-GitHub-ea4aaa?style=flat-square&logo=github)](https://github.com/sponsors/TangRufus](https://github.com/sponsors/TangRufus)
37 [](https://typist.tech/go/paypal-donate/![Sponsor via PayPal](https://img.shields.io/badge/Sponsor-PayPal-blue.svg?style=flat-square&logo=paypal)](https://typist.tech/go/paypal-donate/](https://typist.tech/go/paypal-donate/)
38 [](https://typist.tech/donate/imposter/![More Sponsorship Information](https://img.shields.io/badge/Sponsor-More%20Details-ff69b4?style=flat-square)](https://typist.tech/donate/imposter/](https://typist.tech/donate/imposter/)
39
40 </div>
41
42 ---
43
44 Wrapping all composer vendor packages inside your own namespace. Intended for WordPress plugins.
45
46 ## Why?
47
48 Because of the lack of dependency management in WordPress, if two plugins bundled conflicting versions of the same package, hard-to-reproduce bugs arise.
49 Monkey patching composer vendor packages, wrapping them inside your own namespace is a less-than-ideal solution to avoid such conflicts.
50
51 See:
52 - [](https://wptavern.com/a-narrative-of-using-composer-in-a-wordpress-pluginA Narrative of Using Composer in a WordPress Plugin](https://wptavern.com/a-narrative-of-using-composer-in-a-wordpress-plugin](https://wptavern.com/a-narrative-of-using-composer-in-a-wordpress-plugin)
53 - [](https://wppusher.com/blog/a-warning-about-using-composer-with-wordpress/A Warning About Using Composer With WordPress](https://wppusher.com/blog/a-warning-about-using-composer-with-wordpress/](https://wppusher.com/blog/a-warning-about-using-composer-with-wordpress/)
54
55 ## Install
56
57 > If you want to hook Imposter into [](https://getcomposer.org/doc/articles/scripts.md#command-eventscomposer command events](https://getcomposer.org/doc/articles/scripts.md#command-events](https://getcomposer.org/doc/articles/scripts.md#command-events), install [](https://github.com/TypistTech/imposter-pluginImposter Plugin](https://github.com/TypistTech/imposter-plugin](https://github.com/TypistTech/imposter-plugin) instead.
58 > See: [](#how-can-i-integrate-imposter-with-composerHow can I integrate Imposter with composer?](#how-can-i-integrate-imposter-with-composer](#how-can-i-integrate-imposter-with-composer)
59
60 Installation should be done via composer, details of how to install composer can be found at [](https://getcomposer.org/https://getcomposer.org/](https://getcomposer.org/](https://getcomposer.org/).
61
62 ```bash
63 composer require typisttech/imposter
64 ```
65
66 ## Config
67
68 In your `composer.json`:
69
70 ```json
71 "extra": {
72 "imposter": {
73 "namespace": "My\\App\\Vendor",
74 "excludes": [
75 "dummy/dummy-excluded"
76 ]
77 }
78 }
79 ```
80
81 ### extra.imposter.namespace
82
83 *Required* String
84
85 This is the namespace prefix to be added to vendor packages.
86
87 ### extra.imposter.excludes
88
89 *Optional* Array of strings
90
91 Vendor packages which needs to be excluded from namespace prefixing.
92 All [](https://packagist.org/packages/composer/composer-made packages](https://packagist.org/packages/composer/](https://packagist.org/packages/composer/) are excluded by default.
93 Besides, anything under the `Composer` namespace will be excluded.
94
95 ## Usage
96
97 After every `$ composer install` and `$ composer update`:
98
99 ```php
100 <?php
101
102 use TypistTech\Imposter\ImposterFactory;
103
104 $imposter = ImposterFactory::forProject('/path/to/project/root');
105 $imposter->run();
106 ```
107
108 The above snippet:
109 1. Look for `/path/to/project/root/composer.json`
110 1. Find out [](https://getcomposer.org/doc/06-config.md#vendor-dirvendor-dir](https://getcomposer.org/doc/06-config.md#vendor-dir](https://getcomposer.org/doc/06-config.md#vendor-dir)
111 1. Find out all [](https://getcomposer.org/doc/04-schema.md#requirerequired packages](https://getcomposer.org/doc/04-schema.md#require](https://getcomposer.org/doc/04-schema.md#require), including those required by dependencies
112 1. Find out all [](https://getcomposer.org/doc/04-schema.md#autoloadautoload paths](https://getcomposer.org/doc/04-schema.md#autoload](https://getcomposer.org/doc/04-schema.md#autoload) for all required packages
113 1. Prefix all namespaces with the imposter namespace defined in your `composer.json`
114
115 Before:
116 ```php
117 <?php
118
119 namespace Dummy\File;
120
121 use AnotherDummy\{
122 SubAnotherDummy, SubOtherDummy
123 };
124 use Composer;
125 use Composer\Plugin\PluginInterface;
126 use Dummy\SubOtherDummy;
127 use OtherDummy\SubOtherDummy;
128 use RuntimeException;
129 use \UnexpectedValueException;
130 use function OtherVendor\myFunc;
131 use const OtherVendor\MY_MAGIC_NUMBER;
132
133 $closure = function () use ($aaa) {
134 // Just testing.
135 };
136
137 class DummyClass
138 {
139 public function useClosure()
140 {
141 array_map(function () use ($xxx) {
142 // Just testing.
143 }, []);
144 }
145 }
146
147 function dummyFunction(string $namespace = null, string $use = null): array
148 {
149 if (! is_null($namespace) && $namespace === 'dummy string' && $use === 'dummy string') {
150 // Just testing.
151 }
152
153 return [];
154 }
155
156 foreach ([] as $namespace => $prefix) {
157 $aaaa = '{' . $namespace . '}' . $prefix;
158 }
159
160 /** Just a comment for testing $namespace transformation */
161 ```
162
163 After:
164 ```php
165 <?php
166
167 namespace MyPlugin\Vendor\Dummy\File;
168
169 use MyPlugin\Vendor\AnotherDummy\{
170 SubAnotherDummy, SubOtherDummy
171 };
172 use Composer;
173 use Composer\Plugin\PluginInterface;
174 use MyPlugin\Vendor\Dummy\SubOtherDummy;
175 use MyPlugin\Vendor\OtherDummy\SubOtherDummy;
176 use RuntimeException;
177 use \UnexpectedValueException;
178 use function MyPlugin\Vendor\OtherVendor\myFunc;
179 use const MyPlugin\Vendor\OtherVendor\MY_MAGIC_NUMBER;
180
181 $closure = function () use ($aaa) {
182 // Just testing.
183 };
184
185 class DummyClass
186 {
187 public function useClosure()
188 {
189 array_map(function () use ($xxx) {
190 // Just testing.
191 }, []);
192 }
193 }
194
195 function dummyFunction(string $namespace = null, string $use = null): array
196 {
197 if (! is_null($namespace) && $namespace === 'dummy string' && $use === 'dummy string') {
198 // Just testing.
199 }
200
201 return [];
202 }
203
204 foreach ([] as $namespace => $prefix) {
205 $aaaa = '{' . $namespace . '}' . $prefix;
206 }
207
208 /** Just a comment for testing $namespace transformation */
209 ```
210
211 ## Known Issues
212
213 **Help Wanted.** Pull requests are welcomed.
214
215 1. Traits are not transformed
216 1. Virtual packages are not supported
217
218 ## Frequently Asked Questions
219
220 ### How can I integrate imposter with composer?
221
222 Use [](https://github.com/TypistTech/imposter-pluginImposter Plugin](https://github.com/TypistTech/imposter-plugin](https://github.com/TypistTech/imposter-plugin) instead.
223 It hooks imposter into [](https://getcomposer.org/doc/articles/scripts.md#command-eventscomposer command events](https://getcomposer.org/doc/articles/scripts.md#command-events](https://getcomposer.org/doc/articles/scripts.md#command-events).
224
225 ### Does imposter support `PSR4`, `PSR0`, `Classmap` and `Files`?
226
227 Yes for all. PSR-4 and PSR-0 autoloading, classmap generation and files includes are supported.
228
229 ### Can I exclude some of the packages from imposter?
230
231 Yes, see [](#extraimposterexcludes`extra.imposter.excludes`](#extraimposterexcludes](#extraimposterexcludes).
232 All [](https://packagist.org/packages/composer/composer made packages](https://packagist.org/packages/composer/](https://packagist.org/packages/composer/) are excluded by default.
233
234 ### How about `require-dev` packages?
235
236 Imposter do nothing on `require-dev` packages because imposter is intended for avoiding production environment., not for development environment.
237
238 ### How about PHP built-in classes?
239
240 Imposter skips classes that on global namespace, for example: `\ArrayObject`, `\RuntimeException`
241
242 ### How about packages that don't use namespaces?
243
244 Not for now.
245 Tell me your idea by [](https://github.com/TypistTech/imposter/issues/newopening an issue](https://github.com/TypistTech/imposter/issues/new](https://github.com/TypistTech/imposter/issues/new).
246
247 ### How about packages that use fully qualified name?
248
249 Not for now. We need a better regex(or something better than regex) in the [](src/Transformer.phpTransformer](src/Transformer.php](src/Transformer.php) class.
250 Tell me your idea by [](https://github.com/TypistTech/imposter/issues/newopening an issue](https://github.com/TypistTech/imposter/issues/new](https://github.com/TypistTech/imposter/issues/new)
251
252 ### Which composer versions are supported?
253
254 Both v1 and v2.
255
256 ### Will you add support for older PHP versions?
257
258 Never! This plugin will only work on [](https://secure.php.net/supported-versions.phpactively supported PHP versions](https://secure.php.net/supported-versions.php](https://secure.php.net/supported-versions.php).
259
260 Don't use it on **end of life** or **security fixes only** PHP versions.
261
262 ### It looks awesome. Where can I find some more goodies like this
263
264 - Articles on [](https://typist.techTypist Tech's blog](https://typist.tech](https://typist.tech)
265 - [](https://profiles.wordpress.org/tangrufus#content-pluginsTang Rufus' WordPress plugins](https://profiles.wordpress.org/tangrufus#content-plugins](https://profiles.wordpress.org/tangrufus#content-plugins) on wp.org
266 - More projects on [](https://github.com/TypistTechTypist Tech's GitHub profile](https://github.com/TypistTech](https://github.com/TypistTech)
267 - Stay tuned on [](https://typist.tech/go/newsletterTypist Tech's newsletter](https://typist.tech/go/newsletter](https://typist.tech/go/newsletter)
268 - Follow [](https://twitter.com/TangRufusTang Rufus' Twitter account](https://twitter.com/TangRufus](https://twitter.com/TangRufus)
269 - **Hire [](https://typist.tech/contactTang Rufus](https://typist.tech/contact](https://typist.tech/contact) to build your next awesome site**
270
271 ### Where can I give 5-star reviews?
272
273 Thanks! Glad you like it. It's important to let me knows somebody is using this project. Please consider:
274
275 - [](https://twitter.com/intent/tweet?url=https%3A%2F%2Fgithub.com%2FTypistTech%2Fimposter&via=tangrufus&text=Wrapping%20all%20%23composer%20vendor%20packages%20inside%20your%20own%20namespace.%20Intended%20for%20%23WordPress%20plugins&hashtags=phptweet](https://twitter.com/intent/tweet?url=https%3A%2F%2Fgithub.com%2FTypistTech%2Fimposter&via=tangrufus&text=Wrapping%20all%20%23composer%20vendor%20packages%20inside%20your%20own%20namespace.%20Intended%20for%20%23WordPress%20plugins&hashtags=php](https://twitter.com/intent/tweet?url=https%3A%2F%2Fgithub.com%2FTypistTech%2Fimposter&via=tangrufus&text=Wrapping%20all%20%23composer%20vendor%20packages%20inside%20your%20own%20namespace.%20Intended%20for%20%23WordPress%20plugins&hashtags=php) something good with mentioning [](https://twitter.com/tangrufus@TangRufus](https://twitter.com/tangrufus](https://twitter.com/tangrufus)
276 - �
277 star [](https://github.com/TypistTech/imposterthe Github repo](https://github.com/TypistTech/imposter](https://github.com/TypistTech/imposter)
278 - [](https://github.com/TypistTech/imposter/subscription👀 watch](https://github.com/TypistTech/imposter/subscription](https://github.com/TypistTech/imposter/subscription) the Github repo
279 - write tutorials and blog posts
280 - **[](https://www.typist.tech/contact/hire](https://www.typist.tech/contact/](https://www.typist.tech/contact/) Typist Tech**
281
282 ## Testing
283
284 ```bash
285 composer test
286 composer style:check
287 ```
288
289 ## Alternatives
290
291 Here is a list of alternatives that I found. However, none of these satisfied my requirements.
292
293 *If you know other similar projects, feel free to edit this section!*
294
295 * [](https://github.com/coenjacobs/mozartMozart](https://github.com/coenjacobs/mozart](https://github.com/coenjacobs/mozart) by Coen Jacobs
296 - Works with PSR0 and PSR4
297 - Dependency packages store in a different directory
298
299 * [](https://github.com/humbug/php-scoperPHP Scoper](https://github.com/humbug/php-scoper](https://github.com/humbug/php-scoper)
300 - Prefixes all PHP namespaces in a file/directory to isolate the code bundled in PHARs
301
302 ## Feedback
303
304 **Please provide feedback!** We want to make this project as useful as possible.
305 Please [](https://github.com/TypistTech/imposter/issues/newsubmit an issue](https://github.com/TypistTech/imposter/issues/new](https://github.com/TypistTech/imposter/issues/new) and point out what you do and don't like, or fork the project and [](https://github.com/TypistTech/imposter/pulls/send pull requests](https://github.com/TypistTech/imposter/pulls/](https://github.com/TypistTech/imposter/pulls/).
306 **No issue is too small.**
307
308 ## Security Vulnerabilities
309
310 If you discover a security vulnerability within this project, please email us at [](mailto:imposter@typist.techimposter@typist.tech](mailto:imposter@typist.tech](mailto:imposter@typist.tech).
311 All security vulnerabilities will be promptly addressed.
312
313 ## Credits
314
315 [](https://github.com/TypistTech/imposterImposter](https://github.com/TypistTech/imposter](https://github.com/TypistTech/imposter) is a [](https://typist.techTypist Tech](https://typist.tech](https://typist.tech) project and maintained by [](https://twitter.com/TangRufusTang Rufus](https://twitter.com/TangRufus](https://twitter.com/TangRufus), freelance developer for [](https://www.typist.tech/contact/hire](https://www.typist.tech/contact/](https://www.typist.tech/contact/).
316
317 Full list of contributors can be found [](https://github.com/TypistTech/imposter/graphs/contributorshere](https://github.com/TypistTech/imposter/graphs/contributors](https://github.com/TypistTech/imposter/graphs/contributors).
318
319 ## License
320
321 [](https://github.com/TypistTech/imposterImposter](https://github.com/TypistTech/imposter](https://github.com/TypistTech/imposter) is released under the [](https://opensource.org/licenses/MITMIT License](https://opensource.org/licenses/MIT](https://opensource.org/licenses/MIT).
322