Skip to content

Commit 74d3602

Browse files
authored
Merge pull request #52 from picamator/development
Release 5.4.4
2 parents af850d7 + 62ad1e8 commit 74d3602

39 files changed

+710
-160
lines changed

AGENTS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ Code Style
100100

101101
### Tests
102102

103-
- all tests classes should be a `final`
103+
- tests classes should be a `final`
104+
- tests should have at least one test group
104105

105106
Module Structure
106107
----------------

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,12 @@ Usage Tests
115115
Definition Files and Transfer Object generators have been tested against the following APIs:
116116

117117
* [NASA Open Api](https://api.nasa.gov/neo/rest/v1/neo/2465633?api_key=DEMO_KEY)
118-
* [OpenWeather](https://openweathermap.org/current#example_JSON)
119-
* [Content API for Shopping](https://developers.google.com/shopping-content/guides/products/products-api?hl=en)
120-
* [Frankfurter is a free, open-source currency data API](https://api.frankfurter.dev/v1/latest)
118+
* [OpenWeather](https://openweathermap.org/current?collection=current_forecast#example_JSON)
119+
* [Google Content API for Shopping](https://developers.google.com/shopping-content/guides/products/products-api?hl=en)
120+
* [Frankfurter - open-source currency data API](https://api.frankfurter.dev/v1/latest)
121121
* [Tagesschau API](https://tagesschau.api.bund.dev)
122122
* [Statistisches Bundesamt (Destatis)](https://www-genesis.destatis.de/genesisWS/swagger-ui/index.html#/find/findPost)
123+
* [Wero - Digital Payment Wallet](https://developerhub.ppro.com/global-api/docs/wero)
123124

124125
### Scenario
125126

composer.lock

Lines changed: 14 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docker/sdk

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,14 @@ case $1 in
8484
docker compose stop
8585
;;
8686
cli)
87-
if [ -n "$2" ]; then
88-
$DOCKER_EXEC php -f $2
87+
if [ -n "$5" ]; then
88+
$DOCKER_EXEC php "$2" "$3" "$4" "$5"
89+
elif [ -n "$4" ]; then
90+
$DOCKER_EXEC php "$2" "$3" "$4"
91+
elif [ -n "$3" ]; then
92+
$DOCKER_EXEC php "$2" "$3"
93+
elif [ -n "$2" ]; then
94+
$DOCKER_EXEC php $2
8995
else
9096
$DOCKER_EXEC bash
9197
fi

src/Command/TransferGeneratorCommand.php

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -122,27 +122,22 @@ private function generateTransfers(SymfonyStyle $io, string $configPath): bool
122122
}
123123

124124
$this->writelnErrorMessages($io, $generatorTransfer);
125-
$this->writelnDebugMessages($io, $generatorTransfer);
125+
if ($this->isDebugMessages($io, $generatorTransfer)) {
126+
$lastFileName ??= $generatorTransfer->fileName;
127+
$this->writelnDebugMessages($io, $generatorTransfer, $lastFileName);
128+
}
126129
}
127130

128131
return $generatorFiber->getReturn();
129132
}
130133

131-
private function writelnDebugMessages(SymfonyStyle $io, TransferGeneratorTransfer $generatorTransfer): void
132-
{
133-
if (
134-
!$io->isVerbose()
135-
|| $generatorTransfer->validator->isValid === false
136-
|| $generatorTransfer->fileName === null
137-
|| $generatorTransfer->className === null
138-
) {
139-
return;
140-
}
141-
142-
static $fileName = $generatorTransfer->fileName;
143-
144-
if ($fileName !== $generatorTransfer->fileName) {
145-
$fileName = $generatorTransfer->fileName;
134+
private function writelnDebugMessages(
135+
SymfonyStyle $io,
136+
TransferGeneratorTransfer $generatorTransfer,
137+
?string &$lastFileName,
138+
): void {
139+
if ($lastFileName !== $generatorTransfer->fileName) {
140+
$lastFileName = $generatorTransfer->fileName;
146141

147142
$io->newLine();
148143
}
@@ -156,6 +151,14 @@ private function writelnDebugMessages(SymfonyStyle $io, TransferGeneratorTransfe
156151
);
157152
}
158153

154+
private function isDebugMessages(SymfonyStyle $io, TransferGeneratorTransfer $generatorTransfer): bool
155+
{
156+
return $io->isVerbose()
157+
&& $generatorTransfer->validator->isValid === true
158+
&& $generatorTransfer->fileName !== null
159+
&& $generatorTransfer->className !== null;
160+
}
161+
159162
private function writelnErrorMessages(SymfonyStyle $io, TransferGeneratorTransfer $generatorTransfer): void
160163
{
161164
if ($generatorTransfer->validator->isValid === true) {

src/DefinitionGenerator/Content/Expander/BuiltInTypeBuilderExpander.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,13 @@ private function createDateTimePropertyTransfer(string $propertyName): Definitio
132132

133133
private function createPropertyTransfer(string $propertyName, string $builtInType): DefinitionPropertyTransfer
134134
{
135-
$tapeWithDocBlock = $this->parseTypeWithDocBlock($builtInType) ?? [];
135+
$typeDocBlock = $this->parseTypeWithDocBlock($builtInType);
136136

137-
/** @var string $type */
138-
$type = array_key_first($tapeWithDocBlock);
139-
$type = BuiltInTypeEnum::from($type);
140-
141-
$docBlock = array_first($tapeWithDocBlock);
137+
$type = BuiltInTypeEnum::from($typeDocBlock->type);
142138

143139
$builtInTypeTransfer = new DefinitionBuiltInTypeTransfer();
144140
$builtInTypeTransfer->name = $type;
145-
$builtInTypeTransfer->docBlock = $docBlock;
141+
$builtInTypeTransfer->docBlock = $typeDocBlock->docBlock;
146142

147143
$propertyTransfer = new DefinitionPropertyTransfer();
148144
$propertyTransfer->propertyName = $propertyName;

src/Shared/Filesystem/FileAppender.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function appendToFile(string $filename, string $content): void
2020

2121
if ($writeResult === false) {
2222
throw new FileAppenderException(
23-
sprintf('Failed to write content into the file "%s".', $filename),
23+
sprintf('Failed to write content to file "%s".', $filename),
2424
);
2525
}
2626
}
@@ -35,7 +35,7 @@ public function closeFile(string $filename): void
3535
$isClosed = $this->fclose($file);
3636
if ($isClosed === false) {
3737
throw new FileAppenderException(
38-
sprintf('Failed to close the file "%s".', $filename),
38+
sprintf('Failed to close file "%s".', $filename),
3939
);
4040
}
4141

src/Shared/Filesystem/FileReader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private function assertEndOfFile($file, string $filename, int $fileLine): void
6161
$this->fclose($file);
6262

6363
throw new FileReaderException(
64-
sprintf('Failed to read file "%s" line "%d".', $filename, $fileLine),
64+
sprintf('Failed to read file "%s" at line "%d".', $filename, $fileLine),
6565
);
6666
}
6767

src/Shared/Parser/DocBlockParserTrait.php

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,17 @@
66

77
trait DocBlockParserTrait
88
{
9-
private const string TYPE_KEY = 'type';
9+
private const string DOCK_BLOCK_REGEX = '#^(?<type>[^<> ]+)\s*(?<docBlock><.+>)$#';
1010

11-
private const string DOC_BLOCK_KEY = 'docBlock';
12-
13-
private const string TYPE_REGEX = '#(?<type>[^<>]*)(?<docBlock>.*)#';
14-
15-
/**
16-
* @return array<string,string|null>|null
17-
*/
18-
final protected function parseTypeWithDocBlock(string $type): ?array
11+
final protected function parseTypeWithDocBlock(string $type): TypeDocBlock
1912
{
20-
if (preg_match(self::TYPE_REGEX, $type, $matches) === false) {
21-
return null;
13+
if (!str_contains($type, '<') || preg_match(self::DOCK_BLOCK_REGEX, $type, $matches) !== 1) {
14+
return new TypeDocBlock(type: $type);
2215
}
2316

24-
$type = $matches[self::TYPE_KEY] ?? '';
25-
$docBlock = $matches[self::DOC_BLOCK_KEY] ?? null;
26-
27-
return [$type => $docBlock];
17+
return new TypeDocBlock(
18+
type: $matches['type'],
19+
docBlock: $matches['docBlock'],
20+
);
2821
}
2922
}

src/Shared/Parser/TypeDocBlock.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Picamator\TransferObject\Shared\Parser;
6+
7+
readonly class TypeDocBlock
8+
{
9+
public function __construct(
10+
public string $type,
11+
public ?string $docBlock = null,
12+
) {
13+
}
14+
}

0 commit comments

Comments
 (0)