ext-php-rs
ext-php-rs copied to clipboard
Stub generation of optional arguments doesn't set default value to NULL
Given a function like this:
#[php_function()]
pub fn foo(a: String, b: Option<bool>) -> PhpResult<Zval> {
...
}
The generated stub looks like this:
namespace {
function foo(string $a, ?bool $b): mixed {}
}
However, this is not reflecting the truth, as $b here is just documented as nullable, but must be specified, whereas in reality it's optional. The stub should therefore be
namespace {
function foo(string $a, ?bool $b = null): mixed {}
}