Skip to content

Generate nullable param in function signature #538

@Norbytus

Description

@Norbytus

Description

Description

When declare function/method with macros, it's generate nullable params.

Steps to Reproduce

In rust declare a struct with function with default value. In macro crate function.rs on nullable check it's set nullable for default value.
For me it's weird, but maybe only for me)

Example

Extension Code:

#[php_class]
#[php(name = "Rust\\A")]
struct A;

#[php_impl]
impl A {
    #[php(defaults(value = 0))]
    pub fn test(value: i32) -> i32 {
        value
    }
}

PHP Code:

<?php
$test = new Rust\A;
// Will work find
var_dump($test->test(null));

Expected Behavior

Should be error.

Log Output

Affected Components

  • ext-php-rs
  • macros
  • cli (cargo-php)

PHP Version

PHP 8.4

ext-php-rs Version

0.4.12

Operating System

Archlinux

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions