public function prepareOutput($file, $strict = false)
    {
        if ($strict && PHP_VERSION_ID < 70000) {
            throw new RuntimeException('Strict mode requires PHP 7 or greater.');
        }

        $dir = dirname($file);
        if (!is_dir($dir) && !mkdir($dir, 0777, true)) {
            throw new RuntimeException("Unable to create directory $dir.");
        }

        $r = fopen($file, 'w');

        if (!$r) {
            throw new RuntimeException("Unable to open $file for writing.");
        }

        if ($strict) {
            fwrite($r, "<?php declare(strict_types=1);\n");
        } else {
            fwrite($r, "<?php\n");
        }

        return $r;
    }