Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-static methods called statically should report error #8509

Closed
kkmuffme opened this issue Sep 24, 2022 · 1 comment · Fixed by #10839
Closed

Non-static methods called statically should report error #8509

kkmuffme opened this issue Sep 24, 2022 · 1 comment · Fixed by #10839

Comments

@kkmuffme
Copy link
Contributor

https://psalm.dev/r/8d8e02aefb

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/8d8e02aefb
<?php

/**
 * @param callable $callable
 * @return void
 */
function do_action( $callable ) {
    call_user_func( $callable );
}

class foo {
    public function __construct() {        
        // should give error, since "hello" isn't static
        do_action( array( __CLASS__, 'hello' ) );
        do_action( array( foo::class, 'hello' ) );
        do_action( array( 'foo', 'hello' ) );
        do_action( 'foo::hello' );
    }
    
    /**
     * @return string
     */
 	public function hello() {
        return 'hello';
    }
}
Psalm output (using commit 028ac7f):

No issues!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants