Commit 1c093061 authored by Felix Flor's avatar Felix Flor

renaming and cleanup

parent 82be3571
<?php
namespace PHPAutoAnalyse;
namespace APHPBreakdown;
require_once __DIR__ . '/config.inc.php';
......
<?php
$objPhar = new \Phar('aphpanalyse.phar', 0, 'aphpanalyse.phar');
$objPhar = new \Phar('aphpbreakdown.phar', 0, 'aphpbreakdown.phar');
$objPhar->addFile('autoanalyse.php');
$objPhar->addFile('config.inc.php');
......
{
"name": "code-mesa/aphpanalyse",
"name": "code-mesa/aphpbreakdown",
"description": "analyses your project and provides you an checkup for your deployment server for php modules, functions, classes and constants.",
"type": "library",
"version": "1.0.0",
"keywords": ["analyse", "auto analyse", "deployment", "check"],
"keywords": ["analyze", "auto analyze", "deployment", "check"],
"license": "BSD-2-Clause",
"homepage": "https://aphpanalyse.code-mesa.com",
"homepage": "https://aphpbreakdown.code-mesa.com",
"authors": [
{
"name": "Felix Flor",
......@@ -26,6 +26,6 @@
"ext-hash": "*"
},
"support": {
"issues": "http://gitlab.code-mesa.com/code-mesa/aphpanalyse/issues"
"issues": "http://gitlab.code-mesa.com/code-mesa/aphpbreakdown/issues"
}
}
<?php
namespace PHPAutoAnalyse;
namespace APHPBreakdown;
error_reporting(E_ALL & ~E_WARNING & ~E_NOTICE);
......
<?php
namespace PHPAutoAnalyse;
namespace APHPBreakdown;
/**
*
......@@ -14,9 +14,9 @@ function checkEnvironment(){
$minPphVersion = "5.6";
if (version_compare(phpversion(), $minPphVersion, '<'))
exitWithErrorMessage("APHPAutoanalyse: Your php version is not high enough. Must be php \"$minPphVersion\" an higher.\n");
exitWithErrorMessage("APHPBreakdown: Your php version is not high enough. Must be php \"$minPphVersion\" an higher.\n");
if(!extension_loaded('tokenizer'))
exitWithErrorMessage("APHPAutoanalyse: Missing module! php module \"tokenizer\" not found!\n");
exitWithErrorMessage("APHPBreakdown: Missing module! php module \"tokenizer\" not found!\n");
}
<?php
namespace PHPAutoAnalyse;
namespace APHPBreakdown;
/**
*
......@@ -16,7 +16,7 @@ namespace PHPAutoAnalyse;
function checkGivenArguments($argv) {
if(!is_array($argv))
throw new \Exception ("Invalid parameter type! Must: array, Is: " . gettype($argv));
throw new \Exception ("APHPBreakdown: Invalid parameter type! Must: array, Is: " . gettype($argv));
$acceptedOutputArguments = array("--console-basic","--console-full", "--testfile");
$acceptedTemplateArguments = array("--basic", "--advanced");
......@@ -24,10 +24,10 @@ function checkGivenArguments($argv) {
$path = realpath($argv[1]);
if(!isset($path) || !isset($argv[2]))
exitWithErrorMessage("APHPAutoanalyse: Not enough arguments given!\n\t\t aphpanalyse <PATH> <OPTIONS> [--testfile <TEMPLATE>] [--testfile <EXPORT_FILENAME>]\n\t\t <PATH> /path/to/dir\n\t\t <OPTIONS> --console-full | --testfile\n\t\t [--testfile <TEMPLATE>] --basic | --advanced\n\t\t [<EXPORT_FILENAME>] optional, no path, don't forget file extension\n");
exitWithErrorMessage("APHPBreakdown: Not enough arguments given!\n\t\t aphpanalyse <PATH> <OPTIONS> [--testfile <TEMPLATE>] [--testfile <EXPORT_FILENAME>]\n\t\t <PATH> /path/to/dir\n\t\t <OPTIONS> --console-full | --testfile\n\t\t [--testfile <TEMPLATE>] --basic | --advanced\n\t\t [<EXPORT_FILENAME>] optional, no path, don't forget file extension\n");
if(!is_dir($path))
exitWithErrorMessage("APHPAutoanalyse: There is no directory found on path \"$path\"\n");
exitWithErrorMessage("APHPBreakdown: There is no directory found on path \"$path\"\n");
/**
* checks the readability of file and directories given in argument.
......@@ -45,21 +45,21 @@ function checkGivenArguments($argv) {
}
if($notReadableFileOrDirectoryCounter > 0)
exitWithErrorMessage("APHPAutoanalyse: There are sone or more Files which are not readable. Check the Output above for Details.\nChange the file Permissions. To do that use this command \"$ chmod u+r <FILE>\"\n");
exitWithErrorMessage("APHPBreakdown: There are sone or more Files which are not readable. Check the Output above for Details.\nChange the file Permissions. To do that use this command \"$ chmod u+r <FILE>\"\n");
if(!isset($argv[2]))
exitWithErrorMessage("APHPAutoanalyse: You have to give argument for output. ( aphpanalyse <PATH> <OUTPUT> [ --console-full | --testfile ] ).\n");
exitWithErrorMessage("APHPBreakdown: You have to give argument for output. ( aphpanalyse <PATH> <OUTPUT> [ --console-full | --testfile ] ).\n");
if(!in_array($argv[2], $acceptedOutputArguments))
exitWithErrorMessage("APHPAutoanalyse: The Argument you have given is not valid. Avaible Options: <OUTPUT> [ --console-full | --testfile ].\n");
exitWithErrorMessage("APHPBreakdown: The Argument you have given is not valid. Avaible Options: <OUTPUT> [ --console-full | --testfile ].\n");
if($argv[2] == "--testfile" && !isset($argv[3]))
exitWithErrorMessage("APHPAutoanalyse: Missing Argument for --testfile. Avaible Options: [<TEMPLATE>] [ --basic | --advanced ].\n");
exitWithErrorMessage("APHPBreakdown: Missing Argument for --testfile. Avaible Options: [<TEMPLATE>] [ --basic | --advanced ].\n");
if($argv[2] == "--testfile" && !in_array($argv[3], $acceptedTemplateArguments))
exitWithErrorMessage("APHPAutoanalyse: The Argument you have given is not valid. Avaible Options: [<TEMPLATE>] [ --basic | --advanced ].\n");
exitWithErrorMessage("APHPBreakdown: The Argument you have given is not valid. Avaible Options: [<TEMPLATE>] [ --basic | --advanced ].\n");
if(preg_match('/[^A-Za-z0-9 _ .-]/', $argv[4]) && isset($argv[4]))
exitWithErrorMessage("APHPAutoanalyse: You use inadmissible charachters for filename! Not Path! \n");
exitWithErrorMessage("APHPBreakdown: You use inadmissible charachters for filename! Not Path! \n");
}
<?php
namespace PHPAutoAnalyse;
namespace APHPBreakdown;
/**
* @param string $errorMessage - message to print
*
* @throws \Exception - if the given argument is not of type string
*
*
* performs an exit of the program an prints
* an error message to the console.
*
*
**/
function exitWithErrorMessage($errorMessage){
if(!is_string($errorMessage))
throw new \Exception ("Invalid parameter type! Must: string, Is: " . gettype($errorMessage));
echo $errorMessage."\n";
exit;
}
<?php
namespace PHPAutoAnalyse;
namespace APHPBreakdown;
/**
*
* @param string $pathToFile - path to file
*
* @return (array) $fileAsArray - file found on path in an array
* @return (array) $fileAsArray - file found on path in an array
*
* @throws \Exception - if given parameter is not of type string
* @throws \Exception - if file is not readable
*
*
* this function gets the path to a file and fills an array
* with its content. the filled array will returned by this
* function. one field in the array ontains a row of the file.
*
*
**/
function fileToArray($pathToFile) {
......@@ -23,19 +23,19 @@ function fileToArray($pathToFile) {
throw new \Exception ("Invalid parameter type! Must: string, Is: " . gettype($pathToFile));
try{
if(is_readable($pathToFile) && file_exists($pathToFile)){
$fileAsArray = file($pathToFile, FILE_IGNORE_NEW_LINES);
return $fileAsArray;
} else {
throw new \Exception("File \"$pathToFile\" is not readable or dosn't exists. Change file permissions with command \"chmod u+r <FILE>\" and check file exists.\n");
}
} catch (\Exception $e) {
exitWithErrorMessage($e->getMessage());
}
}
<?php
namespace PHPAutoAnalyse;
namespace APHPBreakdown;
use RecursiveIteratorIterator;
use RecursiveDirectoryIterator;
......
<?php
namespace PHPAutoAnalyse;
namespace APHPBreakdown;
/**
*
......@@ -9,9 +9,9 @@ namespace PHPAutoAnalyse;
* @return bool - true if the constant is found
*
* @throws \Exception - if given parameter is not of type string
*
*
* matches the given php constant to the module and returns a bool
*
*
**/
function isConstantInArray($phpConstantName) {
......@@ -22,8 +22,8 @@ function isConstantInArray($phpConstantName) {
foreach($GLOBALS['php71_constants_to_module_list'] as $constantModules => $constantOfModule){
if(array_key_exists($phpConstantName ,$constantOfModule))
return true;
}
return false;
}
<?php
namespace PHPAutoAnalyse;
namespace APHPBreakdown;
/**
* @param string $phpClassName - name of the php class
......@@ -8,22 +8,22 @@ namespace PHPAutoAnalyse;
* @return bool
*
* @throws \Exception - if given parameter is not of type string
*
*
* this function gets a name of a php class and checks if
* the module you need to use the class is installed
* on the system where the script is running
*
**/
function isModuleForClassInstalled($phpClassName) {
if(!is_string($phpClassName))
throw new \Exception ("Invalid parameter type! Must: string, Is: " . gettype($phpClassName));
$phpModule = matchClassToModule($phpClassName);
if(!extension_loaded($phpModule) && !dl("$phpModule.so") && $phpModule != "Core")
return false;
return true;
}
<?php
namespace PHPAutoAnalyse;
namespace APHPBreakdown;
/**
* @param string $phpClassName - name of the php class
*
*
* @return string - contains "INSTALLED" or "NOT INSTALLED"
*
* @throws \Exception - if the given argument is not of type string
*
*
* the function gets the name of the php class you want to knwo
* and gives you information about if the module is installed or not.
*
*
**/
function isModuleForClassInstalledAsString($phpClassName){
if(!is_string($phpClassName))
......
<?php
namespace PHPAutoAnalyse;
namespace APHPBreakdown;
/**
* @param string $phpConstantsName - name of the php constant
......@@ -19,7 +19,7 @@ function isModuleForConstantInstalled($phpConstantsName){
if(!is_string($phpConstantsName))
throw new \Exception ("Invalid parameter type! Must: string, Is: " . gettype($phpConstantsName));
$phpModule = matchConstantToModule($phpConstantsName);
if(!extension_loaded($phpModule) && !dl("$phpModule.so") && $phpModule != "Core")
......
<?php
namespace PHPAutoAnalyse;
namespace APHPBreakdown;
/**
* @param string $phpConstantsName - name of the php constant
*
*
* @return string - contains "INSTALLED" or "NOT INSTALLED"
*
* @throws \Exception - if the given argument is not of type string
*
* the function gets the name of the php function you want to knwo
* if it is installed or not.
*
*
**/
function isModuleForConstantInstalledAsString($phpConstantsName){
if(!is_string($phpConstantsName))
......
<?php
namespace PHPAutoAnalyse;
namespace APHPBreakdown;
/**
* @param string $phpFunctionName - name of the php function
......
<?php
namespace PHPAutoAnalyse;
namespace APHPBreakdown;
/**
* @param string $phpFunctionName - name of the php function
*
*
* @return string - contains "INSTALLED" or "NOT INSTALLED"
*
* @throws \Exception - if the given argument is not of type string
*
* the function gets the name of the php function you want to knwo
* if it is installed or not.
*
*
**/
function isModuleForFunctionInstalledAsString($phpFunctionName) {
if(!is_string($phpFunctionName))
......
<?php
namespace PHPAutoAnalyse;
namespace APHPBreakdown;
/**
*
* @param string $phpClassName - name of the php class
*
* @return string - name of the list of all classes
*
*
* @throws \Exception - if the given argument is not of type string
*
* matches the given php class to the module and returns the name of
......
<?php
namespace PHPAutoAnalyse;
namespace APHPBreakdown;
/**
*
......
<?php
namespace PHPAutoAnalyse;
namespace APHPBreakdown;
/**
*
......
<?php
namespace PHPAutoAnalyse;
namespace APHPBreakdown;
/**
*
......
<?php
namespace PHPAutoAnalyse;
namespace APHPBreakdown;
/**
*
......@@ -28,7 +28,7 @@ function basicConsoleOutput($filesToCheck){
foreach($filesToCheck as $fileToCheck){
system("clear");
echo "APHPAnalyse: Analysing File [ ".++$i." / $countAllFiles ] \n";
echo "APHPBreakdown: Analyzing File [ ".++$i." / $countAllFiles ] \n";
$tokens = token_get_all(file_get_contents($fileToCheck['fullpath']));
......@@ -83,7 +83,7 @@ function basicConsoleOutput($filesToCheck){
$countAllModules = count($neededModules);
echo "APHPAnalyse: Checking Modul Status ... ";
echo "APHPBreakdown: Checking Modul Status ... ";
foreach ($neededModules as $neededModule) {
......@@ -101,7 +101,7 @@ function basicConsoleOutput($filesToCheck){
system("clear");
echo "\n APHPAnalyse : Results\n";
echo "\n APHPBreakdown : Results\n";
echo "======================================================\n\n";
echo " Checked Files: $countAllFiles\n";
echo " Needed Modules: $countAllModules\n\n";
......
<?php
namespace PHPAutoAnalyse;
namespace APHPBreakdown;
/**
*
......@@ -47,7 +47,7 @@ function createTestfileFromTemplate($filesToCheck, $template, $exportFileName){
foreach($filesToCheck as $fileToCheck){
system("clear");
echo "APHPAnalyse: Analysing File [ ".++$i." / $countAllFiles ] \n";
echo "APHPBreakdown: Analyzing File [ ".++$i." / $countAllFiles ] \n";
$tokens = token_get_all(file_get_contents($fileToCheck['fullpath']));
......@@ -138,5 +138,5 @@ function createTestfileFromTemplate($filesToCheck, $template, $exportFileName){
$endTime = time();
$time = $endTime - $startTime;
echo "APHPAnalyse: DONE! Testfile create! ($workingDir/$exportFileName) Time: $time sec.\n\n";
echo "APHPBreakdown: DONE! Testfile create! ($workingDir/$exportFileName) Time: $time sec.\n\n";
}
......@@ -86,7 +86,7 @@ foreach($neededClasses as $neededClass){
<div class="col-lg-12">
<h4>Basic-Results</h4>
<p>
This output provides you the result of a basic ckeckup for your analysed project. It tells you
This output provides you the result of a basic checkup for your analysed project. It tells you
if the webserver you want to deploy to has all modules installed or not. Missing modules are
listed beneath.
</p>
......
......@@ -27,7 +27,7 @@ foreach($neededModules as $neededModule){
<style>
<CSSFILE>
</style>
</head>
<body>
......@@ -44,8 +44,8 @@ foreach($neededModules as $neededModule){
<div class="col-lg-12">
<h4>Results</h4>
<p>
This output provides you the result of a basic ckeckup for your analysed project. It tells you
if the webserver you want to deploy to has all modules installed or not. Missing modules are
This output provides you the result of a basic checkup for your analysed project. It tells you
if the webserver you want to deploy to has all modules installed or not. Missing modules are
listed beneath.
</p>
</div>
......
<?php
namespace PHPAutoAnalyse;
namespace APHPBreakdown;
/**
*
......
......@@ -9,9 +9,9 @@ function testMatchFunctionToModule(){
$funtion = "session_destroy";
$module = "session";
$result = \PHPAutoAnalyse\matchFunctionToModule($funtion);
$result = \APHPBreakdown\matchFunctionToModule($funtion);
assertEquals($module, $result);
}
function testMatchClassToModule(){
......@@ -19,33 +19,33 @@ function testMatchClassToModule(){
$class = "PDOStatement";
$module = "pdo";
$result = \PHPAutoAnalyse\matchClassToModule($class);
$result = \APHPBreakdown\matchClassToModule($class);
assertEquals($module, $result);
}
function testGetFilesystemPathAndReadability(){
$numberOfFilesMustFound = 4;
$pathToDirectory = realpath("aphpanalyse/aphpunitTests/directoryForUnitTests/");
$resultArray = \PHPAutoAnalyse\getFilesystemPathAndReadability($pathToDirectory);
$resultArray = \APHPBreakdown\getFilesystemPathAndReadability($pathToDirectory);
$numberOfFilesInArray = count($resultArray);
assertEquals($numberOfFilesMustFound ,$numberOfFilesInArray);
}
function testIsConstantInArrayTrue(){
$phpConstantName = "STREAM_NOTIFY_CONNECT";
assertTrue(\PHPAutoAnalyse\isConstantInArray($phpConstantName));
assertTrue(\APHPBreakdown\isConstantInArray($phpConstantName));
}
function testIsConstantInArrayFalse(){
$phpConstantName = "STREAM_NOT";
assertFalse(\PHPAutoAnalyse\isConstantInArray($phpConstantName));
assertFalse(\APHPBreakdown\isConstantInArray($phpConstantName));
}
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