👌 peer review

mostly coding convention,

thanks @molkobain
This commit is contained in:
bruno DA SILVA
2020-01-07 15:34:27 +01:00
parent 2043010aad
commit 838c4f123c
7 changed files with 11 additions and 17 deletions

View File

@@ -1250,7 +1250,7 @@ class Config
),
);
/**
* @var \Combodo\iTop\Config\Parser\iTopConfigParser|null
* @var \iTopConfigParser|null
*/
private $oItopConfigParser;

View File

@@ -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();

View File

@@ -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);
}
/**

View File

@@ -21,7 +21,7 @@ class iTopConfigAstValidator
*
* @throws \Exception
*/
public function validate($sConfig)
public function Validate($sConfig)
{
$oParser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7);

View File

@@ -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);

View File

@@ -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()

View File

@@ -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());