Chaining

Chaining refers to the practice to link several elements one to each other.

There are two types of PHP chaining: exception and method call.

Exception chaining happens when an exception is created, while including a previous exception. This is convenient to provide all information in the end.

Method chaining happens when the result of a method call is used to call another method. This is common with fluent interfaces. Sometimes, properties may be part of such a chain.

<?php

    try {
        doSomething();
    } catch (Exception $e) {
        throw new exception('new error', 0, $e);
    }

    $object->m1()->m2($b)->m3();

?>

Documentation

See also Unleashing the Power of Method Chaining in PHP.

Related : Fluent Interface, Exception, Methodcall