-
Notifications
You must be signed in to change notification settings - Fork 78
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
While write tests for __call_static, some test running get error cause get wrong result,
use std::collections::HashMap;
use ext_php_rs::prelude::*;
use ext_php_rs::types::Zval;
pub fn startup(_ty: i32, _: i32) -> i32 {
0
}
#[php_class]
#[derive(Default)]
struct Test {}
#[php_impl]
impl Test {
#[php(constructor)]
fn __constructor() -> Self {
Self {}
}
pub fn __call_static(name: String, arguments: HashMap<String, &Zval>) -> Zval {
let mut zval = Zval::new();
if name == "callStaticSomeMagic" {
let concat_args = format!(
"Hello from static call {}",
arguments
.iter()
.filter(|(_, v)| v.is_long())
.map(|(_, s)| s.long().unwrap().to_string())
.collect::<Vec<_>>()
.join(" ")
);
let _ = zval.set_string(&concat_args, false);
zval
} else {
zval.set_null();
zval
}
}
}
#[php_module]
fn module(module: ModuleBuilder) -> ModuleBuilder {
module.class::<Test>()
}
<?php
$t = new Test;
var_dump($t::callStaticSomeMagic(1, 2, 3));
// Some time show correct result but some time input number in different order
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request