<?php
declare(strict_types=1);
...
// validation for constraint: float
if (!is_null($secondOperand) && !(is_float($secondOperand) || is_numeric($secondOperand))) {
throw new InvalidArgumentException(sprintf('Invalid value %s, please provide a float value, %s given', var_export($secondOperand, true), gettype($secondOperand)), __LINE__);
}
// validation for constraint: pattern([\-]?[0-9]+\.[0-9]{2})
if (!is_null($secondOperand) && !preg_match('/[\\-]?[0-9]+\\.[0-9]{2}/', $secondOperand)) {
throw new InvalidArgumentException(sprintf('Invalid value %s, please provide a literal that is among the set of character sequences denoted by the regular expression /[\\-]?[0-9]+\\.[0-9]{2}/', var_export($secondOperand, true)), __LINE__);
}
This leads to the following PHP error:
Uncaught TypeError: preg_match(): Argument #2 ($subject) must be of type string, float given in
The error is caused by the strict type checking in >= PHP 8.1, where the second argument of preg_match is a string, while it is in fact a float.
It could maybe fixed by doing an explicit (string) casting.
To Reproduce
The issue occurs during the usage of the generated package
I think it is quite clear, what happens. If not, I could provide the wsdl and xsd files.
Describe the bug
There is a type error issue when using a regex pattern for a decimal restriction.
In a project we are using the following XSD restriction:
The generated PHP part looks like this:
This leads to the following PHP error:
The error is caused by the strict type checking in >= PHP 8.1, where the second argument of
preg_match
is a string, while it is in fact a float.It could maybe fixed by doing an explicit (string) casting.
To Reproduce The issue occurs during the usage of the generated package I think it is quite clear, what happens. If not, I could provide the wsdl and xsd files.
Expected behavior Well, no type error :-)