phalcon/cphalcon · error · InvalidEventSource

The source of event must be an object, got

Error message

The source of {} event must be an object, got {}

What it means

Thrown by the Events Event constructor when source is supplied but is not an object (and not null). The event source is used to dispatch and identify the emitter, so only objects are accepted. Pass the object firing the event, or omit source.

Solutions

  1. Pass the emitting object (e.g. the component firing the event) as source
  2. Pass null explicitly when there is no source
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at phalcon/Events/Event.zep:79 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21). Data as JSON: /api/errors/1e7e04b6c3b44318. Report an issue: GitHub.

Appendix: source

Thrown at phalcon/Events/Event.zep:79

     * Event type
     *
     * @var string
     */
    protected type;

    /**
     * Phalcon\Events\Event constructor
     *
     * @param object source
     */
    public function __construct(
        string type,
        var source = null,
        var data = null,
        bool cancelable = true
    ) {
        if unlikely null !== source && typeof source !== "object" {
            throw new InvalidEventSource(type, (typeof source));
        }

        let this->type       = type,
            this->source     = source,
            this->data       = data,
            this->cancelable = cancelable;
    }

    public function getData() -> var
    {
        return this->data;
    }

    public function getSource() -> object | null
    {
        return this->source;
    }

View on GitHub (pinned to b7419de9cd)