Skip to content

Commit

Permalink
Add trailing comma
Browse files Browse the repository at this point in the history
Fix implicit nullable (deprecated in PHP8.4)
  • Loading branch information
wol-soft committed Mar 15, 2024
1 parent 2604a21 commit 0790387
Show file tree
Hide file tree
Showing 112 changed files with 746 additions and 746 deletions.
2 changes: 1 addition & 1 deletion src/Model/GeneratorConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function addFilter(FilterInterface ...$additionalFilter): self
foreach ($additionalFilter as $filter) {
$this->validateFilterCallback(
$filter->getFilter(),
"Invalid filter callback for filter {$filter->getToken()}"
"Invalid filter callback for filter {$filter->getToken()}",
);

if ($filter instanceof TransformingFilterInterface) {
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Property/CompositionPropertyDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct(string $propertyName, JsonSchema $jsonSchema, Proper
$propertyName,
$jsonSchema,
new ResolvedDefinitionsCollection([self::PROPERTY_KEY => $property]),
self::PROPERTY_KEY
self::PROPERTY_KEY,
);

$property->onResolve(function (): void {
Expand Down
14 changes: 7 additions & 7 deletions src/Model/Property/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ public function getType(bool $outputType = false): ?PropertyType
* @inheritdoc
*/
public function setType(
PropertyType $type = null,
PropertyType $outputType = null,
bool $reset = false
?PropertyType $type = null,
?PropertyType $outputType = null,
bool $reset = false,
): PropertyInterface {
if ($reset) {
$this->typeHintDecorators = [];
Expand Down Expand Up @@ -134,15 +134,15 @@ public function getTypeHint(bool $outputType = false, array $skipDecorators = []
$this->typeHintDecorators,
static function (TypeHintDecoratorInterface $decorator) use ($skipDec): bool {
return !in_array(get_class($decorator), $skipDec);
}
},
);

foreach ($filteredDecorators as $decorator) {
$typeHint = $decorator->decorate($typeHint, $outputType);
}

return $typeHint;
}, $input))
}, $input)),
);

$skipDec = array_diff($skipDec, $additionalSkips);
Expand Down Expand Up @@ -220,14 +220,14 @@ static function (Validator $validator, Validator $comparedValidator): int {
return 0;
}
return ($validator->getPriority() < $comparedValidator->getPriority()) ? -1 : 1;
}
},
);

return array_map(
static function (Validator $validator): PropertyValidatorInterface {
return $validator->getValidator();
},
$this->validators
$this->validators,
);
}

Expand Down
6 changes: 3 additions & 3 deletions src/Model/Property/PropertyInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public function getType(bool $outputType = false): ?PropertyType;
* @return PropertyInterface
*/
public function setType(
PropertyType $type = null,
PropertyType $outputType = null,
bool $reset = false
?PropertyType $type = null,
?PropertyType $outputType = null,
bool $reset = false,
): PropertyInterface;

/**
Expand Down
10 changes: 5 additions & 5 deletions src/Model/Property/PropertyProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct(
string $name,
JsonSchema $jsonSchema,
ResolvedDefinitionsCollection $definitionsCollection,
string $key
string $key,
) {
parent::__construct($name, $jsonSchema);

Expand Down Expand Up @@ -70,9 +70,9 @@ public function getType(bool $outputType = false): ?PropertyType
* @inheritdoc
*/
public function setType(
PropertyType $type = null,
PropertyType $outputType = null,
bool $reset = false
?PropertyType $type = null,
?PropertyType $outputType = null,
bool $reset = false,
): PropertyInterface {
return $this->getProperty()->setType($type, $outputType);
}
Expand Down Expand Up @@ -134,7 +134,7 @@ public function getOrderedValidators(): array
function (PropertyValidatorInterface $propertyValidator): PropertyValidatorInterface {
return $propertyValidator->withProperty($this);
},
$this->getProperty()->getOrderedValidators()
$this->getProperty()->getOrderedValidators(),
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Model/Property/PropertyType.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class PropertyType
* @param bool|null $nullable Is the property nullable? if not provided the nullability will be determined
* automatically from the required flag/implicitNull setting etc.
*/
public function __construct(string $name, bool $nullable = null)
public function __construct(string $name, ?bool $nullable = null)
{
$this->name = $name;
$this->nullable = $nullable;
Expand Down
10 changes: 5 additions & 5 deletions src/Model/RenderJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(
string $fileName,
string $classPath,
string $className,
Schema $schema
Schema $schema,
) {
$this->fileName = $fileName;
$this->classPath = $classPath;
Expand Down Expand Up @@ -90,7 +90,7 @@ public function render(GeneratorConfiguration $generatorConfiguration): void
"Rendered class %s\n",
join(
'\\',
array_filter([$generatorConfiguration->getNamespacePrefix(), $this->classPath, $this->className])
array_filter([$generatorConfiguration->getNamespacePrefix(), $this->classPath, $this->className]),
)
);
}
Expand Down Expand Up @@ -138,9 +138,9 @@ protected function renderClass(GeneratorConfiguration $generatorConfiguration):
$this->schema->getBaseValidators(),
static function ($validator): bool {
return !is_a($validator, AbstractComposedPropertyValidator::class);
}
},
),
]
],
);
} catch (PHPMicroTemplateException $exception) {
throw new RenderException("Can't render class $this->classPath\\$this->className", 0, $exception);
Expand All @@ -162,7 +162,7 @@ protected function getUseForSchema(GeneratorConfiguration $generatorConfiguratio
$this->schema->getUsedClasses(),
$generatorConfiguration->collectErrors()
? [$generatorConfiguration->getErrorRegistryClass()]
: [ValidationException::class]
: [ValidationException::class],
)
);

Expand Down
8 changes: 4 additions & 4 deletions src/Model/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public function __construct(
string $classPath,
string $className,
JsonSchema $schema,
SchemaDefinitionDictionary $dictionary = null,
bool $initialClass = false
?SchemaDefinitionDictionary $dictionary = null,
bool $initialClass = false,
) {
$this->className = $className;
$this->classPath = $classPath;
Expand Down Expand Up @@ -141,7 +141,7 @@ public function getProperties(): array
$this->properties,
static function (
PropertyInterface $property,
PropertyInterface $comparedProperty
PropertyInterface $comparedProperty,
) use ($hasSchemaDependencyValidator): int {
$propertyHasSchemaDependencyValidator = $hasSchemaDependencyValidator($property);
$comparedPropertyHasSchemaDependencyValidator = $hasSchemaDependencyValidator($comparedProperty);
Expand All @@ -151,7 +151,7 @@ static function (
}

return ($propertyHasSchemaDependencyValidator < $comparedPropertyHasSchemaDependencyValidator) ? 1 : -1;
}
},
);

return $this->properties;
Expand Down
4 changes: 2 additions & 2 deletions src/Model/SchemaDefinition/SchemaDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function getSchema(): Schema
public function resolveReference(
string $propertyName,
array $path,
PropertyMetaDataCollection $propertyMetaDataCollection
PropertyMetaDataCollection $propertyMetaDataCollection,
): PropertyInterface {
$jsonSchema = $this->source->getJson();
$originalPath = $path;
Expand All @@ -100,7 +100,7 @@ public function resolveReference(
$this->schemaProcessor,
$this->schema,
$propertyName,
$this->source->withJson($jsonSchema)
$this->source->withJson($jsonSchema),
);
$this->resolvedPaths->offsetSet($key, $property);

Expand Down
12 changes: 6 additions & 6 deletions src/Model/SchemaDefinition/SchemaDefinitionDictionary.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function setUpDefinitionDictionary(SchemaProcessor $schemaProcessor, Sche
// add the root nodes of the schema to resolve path references
$this->addDefinition(
$key,
new SchemaDefinition($schema->getJsonSchema()->withJson($propertyEntry), $schemaProcessor, $schema)
new SchemaDefinition($schema->getJsonSchema()->withJson($propertyEntry), $schemaProcessor, $schema),
);
}

Expand All @@ -68,14 +68,14 @@ public function setUpDefinitionDictionary(SchemaProcessor $schemaProcessor, Sche
protected function fetchDefinitionsById(
JsonSchema $jsonSchema,
SchemaProcessor $schemaProcessor,
Schema $schema
Schema $schema,
): void {
$json = $jsonSchema->getJson();

if (isset($json['$id'])) {
$this->addDefinition(
strpos($json['$id'], '#') === 0 ? $json['$id'] : "#{$json['$id']}",
new SchemaDefinition($jsonSchema, $schemaProcessor, $schema)
new SchemaDefinition($jsonSchema, $schemaProcessor, $schema),
);
}

Expand Down Expand Up @@ -136,7 +136,7 @@ public function getDefinition(string $key, SchemaProcessor $schemaProcessor, arr
return $this->parsedExternalFileSchemas[$jsonSchemaFile]->getSchemaDictionary()->getDefinition(
"#$externalKey",
$schemaProcessor,
$path
$path,
);
}

Expand All @@ -162,7 +162,7 @@ protected function parseExternalFile(
string $jsonSchemaFile,
string $externalKey,
SchemaProcessor $schemaProcessor,
array &$path
array &$path,
): ?SchemaDefinition {
$jsonSchemaFilePath = filter_var($jsonSchemaFile, FILTER_VALIDATE_URL)
? $jsonSchemaFile
Expand All @@ -183,7 +183,7 @@ protected function parseExternalFile(
$schemaProcessor->getCurrentClassPath(),
'ExternalSchema',
new JsonSchema($jsonSchemaFilePath, $decodedJsonSchema),
new self(dirname($jsonSchemaFilePath))
new self(dirname($jsonSchemaFilePath)),
);

$schema->getSchemaDictionary()->setUpDefinitionDictionary($schemaProcessor, $schema);
Expand Down
8 changes: 4 additions & 4 deletions src/Model/Validator/AdditionalPropertiesValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct(
SchemaProcessor $schemaProcessor,
Schema $schema,
JsonSchema $propertiesStructure,
?string $propertyName = null
?string $propertyName = null,
) {
$propertyFactory = new PropertyFactory(new PropertyProcessorFactory());

Expand All @@ -58,7 +58,7 @@ public function __construct(
$schemaProcessor,
$schema,
static::PROPERTY_NAME,
$propertiesStructure->withJson($propertiesStructure->getJson()[static::ADDITIONAL_PROPERTIES_KEY])
$propertiesStructure->withJson($propertiesStructure->getJson()[static::ADDITIONAL_PROPERTIES_KEY]),
);

$this->validationProperty->onResolve(function (): void {
Expand All @@ -74,7 +74,7 @@ public function __construct(
'schema' => $schema,
'validationProperty' => $this->validationProperty,
'additionalProperties' => RenderHelper::varExportArray(
array_keys($propertiesStructure->getJson()[static::PROPERTIES_KEY] ?? [])
array_keys($propertiesStructure->getJson()[static::PROPERTIES_KEY] ?? []),
),
'patternProperties' => $patternProperties ? RenderHelper::varExportArray($patternProperties) : null,
'generatorConfiguration' => $schemaProcessor->getGeneratorConfiguration(),
Expand All @@ -83,7 +83,7 @@ public function __construct(
'collectAdditionalProperties' => &$this->collectAdditionalProperties,
],
static::EXCEPTION_CLASS,
['&$invalidProperties']
['&$invalidProperties'],
);
}

Expand Down
6 changes: 3 additions & 3 deletions src/Model/Validator/ArrayItemValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(
SchemaProcessor $schemaProcessor,
Schema $schema,
JsonSchema $itemStructure,
PropertyInterface $property
PropertyInterface $property,
) {
$nestedPropertyName = "item of array {$property->getName()}";
$this->variableSuffix = '_' . md5($nestedPropertyName);
Expand All @@ -54,7 +54,7 @@ public function __construct(
$schemaProcessor,
$schema,
$nestedPropertyName,
$itemStructure
$itemStructure,
);

$this->nestedProperty->onResolve(function () use ($property): void {
Expand All @@ -75,7 +75,7 @@ public function __construct(
'suffix' => $this->variableSuffix,
],
InvalidItemException::class,
["&\$invalidItems{$this->variableSuffix}"]
["&\$invalidItems{$this->variableSuffix}"],
);
}

Expand Down
6 changes: 3 additions & 3 deletions src/Model/Validator/ArrayTupleValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct(
SchemaProcessor $schemaProcessor,
Schema $schema,
JsonSchema $propertiesStructure,
string $propertyName
string $propertyName,
) {
$propertyFactory = new PropertyFactory(new PropertyProcessorFactory());

Expand All @@ -55,7 +55,7 @@ public function __construct(
$schemaProcessor,
$schema,
$tupleItemName,
$propertiesStructure->withJson($tupleItem)
$propertiesStructure->withJson($tupleItem),
);

$this->tupleProperties[] = $tupleProperty;
Expand All @@ -73,7 +73,7 @@ public function __construct(
'generatorConfiguration' => $schemaProcessor->getGeneratorConfiguration(),
],
InvalidTupleException::class,
['&$invalidTuples']
['&$invalidTuples'],
);
}

Expand Down
Loading

0 comments on commit 0790387

Please sign in to comment.