Skip to content

Commit

Permalink
Merge pull request #111 from DoclerLabs/fix-datetimeinterface-php81
Browse files Browse the repository at this point in the history
fix DateTimeInterface missing from php 8.1+
  • Loading branch information
vsouz4 authored May 7, 2024
2 parents 8eaf0ab + dae4020 commit 84f5211
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [10.7.1] - 2024.05.07
### Fixed
- Missing DateTimeInterface import for php 8.1+

## [10.7.0] - 2024.02.15
### Added
- Added support for php 8.1, 8.2, 8.3 constraints
Expand Down
5 changes: 0 additions & 5 deletions src/Generator/MutatorAccessorClassGeneratorAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace DoclerLabs\ApiClientGenerator\Generator;

use DateTimeInterface;
use DoclerLabs\ApiClientException\RequestValidationException;
use DoclerLabs\ApiClientGenerator\Ast\Builder\CodeBuilder;
use DoclerLabs\ApiClientGenerator\Entity\Constraint\ConstraintInterface;
Expand Down Expand Up @@ -81,10 +80,6 @@ protected function generateGet(Field $field): ClassMethod

protected function generateProperty(Field $field): Property
{
if ($field->isDate()) {
$this->addImport(DateTimeInterface::class);
}

return $this->builder->localProperty(
$field->getPhpVariableName(),
$field->getPhpTypeHint(),
Expand Down
4 changes: 4 additions & 0 deletions src/Generator/RequestGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace DoclerLabs\ApiClientGenerator\Generator;

use DateTimeInterface;
use DoclerLabs\ApiClientGenerator\Ast\Builder\CodeBuilder;
use DoclerLabs\ApiClientGenerator\Ast\Builder\ParameterBuilder;
use DoclerLabs\ApiClientGenerator\Ast\ParameterNode;
Expand Down Expand Up @@ -103,6 +104,9 @@ protected function generateProperties(Request $request, Operation $operation, Sp
)
);
}
if ($field->isDate()) {
$this->addImport(DateTimeInterface::class);
}
if (
$field->isRequired()
&& $this->phpVersion->isConstructorPropertyPromotionSupported()
Expand Down
4 changes: 4 additions & 0 deletions src/Generator/SchemaGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace DoclerLabs\ApiClientGenerator\Generator;

use DateTimeInterface;
use DoclerLabs\ApiClientGenerator\Ast\Builder\ParameterBuilder;
use DoclerLabs\ApiClientGenerator\Ast\ParameterNode;
use DoclerLabs\ApiClientGenerator\Entity\Field;
Expand Down Expand Up @@ -108,6 +109,9 @@ protected function generateProperties(Field $root): array
{
$statements = [];
foreach ($root->getObjectProperties() as $propertyField) {
if ($propertyField->isDate()) {
$this->addImport(DateTimeInterface::class);
}
if (
$propertyField->isRequired()
&& $this->phpVersion->isConstructorPropertyPromotionSupported()
Expand Down

0 comments on commit 84f5211

Please sign in to comment.