[FEATURE] add phpmd

This commit is contained in:
Marco Stoll 2019-06-27 10:27:43 +02:00
parent 5844b05d64
commit 5ba3f8efe8
12 changed files with 34 additions and 32 deletions

3
bin/phpmd.bat Normal file
View File

@ -0,0 +1,3 @@
@ECHO OFF
SET PROJECT_HOME=C:\dev\ffe\fastforward\FF
vendor\bin\phpmd %PROJECT_HOME%\src xml cleancode,codesize,controversial,design,naming,unusedcode --strict --reportfile %PROJECT_HOME%\logs\phpmd\report.xml

View File

@ -23,6 +23,7 @@
"twig/twig": "^2.0"
},
"require-dev": {
"phpmd/phpmd" : "@stable",
"phpunit/phpunit": "^8",
"squizlabs/php_codesniffer": "^3",
"theseer/phpdox": "*"

View File

@ -90,11 +90,9 @@
</source>
<!-- PHPMessDetector -->
<!--
<source type="pmd">
<file name="pmd.xml" />
<file name="../logs/phpmd/report.xml" />
</source>
-->
<!-- PHPUnit Coverage XML -->
<!-- <source type="phpunit"> -->

View File

@ -71,7 +71,7 @@ class Dispatcher extends AbstractService
/**
* @return bool
*/
public function getFireEvents(): bool
public function hasFireEvents(): bool
{
return $this->fireEvents;
}
@ -311,10 +311,10 @@ class Dispatcher extends AbstractService
. 'of controller [' . get_class($controller) . ']'
);
}
$methodArgs[] = $param->getDefaultValue();
} else {
$methodArgs[] = $args[$name];
$args[$name] = $param->getDefaultValue();
}
$methodArgs[] = $args[$name];
}
} catch (\ReflectionException $e) {
throw new ControllerInspectionException(

View File

@ -17,8 +17,8 @@ use FF\Services\AbstractService;
*
* Options:
*
* - error-types : int (default: E_ALL) - error type bit mask to trigger this handler
* - bypass-php-error-handling . bool (default: false) - whether to suppress php's built-in error handling
* - error-types : int (default: E_ALL) - error type bit mask to trigger this handler
* - bypass-php : bool (default: false) - whether to suppress php's built-in error handling
*
* @package FF\Services\Runtime
*/
@ -37,7 +37,7 @@ class ErrorHandler extends AbstractService implements RuntimeEventHandlerInterfa
/**
* @var bool
*/
protected $bypassPhpErrorHandling = false;
protected $bypassPhp = false;
/**
* {@inheritdoc}
@ -103,18 +103,18 @@ class ErrorHandler extends AbstractService implements RuntimeEventHandlerInterfa
/**
* @return bool
*/
public function getBypassPhpErrorHandling(): bool
public function hasBypassPhp(): bool
{
return $this->bypassPhpErrorHandling;
return $this->bypassPhp;
}
/**
* @param bool $bypassPhpErrorHandling
* @param bool $bypassPhp
* @return $this
*/
public function setBypassPhpErrorHandling(bool $bypassPhpErrorHandling)
public function setBypassPhp(bool $bypassPhp)
{
$this->bypassPhpErrorHandling = $bypassPhpErrorHandling;
$this->bypassPhp = $bypassPhp;
return $this;
}
@ -139,7 +139,7 @@ class ErrorHandler extends AbstractService implements RuntimeEventHandlerInterfa
): bool {
$this->fire('Runtime\Error', $errNo, $errMsg, $errFile, $errLine, $errContext);
return $this->bypassPhpErrorHandling;
return $this->bypassPhp;
}
/**
@ -150,6 +150,6 @@ class ErrorHandler extends AbstractService implements RuntimeEventHandlerInterfa
parent::initialize($options);
$this->errorTypes = $this->getOption('error-types', E_ALL);
$this->bypassPhpErrorHandling = $this->getOption('bypass-php-error-handling', false);
$this->bypassPhp = $this->getOption('bypass-php', false);
}
}

View File

@ -71,15 +71,15 @@ class ExceptionHandler extends AbstractService implements RuntimeEventHandlerInt
* To prevent potential loops any unhandled exception thrown while processing the Exception event
* is caught and discarded.
*
* @param \Throwable $e
* @param \Throwable $throwable
* @fires Runtime\Exception
* @see http://php.net/set_exception_handler
*/
public function onException(\Throwable $e)
public function onException(\Throwable $throwable)
{
try {
$this->fire('Runtime\Exception', $e);
} catch (\Exception $e) {
$this->fire('Runtime\Exception', $throwable);
} catch (\Exception $exception) {
// do not handle exceptions thrown while
// processing the Exception event
}

View File

@ -55,7 +55,7 @@ class ShutdownHandler extends AbstractService implements RuntimeEventHandlerInte
/**
* @return bool
*/
public function getForceExit(): bool
public function hasForceExit(): bool
{
return $this->forceExit;
}

View File

@ -81,7 +81,7 @@ class TwigRenderer extends AbstractService implements TemplateRendererInterface
/**
* @return bool
*/
public function getFireEvents(): bool
public function hasFireEvents(): bool
{
return $this->fireEvents;
}

View File

@ -117,12 +117,12 @@ namespace FF\Tests\Services\Dispatching {
/**
* Tests the namesake method/feature
*/
public function testSetGetFireEvents()
public function testSetHasFireEvents()
{
$value = false;
$same = $this->uut->setFireEvents($value);
$this->assertSame($this->uut, $same);
$this->assertSame($value, $this->uut->getFireEvents());
$this->assertSame($value, $this->uut->hasFireEvents());
}
/**

View File

@ -131,11 +131,11 @@ class ErrorHandlerTest extends TestCase
/**
* Tests the namesake method/feature
*/
public function testSetGetBypassPhpErrorHandling()
public function testSetHasBypassPhp()
{
$same = $this->uut->setBypassPhpErrorHandling(false);
$same = $this->uut->setBypassPhp(false);
$this->assertSame($this->uut, $same);
$this->assertFalse($this->uut->getBypassPhpErrorHandling());
$this->assertFalse($this->uut->hasBypassPhp());
}
/**

View File

@ -76,11 +76,11 @@ class ShutdownHandlerTest extends TestCase
/**
* Tests the namesake method/feature
*/
public function testSetGetForceExit()
public function testSetHasForceExit()
{
$same = $this->uut->setForceExit(false);
$this->assertSame($this->uut, $same);
$this->assertFalse($this->uut->getForceExit());
$this->assertFalse($this->uut->hasForceExit());
}
/**

View File

@ -105,12 +105,12 @@ class TwigRendererTest extends TestCase
/**
* Tests the namesake method/feature
*/
public function testSetGetFireEvents()
public function testSetHasFireEvents()
{
$value = false;
$same = $this->uut->setFireEvents($value);
$this->assertSame($this->uut, $same);
$this->assertEquals($value, $this->uut->getFireEvents());
$this->assertEquals($value, $this->uut->hasFireEvents());
}
/**