diff --git a/app/composer.json b/app/composer.json
index 0a7a2ef..0e679bf 100644
--- a/app/composer.json
+++ b/app/composer.json
@@ -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": {
diff --git a/app/composer.lock b/app/composer.lock
index eb35a5a..c8af7f2 100644
--- a/app/composer.lock
+++ b/app/composer.lock
@@ -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",
diff --git a/app/phpcs.xml b/app/phpcs.xml
index 7264bbf..50e669d 100644
--- a/app/phpcs.xml
+++ b/app/phpcs.xml
@@ -7,14 +7,18 @@
{$cell} | "; } @@ -106,7 +106,7 @@ class PdfExportService implements PdfExportInterface return $table; } - public function replaceTokensInTemplate(string $template_path, array $tokens): ?string + public function replaceTokensInTemplate(string $template_path, array $tokens) : ?string { $template = file_get_contents($template_path); foreach ($tokens as $key => $value) { @@ -116,7 +116,7 @@ class PdfExportService implements PdfExportInterface } // @TODO write a method to gather tokens. - public function getTokensInTemplate(string $template): array + public function getTokensInTemplate(string $template) : array { // @TODO find substrings of type [[key]] preg_match_all('/\[\[([a-z0-9-_]+)\]\]/', $template, $match); @@ -144,7 +144,7 @@ class PdfExportService implements PdfExportInterface bool $skip_missing = false, array $runtime_tokens = [], string $config = 'export.tokens' - ): array { + ) : array { [$tokens, $missing] = [[], []]; $token_keys = $this->getTokensInTemplate(file_get_contents($template_path)); $config_tokens = $this->config->get($config); @@ -162,7 +162,7 @@ class PdfExportService implements PdfExportInterface return $tokens; } - public function pdfExport(string $html, $output = null): bool + public function pdfExport(string $html, $output = null) : bool { $this->mpdf->SetProtection(['print']); // @TODO make configurable. @@ -187,12 +187,12 @@ class PdfExportService implements PdfExportInterface return $output; } - public function setOutput(string $path): void + public function setOutput(string $path) : void { $this->output = $path; } - public function fromDefaultDataToPdf(array $data, array $tokens = []): string + public function fromDefaultDataToPdf(array $data, array $tokens = []) : string { $template_path = $this->getTemplatePath(); $tokens = $this->defaultTokens(); @@ -209,7 +209,7 @@ class PdfExportService implements PdfExportInterface /** * Get default tokens. */ - protected function defaultTokens(): array + protected function defaultTokens() : array { $tokens = []; $tokens['today'] = date('j. m. y'); diff --git a/app/src/Utils/TimeTrackingServices/YoutrackInterface.php b/app/src/Utils/TimeTrackingServices/YoutrackInterface.php index cd790aa..cb29e19 100644 --- a/app/src/Utils/TimeTrackingServices/YoutrackInterface.php +++ b/app/src/Utils/TimeTrackingServices/YoutrackInterface.php @@ -9,12 +9,12 @@ interface YoutrackInterface /** * Check if client can sign into youtrack with provided token. */ - public function testYoutrackapi(): ?string; + public function testYoutrackapi() : ?string; /** * Get the id of the report from configuration. */ - public function getReportId(): ?string; + public function getReportId() : ?string; /** * Downloads report and returns file path. @@ -25,7 +25,7 @@ interface YoutrackInterface * * If fetch was unsuccssefull return false, otherwise the file path. */ - public function downloadReport(string $report_id): ?string; + public function downloadReport(string $report_id) : ?string; /** * Get a list of reports. @@ -33,16 +33,16 @@ interface YoutrackInterface * * Array of reports with ids as keys and names as values. */ - public function listReports(): array; + public function listReports() : array; - public function setReportId(string $report_id): void; + public function setReportId(string $report_id) : void; - public function setReportName(?string $report_name = null): void; + public function setReportName(?string $report_name = null) : void; - public function getReportName(): ?string; + public function getReportName() : ?string; /** * Clears cache for youtrack report. */ - public function clearReportCache(string $report_id): int; + public function clearReportCache(string $report_id) : int; } diff --git a/app/src/Utils/TimeTrackingServices/YoutrackService.php b/app/src/Utils/TimeTrackingServices/YoutrackService.php index d333553..ab138dd 100644 --- a/app/src/Utils/TimeTrackingServices/YoutrackService.php +++ b/app/src/Utils/TimeTrackingServices/YoutrackService.php @@ -44,7 +44,7 @@ class YoutrackService implements YoutrackInterface $this->httpClient = $http_client; } - public function testYoutrackapi(): ?string + public function testYoutrackapi() : ?string { // Get base url from config or add input. // Get token or add input. @@ -88,7 +88,7 @@ class YoutrackService implements YoutrackInterface ]; } - public function getReportId(): ?string + public function getReportId() : ?string { // --report option value should take precedence. // @TODO error handling. @@ -102,12 +102,12 @@ class YoutrackService implements YoutrackInterface return $yt_report_id; } - public function setReportId(string $report_id): void + public function setReportId(string $report_id) : void { $this->report_id = $report_id; } - public function setReportName(?string $report_name = null): void + public function setReportName(?string $report_name = null) : void { if (! $report_name) { $reports = $this->listReports(); @@ -120,12 +120,12 @@ class YoutrackService implements YoutrackInterface $this->reportName = $report_name; } - public function getReportName(): ?string + public function getReportName() : ?string { return $this->reportName; } - public function downloadReport(string $report_id): ?string + public function downloadReport(string $report_id) : ?string { $path = "youtrack/api/reports/$report_id/export/csv"; $query = ['$top' => -1]; @@ -161,7 +161,7 @@ class YoutrackService implements YoutrackInterface throw new Exception("Unable to download report {$report_id}!"); } - protected function getYtToken(): string + protected function getYtToken() : string { if (isset($this->ytToken)) { return $this->ytToken; @@ -173,12 +173,12 @@ class YoutrackService implements YoutrackInterface return $yt_token; } - public function setYtToken(string $token): void + public function setYtToken(string $token) : void { $this->ytToken = $token; } - protected function getYtUrl(string $path = ''): ?string + protected function getYtUrl(string $path = '') : ?string { if (isset($this->ytBaseUrl)) { $yt_base_url = $this->ytBaseUrl; @@ -199,7 +199,7 @@ class YoutrackService implements YoutrackInterface $this->ytBaseUrl = $base_url; } - public function listReports(): array + public function listReports() : array { // Now filter results by own = true; $url = '/youtrack/api/reports'; @@ -218,11 +218,11 @@ class YoutrackService implements YoutrackInterface return $reports; } - public function clearReportCache(string $report_id): int + public function clearReportCache(string $report_id) : int { $path = "/youtrack/api/reports/${report_id}/status"; $query = [ - '$top' => -1, + '$top' => -1, // phpcs:ignore 'fields' => 'calculationInProgress,error(id),errorMessage,isOutdated,lastCalculated,progress,wikifiedErrorMessage', ]; diff --git a/app/tests/Kernel/ReportCommandTest.php b/app/tests/Kernel/ReportCommandTest.php index fcedf53..c9ee2ed 100644 --- a/app/tests/Kernel/ReportCommandTest.php +++ b/app/tests/Kernel/ReportCommandTest.php @@ -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,8 +46,7 @@ class ReportCommandTest extends TestCase { $reportCommand = $container->get(ReportCommand::class); $application->add($reportCommand); - - $reportCommand = $application->find('report'); + $reportCommand = $application->find('report'); $reportCommandTester = new CommandTester($reportCommand); $reportCommandTester->execute([ // pass arguments to the helper @@ -66,11 +69,11 @@ class ReportCommandTest extends TestCase { if (file_exists(self::INVOICE_OUTPUT_PDF)) { unlink(self::INVOICE_OUTPUT_PDF); } - $invoiceCommand = $application->find('invoice'); + $invoiceCommand = $application->find('invoice'); $invoiceCommandTester = new CommandTester($invoiceCommand); $invoiceCommandTester->execute([ - '--file' => self::INPUT_CSV_FILE, - '--pdf' => TRUE, + '--file' => self::INPUT_CSV_FILE, + '--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); } - } diff --git a/app/tests/test-dependencies.php b/app/tests/test-dependencies.php index 8424b58..1697d6a 100644 --- a/app/tests/test-dependencies.php +++ b/app/tests/test-dependencies.php @@ -1,6 +1,8 @@
---|