Created
August 8, 2017 09:12
-
-
Save avtehnik/43fa00bb2d679150443f22a263d7db28 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 | |
$memcache = $this->getContainer()->get('busmap.memcached'); | |
// $task = $input->getArgument('task', false); | |
$methods = get_class_methods($memcache); | |
$class = new \ReflectionClass(Memcached::class); | |
$class->getProperties(); | |
$lines = []; | |
$lines[] = $class->getName() . ':'; | |
$lines[] = ' ' . $class->getShortName() . '{1..2}:'; | |
$fileName = $class->getFileName(); | |
$startLine = $class->getStartLine()-1; // getStartLine() seems to start after the {, we want to include the signature | |
$endLine = $class->getEndLine(); | |
$numLines = $endLine - $startLine; | |
$lastLink = ""; | |
$links = []; | |
if(!empty($fileName)) { | |
foreach (array_slice(file($fileName),$startLine,$numLines) as $item) { | |
foreach ($methods as $method) { | |
if(strpos($item, "function ".$method )!==false){ | |
$lastLink = $method; | |
$links[$lastLink]=[]; | |
echo $lastLink.PHP_EOL; | |
} | |
} | |
foreach ($methods as $method) { | |
if(strpos($item, "this->".$method."(" )!==false){ | |
$links[$lastLink][] = $method; | |
} | |
} | |
} | |
} | |
print_r($links); | |
foreach ($links as $link) { | |
foreach ($link as $item) { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment