Add code style checks.

master
Lio Novelli 2021-04-08 19:23:19 +02:00
parent b6e5502372
commit 0346b9f29d
6 changed files with 2011 additions and 5 deletions

3
.gitignore vendored
View File

@ -1,3 +1,4 @@
/app/vendor
/resources/data
/scratch
/scratch
.phpcs-cache

View File

@ -25,5 +25,14 @@
"psr-4": {
"RprtCli\\": "src"
}
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.5",
"phpunit/phpunit": "^9.5",
"opsway/psr12-strict-coding-standard": "^0.5.0"
},
"scripts": {
"cs": "phpcs",
"cbf": "phpcbf"
}
}

1978
app/composer.lock generated

File diff suppressed because it is too large Load Diff

20
app/phpcs.xml 100644
View File

@ -0,0 +1,20 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
<arg name="basepath" value="."/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="10"/>
<!-- Show progress -->
<arg value="p"/>
<!-- Paths to check -->
<file>src</file>
<file>test</file>
<!-- Include all rules from the Zend Coding Standard -->
<rule ref="OpsWayStrictPSR12CodingStandard"/>
</ruleset>

View File

@ -48,14 +48,17 @@ class RprtCommand extends Command {
return Command::SUCCESS;
}
/**
* Create table from data that is already inline with configuration.
*/
protected function generateTable($output, $data) {
$table = new Table($output);
$table->setHeaders(['Project', 'Hours', 'Rate', 'Price']);
list($rows, $total_hours, $total_price) = [[], 0, 0];
$projects_config = $this->configuration->get('projects');
var_dump($projects_config);
foreach ($projects_config as $name => $config) {
if (!isset($data[$name])) {
// @TODO Proper error handling.
var_dump('Project ' . $name . ' is not set!');
continue;
}

View File

@ -77,7 +77,6 @@ class ConfigurationService implements ConfigurationInterface
*/
public function getConfig() {
if ($this->configFilePath) {
var_dump($this->configFilePath);
$config = Yaml::parseFile($this->configFilePath);
$this->data = $config;
return TRUE;