else { $code =
$p->
areScalarsAllowed() ? '$this->PROPERTY instanceof CLASS ? $this->PROPERTY->toArray() : $this->PROPERTY'
: '$this->PROPERTY->toArray()'
;
} } $body .=
strtr('
if (isset($this->_usedProperties[\'PROPERTY\'])) {
$output[\'ORG_NAME\'] = '.
$code.';
}',
['PROPERTY' =>
$p->
getName(), 'ORG_NAME' =>
$p->
getOriginalName(), 'CLASS' =>
$p->
getType()]);
} $extraKeys =
$class->
shouldAllowExtraKeys() ? ' + $this->_extraKeys' : '';
$class->
addMethod('toArray', '
public function NAME(): array
{
'.
$body.'
return $output'.
$extraKeys.';
}'
);
}