Methodcall

A method call is the actual usage of a method. It requires an object, the method name and the arguments for the method.

A method call is based on an object, and the -> and ?-> operators. A method call may be static: the operator is then ::, and the left operand is a class name, expressed as a string; although, it may also be an object, though the class of that object is used, not the object itself.

Methods may be called by using the array syntax: array($object, $methodname)($arguments).

Method call may be chained. This means that the method returns an object, either the current one or another; then another call of method is built on top of this call.

Static methods must be called statically. Method must be called non-statically, although it is possible to call them statically within a class: this is convenient for parent::__construct(), for example.

<?php

    class X {
        function foo($a) {}

        static function bar($b) {}
    }

    $x = new x;

    // a method call
    $x->foo(1);
    [$x, 'foo'](1);

    // a static method call
    x::bar(2);
    $x::bar(3);
    x::class::bar(4);
    [x::class, 'bar'](1);

?>

Documentation

Related : Fluent Interface, Chaining