Skip to content

Commit 0b93989

Browse files
author
roadiz-ci
committed
chore: bumped
1 parent e70e8ac commit 0b93989

12 files changed

Lines changed: 30 additions & 48 deletions

.github/workflows/run-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
runs-on: ubuntu-latest
2121
strategy:
2222
matrix:
23-
php-version: ['8.3', '8.4']
23+
php-version: ['8.2', '8.3']
2424
steps:
2525
- uses: shivammathur/setup-php@v2
2626
with:

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright © 2025 Ambroise Maupate
3+
Copyright © 2024 Ambroise Maupate
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
66

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
"description": "Roadiz sub-package which generates Typescript interfaces skeleton based on your schema",
44
"type": "library",
55
"require": {
6-
"roadiz/nodetype-contracts": "^3.1.1",
7-
"symfony/http-foundation": "7.4.*"
6+
"roadiz/nodetype-contracts": "^2.0.0",
7+
"symfony/http-foundation": "6.4.*"
88
},
99
"require-dev": {
10-
"phpstan/phpstan": "^2.1.36",
10+
"phpstan/phpstan": "^1.5.3",
1111
"phpstan/phpdoc-parser": "<2"
1212
},
1313
"license": "MIT",
@@ -26,8 +26,8 @@
2626
},
2727
"extra": {
2828
"branch-alias": {
29-
"dev-master": "2.7.x-dev",
30-
"dev-develop": "2.8.x-dev"
29+
"dev-master": "2.5.x-dev",
30+
"dev-develop": "2.6.x-dev"
3131
}
3232
}
3333
}

src/DeclarationGeneratorFactory.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace RZ\Roadiz\Typescript\Declaration;
66

7-
use RZ\Roadiz\Contracts\NodeType\NodeTypeClassLocatorInterface;
87
use RZ\Roadiz\Contracts\NodeType\NodeTypeFieldInterface;
98
use RZ\Roadiz\Contracts\NodeType\NodeTypeInterface;
109
use RZ\Roadiz\Typescript\Declaration\Generators\AbstractFieldGenerator;
@@ -18,10 +17,8 @@
1817

1918
final readonly class DeclarationGeneratorFactory
2019
{
21-
public function __construct(
22-
private ParameterBag $nodeTypesBag,
23-
private NodeTypeClassLocatorInterface $nodeTypeClassLocator,
24-
) {
20+
public function __construct(private ParameterBag $nodeTypesBag)
21+
{
2522
}
2623

2724
public function getNodeTypesBag(): ParameterBag
@@ -38,16 +35,15 @@ public function createForNodeType(NodeTypeInterface $nodeType): NodeTypeGenerato
3835
{
3936
return new NodeTypeGenerator(
4037
$nodeType,
41-
$this,
42-
$this->nodeTypeClassLocator
38+
$this
4339
);
4440
}
4541

4642
public function createForNodeTypeField(NodeTypeFieldInterface $field): AbstractFieldGenerator
4743
{
4844
return match (true) {
4945
$field->isDocuments() => new DocumentsFieldGenerator($field, $this->nodeTypesBag),
50-
$field->isNodes() => new NodeReferencesFieldGenerator($this->nodeTypeClassLocator, $field, $this->nodeTypesBag),
46+
$field->isNodes() => new NodeReferencesFieldGenerator($field, $this->nodeTypesBag),
5147
$field->isChildrenNodes() => new ChildrenNodeFieldGenerator($field, $this->nodeTypesBag),
5248
$field->isMultiple(), $field->isEnum() => new EnumFieldGenerator($field, $this->nodeTypesBag),
5349
default => new ScalarFieldGenerator($field, $this->nodeTypesBag),

src/Generators/AbstractFieldGenerator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ protected function getIntroductionLines(): array
5959

6060
public function getIntroduction(): string
6161
{
62-
return implode(PHP_EOL, array_map(fn (string $line) => static::INDENTATION_MARK.'// '.$line, $this->getIntroductionLines()));
62+
return implode(PHP_EOL, array_map(function (string $line) {
63+
return static::INDENTATION_MARK.'// '.$line;
64+
}, $this->getIntroductionLines()));
6365
}
6466
}

src/Generators/ChildrenNodeFieldGenerator.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@
66

77
final class ChildrenNodeFieldGenerator extends AbstractFieldGenerator
88
{
9-
#[\Override]
109
public function getContents(): string
1110
{
1211
return implode(PHP_EOL, [
1312
$this->getIntroduction(),
1413
]);
1514
}
1615

17-
#[\Override]
1816
protected function getIntroductionLines(): array
1917
{
2018
$lines = [
@@ -27,7 +25,6 @@ protected function getIntroductionLines(): array
2725
return $lines;
2826
}
2927

30-
#[\Override]
3128
protected function getType(): string
3229
{
3330
return '';

src/Generators/DeclarationGenerator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace RZ\Roadiz\Typescript\Declaration\Generators;
66

7-
use RZ\Roadiz\Contracts\NodeType\NodeTypeClassLocatorInterface;
87
use RZ\Roadiz\Contracts\NodeType\NodeTypeInterface;
98
use RZ\Roadiz\Typescript\Declaration\DeclarationGeneratorFactory;
109

@@ -20,7 +19,6 @@ final class DeclarationGenerator
2019
*/
2120
public function __construct(
2221
private readonly DeclarationGeneratorFactory $generatorFactory,
23-
private readonly NodeTypeClassLocatorInterface $nodeTypeClassLocator,
2422
array $nodeTypes = [],
2523
) {
2624
if (empty($nodeTypes)) {
@@ -47,7 +45,9 @@ public function getContents(): string
4745

4846
private function getAllTypesInterface(): string
4947
{
50-
$nodeTypeNames = array_map($this->nodeTypeClassLocator->getSourceEntityClassName(...), $this->nodeTypes);
48+
$nodeTypeNames = array_map(function (NodeTypeInterface $nodeType) {
49+
return $nodeType->getSourceEntityClassName();
50+
}, $this->nodeTypes);
5151

5252
$nodeTypeNames = implode(' | ', $nodeTypeNames);
5353

src/Generators/DocumentsFieldGenerator.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66

77
final class DocumentsFieldGenerator extends AbstractFieldGenerator
88
{
9-
#[\Override]
109
protected function getNullableAssertion(): string
1110
{
1211
return ''; // always available even if empty
1312
}
1413

15-
#[\Override]
1614
protected function getType(): string
1715
{
1816
return 'Array<RoadizDocument>';

src/Generators/EnumFieldGenerator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66

77
final class EnumFieldGenerator extends AbstractFieldGenerator
88
{
9-
#[\Override]
109
protected function getType(): string
1110
{
1211
switch (true) {
1312
case $this->field->isEnum():
1413
$defaultValues = $this->field->getDefaultValuesAsArray();
1514
if (!empty($defaultValues) && count($defaultValues) > 0) {
16-
$defaultValues = array_map(fn (string $value) => '\''.$value.'\'', $defaultValues);
15+
$defaultValues = array_map(function (string $value) {
16+
return '\''.$value.'\'';
17+
}, $defaultValues);
1718

1819
return implode(' | ', $defaultValues).' | null';
1920
}
@@ -26,7 +27,6 @@ protected function getType(): string
2627
}
2728
}
2829

29-
#[\Override]
3030
protected function getIntroductionLines(): array
3131
{
3232
$lines = parent::getIntroductionLines();

src/Generators/NodeReferencesFieldGenerator.php

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,15 @@
44

55
namespace RZ\Roadiz\Typescript\Declaration\Generators;
66

7-
use RZ\Roadiz\Contracts\NodeType\NodeTypeClassLocatorInterface;
8-
use RZ\Roadiz\Contracts\NodeType\NodeTypeFieldInterface;
97
use RZ\Roadiz\Contracts\NodeType\NodeTypeInterface;
10-
use Symfony\Component\HttpFoundation\ParameterBag;
118

129
final class NodeReferencesFieldGenerator extends AbstractFieldGenerator
1310
{
14-
public function __construct(
15-
private readonly NodeTypeClassLocatorInterface $nodeTypeClassLocator,
16-
NodeTypeFieldInterface $field,
17-
ParameterBag $nodeTypesBag,
18-
) {
19-
parent::__construct($field, $nodeTypesBag);
20-
}
21-
22-
#[\Override]
2311
protected function getNullableAssertion(): string
2412
{
2513
return ''; // always available even if empty
2614
}
2715

28-
#[\Override]
2916
protected function getType(): string
3017
{
3118
return 'Array<'.$this->getUnionType().'>';
@@ -57,10 +44,11 @@ private function getUnionType(): string
5744
return 'RoadizNodesSources';
5845
}
5946

60-
return implode(' | ', array_map($this->nodeTypeClassLocator->getSourceEntityClassName(...), $nodeTypes));
47+
return implode(' | ', array_map(function (NodeTypeInterface $nodeType) {
48+
return $nodeType->getSourceEntityClassName();
49+
}, $nodeTypes));
6150
}
6251

63-
#[\Override]
6452
protected function getIntroductionLines(): array
6553
{
6654
$lines = parent::getIntroductionLines();

0 commit comments

Comments
 (0)