Skip to content

Commit 1550ee1

Browse files
committed
fix: align quality and release checks for ci
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 66de3df commit 1550ee1

8 files changed

Lines changed: 55 additions & 29 deletions

File tree

.github/release-drafter.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
name-template: 'v$RESOLVED_VERSION'
22
tag-template: 'v$RESOLVED_VERSION'
3+
template: |
4+
## Changes
5+
6+
$CHANGES
7+
8+
## Contributors
9+
10+
$CONTRIBUTORS
311
change-template: '- $TITLE (#$NUMBER)'
412
categories:
513
- title: 'Features'

REUSE.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,9 @@ path = ["src/**", "tests/**", "benchmarks/**", "scripts/**", ".github/**", "*.ph
1414
precedence = "override"
1515
SPDX-FileCopyrightText = "2026 LibreSign"
1616
SPDX-License-Identifier = "AGPL-3.0-or-later"
17+
18+
[[annotations]]
19+
path = ["phpunit.xml.dist", "vendor-bin/**/composer.json"]
20+
precedence = "override"
21+
SPDX-FileCopyrightText = "2026 LibreSign"
22+
SPDX-License-Identifier = "AGPL-3.0-or-later"

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"config": {
3131
"sort-packages": true,
3232
"allow-plugins": {
33-
"bamarni/composer-bin-plugin": true
33+
"bamarni/composer-bin-plugin": true,
34+
"infection/extension-installer": true
3435
}
3536
},
3637
"extra": {

phpmd.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 https://pmd.github.io/pmd-6.55.0/ruleset_xml_schema.xsd">
66
<description>PHPMD baseline ruleset.</description>
7-
<rule ref="rulesets/cleancode.xml"/>
7+
<rule ref="rulesets/cleancode.xml">
8+
<exclude name="ErrorControlOperator"/>
9+
</rule>
810
<rule ref="rulesets/codesize.xml"/>
911
<rule ref="rulesets/design.xml"/>
10-
<rule ref="rulesets/naming.xml"/>
12+
<rule ref="rulesets/naming.xml">
13+
<exclude name="ShortVariable"/>
14+
</rule>
1115
</ruleset>

src/Integration/SignatureAppearanceXObjectAdapter.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ final class SignatureAppearanceXObjectAdapter
1111
/**
1212
* Output compatible with consumers expecting stream/resources pair.
1313
*
14-
* @return array{stream: string, resources: array<string, mixed>, bbox: array{0: float, 1: float, 2: float, 3: float}}
14+
* @return array{
15+
* stream: string,
16+
* resources: array<string, mixed>,
17+
* bbox: array{0: float, 1: float, 2: float, 3: float}
18+
* }
1519
*/
1620
public function toPdfSignerPayload(CompileResult $result): array
1721
{

src/Layout/LinearLayoutEngine.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,10 @@
77
use LibreSign\XObjectTemplate\Css\InlineStyleParser;
88
use LibreSign\XObjectTemplate\Html\Node;
99

10-
final class LinearLayoutEngine
10+
final readonly class LinearLayoutEngine
1111
{
12-
private InlineStyleParser $styleParser;
13-
14-
public function __construct(?InlineStyleParser $styleParser = null)
12+
public function __construct(private InlineStyleParser $styleParser = new InlineStyleParser())
1513
{
16-
$this->styleParser = $styleParser ?? new InlineStyleParser();
1714
}
1815

1916
/**
@@ -35,9 +32,15 @@ public function layout(array $nodes, float $width, float $height): LayoutResult
3532

3633
$cursorY -= ($margin['top'] + $padding['top']);
3734

38-
$fontSize = $this->toPoints($style->get('font-size', '10'));
39-
$lineHeight = max($fontSize * 1.2, $this->toPoints($style->get('line-height', (string) ($fontSize * 1.2))));
40-
$fontAlias = $this->resolveFontAlias((string) $style->get('font-family', 'helvetica'), (string) $style->get('font-weight', 'normal'));
35+
$fontSize = $this->toPoints((string) $style->get('font-size', '10'));
36+
$lineHeight = max(
37+
$fontSize * 1.2,
38+
$this->toPoints((string) $style->get('line-height', (string) ($fontSize * 1.2))),
39+
);
40+
$fontAlias = $this->resolveFontAlias(
41+
(string) $style->get('font-family', 'helvetica'),
42+
(string) $style->get('font-weight', 'normal'),
43+
);
4144

4245
$boxWidth = $this->toPoints((string) $style->get('width', '0'));
4346
if ($boxWidth <= 0) {

src/XObjectTemplateCompiler.php

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,14 @@
1212
use LibreSign\XObjectTemplate\Pdf\ColorParser;
1313
use LibreSign\XObjectTemplate\Pdf\PdfEscaper;
1414

15-
final class XObjectTemplateCompiler implements XObjectTemplateCompilerInterface
15+
final readonly class XObjectTemplateCompiler implements XObjectTemplateCompilerInterface
1616
{
17-
private SubsetHtmlParser $htmlParser;
18-
private LinearLayoutEngine $layoutEngine;
19-
private PdfEscaper $pdfEscaper;
20-
private ColorParser $colorParser;
21-
2217
public function __construct(
23-
?SubsetHtmlParser $htmlParser = null,
24-
?LinearLayoutEngine $layoutEngine = null,
25-
?PdfEscaper $pdfEscaper = null,
26-
?ColorParser $colorParser = null,
18+
private SubsetHtmlParser $htmlParser = new SubsetHtmlParser(),
19+
private LinearLayoutEngine $layoutEngine = new LinearLayoutEngine(),
20+
private PdfEscaper $pdfEscaper = new PdfEscaper(),
21+
private ColorParser $colorParser = new ColorParser(),
2722
) {
28-
$this->htmlParser = $htmlParser ?? new SubsetHtmlParser();
29-
$this->layoutEngine = $layoutEngine ?? new LinearLayoutEngine();
30-
$this->pdfEscaper = $pdfEscaper ?? new PdfEscaper();
31-
$this->colorParser = $colorParser ?? new ColorParser();
3223
}
3324

3425
public function compile(CompileRequest $request): CompileResult
@@ -42,7 +33,14 @@ public function compile(CompileRequest $request): CompileResult
4233
$stream[] = 'q';
4334

4435
foreach ($layout->images as $image) {
45-
$stream[] = sprintf('q %F 0 0 %F %F %F cm /%s Do Q', $image->width, $image->height, $image->x, $image->y, $image->alias);
36+
$stream[] = sprintf(
37+
'q %F 0 0 %F %F %F cm /%s Do Q',
38+
$image->width,
39+
$image->height,
40+
$image->x,
41+
$image->y,
42+
$image->alias,
43+
);
4644
}
4745

4846
$stream[] = 'BT';

tests/Integration/VisibleSignatureBusinessRuleTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@ public static function signatureScenarioProvider(): iterable
3535
];
3636

3737
yield 'signer with image mark' => [
38-
'html' => '<img src="/fixture/sign.png" style="width:20px;height:20px" /><span style="font-size:9">ID 42</span>',
38+
'html' => '<img src="/fixture/sign.png" style="width:20px;height:20px" />'
39+
. '<span style="font-size:9">ID 42</span>',
3940
'maxStreamLength' => 1400,
4041
];
4142

4243
yield 'styled signer with alignment and spacing' => [
43-
'html' => '<div style="font-family:Times New Roman;font-weight:700;text-align:right;margin:6;padding:2;width:220">Signed by Styled User</div>',
44+
'html' => '<div style="font-family:Times New Roman;font-weight:700;text-align:right;'
45+
. 'margin:6;padding:2;width:220">Signed by Styled User</div>',
4446
'maxStreamLength' => 1800,
4547
];
4648
}

0 commit comments

Comments
 (0)