mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 02:28:44 +02:00
👌 peer review
mostly coding convention, thanks @molkobain
This commit is contained in:
@@ -1250,7 +1250,7 @@ class Config
|
||||
),
|
||||
);
|
||||
/**
|
||||
* @var \Combodo\iTop\Config\Parser\iTopConfigParser|null
|
||||
* @var \iTopConfigParser|null
|
||||
*/
|
||||
private $oItopConfigParser;
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class iTopConfigParser
|
||||
{
|
||||
$oParser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7);
|
||||
|
||||
$this->browseFile($oParser, $sConfig);
|
||||
$this->BrowseFile($oParser, $sConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,7 +73,7 @@ class iTopConfigParser
|
||||
*
|
||||
* @return \Combodo\iTop\Config\Validator\ConfigNodesVisitor
|
||||
*/
|
||||
private function browseFile(\PhpParser\Parser $oParser, $sConfig)
|
||||
private function BrowseFile(\PhpParser\Parser $oParser, $sConfig)
|
||||
{
|
||||
$prettyPrinter = new Standard();
|
||||
|
||||
|
||||
@@ -43,11 +43,11 @@ function TestConfig($sContents, $oP)
|
||||
{
|
||||
/// 1- first check if there is no malicious code
|
||||
$oiTopConfigValidator = new iTopConfigAstValidator();
|
||||
$oiTopConfigValidator->validate($sContents);
|
||||
$oiTopConfigValidator->Validate($sContents);
|
||||
|
||||
/// 2 - only after we are sure that there is no malicious cade, we can perform a syntax check!
|
||||
$oiTopConfigValidator = new iTopConfigSyntaxValidator();
|
||||
$oiTopConfigValidator->validate($sContents, true);
|
||||
$oiTopConfigValidator->Validate($sContents, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,7 +21,7 @@ class iTopConfigAstValidator
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function validate($sConfig)
|
||||
public function Validate($sConfig)
|
||||
{
|
||||
$oParser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7);
|
||||
|
||||
|
||||
@@ -7,12 +7,6 @@
|
||||
|
||||
namespace Combodo\iTop\Config\Validator;
|
||||
|
||||
|
||||
use PhpParser\NodeTraverser;
|
||||
use PhpParser\NodeVisitor;
|
||||
use PhpParser\Parser;
|
||||
use PhpParser\ParserFactory;
|
||||
|
||||
class iTopConfigSyntaxValidator
|
||||
{
|
||||
/**
|
||||
@@ -21,7 +15,7 @@ class iTopConfigSyntaxValidator
|
||||
* @param $sConfig
|
||||
* @param $bAllowUnsecure
|
||||
*/
|
||||
public function validate($sConfig, $bAllowUnsecure)
|
||||
public function Validate($sConfig, $bAllowUnsecure)
|
||||
{
|
||||
exec('php -v', $aOutput, $iReturnVar);
|
||||
$bCanRunCli = ($iReturnVar == 0);
|
||||
|
||||
@@ -35,7 +35,7 @@ class iTopConfigAstValidatorTest extends ItopTestCase
|
||||
$oiTopConfigValidator = new iTopConfigAstValidator();
|
||||
$this->expectException(\Exception::class);
|
||||
try{
|
||||
$oiTopConfigValidator->validate($sConf);
|
||||
$oiTopConfigValidator->Validate($sConf);
|
||||
}catch (\Exception $e)
|
||||
{
|
||||
$this->assertStringStartsWith('Invalid configuration:', $e->getMessage());
|
||||
@@ -81,7 +81,7 @@ class iTopConfigAstValidatorTest extends ItopTestCase
|
||||
{
|
||||
$oiTopConfigValidator = new iTopConfigAstValidator();
|
||||
|
||||
$oiTopConfigValidator->validate($sConf);
|
||||
$oiTopConfigValidator->Validate($sConf);
|
||||
}
|
||||
|
||||
public function ValidDataProvider()
|
||||
|
||||
@@ -32,7 +32,7 @@ class iTopConfigAstValidatorTest extends ItopTestCase
|
||||
public function testValidCode()
|
||||
{
|
||||
$oiTopConfigValidator = new iTopConfigSyntaxValidator();
|
||||
$oiTopConfigValidator->validate("<?php \n echo 'foo'; ", false);
|
||||
$oiTopConfigValidator->Validate("<?php \n echo 'foo'; ", false);
|
||||
}
|
||||
|
||||
public function testThrowOnInvalidCode()
|
||||
@@ -41,7 +41,7 @@ class iTopConfigAstValidatorTest extends ItopTestCase
|
||||
|
||||
$this->expectException(\Exception::class);
|
||||
try{
|
||||
$oiTopConfigValidator->validate("<?php \n zef;zefzef \n zdadz = azdazd \n zerfgzaezerfgzef>", false);
|
||||
$oiTopConfigValidator->Validate("<?php \n zef;zefzef \n zdadz = azdazd \n zerfgzaezerfgzef>", false);
|
||||
}catch (\Exception $e)
|
||||
{
|
||||
$this->assertStringStartsWith('PHP Parse error: syntax error, unexpected \'zdadz\' (T_STRING)', $e->getMessage());
|
||||
|
||||
Reference in New Issue
Block a user