Skip to content

Commit 6c9f01d

Browse files
authored
backport change (#61)
* backport change * fix obsolete test (only 3.x) * fix cs
1 parent e272c9d commit 6c9f01d

13 files changed

+31
-17
lines changed

src/Generator/SchemaGenerator.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
final class SchemaGenerator implements SchemaGeneratorInterface
1313
{
14-
1514
/**
1615
* @var int[]
1716
*/
@@ -89,7 +88,7 @@ public function generate(): array
8988
$schema['fields'][] = $field;
9089
}
9190

92-
$schemas[$schema['namespace'] . '.' . $schema['name']] = json_encode($schema);
91+
$schemas[$schema['namespace'] . '.' . $schema['name']] = json_encode($schema, JSON_PRESERVE_ZERO_FRACTION);
9392
}
9493

9594
return $schemas;

src/Merger/SchemaMerger.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public function exportSchema(
176176
}
177177

178178
/** @var string $fileContents */
179-
$fileContents = json_encode($rootSchemaDefinition);
179+
$fileContents = json_encode($rootSchemaDefinition, JSON_PRESERVE_ZERO_FRACTION);
180180

181181
file_put_contents($this->getOutputDirectory() . '/' . $schemaFilename, $fileContents);
182182
}

src/Merger/SchemaMergerInterface.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
interface SchemaMergerInterface
1212
{
13-
1413
/**
1514
* @return SchemaRegistryInterface
1615
*/

src/Optimizer/FieldOrderOptimizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function optimize(string $definition): string
1717

1818
$data = $this->processSchema($data);
1919

20-
return json_encode($data, JSON_THROW_ON_ERROR);
20+
return json_encode($data, JSON_THROW_ON_ERROR | JSON_PRESERVE_ZERO_FRACTION);
2121
}
2222

2323
/**

src/Optimizer/FullNameOptimizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function optimize(string $definition): string
1818
$currentNamespace = $data['namespace'] ?? '';
1919
$data = $this->processSchema($currentNamespace, $data, true);
2020

21-
return json_encode($data, JSON_THROW_ON_ERROR);
21+
return json_encode($data, JSON_THROW_ON_ERROR | JSON_PRESERVE_ZERO_FRACTION);
2222
}
2323

2424
/**

src/Optimizer/PrimitiveSchemaOptimizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function optimize(string $definition, bool $isPrimitive = false): string
2222

2323
$data = $this->processSchema($data);
2424

25-
return json_encode($data, JSON_THROW_ON_ERROR);
25+
return json_encode($data, JSON_THROW_ON_ERROR | JSON_PRESERVE_ZERO_FRACTION);
2626
}
2727

2828
/**

src/PhpClass/PhpClassProperty.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
class PhpClassProperty implements PhpClassPropertyInterface
88
{
9-
109
/**
1110
* @var string
1211
*/

src/Registry/ClassRegistry.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
final class ClassRegistry implements ClassRegistryInterface
1616
{
17-
1817
/**
1918
* @var array<string,int>
2019
*/

src/Registry/ClassRegistryInterface.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
interface ClassRegistryInterface
1010
{
11-
1211
/**
1312
* @param string $classDirectory
1413
* @return ClassRegistryInterface

src/Registry/SchemaRegistry.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,11 @@ private function registerSchemaFile(\SplFileInfo $fileInfo): void
135135
}
136136

137137
$schemaData = json_decode($fileContent, true, JSON_THROW_ON_ERROR);
138-
$namespace = '';
138+
$namespace = '';
139139

140-
if (true === isset($schemaData['namespace'])) {
141-
$namespace = $schemaData['namespace'];
142-
}
140+
if (true === isset($schemaData['namespace'])) {
141+
$namespace = $schemaData['namespace'];
142+
}
143143

144144
if (null === $schemaData) {
145145
throw new SchemaRegistryException(sprintf(SchemaRegistryException::FILE_INVALID, $fileName));

0 commit comments

Comments
 (0)