Registers a new shutdown callback with the specified priority.

@param string $id unique identifier of this callback
@param callable $callback to register
@param int $priority of the callback
765296
public function register(
    /*string*/ $id,
    callable $callback,
    /*int*/ $priority = self::PRIO_EARLY
  ) {
    // Normalize priority.
    $priority = intval($priority);

    // The priority must be valid.
    if(self::PRIO_START <= $priority && self::PRIO_END >= $priority) {
      // Register new callback.
      $this->registerImpl($id, $callback, $priority);
    }
  }
815422
public function extend($id, callable $callback)
    {
        if (!$this->has($id)) {
            throw new Exception\NotFoundException;
        }
        $oldCallback = $this->callbacks[$id];
        $this->callbacks[$id] = function () use ($oldCallback, $callback, $id) {
            if (!$this->isReady($id)) {
                $thisFunction = $this->callbacks[$id];
                $this->callbacks[$id] = $oldCallback;
                $this->instantiate($id);
                $this->callbacks[$id] = $thisFunction;
            }
            $instance = $this->instances[$id];
            $newInstance = call_user_func($callback, $instance, $this);
            return $newInstance ?: $instance;
        };
        if ($this->isReady($id)) {
            $instance = $this->instances[$id];
            $newInstance = call_user_func($callback, $instance, $this);
            $this->instances[$id] = $newInstance ?: $instance;
        }
        return $this;
    }
207689
protected function registerCloseCallback()
    {
        $this->swoolePort->on('Close', function ($server, $fd, $reactorId) {
            $this->dispatchEvent('Close', $this->server, $this, $fd, $reactorId);
        });
    }
435067
public function registerCallback($event, $callback)
    {
        $this->checkEventType($event);
        $this->events[$event][] = $callback;
    }
1327496
public function set($id, callable $callback)
    {
        if ($this->has($id)) {
            throw new Exception\AlreadyExistsException;
        }
        $this->callbacks[$id] = $callback;
    }
806812
public function addFilter(string $filterName, callable  $callback, int $priority = 20, $args = 1)
	{
		$this->filters[$filterName][$priority][] = [$callback,$args];
	}
1346223
public function register($hook, $callback, $priority = 0) {
		if (!isset($this->hooks[$hook])) {
			$this->hooks[$hook] = array();
		}
		if (!isset($this->hooks[$hook][$priority])) {
			$this->hooks[$hook][$priority] = array();
		}

		$this->hooks[$hook][$priority][] = $callback;
	}
291535
void registerCallback(AsynchConsumerCallback callback)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "registerCallback", callback);

    asynchConsumerCallback = callback;

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "registerCallback");
  }
1088050
public static function userRegister( $callback, $priority = null, $accepted_args = null ) {
		self::action( 'user_register', $callback, $priority, $accepted_args );
	}
1234278
public static function on($name, $callback, $priority = 0)
    {
        if (is_string($name) && is_callable($callback)) {
            if (isset(self::$events[$name]) === false) {
                self::$events[$name] = array();
            }

            self::$events[$name][] = array($callback, $priority);
        }
    }
1194505
public function addAction( $action, $callback, $priority = 10 )
    {
        if ( !isset( $this->actions[ $action ] ) )
        {
            $this->actions[ $action ] = array();
        }

        $this->actions[ $action ][] = array(
            'priority' => $priority,
            'callback' => $callback,
        );

        if ( 1 < count( $this->actions[ $action ] ) )
        {
            usort( $this->actions[ $action ], array( $this, '_sortByPriority' ) );
        }

        if ( $this->debug )
        {
            echo PHP_EOL . '+ACTION: ' . $action . ' -> '
                    . $this->_serializeCallback( $callback )
                    . ' + Priority: ' . $priority
                    . PHP_EOL;
        }
    }
1028223
public function on(string $eventName, callable $callBack, int $priority = 100)
    {
        if (!isset($this->listeners[$eventName])) {
            $this->listeners[$eventName] = [
                true,  // If there's only one item, it's sorted
                [$priority],
                [$callBack]
            ];
        } else {
            $this->listeners[$eventName][0] = false; // marked as unsorted
            $this->listeners[$eventName][1][] = $priority;
            $this->listeners[$eventName][2][] = $callBack;
        }
    }
879745
public function delete(string $path, callable $callback, int $priority = 0)
    {
        return $this->route('delete', $path, $callback, $priority);
    }
905577
public function error($callback, $priority = -8)
    {
        $this->on(KernelEvents::EXCEPTION, new ExtendedExceptionListnerWrapper($this, $callback), $priority);
    }
444963
protected function registerListener($event, $listener, $priority)
    {
        if (!is_callable($listener)) {
            throw new DispatcherException(sprintf('Invalid event listener. Only callables or ListenerInterface instances can be registered, got "%s"', gettype($listener)));
        }

        if (!isset($this->events[$event])) {
            $this->events[$event] = [];
        }

        if ($priority === null) {
            $this->events[$event][] = $listener;

            return;
        }

        array_splice($this->events[$event], (int) $priority, 0, [$listener]);
    }
74379
public function listen($event, $callable, $priority = ListenerPriority::NORMAL)
    {
        $this->addListener($callable, [$event => $priority]);

        return $this;
    }
582867
static public function _registered_shutdown()
	{
		if( self::$_byPassCallBacks )
		{
			return;
		}
		#- first sort the stack
		uasort( self::$_registeredCallbacks, array( __class__, '_compare' ) );
		foreach( self::$_registeredCallbacks as $cb )
		{
			call_user_func_array( $cb[ 0 ], $cb[ 3 ] );
		}
	}