-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Closed
Description
Description
ext-soap
should handle parsing and creating tags that are from type xsd:date
or similar
old PHP Bug about it: https://bugs.php.net/bug.php?id=44383
currently when you try to send a Datetime Object from php via soap, the send field is just empty without any exception
what would be better:
- if either it would better show an exception for types that can't be converted
- it could handle the transformation from Datetime(Interface) into
xsd:date
itself
My first try was this:
$typeMap = [
[
"type_ns" => "http://www.w3.org/2001/XMLSchema",
"type_name" => "date", // xsd:date
"to_xml" => [self::class, 'toXSDDate']
]
];
public static function toXSDDate(?DateTimeInterface $dateTime): ?string
{
if (is_null($dateTime)) {
return null;
}
return $dateTime->format(DateTimeInterface::ATOM);
}
But that still doesn't work, because it is NOWHERE documented (or shown a warning or thrown an exception) that the to_xml
callback explicit wants a string that somewhat looks like an xml, IMO that should have been better documented or shown as an example.
function static toXSDDate(?DateTimeInterface $dateTime) : ?string
{
if (is_null($dateTime)) {
return null;
}
return '<value>' . $dateTime->format(DateTimeInterface::ATOM) . '</value>';
}
- The Bug is that it is silently ignored
- The Feature would be to implement the conversion of DateTime objects
- and the related Problem is that the handling of SOAP
typemap
isn't documented
PHP Version
PHP 8.2.6
Operating System
No response