ext-php-rs icon indicating copy to clipboard operation
ext-php-rs copied to clipboard

Stub generation of optional arguments doesn't set default value to NULL

Open pprkut opened this issue 1 year ago • 0 comments

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 {}
}

pprkut avatar Dec 19 '23 14:12 pprkut