Commit 82dd78f2 authored by Felix Flor's avatar Felix Flor

fullConsoleOutput.func.php: Reworked, no it gives you a list auf all modules...

fullConsoleOutput.func.php: Reworked, no it gives you a list auf all modules needed for the project. I markes the list-entries in green (installed) or red (missing) to give you a better overwiev. this makes the given output name more meaningful
parent 73c0f8d5
......@@ -4,91 +4,122 @@ namespace APHPBreakdown;
/**
*
* @param mixed[] $filesToCheck - contains all paths to files, one path per field
* @param mixed[] $filesToCheck - contains all paths to files, one path per field
*
* @const T_STRING - same as 319. function, class, constant names are found as T_STRING by tokenizer.
* @throws \Exception - if $filesToCheck is not of type array
*
* @throws \Exception - if the given argument is not of type array
*
* this function gets an array of paths to files and performes on every file in
* the array an checkup and output. it prints you on console if the class, constant,
* function and module are defined / installed or not and in which row and file in the
* project it is used.
*
* $token[0] : number of token
* $token[1] : name of the function
* $token[2] : the row of the file where function is found
* 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
*
**/
function fullConsoleOutput($filesToCheck) {
function fullConsoleOutput($filesToCheck){
if(!is_array($filesToCheck))
throw new \Exception ("Invalid parameter type! Must: array, Is: " . gettype($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){
$filesAsString = file_get_contents($fileToCheck['fullpath']);
system("clear");
echo "APHPBreakdown: Analyzing File [ ".++$i." / $countAllFiles ] \n";
$tokens = token_get_all($filesAsString);
$tokens = token_get_all(file_get_contents($fileToCheck['fullpath']));
foreach ($tokens as $token) {
foreach($tokens as $token){
if(is_array($token)){
$numberOfToken = $token[0];
} else {
$numberOfToken = null;
}
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($numberOfToken == T_STRING) {
if(null == $functionToModule)
$functionToModule = "UNKNOWN";
if(isset($token[1])){
if(!in_array($functionToModule ,$neededModules))
$neededModules[] = $functionToModule;
/* part for functions checkup */
if(in_array($token[1], $GLOBALS['php71_functions_list'])){
}
$moduleOfFunction = matchFunctionToModule($token[1]);
$installStatus = isModuleForFunctionInstalledAsString($token[1]);
/* check class */
if(in_array($token[1], $GLOBALS['php71_classes_list'])){
if(null == $moduleOfFunction){
$moduleOfFunction = "UNKNOWN MODULE - Update lists of Modules for Functions";
echo "$moduleOfFunction [ Function: \"$token[1]\" ]\n";
} else {
echo "MODUL \"$moduleOfFunction\" $installStatus [ Function \"$token[1]\" found in file ".$fileToCheck['relpath']." in Row $token[2]\n";
}
}
$classToModule = matchClassToModule($token[1]);
/* part of classes checkup */
if(in_array($token[1], $GLOBALS['php71_classes_list'])){
if(null == $classToModule)
$classToModule = "UNKNOWN";
$moduleOfClass = matchClassToModule($token[1]);
$installStatus = isModuleForClassInstalledAsString($token[1]);
if(!in_array($classToModule ,$neededModules))
$neededModules[] = $classToModule;
if(null == $moduleOfClass){
$moduleOfClass = "UNKNOWN MODULE - Update lists of Modules for Classes";
echo "$moduleOfClass [ Class: \"$token[1]\" ]\n";
} else {
echo "MODUL \"$moduleOfClass\" $installStatus [ Class \"$token[1]\" found in file ".$fileToCheck['relpath']." in Row $token[2]\n";
}
}
}
/* check constants */
if(isConstantInArray($token[1])){
/* port of constants checkup */
if(isConstantInArray($token[1])){
$constantToModule = matchConstantToModule($token[1]);
$moduleOfConstant = matchConstantToModule($token[1]);
$installStatus = isModuleForConstantInstalledAsString($token[1]);
if(null == $constantToModule)
$constantToModule = "UNKNOWN";
if(null == $moduleOfConstant){
$moduleOfConstant = "UNKNOWN MODULE - Update lists of Modules for Constants";
echo "$moduleOfClass [ Class: \"$token[1]\" ]\n";
} else {
echo "MODUL \"$moduleOfConstant\" $installStatus [ Constant \"$token[1]\" found in file ".$fileToCheck['relpath']." in Row $token[2]\n";
}
if(!in_array($constantToModule ,$neededModules))
$neededModules[] = $constantToModule;
}
}
}
}
}
$countAllModules = count($neededModules);
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;
system("clear");
echo "\n APHPBreakdown : Results\n";
echo "======================================================\n\n";
echo " Checked Files: $countAllFiles\n";
echo " Needed Modules: $countAllModules\n\n";
echo " List of all Modules [ \033[0;31m missing \033[0m | \033[0;32m installed \033[0m ] :\n";
foreach($neddedModulesInstallStatus as $module => $moduleStatus){
if(!$moduleStatus){
echo " - \033[0;31m$module\033[0m\n";
} else {
echo " - \033[0;32m$module\033[0m\n";
}
}
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