public function sendNotifications($notification_type, array $args = [])
    {
        if (!isset($this->_notifications[$notification_type])) {
            // No exception thrown and error logged since this method will be called from
            // within the SDK
            return;
        }

        /**
         * Note: Before PHP 7, if the callback in call_user_func is called with less number of arguments than expected,
         * a warning is issued but the method is still executed with assigning null to the remaining
         * arguments. From PHP 7, ArgumentCountError is thrown in such case and the method isn't executed.
         * Therefore, we set error handler for warnings so that we raise an exception and notify the
         * user that the registered callback has more number of arguments than
         * expected. This should be done to keep a consistent behavior across all PHP versions.
         */

        set_error_handler(array($this, 'reportArgumentCountError'), E_WARNING);

        foreach (array_values($this->_notifications[$notification_type]) as $callback) {
            try {
                call_user_func_array($callback, $args);
            } catch (ArgumentCountError $e) {
                $this->reportArgumentCountError();
            } catch (Exception $e) {
                $this->_logger->log(Logger::ERROR, "Problem calling notify callback.");
            }
        }

        restore_error_handler();
    }
public function sendNotifications($notification_type, array $args = [])
    {
        if (!isset($this->_notifications[$notification_type])) {
            // No exception thrown and error logged since this method will be called from
            // within the SDK
            return;
        }

        /**
         * Note: Before PHP 7, if the callback in call_user_func is called with less number of arguments than expected,
         * a warning is issued but the method is still executed with assigning null to the remaining
         * arguments. From PHP 7, ArgumentCountError is thrown in such case and the method isn't executed.
         * Therefore, we set error handler for warnings so that we raise an exception and notify the
         * user that the registered callback has more number of arguments than
         * expected. This should be done to keep a consistent behavior across all PHP versions.
         */

        set_error_handler(array($this, 'reportArgumentCountError'), E_WARNING);

        foreach (array_values($this->_notifications[$notification_type]) as $callback) {
            try {
                call_user_func_array($callback, $args);
            } catch (ArgumentCountError $e) {
                $this->reportArgumentCountError();
            } catch (Exception $e) {
                $this->_logger->log(Logger::ERROR, "Problem calling notify callback.");
            }
        }

        restore_error_handler();
    }
public function sendNotifications ( $ notification_type , array $ args = [ ] ) { if ( ! isset ( $ this -> _notifications [ $ notification_type ] ) ) { // No exception thrown and error logged since this method will be called from // within the SDK return ; } /**
         * Note: Before PHP 7, if the callback in call_user_func is called with less number of arguments than expected,
         * a warning is issued but the method is still executed with assigning null to the remaining
         * arguments. From PHP 7, ArgumentCountError is thrown in such case and the method isn't executed.
         * Therefore, we set error handler for warnings so that we raise an exception and notify the
         * user that the registered callback has more number of arguments than
         * expected. This should be done to keep a consistent behavior across all PHP versions.
         */ set_error_handler ( array ( $ this , 'reportArgumentCountError' ) , E_WARNING ) ; foreach ( array_values ( $ this -> _notifications [ $ notification_type ] ) as $ callback ) { try { call_user_func_array ( $ callback , $ args ) ; } catch ( ArgumentCountError $ e ) { $ this -> reportArgumentCountError ( ) ; } catch ( Exception $ e ) { $ this -> _logger -> log ( Logger :: ERROR , "Problem calling notify callback." ) ; } } restore_error_handler ( ) ; }
Executes all registered callbacks for the given notification type

@param string $notification_type One of the constants defined in NotificationType
@param array  $args              Array of items to pass as arguments to the callback
Executes all registered callbacks for the given notification type