1 | <?php |
||
26 | class MagicConstantTransformer extends BaseSourceTransformer |
||
27 | { |
||
28 | |||
29 | /** |
||
30 | * Root path of application |
||
31 | * |
||
32 | * @var string |
||
33 | */ |
||
34 | protected static $rootPath = ''; |
||
35 | |||
36 | /** |
||
37 | * Path to rewrite to (cache directory) |
||
38 | * |
||
39 | * @var string |
||
40 | */ |
||
41 | protected static $rewriteToPath = ''; |
||
42 | |||
43 | /** |
||
44 | * Class constructor |
||
45 | * |
||
46 | * @param AspectKernel $kernel Instance of kernel |
||
47 | */ |
||
48 | 6 | public function __construct(AspectKernel $kernel) |
|
54 | |||
55 | /** |
||
56 | * This method may transform the supplied source and return a new replacement for it |
||
57 | * |
||
58 | * @param StreamMetaData $metadata Metadata for source |
||
59 | * @return string See RESULT_XXX constants in the interface |
||
60 | */ |
||
61 | 5 | public function transform(StreamMetaData $metadata): string |
|
69 | |||
70 | /** |
||
71 | * Resolves file name from the cache directory to the real application root dir |
||
72 | * |
||
73 | * @param string $fileName Absolute file name |
||
74 | * |
||
75 | * @return string Resolved file name |
||
76 | */ |
||
77 | 1 | public static function resolveFileName(string $fileName): string |
|
85 | |||
86 | /** |
||
87 | * Wraps all possible getFileName() methods from ReflectionFile |
||
88 | * |
||
89 | * @param StreamMetaData $metadata |
||
90 | */ |
||
91 | 5 | private function wrapReflectionGetFileName(StreamMetaData $metadata) |
|
112 | |||
113 | /** |
||
114 | * Replaces all magic __DIR__ and __FILE__ constants in the file with calculated value |
||
115 | * |
||
116 | * @param StreamMetaData $metadata |
||
117 | */ |
||
118 | 5 | private function replaceMagicDirFileConstants(StreamMetaData $metadata) |
|
136 | } |
||
137 |