Skip to content

Conversation

Norbytus
Copy link
Contributor

@Norbytus Norbytus commented Apr 6, 2025

If try class static method from php it throws exception

Uncaught Error: Non-static method Test::staticTest()

Cause in proc_macros missing usage of MethodFlags::Static

#[php_class]
#[derive(Default)]
struct Test {}

#[php_impl]
impl Test {
    #[php(constructor)]
    fn new() -> Self {
        Self {}
    }
    /// Declare as static method
    fn static_test() -> String {
        String::from("Hello")
    }
}
<?php

$t = new Test;
Test::staticTest(); // Get exception

In PR i change FnBuilder from single additional modifier with flag abstract to Vec, Myabe we should make uniq Vec, idk)

@Xenira
Copy link
Collaborator

Xenira commented Apr 6, 2025

Nice catch. Would you mind including an integration test as well.

Will have a closer look at the implementation this evening.

@Norbytus Norbytus force-pushed the fix/fix_missing_static_flags branch 2 times, most recently from a12c512 to c4a8270 Compare April 6, 2025 14:30
@Norbytus Norbytus force-pushed the fix/fix_missing_static_flags branch from c4a8270 to fa00137 Compare April 6, 2025 19:49
@Xenira Xenira merged commit 645ffb8 into davidcole1340:master Apr 7, 2025
33 of 35 checks passed
@davidcole1340 davidcole1340 mentioned this pull request Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants