Skip to content

Commit ad4d0ef

Browse files
author
roadiz-ci
committed
chore: bumped
1 parent b5b214b commit ad4d0ef

6 files changed

Lines changed: 14 additions & 32 deletions

File tree

.github/workflows/run-test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Static analysis and code style
33
on:
44
push:
55
branches:
6+
- main
67
- develop
78
- 'release/**'
89
- 'hotfix/**'
@@ -19,7 +20,7 @@ jobs:
1920
runs-on: ubuntu-latest
2021
strategy:
2122
matrix:
22-
php-version: ['8.3', '8.4', '8.5']
23+
php-version: ['8.3', '8.4']
2324
steps:
2425
- uses: shivammathur/setup-php@v2
2526
with:

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": "^3.0.0",
7+
"symfony/http-foundation": "7.3.*"
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.6.x-dev",
30+
"dev-develop": "2.7.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/DeclarationGenerator.php

Lines changed: 1 addition & 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,7 @@ public function getContents(): string
4745

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

5250
$nodeTypeNames = implode(' | ', $nodeTypeNames);
5351

src/Generators/NodeReferencesFieldGenerator.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,10 @@
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-
2211
#[\Override]
2312
protected function getNullableAssertion(): string
2413
{
@@ -57,7 +46,7 @@ private function getUnionType(): string
5746
return 'RoadizNodesSources';
5847
}
5948

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

6352
#[\Override]

src/Generators/NodeTypeGenerator.php

Lines changed: 1 addition & 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\NodeTypeFieldInterface;
98
use RZ\Roadiz\Contracts\NodeType\NodeTypeInterface;
109
use RZ\Roadiz\Contracts\NodeType\SerializableInterface;
@@ -20,7 +19,6 @@ final class NodeTypeGenerator
2019
public function __construct(
2120
private readonly NodeTypeInterface $nodeType,
2221
private readonly DeclarationGeneratorFactory $generatorFactory,
23-
private readonly NodeTypeClassLocatorInterface $nodeTypeClassLocator,
2422
) {
2523
$this->fieldGenerators = [];
2624

@@ -56,7 +54,7 @@ public function getContents(): string
5654
private function getInterfaceBody(): string
5755
{
5856
$lines = [
59-
'export interface '.$this->nodeTypeClassLocator->getSourceEntityClassName($this->nodeType).' extends RoadizNodesSources {',
57+
'export interface '.$this->nodeType->getSourceEntityClassName().' extends RoadizNodesSources {',
6058
$this->getFieldsContents(),
6159
'}',
6260
];

0 commit comments

Comments
 (0)