Skip to content

Commit db2726a

Browse files
committed
Add soap-enc array information
1 parent 789fb1c commit db2726a

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

src/Metadata/Model/TypeMeta.php

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ final class TypeMeta
6868
*/
6969
private $isList;
7070

71+
/**
72+
* @var bool|null
73+
*/
74+
private $isRepeatingElement;
75+
7176
/**
7277
* @var bool|null
7378
*/
@@ -123,6 +128,20 @@ final class TypeMeta
123128
*/
124129
private $isQualified;
125130

131+
/**
132+
* The soap-enc array-type information
133+
*
134+
* @var array{type: non-empty-string, itemType: non-empty-string, namespace: non-empty-string}|null
135+
*/
136+
private $arrayType;
137+
138+
/**
139+
* The name of the internal array nodes for soap-enc arrays
140+
*
141+
* @var string|null
142+
*/
143+
private $arrayNodeName;
144+
126145
/**
127146
* @return Option<bool>
128147
*/
@@ -295,6 +314,22 @@ public function withIsList(?bool $isList): self
295314
return $new;
296315
}
297316

317+
/**
318+
* @return Option<bool>
319+
*/
320+
public function isRepeatingElement(): Option
321+
{
322+
return from_nullable($this->isRepeatingElement);
323+
}
324+
325+
public function withIsRepeatingElement(?bool $isRepeatingElement): self
326+
{
327+
$new = clone $this;
328+
$new->isRepeatingElement = $isRepeatingElement;
329+
330+
return $new;
331+
}
332+
298333
/**
299334
* @return Option<bool>
300335
*/
@@ -484,4 +519,42 @@ public function withIsQualified(?bool $qualified): self
484519

485520
return $new;
486521
}
522+
523+
/**
524+
* @return Option<array{type: non-empty-string, itemType: non-empty-string, namespace: non-empty-string}>
525+
*/
526+
public function arrayType(): Option
527+
{
528+
return from_nullable($this->arrayType);
529+
}
530+
531+
public function withArrayType(?array $arrayType): self
532+
{
533+
$new = clone $this;
534+
$new->arrayType = optional(
535+
shape([
536+
'type' => non_empty_string(),
537+
'itemType' => non_empty_string(),
538+
'namespace' => non_empty_string(),
539+
], true)
540+
)->coerce($arrayType);
541+
542+
return $new;
543+
}
544+
545+
/**
546+
* @return Option<string>
547+
*/
548+
public function arrayNodeName(): Option
549+
{
550+
return from_nullable($this->arrayNodeName);
551+
}
552+
553+
public function withArrayNodeName(?string $arrayNodeName): self
554+
{
555+
$new = clone $this;
556+
$new->arrayNodeName = $arrayNodeName;
557+
558+
return $new;
559+
}
487560
}

src/Metadata/Model/XsdType.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Soap\Engine\Metadata\Model;
66

7+
use Soap\Xml\Xmlns;
8+
79
final class XsdType
810
{
911
/**
@@ -75,6 +77,19 @@ public static function guess(string $name): self
7577
->withBaseType(self::convertBaseType($name, ''));
7678
}
7779

80+
public static function any(): self
81+
{
82+
return self::guess('anyType')
83+
->withXmlTypeName('anyType')
84+
->withXmlNamespace(Xmlns::xsd()->value())
85+
->withMeta(
86+
static fn (TypeMeta $meta): TypeMeta => $meta
87+
->withIsSimple(true)
88+
->withIsNullable(true)
89+
->withIsNil(true)
90+
);
91+
}
92+
7893
/**
7994
* @return array<string, string>
8095
*/
@@ -86,6 +101,7 @@ public static function fetchAllKnownBaseTypeMappings(): array
86101
'anyuri' => 'string',
87102
'anyxml' => 'string',
88103
'anysimpletype' => 'mixed',
104+
'array' => 'array',
89105
'base64binary' => 'string',
90106
'byte' => 'integer',
91107
'decimal' => 'float',

0 commit comments

Comments
 (0)