public function transform(StreamMetaData $metadata)
{
// Make the job only when we use cache directory
if (!self::$rewriteToPath) {
return;
}
$hasReflectionFilename = strpos($metadata->source, 'getFileName') !== false;
$hasMagicConstants = strpos($metadata->source, '__DIR__') !== false || strpos($metadata->source, '__FILE__') !== false;
if (!$hasMagicConstants && !$hasReflectionFilename) {
return;
}
// Resolve magic constants
if ($hasMagicConstants) {
$this->replaceMagicConstants($metadata);
}
if ($hasReflectionFilename) {
// need to make more reliable solution
$metadata->source = preg_replace('/\\$([\\w\\$\\-\\>\\:\\(\\)]*?getFileName\\(\\))/S', '\\' . __CLASS__ . '::resolveFileName(\\$\\1)', $metadata->source);
}
}