Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 9
CRAP
0.00% covered (danger)
0.00%
0 / 1
ReplayMinifierState
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 9
110
0.00% covered (danger)
0.00%
0 / 1
 replayOn
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
6
 outputFile
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 sourceRoot
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 addSourceFile
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 setErrorHandler
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 minify
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 addOutput
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 ensureNewline
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getMinifiedOutput
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3// @phan-file-suppress PhanPluginNeverReturnMethod
4
5namespace MediaWiki\ResourceLoader;
6
7use LogicException;
8use 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 */
19class ReplayMinifierState extends MinifierState {
20
21    /** @var array<array{0:string,1:array}> */
22    protected array $calls = [];
23
24    /**
25     * Replay all supported method calls from this minifier on another minifier.
26     */
27    public function replayOn( MinifierState $otherMinifier ): void {
28        foreach ( $this->calls as [ $method, $args ] ) {
29            $otherMinifier->$method( ...$args );
30        }
31    }
32
33    /** @inheritDoc */
34    public function outputFile( string $file ) {
35        $this->calls[] = [ __FUNCTION__, func_get_args() ];
36        return $this;
37    }
38
39    /** @inheritDoc */
40    public function sourceRoot( string $url ) {
41        throw new LogicException( "Not implemented" );
42    }
43
44    /** @inheritDoc */
45    public function addSourceFile( string $url, string $source, bool $bundle = false ) {
46        $this->calls[] = [ __FUNCTION__, func_get_args() ];
47        return $this;
48    }
49
50    /** @inheritDoc */
51    public function setErrorHandler( $onError ) {
52        throw new LogicException( "Not implemented" );
53    }
54
55    /** @inheritDoc */
56    protected function minify( string $source ): string {
57        throw new LogicException( "Not implemented" );
58    }
59
60    /** @inheritDoc */
61    public function addOutput( string $output ) {
62        $this->calls[] = [ __FUNCTION__, func_get_args() ];
63        return $this;
64    }
65
66    /** @inheritDoc */
67    public function ensureNewline() {
68        $this->calls[] = [ __FUNCTION__, func_get_args() ];
69        return $this;
70    }
71
72    /** @inheritDoc */
73    public function getMinifiedOutput() {
74        throw new LogicException( "Not implemented" );
75    }
76
77}