Created
December 11, 2018 18:03
-
-
Save Frago9876543210/d8e6c9b6a18436b2d509b320450f9fc1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
if($argc < 2){ | |
die("Usage: php {$argv[0]} symbol\n"); | |
} | |
array_shift($argv); | |
$sym = trim(shell_exec("c++filt " . $raw = implode(" ", $argv))); | |
$parts = explode("::", $sym); | |
$class = substr_count($sym, "::") >= 2 ? implode("::", array_slice($parts, 0, 2)) : $parts[0]; | |
list($function, $params) = explode("(", substr($sym, strlen($class) + 2)); | |
$params = substr($params, 0, strrpos($params, ")")); | |
$params = !empty($params) ? explode(", ", $params) : []; | |
foreach($params as $i => &$param){ | |
$param .= " a" . (++$i); | |
} | |
$i = 1; | |
$original = implode(", ", (["this"] + array_map(function($key) use (&$i){ | |
return $key . $i++; | |
}, array_fill(1, count($params), "a")))); | |
$params = implode(", ", $params); | |
$params = str_replace("const", "\x1b[38;5;214mconst\x1b[38;5;231m", $params); | |
echo "\x1b[38;5;83m///\x1b[38;5;34m\x1b[1m@symbol\x1b[m \x1b[38;5;83m$sym, \x1b[38;5;227m//TODO: Don't forget replace return type!\nTInstanceHook\x1b[38;5;231m(\x1b[38;5;214mvoid\x1b[38;5;231m, \x1b[38;5;87m$raw\x1b[38;5;231m, $class" . (empty($params) ? "" : ", ") . "$params){\n\t\x1b[38;5;145m//return original($original);\n\x1b[38;5;231m}\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment