Commit b3d534d9 authored by Felix Flor's avatar Felix Flor

update and refactor the console output functions: now using the two new...

update and refactor the console output functions: now using the two new functions getNeededModules() and getModulesInstalledStatus()
parent 674a53f4
......@@ -18,86 +18,15 @@ function basicConsoleOutput($filesToCheck){
if(!is_array($filesToCheck))
throw new \Exception ("Invalid parameter type for \$filesToCheck! Must: array, Is: " . gettype($filesToCheck));
$neededModules = array();
$neddedModulesInstallStatus = array();
$startTime = time();
$countAllFiles = count($filesToCheck);
$i = 0;
foreach($filesToCheck as $fileToCheck){
system("clear");
echo "APHPBreakdown: Analyzing File [ ".++$i." / $countAllFiles ] \n";
$tokens = token_get_all(file_get_contents($fileToCheck['fullpath']));
foreach($tokens as $token){
if(is_array($token) && T_STRING == $token[0] && isset($token[1])){
/* check function */
if(in_array($token[1], $GLOBALS['php71_functions_list'])){
$functionToModule = matchFunctionToModule($token[1]);
if(null == $functionToModule)
$functionToModule = "UNKNOWN";
if(!in_array($functionToModule ,$neededModules))
$neededModules[] = $functionToModule;
}
/* check class */
if(in_array($token[1], $GLOBALS['php71_classes_list'])){
$classToModule = matchClassToModule($token[1]);
if(null == $classToModule)
$classToModule = "UNKNOWN";
if(!in_array($classToModule ,$neededModules))
$neededModules[] = $classToModule;
$neededModules = getNeededModules($filesToCheck);
}
/* check constants */
if(isConstantInArray($token[1])){
$constantToModule = matchConstantToModule($token[1]);
if(null == $constantToModule)
$constantToModule = "UNKNOWN";
if(!in_array($constantToModule ,$neededModules))
$neededModules[] = $constantToModule;
}
}
}
}
$neddedModulesInstallStatus = getModulesInstalledStatus($neededModules);
$countAllFiles = count($filesToCheck);
$countAllModules = count($neededModules);
sort($neededModules, SORT_STRING | SORT_FLAG_CASE);
echo "APHPBreakdown: Checking Modul Status ... ";
foreach ($neededModules as $neededModule) {
if(!extension_loaded($neededModule) && $neededModule != "Core"){
$neddedModulesInstallStatus[$neededModule] = false;
} else {
$neddedModulesInstallStatus[$neededModule] = true;
}
}
echo "Finished!\n\n";
$endTime = time();
$time = $endTime - $startTime;
......
......@@ -8,8 +8,7 @@ namespace APHPBreakdown;
*
* @throws \Exception - if $filesToCheck is not of type array
*
* this functions checks all given files for functions, constants and classes to
* to perform a checkup which modules are not installed but needed on you system
* this function gives you the output for the analyse
*
**/
......@@ -18,86 +17,15 @@ function fullConsoleOutput($filesToCheck){
if(!is_array($filesToCheck))
throw new \Exception ("Invalid parameter type for \$filesToCheck! Must: array, Is: " . gettype($filesToCheck));
$neededModules = array();
$neddedModulesInstallStatus = array();
$startTime = time();
$countAllFiles = count($filesToCheck);
$i = 0;
foreach($filesToCheck as $fileToCheck){
system("clear");
echo "APHPBreakdown: Analyzing File [ ".++$i." / $countAllFiles ] \n";
$tokens = token_get_all(file_get_contents($fileToCheck['fullpath']));
foreach($tokens as $token){
if(is_array($token) && T_STRING == $token[0] && isset($token[1])){
/* check function */
if(in_array($token[1], $GLOBALS['php71_functions_list'])){
$functionToModule = matchFunctionToModule($token[1]);
if(null == $functionToModule)
$functionToModule = "UNKNOWN";
if(!in_array($functionToModule ,$neededModules))
$neededModules[] = $functionToModule;
}
/* check class */
if(in_array($token[1], $GLOBALS['php71_classes_list'])){
$classToModule = matchClassToModule($token[1]);
if(null == $classToModule)
$classToModule = "UNKNOWN";
if(!in_array($classToModule ,$neededModules))
$neededModules[] = $classToModule;
}
/* check constants */
if(isConstantInArray($token[1])){
$constantToModule = matchConstantToModule($token[1]);
$neededModules = getNeededModules($filesToCheck);
if(null == $constantToModule)
$constantToModule = "UNKNOWN";
if(!in_array($constantToModule ,$neededModules))
$neededModules[] = $constantToModule;
}
}
}
}
$neddedModulesInstallStatus = getModulesInstalledStatus($neededModules);
$countAllFiles = count($filesToCheck);
$countAllModules = count($neededModules);
sort($neededModules, SORT_STRING | SORT_FLAG_CASE);
echo "APHPBreakdown: Checking Modul Status ... ";
foreach ($neededModules as $neededModule) {
if(!extension_loaded($neededModule) && $neededModule != "Core"){
$neddedModulesInstallStatus[$neededModule] = false;
} else {
$neddedModulesInstallStatus[$neededModule] = true;
}
}
echo "Finished!\n\n";
$endTime = time();
$time = $endTime - $startTime;
......@@ -122,8 +50,4 @@ function fullConsoleOutput($filesToCheck){
echo "\n======================================================\n";
echo " Time to perform the test: $time sec.\n\n";
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment