Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 14 |
|
0.00% |
0 / 9 |
CRAP | |
0.00% |
0 / 1 |
| ReplayMinifierState | |
0.00% |
0 / 14 |
|
0.00% |
0 / 9 |
110 | |
0.00% |
0 / 1 |
| replayOn | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
| outputFile | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| sourceRoot | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| addSourceFile | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| setErrorHandler | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| minify | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| addOutput | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| ensureNewline | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getMinifiedOutput | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | // @phan-file-suppress PhanPluginNeverReturnMethod |
| 4 | |
| 5 | namespace MediaWiki\ResourceLoader; |
| 6 | |
| 7 | use LogicException; |
| 8 | use Wikimedia\Minify\MinifierState; |
| 9 | |
| 10 | /** |
| 11 | * Fake minifier that buffers additions to later replay to multiple another minifiers. |
| 12 | * |
| 13 | * This exists for ResourceLoader::getOneModuleResponse() to pass module content |
| 14 | * through both IdentityMinifierState and JavaScriptMinifierState/JavaScriptMapperState |
| 15 | * without building the same module twice. |
| 16 | * |
| 17 | * @internal |
| 18 | */ |
| 19 | class ReplayMinifierState extends MinifierState { |
| 20 | |
| 21 | protected array $calls = []; |
| 22 | |
| 23 | /** |
| 24 | * Replay all supported method calls from this minifier on another minifier. |
| 25 | */ |
| 26 | public function replayOn( MinifierState $otherMinifier ): void { |
| 27 | foreach ( $this->calls as [ $method, $args ] ) { |
| 28 | $otherMinifier->$method( ...$args ); |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | /** @inheritDoc */ |
| 33 | public function outputFile( string $file ) { |
| 34 | $this->calls[] = [ __FUNCTION__, func_get_args() ]; |
| 35 | return $this; |
| 36 | } |
| 37 | |
| 38 | /** @inheritDoc */ |
| 39 | public function sourceRoot( string $url ) { |
| 40 | throw new LogicException( "Not implemented" ); |
| 41 | } |
| 42 | |
| 43 | /** @inheritDoc */ |
| 44 | public function addSourceFile( string $url, string $source, bool $bundle = false ) { |
| 45 | $this->calls[] = [ __FUNCTION__, func_get_args() ]; |
| 46 | return $this; |
| 47 | } |
| 48 | |
| 49 | /** @inheritDoc */ |
| 50 | public function setErrorHandler( $onError ) { |
| 51 | throw new LogicException( "Not implemented" ); |
| 52 | } |
| 53 | |
| 54 | /** @inheritDoc */ |
| 55 | protected function minify( string $source ): string { |
| 56 | throw new LogicException( "Not implemented" ); |
| 57 | } |
| 58 | |
| 59 | /** @inheritDoc */ |
| 60 | public function addOutput( string $output ) { |
| 61 | $this->calls[] = [ __FUNCTION__, func_get_args() ]; |
| 62 | return $this; |
| 63 | } |
| 64 | |
| 65 | /** @inheritDoc */ |
| 66 | public function ensureNewline() { |
| 67 | $this->calls[] = [ __FUNCTION__, func_get_args() ]; |
| 68 | return $this; |
| 69 | } |
| 70 | |
| 71 | /** @inheritDoc */ |
| 72 | public function getMinifiedOutput() { |
| 73 | throw new LogicException( "Not implemented" ); |
| 74 | } |
| 75 | |
| 76 | } |