src/Promise.php
protected static function parentCancellerFunction(self &$parent)
    {
        return function () use (&$parent) {
            --$parent->requiredCancelRequests;

            if ($parent->requiredCancelRequests <= 0) {
                $parent->cancel();
            }

            $parent = null;
        };
    }
protected static function parentCancellerFunction(self &$parent)
    {
        return function () use (&$parent) {
            --$parent->requiredCancelRequests;

            if ($parent->requiredCancelRequests <= 0) {
                $parent->cancel();
            }

            $parent = null;
        };
    }
protected static function parentCancellerFunction ( self & $ parent ) { return function ( ) use ( & $ parent ) { -- $ parent -> requiredCancelRequests ; if ( $ parent -> requiredCancelRequests <= 0 ) { $ parent -> cancel ( ) ; } $ parent = null ; } ; }
Creates a static parent canceller callback that is not bound to a promise instance.

Moving the closure creation to a static method allows us to create a
callback that is not bound to a promise instance. By passing the target
promise instance by reference, we can still execute its cancellation logic
and still clear this reference after invocation (canceller can only ever
be called once). This helps avoiding garbage cycles if the parent canceller
creates an Exception.

These assumptions are covered by the test suite, so if you ever feel like
refactoring this, go ahead, any alternative suggestions are welcome!

@param ExtendedPromiseInterface $parent
@return callable
Creates a static parent canceller callback that is not bound to a promise instance .