Trying to invoke %s method %s::%s() from scope %s

Description

This error reports that the requested method exists, but is not available from the context of call. Here, the method is protected and should only be called from a child class of x.

There are distinct messages for calling an unknown method, or calling a private method.

Example

<?php

class X {
    protected function foo() {}
}

class Y {
    function g() {
        $x = new X;
        $x->foo();
    }
}

(new Y)->g();

?>

Solutions

  • Check the name of the method for typo.

  • Check the object of the method is the correct one.