ext-php-rs
ext-php-rs copied to clipboard
PHP Fatal error: Class Foo cannot implement previously implemented interface Stringable in Unknown on line 0
Hi I encountered an issue with the __toString method
rust 1.80 ext-php-rs 0.12.0 php 8.3
rust code
use ext_php_rs::{info_table_end, info_table_row, info_table_start, prelude::*};
use ext_php_rs::{exception::PhpResult, types::Zval, zend::ce};
use ext_php_rs::zend::ModuleEntry;
#[php_class(name = "Foo")]
#[implements(ce::stringable())]
#[implements(ce::countable())]
#[derive(Default)]
pub struct Foo {
}
#[php_impl]
impl Foo {
#[constructor]
pub fn __construct() -> Self {
Foo {
}
}
pub fn __to_string(&self) -> String {
format!("string")
}
pub fn count(&self) -> i32 {
1
}
}
/// Used by the `phpinfo()` function and when you run `php -i`.
pub extern "C" fn php_module_info(_module: *mut ModuleEntry) {
info_table_start!();
info_table_row!("Foo", "enabled");
info_table_end!();
}
#[php_module]
pub fn module(module: ModuleBuilder) -> ModuleBuilder {
module
}
php code
<?php
$foo = new Foo();
echo $foo;
php -d extension=./target/debug/libphp_foo.so test.php PHP Fatal error: Class Foo cannot implement previously implemented interface Stringable in Unknown on line 0 [1] 266183 IOT instruction php -d extension=./target/debug/libphp_foo.so test.php