Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue #280 - put nullable constructor args at the end #282

Merged
merged 1 commit into from
Mar 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions src/Model/Struct.php
Original file line number Diff line number Diff line change
Expand Up @@ -395,24 +395,26 @@ protected function addInheritanceAttributes(StructAttributeContainer $attributes
protected function putRequiredAttributesFirst(StructAttributeContainer $allAttributes): StructAttributeContainer
{
$attributes = new StructAttributeContainer($this->getGenerator());
$requiredAttributes = new StructAttributeContainer($this->getGenerator());
$notRequiredAttributes = new StructAttributeContainer($this->getGenerator());
$requiredAttributes = [];
$notRequiredAttributes = [];
$nullableNotRequiredAttributes = [];

/** @var StructAttribute $attribute */
foreach ($allAttributes as $attribute) {
if ($attribute->isRequired() && !$attribute->isNullable()) {
$requiredAttributes->add($attribute);
$requiredAttributes[] = $attribute;
} elseif (!$attribute->isNullable()) {
$notRequiredAttributes[] = $attribute;
} else {
$notRequiredAttributes->add($attribute);
$nullableNotRequiredAttributes[] = $attribute;
}
}
foreach ($requiredAttributes as $attribute) {
$attributes->add($attribute);
}
foreach ($notRequiredAttributes as $attribute) {
$attributes->add($attribute);
}
unset($requiredAttributes, $notRequiredAttributes);

array_walk($requiredAttributes, [$attributes, 'add']);
array_walk($notRequiredAttributes, [$attributes, 'add']);
array_walk($nullableNotRequiredAttributes, [$attributes, 'add']);

unset($requiredAttributes, $notRequiredAttributes, $nullableNotRequiredAttributes);

return $attributes;
}
Expand Down
264 changes: 132 additions & 132 deletions tests/resources/generated/ValidCampaignGetItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,6 @@ class ApiCampaignGetItem extends ApiCampaignBase
* @var string|null
*/
public ?string $StatusClarification = null;
/**
* The SourceId
* Meta information extracted from the WSDL
* - maxOccurs: 1
* - minOccurs: 0
* - nillable: true
* @var int|null
*/
public ?int $SourceId = null;
/**
* The Statistics
* Meta information extracted from the WSDL
Expand Down Expand Up @@ -119,6 +110,39 @@ class ApiCampaignGetItem extends ApiCampaignBase
* @var \StructType\ApiCampaignAssistant|null
*/
public ?\StructType\ApiCampaignAssistant $RepresentedBy = null;
/**
* The TextCampaign
* Meta information extracted from the WSDL
* - maxOccurs: 1
* - minOccurs: 0
* @var \StructType\ApiTextCampaignGetItem|null
*/
public ?\StructType\ApiTextCampaignGetItem $TextCampaign = null;
/**
* The MobileAppCampaign
* Meta information extracted from the WSDL
* - maxOccurs: 1
* - minOccurs: 0
* @var \StructType\ApiMobileAppCampaignGetItem|null
*/
public ?\StructType\ApiMobileAppCampaignGetItem $MobileAppCampaign = null;
/**
* The DynamicTextCampaign
* Meta information extracted from the WSDL
* - maxOccurs: 1
* - minOccurs: 0
* @var \StructType\ApiDynamicTextCampaignGetItem|null
*/
public ?\StructType\ApiDynamicTextCampaignGetItem $DynamicTextCampaign = null;
/**
* The SourceId
* Meta information extracted from the WSDL
* - maxOccurs: 1
* - minOccurs: 0
* - nillable: true
* @var int|null
*/
public ?int $SourceId = null;
/**
* The DailyBudget
* Meta information extracted from the WSDL
Expand Down Expand Up @@ -164,30 +188,6 @@ class ApiCampaignGetItem extends ApiCampaignBase
* @var \ArrayType\ApiArrayOfString|null
*/
public ?\ArrayType\ApiArrayOfString $ExcludedSites = null;
/**
* The TextCampaign
* Meta information extracted from the WSDL
* - maxOccurs: 1
* - minOccurs: 0
* @var \StructType\ApiTextCampaignGetItem|null
*/
public ?\StructType\ApiTextCampaignGetItem $TextCampaign = null;
/**
* The MobileAppCampaign
* Meta information extracted from the WSDL
* - maxOccurs: 1
* - minOccurs: 0
* @var \StructType\ApiMobileAppCampaignGetItem|null
*/
public ?\StructType\ApiMobileAppCampaignGetItem $MobileAppCampaign = null;
/**
* The DynamicTextCampaign
* Meta information extracted from the WSDL
* - maxOccurs: 1
* - minOccurs: 0
* @var \StructType\ApiDynamicTextCampaignGetItem|null
*/
public ?\StructType\ApiDynamicTextCampaignGetItem $DynamicTextCampaign = null;
/**
* Constructor method for CampaignGetItem
* @uses ApiCampaignGetItem::setId()
Expand All @@ -198,19 +198,19 @@ class ApiCampaignGetItem extends ApiCampaignBase
* @uses ApiCampaignGetItem::setState()
* @uses ApiCampaignGetItem::setStatusPayment()
* @uses ApiCampaignGetItem::setStatusClarification()
* @uses ApiCampaignGetItem::setSourceId()
* @uses ApiCampaignGetItem::setStatistics()
* @uses ApiCampaignGetItem::setCurrency()
* @uses ApiCampaignGetItem::setFunds()
* @uses ApiCampaignGetItem::setRepresentedBy()
* @uses ApiCampaignGetItem::setTextCampaign()
* @uses ApiCampaignGetItem::setMobileAppCampaign()
* @uses ApiCampaignGetItem::setDynamicTextCampaign()
* @uses ApiCampaignGetItem::setSourceId()
* @uses ApiCampaignGetItem::setDailyBudget()
* @uses ApiCampaignGetItem::setEndDate()
* @uses ApiCampaignGetItem::setNegativeKeywords()
* @uses ApiCampaignGetItem::setBlockedIps()
* @uses ApiCampaignGetItem::setExcludedSites()
* @uses ApiCampaignGetItem::setTextCampaign()
* @uses ApiCampaignGetItem::setMobileAppCampaign()
* @uses ApiCampaignGetItem::setDynamicTextCampaign()
* @param int $id
* @param string $name
* @param string $startDate
Expand All @@ -219,21 +219,21 @@ class ApiCampaignGetItem extends ApiCampaignBase
* @param string $state
* @param string $statusPayment
* @param string $statusClarification
* @param int $sourceId
* @param \StructType\ApiStatistics $statistics
* @param string $currency
* @param \StructType\ApiFundsParam $funds
* @param \StructType\ApiCampaignAssistant $representedBy
* @param \StructType\ApiTextCampaignGetItem $textCampaign
* @param \StructType\ApiMobileAppCampaignGetItem $mobileAppCampaign
* @param \StructType\ApiDynamicTextCampaignGetItem $dynamicTextCampaign
* @param int $sourceId
* @param \StructType\ApiDailyBudget $dailyBudget
* @param string $endDate
* @param \ArrayType\ApiArrayOfString $negativeKeywords
* @param \ArrayType\ApiArrayOfString $blockedIps
* @param \ArrayType\ApiArrayOfString $excludedSites
* @param \StructType\ApiTextCampaignGetItem $textCampaign
* @param \StructType\ApiMobileAppCampaignGetItem $mobileAppCampaign
* @param \StructType\ApiDynamicTextCampaignGetItem $dynamicTextCampaign
*/
public function __construct(?int $id = null, ?string $name = null, ?string $startDate = null, ?string $type = null, ?string $status = null, ?string $state = null, ?string $statusPayment = null, ?string $statusClarification = null, ?int $sourceId = null, ?\StructType\ApiStatistics $statistics = null, ?string $currency = null, ?\StructType\ApiFundsParam $funds = null, ?\StructType\ApiCampaignAssistant $representedBy = null, ?\StructType\ApiDailyBudget $dailyBudget = null, ?string $endDate = null, ?\ArrayType\ApiArrayOfString $negativeKeywords = null, ?\ArrayType\ApiArrayOfString $blockedIps = null, ?\ArrayType\ApiArrayOfString $excludedSites = null, ?\StructType\ApiTextCampaignGetItem $textCampaign = null, ?\StructType\ApiMobileAppCampaignGetItem $mobileAppCampaign = null, ?\StructType\ApiDynamicTextCampaignGetItem $dynamicTextCampaign = null)
public function __construct(?int $id = null, ?string $name = null, ?string $startDate = null, ?string $type = null, ?string $status = null, ?string $state = null, ?string $statusPayment = null, ?string $statusClarification = null, ?\StructType\ApiStatistics $statistics = null, ?string $currency = null, ?\StructType\ApiFundsParam $funds = null, ?\StructType\ApiCampaignAssistant $representedBy = null, ?\StructType\ApiTextCampaignGetItem $textCampaign = null, ?\StructType\ApiMobileAppCampaignGetItem $mobileAppCampaign = null, ?\StructType\ApiDynamicTextCampaignGetItem $dynamicTextCampaign = null, ?int $sourceId = null, ?\StructType\ApiDailyBudget $dailyBudget = null, ?string $endDate = null, ?\ArrayType\ApiArrayOfString $negativeKeywords = null, ?\ArrayType\ApiArrayOfString $blockedIps = null, ?\ArrayType\ApiArrayOfString $excludedSites = null)
{
$this
->setId($id)
Expand All @@ -244,19 +244,19 @@ public function __construct(?int $id = null, ?string $name = null, ?string $star
->setState($state)
->setStatusPayment($statusPayment)
->setStatusClarification($statusClarification)
->setSourceId($sourceId)
->setStatistics($statistics)
->setCurrency($currency)
->setFunds($funds)
->setRepresentedBy($representedBy)
->setTextCampaign($textCampaign)
->setMobileAppCampaign($mobileAppCampaign)
->setDynamicTextCampaign($dynamicTextCampaign)
->setSourceId($sourceId)
->setDailyBudget($dailyBudget)
->setEndDate($endDate)
->setNegativeKeywords($negativeKeywords)
->setBlockedIps($blockedIps)
->setExcludedSites($excludedSites)
->setTextCampaign($textCampaign)
->setMobileAppCampaign($mobileAppCampaign)
->setDynamicTextCampaign($dynamicTextCampaign);
->setExcludedSites($excludedSites);
}
/**
* Get Id value
Expand Down Expand Up @@ -410,34 +410,6 @@ public function setStatusClarification(?string $statusClarification = null): sel

return $this;
}
/**
* Get SourceId value
* An additional test has been added (isset) before returning the property value as
* this property may have been unset before, due to the fact that this property is
* removable from the request (nillable=true+minOccurs=0)
* @return int|null
*/
public function getSourceId(): ?int
{
return $this->SourceId ?? null;
}
/**
* Set SourceId value
* This property is removable from request (nillable=true+minOccurs=0), therefore
* if the value assigned to this property is null, it is removed from this object
* @param int $sourceId
* @return \StructType\ApiCampaignGetItem
*/
public function setSourceId(?int $sourceId = null): self
{
if (is_null($sourceId) || (is_array($sourceId) && empty($sourceId))) {
unset($this->SourceId);
} else {
$this->SourceId = $sourceId;
}

return $this;
}
/**
* Get Statistics value
* @return \StructType\ApiStatistics|null
Expand Down Expand Up @@ -514,6 +486,91 @@ public function setRepresentedBy(?\StructType\ApiCampaignAssistant $representedB

return $this;
}
/**
* Get TextCampaign value
* @return \StructType\ApiTextCampaignGetItem|null
*/
public function getTextCampaign(): ?\StructType\ApiTextCampaignGetItem
{
return $this->TextCampaign;
}
/**
* Set TextCampaign value
* @param \StructType\ApiTextCampaignGetItem $textCampaign
* @return \StructType\ApiCampaignGetItem
*/
public function setTextCampaign(?\StructType\ApiTextCampaignGetItem $textCampaign = null): self
{
$this->TextCampaign = $textCampaign;

return $this;
}
/**
* Get MobileAppCampaign value
* @return \StructType\ApiMobileAppCampaignGetItem|null
*/
public function getMobileAppCampaign(): ?\StructType\ApiMobileAppCampaignGetItem
{
return $this->MobileAppCampaign;
}
/**
* Set MobileAppCampaign value
* @param \StructType\ApiMobileAppCampaignGetItem $mobileAppCampaign
* @return \StructType\ApiCampaignGetItem
*/
public function setMobileAppCampaign(?\StructType\ApiMobileAppCampaignGetItem $mobileAppCampaign = null): self
{
$this->MobileAppCampaign = $mobileAppCampaign;

return $this;
}
/**
* Get DynamicTextCampaign value
* @return \StructType\ApiDynamicTextCampaignGetItem|null
*/
public function getDynamicTextCampaign(): ?\StructType\ApiDynamicTextCampaignGetItem
{
return $this->DynamicTextCampaign;
}
/**
* Set DynamicTextCampaign value
* @param \StructType\ApiDynamicTextCampaignGetItem $dynamicTextCampaign
* @return \StructType\ApiCampaignGetItem
*/
public function setDynamicTextCampaign(?\StructType\ApiDynamicTextCampaignGetItem $dynamicTextCampaign = null): self
{
$this->DynamicTextCampaign = $dynamicTextCampaign;

return $this;
}
/**
* Get SourceId value
* An additional test has been added (isset) before returning the property value as
* this property may have been unset before, due to the fact that this property is
* removable from the request (nillable=true+minOccurs=0)
* @return int|null
*/
public function getSourceId(): ?int
{
return $this->SourceId ?? null;
}
/**
* Set SourceId value
* This property is removable from request (nillable=true+minOccurs=0), therefore
* if the value assigned to this property is null, it is removed from this object
* @param int $sourceId
* @return \StructType\ApiCampaignGetItem
*/
public function setSourceId(?int $sourceId = null): self
{
if (is_null($sourceId) || (is_array($sourceId) && empty($sourceId))) {
unset($this->SourceId);
} else {
$this->SourceId = $sourceId;
}

return $this;
}
/**
* Get DailyBudget value
* An additional test has been added (isset) before returning the property value as
Expand Down Expand Up @@ -652,63 +709,6 @@ public function setExcludedSites(?\ArrayType\ApiArrayOfString $excludedSites = n
$this->ExcludedSites = $excludedSites;
}

return $this;
}
/**
* Get TextCampaign value
* @return \StructType\ApiTextCampaignGetItem|null
*/
public function getTextCampaign(): ?\StructType\ApiTextCampaignGetItem
{
return $this->TextCampaign;
}
/**
* Set TextCampaign value
* @param \StructType\ApiTextCampaignGetItem $textCampaign
* @return \StructType\ApiCampaignGetItem
*/
public function setTextCampaign(?\StructType\ApiTextCampaignGetItem $textCampaign = null): self
{
$this->TextCampaign = $textCampaign;

return $this;
}
/**
* Get MobileAppCampaign value
* @return \StructType\ApiMobileAppCampaignGetItem|null
*/
public function getMobileAppCampaign(): ?\StructType\ApiMobileAppCampaignGetItem
{
return $this->MobileAppCampaign;
}
/**
* Set MobileAppCampaign value
* @param \StructType\ApiMobileAppCampaignGetItem $mobileAppCampaign
* @return \StructType\ApiCampaignGetItem
*/
public function setMobileAppCampaign(?\StructType\ApiMobileAppCampaignGetItem $mobileAppCampaign = null): self
{
$this->MobileAppCampaign = $mobileAppCampaign;

return $this;
}
/**
* Get DynamicTextCampaign value
* @return \StructType\ApiDynamicTextCampaignGetItem|null
*/
public function getDynamicTextCampaign(): ?\StructType\ApiDynamicTextCampaignGetItem
{
return $this->DynamicTextCampaign;
}
/**
* Set DynamicTextCampaign value
* @param \StructType\ApiDynamicTextCampaignGetItem $dynamicTextCampaign
* @return \StructType\ApiCampaignGetItem
*/
public function setDynamicTextCampaign(?\StructType\ApiDynamicTextCampaignGetItem $dynamicTextCampaign = null): self
{
$this->DynamicTextCampaign = $dynamicTextCampaign;

return $this;
}
}