src/Events/Event.php
public function raise(...$arguments)
    {
        $firstResponse = null;

        /** @var callable $callBack */
        $callBack = false;

        $count = count($arguments);
        if ($count > 0 && is_object($arguments[$count - 1]) && is_callable($arguments[$count - 1])) {
            $callBack = $arguments[$count - 1];
            $arguments = array_slice($arguments, 0, -1);
        }

        foreach ($this->eventHandlers as $handler) {
            $response = $handler(...$arguments);

            if ($response !== null) {
                if ($callBack) {
                    $callBack($response);
                }

                if ($firstResponse === null) {
                    $firstResponse = $response;
                }
            }
        }

        return $firstResponse;
    }
public function raise(...$arguments)
    {
        $firstResponse = null;

        /** @var callable $callBack */
        $callBack = false;

        $count = count($arguments);
        if ($count > 0 && is_object($arguments[$count - 1]) && is_callable($arguments[$count - 1])) {
            $callBack = $arguments[$count - 1];
            $arguments = array_slice($arguments, 0, -1);
        }

        foreach ($this->eventHandlers as $handler) {
            $response = $handler(...$arguments);

            if ($response !== null) {
                if ($callBack) {
                    $callBack($response);
                }

                if ($firstResponse === null) {
                    $firstResponse = $response;
                }
            }
        }

        return $firstResponse;
    }
public function raise ( ... $ arguments ) { $ firstResponse = null ; /** @var callable $callBack */ $ callBack = false ; $ count = count ( $ arguments ) ; if ( $ count > 0 && is_object ( $ arguments [ $ count - 1 ] ) && is_callable ( $ arguments [ $ count - 1 ] ) ) { $ callBack = $ arguments [ $ count - 1 ] ; $ arguments = array_slice ( $ arguments , 0 , - 1 ) ; } foreach ( $ this -> eventHandlers as $ handler ) { $ response = $ handler ( ... $ arguments ) ; if ( $ response !== null ) { if ( $ callBack ) { $ callBack ( $ response ) ; } if ( $ firstResponse === null ) { $ firstResponse = $ response ; } } } return $ firstResponse ; }
Call all handlers for the event with the passed arguments.
If there are multiple event handlers, this will return the earliest non-null response from the handlers.
If you need to receive response data from multiple handlers, you can pass a callback function as the last argument.
The callback function will only be called for any handler which returns a value.

@param array ...$arguments
@return mixed
Call all handlers for the event with the passed arguments . If there are multiple event handlers this will return the earliest non - null response from the handlers . If you need to receive response data from multiple handlers you can pass a callback function as the last argument . The callback function will only be called for any handler which returns a value .