Work on code style.

yt-rest-api
Lio Novelli 2023-01-02 22:03:59 +01:00
parent 99d16c3a72
commit bbb22ab502
22 changed files with 225 additions and 179 deletions

View File

@ -30,14 +30,14 @@
"require-dev": {
"squizlabs/php_codesniffer": "^3.7",
"phpunit/phpunit": "^9.5",
"opsway/psr12-strict-coding-standard": "^0.5.0",
"opsway/psr12-strict-coding-standard": "^1.0",
"phpcompatibility/php-compatibility": "^9.3",
"phpstan/phpstan": "^1.9"
},
"scripts": {
"cs": "phpcs --colors --standard=PSR12",
"cbf": "phpcbf",
"phpstan": "phpstan analyze -l 5 src"
"cs": "vendor/bin/phpcs --colors",
"cbf": "vendor/bin/phpcbf",
"phpstan": "vendor/bin/phpstan analyze -l 5 src"
},
"config": {
"allow-plugins": {

166
app/composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "eb0c874610e45fa74d8ccc691f5bd9f8",
"content-hash": "dcf2d10608163dc9004a26e38e06a533",
"packages": [
{
"name": "doctrine/lexer",
@ -2603,27 +2603,27 @@
"packages-dev": [
{
"name": "dealerdirect/phpcodesniffer-composer-installer",
"version": "v0.7.1",
"version": "v0.7.2",
"source": {
"type": "git",
"url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git",
"reference": "fe390591e0241955f22eb9ba327d137e501c771c"
"reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/fe390591e0241955f22eb9ba327d137e501c771c",
"reference": "fe390591e0241955f22eb9ba327d137e501c771c",
"url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db",
"reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db",
"shasum": ""
},
"require": {
"composer-plugin-api": "^1.0 || ^2.0",
"php": ">=5.3",
"squizlabs/php_codesniffer": "^2.0 || ^3.0 || ^4.0"
"squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0"
},
"require-dev": {
"composer/composer": "*",
"phpcompatibility/php-compatibility": "^9.0",
"sensiolabs/security-checker": "^4.1.0"
"php-parallel-lint/php-parallel-lint": "^1.3.1",
"phpcompatibility/php-compatibility": "^9.0"
},
"type": "composer-plugin",
"extra": {
@ -2644,6 +2644,10 @@
"email": "franck.nijhof@dealerdirect.com",
"homepage": "http://www.frenck.nl",
"role": "Developer / IT Manager"
},
{
"name": "Contributors",
"homepage": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer/graphs/contributors"
}
],
"description": "PHP_CodeSniffer Standards Composer Installer Plugin",
@ -2655,6 +2659,7 @@
"codesniffer",
"composer",
"installer",
"phpcbf",
"phpcs",
"plugin",
"qa",
@ -2665,7 +2670,11 @@
"stylecheck",
"tests"
],
"time": "2020-12-07T18:04:37+00:00"
"support": {
"issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues",
"source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer"
},
"time": "2022-02-04T12:51:07+00:00"
},
{
"name": "doctrine/instantiator",
@ -2795,30 +2804,29 @@
},
{
"name": "opsway/psr12-strict-coding-standard",
"version": "0.5.0",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/opsway/psr12-strict-modern-standart.git",
"reference": "495d5109079f544ec46ec2f0e2161d48f62a6335"
"reference": "2ce8d92f35ed3c229b1da2668c7c02c490af95f4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/opsway/psr12-strict-modern-standart/zipball/495d5109079f544ec46ec2f0e2161d48f62a6335",
"reference": "495d5109079f544ec46ec2f0e2161d48f62a6335",
"url": "https://api.github.com/repos/opsway/psr12-strict-modern-standart/zipball/2ce8d92f35ed3c229b1da2668c7c02c490af95f4",
"reference": "2ce8d92f35ed3c229b1da2668c7c02c490af95f4",
"shasum": ""
},
"require": {
"dealerdirect/phpcodesniffer-composer-installer": "~0.6",
"php": "^7.3 || ^8.0",
"slevomat/coding-standard": "^6.1",
"squizlabs/php_codesniffer": "^3.5",
"webimpress/coding-standard": "^1.1"
"dealerdirect/phpcodesniffer-composer-installer": "~0.7",
"php": "^8.0",
"slevomat/coding-standard": "^7.0 || ^8.0",
"squizlabs/php_codesniffer": "^3.6 || ^4.0",
"webimpress/coding-standard": "^1.2"
},
"type": "phpcodesniffer-standard",
"extra": {
"branch-alias": {
"dev-master": "0.0.x-dev",
"dev-develop": "1.0.x-dev"
"dev-develop": "2.0.x-dev"
}
},
"autoload": {
@ -2836,7 +2844,13 @@
"opsway",
"psr12-strict"
],
"time": "2021-01-01T11:19:18+00:00"
"support": {
"docs": "https://github.com/opsway/psr12-strict-modern-standart/tree/master/docs",
"issues": "https://github.com/opsway/psr12-strict-modern-standart/issues",
"rss": "https://github.com/opsway/psr12-strict-modern-standart/releases.atom",
"source": "https://github.com/opsway/psr12-strict-modern-standart"
},
"time": "2022-10-22T12:21:38+00:00"
},
{
"name": "phar-io/manifest",
@ -3240,39 +3254,31 @@
},
{
"name": "phpstan/phpdoc-parser",
"version": "0.4.9",
"version": "1.15.3",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpdoc-parser.git",
"reference": "98a088b17966bdf6ee25c8a4b634df313d8aa531"
"reference": "61800f71a5526081d1b5633766aa88341f1ade76"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/98a088b17966bdf6ee25c8a4b634df313d8aa531",
"reference": "98a088b17966bdf6ee25c8a4b634df313d8aa531",
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/61800f71a5526081d1b5633766aa88341f1ade76",
"reference": "61800f71a5526081d1b5633766aa88341f1ade76",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
"php": "^7.2 || ^8.0"
},
"require-dev": {
"consistence/coding-standard": "^3.5",
"ergebnis/composer-normalize": "^2.0.2",
"jakub-onderka/php-parallel-lint": "^0.9.2",
"phing/phing": "^2.16.0",
"php-parallel-lint/php-parallel-lint": "^1.2",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^0.12.26",
"phpstan/phpstan-strict-rules": "^0.12",
"phpunit/phpunit": "^6.3",
"slevomat/coding-standard": "^4.7.2",
"symfony/process": "^4.0"
"phpstan/phpstan": "^1.5",
"phpstan/phpstan-phpunit": "^1.1",
"phpstan/phpstan-strict-rules": "^1.0",
"phpunit/phpunit": "^9.5",
"symfony/process": "^5.2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.4-dev"
}
},
"autoload": {
"psr-4": {
"PHPStan\\PhpDocParser\\": [
@ -3285,7 +3291,11 @@
"MIT"
],
"description": "PHPDoc parser with support for nullable, intersection and generic types",
"time": "2020-08-03T20:32:43+00:00"
"support": {
"issues": "https://github.com/phpstan/phpdoc-parser/issues",
"source": "https://github.com/phpstan/phpdoc-parser/tree/1.15.3"
},
"time": "2022-12-20T20:56:55+00:00"
},
{
"name": "phpstan/phpstan",
@ -4733,37 +4743,37 @@
},
{
"name": "slevomat/coding-standard",
"version": "6.4.1",
"version": "8.7.1",
"source": {
"type": "git",
"url": "https://github.com/slevomat/coding-standard.git",
"reference": "696dcca217d0c9da2c40d02731526c1e25b65346"
"reference": "c51edb898bebd36aac70a190c6a41a7c056bb5b9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/slevomat/coding-standard/zipball/696dcca217d0c9da2c40d02731526c1e25b65346",
"reference": "696dcca217d0c9da2c40d02731526c1e25b65346",
"url": "https://api.github.com/repos/slevomat/coding-standard/zipball/c51edb898bebd36aac70a190c6a41a7c056bb5b9",
"reference": "c51edb898bebd36aac70a190c6a41a7c056bb5b9",
"shasum": ""
},
"require": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7",
"php": "^7.1 || ^8.0",
"phpstan/phpdoc-parser": "0.4.5 - 0.4.9",
"squizlabs/php_codesniffer": "^3.5.6"
"php": "^7.2 || ^8.0",
"phpstan/phpdoc-parser": ">=1.15.0 <1.16.0",
"squizlabs/php_codesniffer": "^3.7.1"
},
"require-dev": {
"phing/phing": "2.16.3",
"php-parallel-lint/php-parallel-lint": "1.2.0",
"phpstan/phpstan": "0.12.48",
"phpstan/phpstan-deprecation-rules": "0.12.5",
"phpstan/phpstan-phpunit": "0.12.16",
"phpstan/phpstan-strict-rules": "0.12.5",
"phpunit/phpunit": "7.5.20|8.5.5|9.4.0"
"phing/phing": "2.17.4",
"php-parallel-lint/php-parallel-lint": "1.3.2",
"phpstan/phpstan": "1.4.10|1.9.3",
"phpstan/phpstan-deprecation-rules": "1.1.0",
"phpstan/phpstan-phpunit": "1.0.0|1.3.1",
"phpstan/phpstan-strict-rules": "1.4.4",
"phpunit/phpunit": "7.5.20|8.5.21|9.5.27"
},
"type": "phpcodesniffer-standard",
"extra": {
"branch-alias": {
"dev-master": "6.x-dev"
"dev-master": "8.x-dev"
}
},
"autoload": {
@ -4776,7 +4786,25 @@
"MIT"
],
"description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.",
"time": "2020-10-05T12:39:37+00:00"
"keywords": [
"dev",
"phpcs"
],
"support": {
"issues": "https://github.com/slevomat/coding-standard/issues",
"source": "https://github.com/slevomat/coding-standard/tree/8.7.1"
},
"funding": [
{
"url": "https://github.com/kukulich",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/slevomat/coding-standard",
"type": "tidelift"
}
],
"time": "2022-12-14T08:49:18+00:00"
},
{
"name": "squizlabs/php_codesniffer",
@ -4886,24 +4914,24 @@
},
{
"name": "webimpress/coding-standard",
"version": "1.2.1",
"version": "1.2.4",
"source": {
"type": "git",
"url": "https://github.com/webimpress/coding-standard.git",
"reference": "fbeb31ee876b3c493779d3aa717ebb57ef258e6a"
"reference": "cd0c4b0b97440c337c1f7da17b524674ca2f9ca9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/webimpress/coding-standard/zipball/fbeb31ee876b3c493779d3aa717ebb57ef258e6a",
"reference": "fbeb31ee876b3c493779d3aa717ebb57ef258e6a",
"url": "https://api.github.com/repos/webimpress/coding-standard/zipball/cd0c4b0b97440c337c1f7da17b524674ca2f9ca9",
"reference": "cd0c4b0b97440c337c1f7da17b524674ca2f9ca9",
"shasum": ""
},
"require": {
"php": "^7.3 || ^8.0",
"squizlabs/php_codesniffer": "^3.5.8"
"squizlabs/php_codesniffer": "^3.6.2"
},
"require-dev": {
"phpunit/phpunit": "^9.4.3"
"phpunit/phpunit": "^9.5.13"
},
"type": "phpcodesniffer-standard",
"extra": {
@ -4927,7 +4955,17 @@
"psr-12",
"webimpress"
],
"time": "2021-01-11T18:13:55+00:00"
"support": {
"issues": "https://github.com/webimpress/coding-standard/issues",
"source": "https://github.com/webimpress/coding-standard/tree/1.2.4"
},
"funding": [
{
"url": "https://github.com/michalbundyra",
"type": "github"
}
],
"time": "2022-02-15T19:52:12+00:00"
},
{
"name": "webmozart/assert",

View File

@ -12,9 +12,13 @@
<arg value="p"/>
<!-- Paths to check -->
<file>tests</file>
<file>src</file>
<file>test</file>
<!-- Include all rules from the Zend Coding Standard -->
<rule ref="OpsWayStrictPSR12CodingStandard"/>
<rule ref="OpsWayStrictPSR12CodingStandard">
<exclude name="Generic.NamingConventions.CamelCapsVariableName.Invalid" />
<exclude name="Squiz.NamingConventions.ValidVariableName" />
<exclude name="WebimpressCodingStandard.NamingConventions.ValidVariableName" />
</rule>
</ruleset>

View File

@ -27,10 +27,10 @@ use function explode;
use function is_array;
use function is_null;
use function is_string;
use function PHPUnit\Framework\throwException;
use function readline;
use function strpos;
use function strtolower;
use function sys_get_temp_dir;
use function var_dump;
use function var_export;
@ -276,7 +276,7 @@ class InvoiceCommand extends Command
$rows[] = new TableSeparator();
// @TODO Check rate in final result.
// $rows[] = [$this->translator->trans('Sum'), $totalHours, $config['price'], $totalPrice];
$rows[] = ['Sum', $totalHours, NULL, $totalPrice];
$rows[] = ['Sum', $totalHours, null, $totalPrice];
$table->setRows($rows);
return $table;
@ -345,9 +345,8 @@ class InvoiceCommand extends Command
} elseif ($type === self::TYPE_EXPENSE) {
$message_name = 'Enter expenses name or leave empty to stop: ';
$message_value = 'Enter expenses value: ';
}
else {
throw new \Exception('Unknown type of custom data.');
} else {
throw new Exception('Unknown type of custom data.');
}
while ($continue) {
$name = readline($message_name);

View File

@ -114,7 +114,7 @@ class CsvReport implements CsvReportInterface
$rows[] = [
'Gesamt netto',
number_format($totalHours, 2, ',', '.'),
NULL,
null,
number_format($totalPrice, 2, ',', '.'),
];
$rows[] = [null, null, 'Gessamt brutto', number_format($totalPrice, 2, ',', '.')];

View File

@ -17,7 +17,6 @@ use function explode;
use function fgetcsv;
use function fopen;
use function implode;
use function is_array;
use function is_numeric;
use function number_format;
use function preg_match;
@ -131,7 +130,7 @@ class ReportCsv implements ReportCsvInterface
'Gesamt netto',
number_format($totalHours, 2, ',', '.'),
' ',
number_format($totalPrice, 2, ',', '.')
number_format($totalPrice, 2, ',', '.'),
];
$add_separator = false;
}
@ -202,7 +201,7 @@ class ReportCsv implements ReportCsvInterface
0,
0,
[],
[$explodeMinus($data[0]['id'])]
[$explodeMinus($data[0]['id'])],
];
foreach ($data as $line) {
$project = $explodeMinus($line['id']);

View File

@ -7,8 +7,8 @@ namespace RprtCli\Utils\Mailer;
/**
* Methods for symfony (swift)mailer service.
*/
interface MailerInterface {
interface MailerInterface
{
/**
* Recipients for message.
*

View File

@ -4,12 +4,15 @@ declare(strict_types=1);
namespace RprtCli\Tests\Kernel;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
use DI\ContainerBuilder;
use PHPUnit\Framework\TestCase;
use RprtCli\Commands\InvoiceCommand;
use RprtCli\Commands\ReportCommand;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
use function file_exists;
use function unlink;
/**
* Report and invoice command test.
@ -17,8 +20,8 @@ use RprtCli\Commands\ReportCommand;
* Does not cover the part of talking to the api, nor does it yet cover email
* and pdf generation. @TODO
*/
class ReportCommandTest extends TestCase {
class ReportCommandTest extends TestCase
{
protected const INPUT_CSV_FILE = __DIR__ . '/../data/21-03.csv';
protected const REPORT_OUTPUT_FILE = __DIR__ . '/../data/report-21-03.txt';
@ -30,7 +33,8 @@ class ReportCommandTest extends TestCase {
/**
* Run report and invoice command with file option parameter. Check if pdf was generated.
*/
public function testExecute() {
public function testExecute()
{
$builder = new ContainerBuilder();
$builder->addDefinitions(__DIR__ . '/../test-dependencies.php');
$container = $builder->build();
@ -42,7 +46,6 @@ class ReportCommandTest extends TestCase {
$reportCommand = $container->get(ReportCommand::class);
$application->add($reportCommand);
$reportCommand = $application->find('report');
$reportCommandTester = new CommandTester($reportCommand);
$reportCommandTester->execute([
@ -70,7 +73,7 @@ class ReportCommandTest extends TestCase {
$invoiceCommandTester = new CommandTester($invoiceCommand);
$invoiceCommandTester->execute([
'--file' => self::INPUT_CSV_FILE,
'--pdf' => TRUE,
'--pdf' => true,
'--output' => self::INVOICE_OUTPUT_PDF,
]);
@ -83,5 +86,4 @@ class ReportCommandTest extends TestCase {
$this->assertStringEqualsFile(self::INVOICE_OUTPUT_FILE, $invoice_output);
$this->assertFileExists(self::INVOICE_OUTPUT_PDF);
}
}

View File

@ -1,6 +1,8 @@
<?php
$dependencies = require_once(__DIR__ . '/../dependencies.php');
declare(strict_types=1);
$dependencies = require_once __DIR__ . '/../dependencies.php';
$dependencies['config.path'] = __DIR__ . '/data/';

View File

@ -12,13 +12,15 @@ TODO:
------------------------
- phing for build automation
- add ddev for dockerization
- invoice command improvements
- pdf and output option could be combined
TODO (end of 2022):
- DONE fix project list output (first is missing)
- DONE report selection trait
- DONE automated tests
- DONE phpcs
- phpstan
- DONE phpstan (level 5)
OPTIONAL:
- phing build system to run quality assurance
- DONE fix -y parameter in invoice