Created
September 7, 2012 20:51
-
-
Save lolgzs/3669516 to your computer and use it in GitHub Desktop.
MinimizeSingletonTest pour Johan
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 | |
/** | |
* $result sera un tableau de lignes: | |
* nombre_occurences chemin/vers/fichier.php:Ma_Classe::instance | |
*/ | |
exec('grep -ro --include="*.php" "\([A-Za-z_]*\)::instance" *|sort|uniq -c|grep -v 1', $result); | |
$infections = []; | |
array_map( | |
function($line) use (&$infections) { | |
preg_match_all('/([0-9])+ ([^:]+):([^:]+)::/', $line, $matches, PREG_SET_ORDER); | |
extract(array_combine(['match', 'number_of_occurences', 'filepath', 'classname'], | |
$matches[0])); | |
if (!isset($infections[$classname])) | |
$infections[$classname] = ['nb' => 0, 'files' => []]; | |
$infections[$classname]['nb'] += $number_of_occurences; | |
$infections[$classname]['files'] []= $filepath; | |
}, | |
$result); | |
print_r($infections); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment