Skip to content

Commit 1b7a21a

Browse files
committed
Make some nested class names and variable names more reliable over multiple runs
1 parent ed44453 commit 1b7a21a

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

src/Model/SchemaDefinition/SchemaDefinitionDictionary.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ protected function parseExternalFile(
180180

181181
// set up a dummy schema to fetch the definitions from the external file
182182
$schema = new Schema(
183-
'ExternalSchema_' . uniqid(),
183+
'ExternalSchema',
184184
'',
185185
new JsonSchema($jsonSchemaFilePath, $decodedJsonSchema),
186186
new self(dirname($jsonSchemaFilePath))

src/Model/Validator/ArrayItemValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ public function __construct(
4444
JsonSchema $itemStructure,
4545
PropertyInterface $property
4646
) {
47-
$this->variableSuffix = '_' . uniqid();
4847
$nestedPropertyName = "item of array {$property->getName()}";
48+
$this->variableSuffix = '_' . md5($nestedPropertyName);
4949

5050
// an item of the array behaves like a nested property to add item-level validation
5151
$this->nestedProperty = (new PropertyFactory(new PropertyProcessorFactory()))

src/PropertyProcessor/Property/AbstractPropertyProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ function ($dependency, $index) use (&$propertyDependency): void {
155155
$dependencySchema = $this->schemaProcessor->processSchema(
156156
new JsonSchema($this->schema->getJsonSchema()->getFile(), $dependencies),
157157
$this->schema->getClassPath(),
158-
ucfirst("{$property->getName()}_Dependency_" . uniqid()),
158+
"{$this->schema->getClassName()}_{$property->getName()}_Dependency",
159159
$this->schema->getSchemaDictionary()
160160
);
161161

tests/Basic/SchemaDependencyTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public function invalidSchemaDependencyCompositionDataProvider(): array
228228
['credit_card' => 12345],
229229
<<<ERROR
230230
Invalid schema which is dependant on credit_card:
231-
- Invalid value for Credit_card_Dependency_(.*) declined by composition constraint.
231+
- Invalid value for SchemaDependencyTest_\w+_credit_card_Dependency declined by composition constraint.
232232
Requires to match all composition elements but matched 0 elements.
233233
- Composition element #1: Failed
234234
\* Missing required value for name
@@ -242,7 +242,7 @@ public function invalidSchemaDependencyCompositionDataProvider(): array
242242
['credit_card' => 12345, 'age' => 42],
243243
<<<ERROR
244244
Invalid schema which is dependant on credit_card:
245-
- Invalid value for Credit_card_Dependency_(.*) declined by composition constraint.
245+
- Invalid value for SchemaDependencyTest_\w+_credit_card_Dependency declined by composition constraint.
246246
Requires to match all composition elements but matched 1 elements.
247247
- Composition element #1: Failed
248248
\* Missing required value for name
@@ -255,7 +255,7 @@ public function invalidSchemaDependencyCompositionDataProvider(): array
255255
['credit_card' => 12345, 'name' => false, 'age' => 42],
256256
<<<ERROR
257257
Invalid schema which is dependant on credit_card:
258-
- Invalid value for Credit_card_Dependency_(.*) declined by composition constraint.
258+
- Invalid value for SchemaDependencyTest_\w+_credit_card_Dependency declined by composition constraint.
259259
Requires to match all composition elements but matched 1 elements.
260260
- Composition element #1: Failed
261261
\* Invalid type for name. Requires string, got boolean

0 commit comments

Comments
 (0)