Skip to content

Commit 2c34661

Browse files
author
roadiz-ci
committed
chore: bumped
1 parent 72e01ed commit 2c34661

11 files changed

Lines changed: 43 additions & 36 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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"description": "Roadiz sub-package which generates Typescript interfaces skeleton based on your schema",
44
"type": "library",
55
"require": {
6-
"roadiz/nodetype-contracts": "^3.0.0",
7-
"symfony/http-foundation": "7.3.*"
6+
"roadiz/nodetype-contracts": "~1.1.2",
7+
"symfony/http-foundation": "6.4.*"
88
},
99
"require-dev": {
1010
"phpstan/phpstan": "^1.5.3",
@@ -26,8 +26,8 @@
2626
},
2727
"extra": {
2828
"branch-alias": {
29-
"dev-master": "2.6.x-dev",
30-
"dev-develop": "2.7.x-dev"
29+
"dev-master": "2.4.x-dev",
30+
"dev-develop": "2.5.x-dev"
3131
}
3232
}
3333
}

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: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,25 @@
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 = [
2119
'This node-type uses "blocks" which are available through parent RoadizNodesSources.blocks',
2220
];
23-
if (!empty($this->field->getDefaultValuesAsArray())) {
24-
$lines[] = 'Possible block node-types: '.json_encode($this->field->getDefaultValuesAsArray());
21+
if (!empty($this->field->getDefaultValues())) {
22+
$lines[] = 'Possible block node-types: '.$this->field->getDefaultValues();
2523
}
2624

2725
return $lines;
2826
}
2927

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

src/Generators/DeclarationGenerator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ public function getContents(): string
4545

4646
private function getAllTypesInterface(): string
4747
{
48-
$nodeTypeNames = array_map(fn (NodeTypeInterface $nodeType) => $nodeType->getSourceEntityClassName(), $this->nodeTypes);
48+
$nodeTypeNames = array_map(function (NodeTypeInterface $nodeType) {
49+
return $nodeType->getSourceEntityClassName();
50+
}, $this->nodeTypes);
4951

5052
$nodeTypeNames = implode(' | ', $nodeTypeNames);
5153

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: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,24 @@
66

77
final class EnumFieldGenerator extends AbstractFieldGenerator
88
{
9-
#[\Override]
109
protected function getType(): string
1110
{
1211
switch (true) {
1312
case $this->field->isEnum():
14-
$defaultValues = $this->field->getDefaultValuesAsArray();
15-
if (!empty($defaultValues) && count($defaultValues) > 0) {
16-
$defaultValues = array_map(fn (string $value) => '\''.$value.'\'', $defaultValues);
13+
if (!empty($this->field->getDefaultValues())) {
14+
$defaultValues = array_filter(
15+
array_map(
16+
'trim',
17+
explode(',', $this->field->getDefaultValues())
18+
)
19+
);
20+
if (count($defaultValues) > 0) {
21+
$defaultValues = array_map(function (string $value) {
22+
return '\''.$value.'\'';
23+
}, $defaultValues);
1724

18-
return implode(' | ', $defaultValues).' | null';
25+
return implode(' | ', $defaultValues).' | null';
26+
}
1927
}
2028

2129
return 'string';
@@ -26,12 +34,11 @@ protected function getType(): string
2634
}
2735
}
2836

29-
#[\Override]
3037
protected function getIntroductionLines(): array
3138
{
3239
$lines = parent::getIntroductionLines();
33-
if (!empty($this->field->getDefaultValuesAsArray())) {
34-
$lines[] = 'Possible values: '.json_encode($this->field->getDefaultValuesAsArray());
40+
if (!empty($this->field->getDefaultValues())) {
41+
$lines[] = 'Possible values: '.$this->field->getDefaultValues();
3542
}
3643

3744
return $lines;

src/Generators/NodeReferencesFieldGenerator.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@
88

99
final class NodeReferencesFieldGenerator extends AbstractFieldGenerator
1010
{
11-
#[\Override]
1211
protected function getNullableAssertion(): string
1312
{
1413
return ''; // always available even if empty
1514
}
1615

17-
#[\Override]
1816
protected function getType(): string
1917
{
2018
return 'Array<'.$this->getUnionType().'>';
@@ -25,11 +23,10 @@ protected function getType(): string
2523
*/
2624
private function getLinkedNodeTypes(): array
2725
{
28-
$nodeTypeNames = $this->field->getDefaultValuesAsArray();
29-
30-
if (0 === count($nodeTypeNames)) {
31-
return $nodeTypeNames;
26+
if (null === $this->field->getDefaultValues()) {
27+
return [];
3228
}
29+
$nodeTypeNames = explode(',', $this->field->getDefaultValues());
3330

3431
return array_values(array_filter(array_map(function (string $name) {
3532
$nodeType = $this->nodeTypesBag->get(trim($name));
@@ -46,15 +43,16 @@ private function getUnionType(): string
4643
return 'RoadizNodesSources';
4744
}
4845

49-
return implode(' | ', array_map(fn (NodeTypeInterface $nodeType) => $nodeType->getSourceEntityClassName(), $nodeTypes));
46+
return implode(' | ', array_map(function (NodeTypeInterface $nodeType) {
47+
return $nodeType->getSourceEntityClassName();
48+
}, $nodeTypes));
5049
}
5150

52-
#[\Override]
5351
protected function getIntroductionLines(): array
5452
{
5553
$lines = parent::getIntroductionLines();
56-
if (!empty($this->field->getDefaultValuesAsArray())) {
57-
$lines[] = 'Possible values: '.json_encode($this->field->getDefaultValuesAsArray());
54+
if (!empty($this->field->getDefaultValues())) {
55+
$lines[] = 'Possible values: '.$this->field->getDefaultValues();
5856
}
5957

6058
return $lines;

src/Generators/NodeTypeGenerator.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,15 @@ protected function getIntroduction(): string
7777
$lines[] = 'Publishable: '.$this->generatorFactory->getHumanBool($this->nodeType->isPublishable());
7878
$lines[] = 'Visible: '.$this->generatorFactory->getHumanBool($this->nodeType->isVisible());
7979

80-
return implode(PHP_EOL, array_map(fn (string $line) => '// '.$line, $lines));
80+
return implode(PHP_EOL, array_map(function (string $line) {
81+
return '// '.$line;
82+
}, $lines));
8183
}
8284

8385
protected function getFieldsContents(): string
8486
{
85-
return implode(PHP_EOL, array_map(fn (AbstractFieldGenerator $abstractFieldGenerator) => $abstractFieldGenerator->getContents(), $this->fieldGenerators));
87+
return implode(PHP_EOL, array_map(function (AbstractFieldGenerator $abstractFieldGenerator) {
88+
return $abstractFieldGenerator->getContents();
89+
}, $this->fieldGenerators));
8690
}
8791
}

0 commit comments

Comments
 (0)