Skip to content

Complete interface impl #590

@Norbytus

Description

@Norbytus

Description

Description

Need impl 2 interface features:

Rust struct declared as php_class and impl trait declared as php_interface

#[php_interface]
#[php(name = "ExtPhpRs\\Interface\\HelloInterface")]
trait HelloTrait {
    fn say_hello(): String; 
}

#[php_class]
#[php(name = "ExtPhpRs\\Test")]
struct Test;

impl HelloTrait for Test {
    fn say_hello(): String {
        String::from("Hello")
    }
}
<?php
assert(class_exists('ExtPhpRs\Test'), 'Class not exist');
assert(interface_exists('ExtPhpRs\Interface\HelloInterface'), 'Interface not exist');
assert(is_a('ExtPhpRs\Test', ExtPhpRs\Interface\HelloInterface', true));

Convert supertrait to interface extending

#[php_interface]
#[php(name = "ExtPhpRs\\Interface\\BaseInterface")]
trait BaseTrait {}
#[php_interface]
#[php(name = "ExtPhpRs\\Interface\\ChildInterface")]
trait ChildTrait: BaseTrait { }
<?php

assert(interface_exists('ExtPhpRs\Interface\BaseInterface'), 'Interface not exist');
assert(interface_exists('ExtPhpRs\Interface\ChildInterface'), 'Interface not exist');
assert(is_a('ExtPhpRs\Interface\ChildInterface', 'ExtPhpRs\Interface\BaseInterface', true), 'Interface could extend ExtPhpRs\Interface\BaseInterface');

Additional Context

  • I can try implementing this feature myself (please assign me to this issue)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions