Wondering about "aweful hack" in PHPStorm's PHPUnit Launcher

The PHPUnit launcher has this bit of code that warns of an aweful hack but doesn't really explain what it's trying to do.  I'm curious why they're not just importing or requiring the .phar file?

            $alias = $phar->getAlias();
            Phar::loadPhar($path, $alias);
            //awful hack start (but I don't know a better way to do it)
            $stub = $phar->getStub();
            $i = strpos($stub, "<?php\n");
            $stub = substr($stub, $i + 6);
            $i = strpos($stub, "Phar::mapPhar");
            $stub_prefix = substr($stub, 0, $i);
            if (!isset($_SERVER['IDE_PHPUNIT_VERSION']) ||  $_SERVER['IDE_PHPUNIT_VERSION'] < "4.6") {
            else {
                $mapEnd = strpos($stub, ")", $i);
                $stub_suffix = substr($stub, $mapEnd + 2);
                eval($stub_prefix . $stub_suffix);
            //awful hack end

1 comment
Comment actions Permalink

Thank you for your contribution - I've contacted the responsible developer and since we're working on making the runner script faster, your solution can actually be implemented.


Please sign in to leave a comment.