psalm
psalm copied to clipboard
Non-static methods called statically should report error
https://psalm.dev/r/8d8e02aefb
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!