Skip to content

Commit

Permalink
Merge branch 'release/4.1.13'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelcom committed Jun 21, 2024
2 parents 92a85e2 + 9211759 commit fb5b007
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 30 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGELOG

## 4.1.13 - 2024-06-21
- issue #312, pr #313 - Invalid getter and annotation for nullable property

## 4.1.12 - 2024-04-13
- issue #308, pr #309 - Symfony 7 / added support for symfony 7

Expand Down
13 changes: 11 additions & 2 deletions src/File/AbstractModelFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,12 @@ protected function getStructAttributeTypeGetAnnotation(StructAttributeModel $att
return '\\DOMDocument|string|null';
}

return sprintf('%s%s%s', $this->getStructAttributeTypeAsPhpType($attribute, false), $this->useBrackets($attribute, $returnArrayType) ? '[]' : '', !$nullableItemType && ($attribute->isRequired() || $attribute->isArray() || $attribute->isList()) ? '' : '|null');
return sprintf(
'%s%s%s',
$this->getStructAttributeTypeAsPhpType($attribute, false),
$this->useBrackets($attribute, $returnArrayType) ? '[]' : '',
!$nullableItemType && !$attribute->isNullable() && ($attribute->isRequired() || $attribute->isArray() || $attribute->isList()) ? '' : '|null'
);
}

protected function getStructAttributeTypeSetAnnotation(StructAttributeModel $attribute, bool $returnArrayType = true, bool $itemType = false): string
Expand All @@ -413,7 +418,11 @@ protected function getStructAttributeTypeSetAnnotation(StructAttributeModel $att
return 'array|string';
}

return sprintf('%s%s', $this->getStructAttributeTypeAsPhpType($attribute, $returnArrayType), $this->useBrackets($attribute, !$itemType) ? '[]' : '');
return sprintf(
'%s%s',
$this->getStructAttributeTypeAsPhpType($attribute, $returnArrayType),
$this->useBrackets($attribute, !$itemType) ? '[]' : ''
);
}

protected function useBrackets(StructAttributeModel $attribute, bool $returnArrayType = true): bool
Expand Down
21 changes: 10 additions & 11 deletions src/File/Struct.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,17 +347,16 @@ protected function addStructMethodGetBodyReturn(PhpMethod $method, StructAttribu

protected function addStructMethodGet(StructAttributeModel $attribute): self
{
switch (true) {
// it can either be a string, a DOMDocument or null...
case $attribute->isXml():
$returnType = '';

break;

default:
$returnType = (!$attribute->getRemovableFromRequest() && !$attribute->isAChoice() && $attribute->isRequired() ? '' : '?').$this->getStructAttributeTypeAsPhpType($attribute);

break;
// it can either be a string, a DOMDocument or null...
if ($attribute->isXml()) {
$returnType = '';
} else {
$returnType = (
!$attribute->getRemovableFromRequest()
&& !$attribute->isAChoice()
&& $attribute->isRequired()
&& !$attribute->isNullable() ? '' : '?'
).$this->getStructAttributeTypeAsPhpType($attribute);
}

$method = new PhpMethod(
Expand Down
10 changes: 5 additions & 5 deletions src/File/StructArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ public function addStructMethodsSetAndGet(): self
return $this;
}

protected function addClassElement(): AbstractModelFile
{
return AbstractModelFile::addClassElement();
}

public function setModel(AbstractModel $model): self
{
if ($model instanceof StructModel && !$model->isArray()) {
Expand All @@ -54,6 +49,11 @@ public function setModel(AbstractModel $model): self
return parent::setModel($model);
}

protected function addClassElement(): AbstractModelFile
{
return AbstractModelFile::addClassElement();
}

/**
* Disable this feature within StructArray class.
*/
Expand Down
20 changes: 10 additions & 10 deletions tests/resources/generated/ValidBannerInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class ApiBannerInfo extends AbstractStructBase
* - base: soapenc:Array
* - nillable: true
* - ref: soapenc:arrayType
* @var \StructType\ApiBannerPhraseInfo[]
* @var \StructType\ApiBannerPhraseInfo[]|null
*/
protected ?array $Phrases = null;
/**
Expand All @@ -89,7 +89,7 @@ class ApiBannerInfo extends AbstractStructBase
* - base: soapenc:Array
* - nillable: true
* - ref: soapenc:arrayType
* @var string[]
* @var string[]|null
*/
protected ?array $MinusKeywords = null;
/**
Expand Down Expand Up @@ -155,7 +155,7 @@ class ApiBannerInfo extends AbstractStructBase
* - base: soapenc:Array
* - nillable: true
* - ref: soapenc:arrayType
* @var \StructType\ApiSitelink[]
* @var \StructType\ApiSitelink[]|null
*/
protected ?array $Sitelinks = null;
/**
Expand All @@ -165,7 +165,7 @@ class ApiBannerInfo extends AbstractStructBase
* - base: soapenc:Array
* - nillable: true
* - ref: soapenc:arrayType
* @var string[]
* @var string[]|null
*/
protected ?array $AdWarnings = null;
/**
Expand All @@ -182,7 +182,7 @@ class ApiBannerInfo extends AbstractStructBase
* - base: soapenc:Array
* - nillable: true
* - ref: soapenc:arrayType
* @var \StructType\ApiRejectReason[]
* @var \StructType\ApiRejectReason[]|null
*/
protected ?array $ModerateRejectionReasons = null;
/**
Expand Down Expand Up @@ -520,7 +520,7 @@ public function setGeo(?string $geo = null): self
}
/**
* Get Phrases value
* @return \StructType\ApiBannerPhraseInfo[]
* @return \StructType\ApiBannerPhraseInfo[]|null
*/
public function getPhrases(): ?array
{
Expand Down Expand Up @@ -587,7 +587,7 @@ public function addToPhrases(\StructType\ApiBannerPhraseInfo $item): self
}
/**
* Get MinusKeywords value
* @return string[]
* @return string[]|null
*/
public function getMinusKeywords(): ?array
{
Expand Down Expand Up @@ -838,7 +838,7 @@ public function setStatusSitelinksModerate(?string $statusSitelinksModerate = nu
}
/**
* Get Sitelinks value
* @return \StructType\ApiSitelink[]
* @return \StructType\ApiSitelink[]|null
*/
public function getSitelinks(): ?array
{
Expand Down Expand Up @@ -905,7 +905,7 @@ public function addToSitelinks(\StructType\ApiSitelink $item): self
}
/**
* Get AdWarnings value
* @return string[]
* @return string[]|null
*/
public function getAdWarnings(): ?array
{
Expand Down Expand Up @@ -995,7 +995,7 @@ public function setFixedOnModeration(?string $fixedOnModeration = null): self
}
/**
* Get ModerateRejectionReasons value
* @return \StructType\ApiRejectReason[]
* @return \StructType\ApiRejectReason[]|null
*/
public function getModerateRejectionReasons(): ?array
{
Expand Down
4 changes: 2 additions & 2 deletions tests/resources/generated/ValidHouseProfileData.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ class ApiHouseProfileData extends AbstractStructBase
* - base: soap-enc:Array
* - nillable: true
* - ref: soap-enc:arrayType
* @var \StructType\ApiLift[]
* @var \StructType\ApiLift[]|null
*/
protected ?array $lifts = null;
/**
Expand Down Expand Up @@ -1691,7 +1691,7 @@ public function setGas_system(?\StructType\ApiGasSystem $gas_system = null): sel
}
/**
* Get lifts value
* @return \StructType\ApiLift[]
* @return \StructType\ApiLift[]|null
*/
public function getLifts(): ?array
{
Expand Down

0 comments on commit fb5b007

Please sign in to comment.