Call to %s %s::%s() from global scope

Description

This error reports that the requested method exists, but is not available from the context of call. Here, the method is private and should only be called from within its definition class.

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

Example

<?php

class X {
    public function foo() {}
    private function goo() {}
}

$x = new X;
$x->goo();

?>

Literal Examples

  • Call to private x::goo() from global scope

Solutions

  • Call a public method on that class.

  • Check for typos in the name of the method.

  • Change the visibility of the method, to be able to call it.