Skip to content

Commit b479381

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

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

src/Metadata/Model/TypeMeta.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,20 @@ final class TypeMeta
123123
*/
124124
private $isQualified;
125125

126+
/**
127+
* The soap-enc array-type information
128+
*
129+
* @var array{type: non-empty-string, itemType: non-empty-string, namespace: non-empty-string}|null
130+
*/
131+
private $arrayType;
132+
133+
/**
134+
* The name of the internal array nodes for soap-enc arrays
135+
*
136+
* @var string|null
137+
*/
138+
private $arrayNodeName;
139+
126140
/**
127141
* @return Option<bool>
128142
*/
@@ -484,4 +498,42 @@ public function withIsQualified(?bool $qualified): self
484498

485499
return $new;
486500
}
501+
502+
/**
503+
* @return Option<array{type: non-empty-string, itemType: non-empty-string, namespace: non-empty-string}>
504+
*/
505+
public function arrayType(): Option
506+
{
507+
return from_nullable($this->arrayType);
508+
}
509+
510+
public function withArrayType(?array $arrayType): self
511+
{
512+
$new = clone $this;
513+
$new->arrayType = optional(
514+
shape([
515+
'type' => non_empty_string(),
516+
'itemType' => non_empty_string(),
517+
'namespace' => non_empty_string(),
518+
], true)
519+
)->coerce($arrayType);
520+
521+
return $new;
522+
}
523+
524+
/**
525+
* @return Option<string>
526+
*/
527+
public function arrayNodeName(): Option
528+
{
529+
return from_nullable($this->arrayNodeName);
530+
}
531+
532+
public function withArrayNodeName(?string $arrayNodeName): self
533+
{
534+
$new = clone $this;
535+
$new->arrayNodeName = $arrayNodeName;
536+
537+
return $new;
538+
}
487539
}

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)