Skip to content

Commit 82008fb

Browse files
authored
fixed compatibility with Kimai 1.17 (#2)
1 parent 8467d12 commit 82008fb

File tree

11 files changed

+86
-71
lines changed

11 files changed

+86
-71
lines changed

.github/workflows/linting.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
php: ['7.2','7.3','7.4']
12+
php: ['7.4', '8.0']
1313

1414
name: Linting - PHP ${{ matrix.php }}
1515
steps:
@@ -20,6 +20,6 @@ jobs:
2020
coverage: none
2121
extensions: intl
2222
- run: composer install --no-progress
23-
- run: composer validate
23+
- run: composer validate --strict --no-check-version
2424
- run: composer codestyle-check
2525
- run: composer phpstan

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.idea
22
.disabled
33
/vendor/
4-
.php_cs.cache
4+
.php-cs-fixer.cache
55
composer.lock

.php_cs.dist renamed to .php-cs-fixer.dist.php

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
file that was distributed with this source code.
99
COMMENT;
1010

11-
return PhpCsFixer\Config::create()
11+
$fixer = new PhpCsFixer\Config();
12+
$fixer
1213
->setRiskyAllowed(true)
1314
->setRules([
1415
'encoding' => true,
@@ -20,7 +21,7 @@
2021
'function_declaration' => true,
2122
'indentation_type' => true,
2223
'line_ending' => true,
23-
'lowercase_constants' => true,
24+
'constant_case' => ['case' => 'lower'],
2425
'lowercase_keywords' => true,
2526
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
2627
'header_comment' => ['header' => $fileHeaderComment, 'separate' => 'both'],
@@ -47,7 +48,7 @@
4748
'statements' => ['return'],
4849
],
4950
'cast_spaces' => true,
50-
'class_attributes_separation' => ['elements' => ['method']],
51+
'class_attributes_separation' => ['elements' => ['method' => 'one']],
5152
'concat_space' => ['spacing' => 'one'],
5253
'declare_equal_normalize' => true,
5354
'function_typehint_space' => true,
@@ -101,10 +102,10 @@
101102
],
102103
'phpdoc_annotation_without_dot' => true,
103104
'phpdoc_indent' => true,
104-
'phpdoc_inline_tag' => true,
105+
'phpdoc_inline_tag_normalizer' => true,
105106
'phpdoc_no_access' => true,
106107
'phpdoc_no_alias_tag' => true,
107-
'phpdoc_no_empty_return' => true,
108+
'phpdoc_no_empty_return' => false,
108109
'phpdoc_no_package' => true,
109110
'phpdoc_no_useless_inheritdoc' => true,
110111
'phpdoc_return_self_reference' => true,
@@ -131,7 +132,7 @@
131132
'standardize_increment' => true,
132133
'standardize_not_equals' => true,
133134
'ternary_operator_spaces' => true,
134-
'trailing_comma_in_multiline_array' => false,
135+
'trailing_comma_in_multiline' => false,
135136
'trim_array_spaces' => true,
136137
'unary_operator_spaces' => true,
137138
'whitespace_after_comma_in_array' => true,
@@ -142,6 +143,18 @@
142143
'method',
143144
'property',
144145
]],
146+
'native_function_invocation' => [
147+
'include' => [
148+
'@compiler_optimized'
149+
],
150+
'scope' => 'namespaced'
151+
],
152+
'native_function_type_declaration_casing' => true,
153+
'no_alias_functions' => [
154+
'sets' => [
155+
'@internal'
156+
]
157+
],
145158
])
146159
->setFinder(
147160
PhpCsFixer\Finder::create()
@@ -150,7 +163,10 @@
150163
])->exclude([
151164
__DIR__ . '/Resources/',
152165
__DIR__ . '/vendor/',
166+
__DIR__ . '/.github/',
153167
])
154168
)
155169
->setFormat('checkstyle')
156170
;
171+
172+
return $fixer;

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 1.0
4+
5+
Compatible with Kimai 1.17
6+
7+
- Fixed: format was not working with Kimai 1.16
8+
39
## 0.2
410

511
Compatible with Kimai 1.11

DependencyInjection/InvoiceFormatFixationExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class InvoiceFormatFixationExtension extends AbstractPluginExtension
2323
* @param ContainerBuilder $container
2424
* @throws Exception
2525
*/
26-
public function load(array $configs, ContainerBuilder $container)
26+
public function load(array $configs, ContainerBuilder $container): void
2727
{
2828
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
2929
$loader->load('services.yaml');

EventSubscriber/InvoicePreRenderSubscriber.php

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,16 @@
1010

1111
namespace KimaiPlugin\InvoiceFormatFixationBundle\EventSubscriber;
1212

13-
use App\Configuration\LanguageFormattings;
1413
use App\Configuration\SystemConfiguration;
1514
use App\Event\InvoicePreRenderEvent;
16-
use App\Invoice\DefaultInvoiceFormatter;
1715
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1816

1917
final class InvoicePreRenderSubscriber implements EventSubscriberInterface
2018
{
21-
/**
22-
* @var LanguageFormattings
23-
*/
24-
private $formatter;
25-
/**
26-
* @var SystemConfiguration
27-
*/
2819
private $configuration;
2920

30-
public function __construct(LanguageFormattings $formatter, SystemConfiguration $configuration)
21+
public function __construct(SystemConfiguration $configuration)
3122
{
32-
$this->formatter = $formatter;
3323
$this->configuration = $configuration;
3424
}
3525

@@ -40,16 +30,14 @@ public static function getSubscribedEvents(): array
4030
];
4131
}
4232

43-
public function configureFormatter(InvoicePreRenderEvent $event)
33+
public function configureFormatter(InvoicePreRenderEvent $event): void
4434
{
4535
$language = $this->configuration->find('invoice.formatter_language');
4636

4737
if (empty($language)) {
4838
return;
4939
}
5040

51-
$formatter = new DefaultInvoiceFormatter($this->formatter, $language);
52-
53-
$event->getModel()->setFormatter($formatter);
41+
$event->getModel()->getFormatter()->setLocale($language);
5442
}
5543
}

EventSubscriber/SystemConfigurationSubscriber.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,22 @@
1212

1313
use App\Event\SystemConfigurationEvent;
1414
use App\Form\Model\Configuration;
15-
use App\Form\Model\SystemConfiguration as SystemConfigurationModel;
1615
use App\Form\Type\LanguageType;
1716
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1817

1918
final class SystemConfigurationSubscriber implements EventSubscriberInterface
2019
{
21-
public static function getSubscribedEvents()
20+
public static function getSubscribedEvents(): array
2221
{
2322
return [
2423
SystemConfigurationEvent::class => ['onSystemConfiguration', 100],
2524
];
2625
}
2726

28-
public function onSystemConfiguration(SystemConfigurationEvent $event)
27+
public function onSystemConfiguration(SystemConfigurationEvent $event): void
2928
{
3029
foreach ($event->getConfigurations() as $configuration) {
31-
if ($configuration->getSection() !== SystemConfigurationModel::SECTION_FORM_INVOICE) {
30+
if ($configuration->getSection() !== 'invoice') {
3231
continue;
3332
}
3433

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
3-
<file source-language="en" target-language="de" datatype="plaintext" original="system-configuration.en.xlf">
4-
<body>
5-
<trans-unit id="label.invoice.formatter_language">
6-
<source>label.invoice.formatter_language</source>
7-
<target>Sprache für Formatierungen</target>
8-
</trans-unit>
9-
<trans-unit id="help.invoice.formatter_language">
10-
<source>help.invoice.formatter_language</source>
11-
<target>Die gewählte Sprache wird genutzt um Datums-, Zeit- und Geldwerte zu formatieren. Die Sprache der Rechnungsvorlage wird danach nur noch für Übersetzungen verwendet.</target>
12-
</trans-unit>
13-
</body>
14-
</file>
2+
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
3+
<file source-language="en" target-language="de" datatype="plaintext" original="system-configuration.en.xlf">
4+
<body>
5+
<trans-unit id="iEnbw47" resname="label.invoice.formatter_language">
6+
<source>label.invoice.formatter_language</source>
7+
<target>Sprache für Formatierungen</target>
8+
</trans-unit>
9+
<trans-unit id="QysT_tz" resname="help.invoice.formatter_language">
10+
<source>help.invoice.formatter_language</source>
11+
<target>Die gewählte Sprache wird genutzt um Datums-, Zeit- und Geldwerte zu formatieren. Die Sprache der Rechnungsvorlage wird danach nur noch für Übersetzungen verwendet.</target>
12+
</trans-unit>
13+
</body>
14+
</file>
1515
</xliff>
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
3-
<file source-language="en" target-language="de" datatype="plaintext" original="system-configuration.en.xlf">
4-
<body>
5-
<trans-unit id="label.invoice.formatter_language">
6-
<source>label.invoice.formatter_language</source>
7-
<target>Language for formatting</target>
8-
</trans-unit>
9-
<trans-unit id="help.invoice.formatter_language">
10-
<source>help.invoice.formatter_language</source>
11-
<target>The selected language is used to format date, time and money values. The language of the invoice template will only be used for translations.</target>
12-
</trans-unit>
13-
</body>
14-
</file>
2+
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
3+
<file source-language="en" target-language="de" datatype="plaintext" original="system-configuration.en.xlf">
4+
<body>
5+
<trans-unit id="iEnbw47" resname="label.invoice.formatter_language">
6+
<source>label.invoice.formatter_language</source>
7+
<target>Language for formatting</target>
8+
</trans-unit>
9+
<trans-unit id="QysT_tz" resname="help.invoice.formatter_language">
10+
<source>help.invoice.formatter_language</source>
11+
<target>The selected language is used to format date, time and money values. The language of the invoice template will only be used for translations.</target>
12+
</trans-unit>
13+
</body>
14+
</file>
1515
</xliff>

composer.json

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Kimai extension to configure a language, which will be used to format money, date and time values in invoices",
44
"homepage": "https://www.kimai.org/store/invoice-format-fixation-bundle.html",
55
"type": "kimai-plugin",
6-
"version": "0.2",
6+
"version": "1.0",
77
"keywords": [
88
"kimai",
99
"kimai-plugin"
@@ -22,8 +22,12 @@
2222
}
2323
},
2424
"config": {
25+
"allow-plugins": {
26+
"composer/package-versions-deprecated": false,
27+
"symfony/flex": false
28+
},
2529
"platform": {
26-
"php": "7.2.9"
30+
"php": "7.3"
2731
},
2832
"preferred-install": {
2933
"*": "dist"
@@ -32,26 +36,26 @@
3236
},
3337
"extra": {
3438
"kimai": {
35-
"require": "1.11",
36-
"version": "0.2",
39+
"require": "1.17",
3740
"name": "Invoice format fixation"
3841
}
3942
},
4043
"scripts": {
41-
"codestyle": "php-cs-fixer fix --dry-run --verbose --show-progress=none",
42-
"codestyle-fix": "php-cs-fixer fix",
43-
"codestyle-check": "vendor/bin/php-cs-fixer fix --dry-run --verbose --config=.php_cs.dist --using-cache=no --show-progress=none --format=checkstyle",
44+
"codestyle": "vendor/bin/php-cs-fixer fix --dry-run --verbose --show-progress=none",
45+
"codestyle-fix": "vendor/bin/php-cs-fixer fix",
46+
"codestyle-check": "vendor/bin/php-cs-fixer fix --dry-run --verbose --using-cache=no --show-progress=none --format=checkstyle",
4447
"phpstan": "vendor/bin/phpstan analyse . -c phpstan.neon --level=7",
4548
"linting": [
46-
"composer validate",
49+
"composer validate --strict --no-check-version",
4750
"@codestyle-check",
4851
"@phpstan"
4952
]
5053
},
5154
"require-dev": {
52-
"friendsofphp/php-cs-fixer": "^2.15",
53-
"phpstan/phpstan": "^0.12.19",
54-
"kevinpapst/kimai2": "^1.11",
55+
"friendsofphp/php-cs-fixer": "^3.0",
56+
"phpstan/phpstan": "^1.0",
57+
"phpstan/phpstan-symfony": "^1.0",
58+
"kevinpapst/kimai2": "dev-master",
5559
"symfony/console": "^4.0",
5660
"symfony/event-dispatcher": "^4.0"
5761
}

0 commit comments

Comments
 (0)