1 | <?php |
||
25 | class SourceTransformingLoader extends PhpStreamFilter |
||
26 | { |
||
27 | /** |
||
28 | * Php filter definition |
||
29 | */ |
||
30 | public const PHP_FILTER_READ = 'php://filter/read='; |
||
31 | |||
32 | /** |
||
33 | * Default PHP filter name for registration |
||
34 | */ |
||
35 | public const FILTER_IDENTIFIER = 'go.source.transforming.loader'; |
||
36 | |||
37 | /** |
||
38 | * String buffer |
||
39 | */ |
||
40 | protected $data = ''; |
||
41 | |||
42 | /** |
||
43 | * List of transformers |
||
44 | * |
||
45 | * @var SourceTransformer[] |
||
46 | */ |
||
47 | protected static $transformers = []; |
||
48 | |||
49 | /** |
||
50 | * Identifier of filter |
||
51 | * |
||
52 | * @var string |
||
53 | */ |
||
54 | protected static $filterId; |
||
55 | |||
56 | /** |
||
57 | * Register current loader as stream filter in PHP |
||
58 | * |
||
59 | * @throws RuntimeException If registration was failed |
||
60 | */ |
||
61 | 1 | public static function register(string $filterId = self::FILTER_IDENTIFIER): void |
|
73 | |||
74 | /** |
||
75 | * Returns the name of registered filter |
||
76 | * |
||
77 | * @throws RuntimeException if filter was not registered |
||
78 | */ |
||
79 | 1 | public static function getId(): string |
|
87 | |||
88 | /** |
||
89 | * {@inheritdoc} |
||
90 | */ |
||
91 | 1 | public function filter($in, $out, &$consumed, $closing) |
|
112 | |||
113 | /** |
||
114 | * Adds a SourceTransformer to be applied by this LoadTimeWeaver. |
||
115 | */ |
||
116 | 1 | public static function addTransformer(SourceTransformer $transformer): void |
|
120 | |||
121 | /** |
||
122 | * Transforms source code by passing it through all transformers |
||
123 | */ |
||
124 | 1 | public static function transformCode(StreamMetaData $metadata): void |
|
133 | } |
||
134 |