{"record":{"id":"352ae5cb6d747654","repo":"phalcon/cphalcon","slug":"invalid-event-type-eventtype","errorCode":null,"errorMessage":"Invalid event type {eventType}","messagePattern":"Invalid event type (.+?)","errorType":"exception","errorClass":"Phalcon\\Events\\Exceptions\\InvalidEventType","httpStatus":null,"severity":"error","filePath":"phalcon/Events/Manager.zep","lineNumber":589,"sourceCode":"        }\n\n        // Fast exit on a manager with no listeners. Mirrors fire().\n        if empty this->events {\n            if unlikely this->strict {\n                throw new NoListenersForEvent(eventType);\n            }\n\n            return [];\n        }\n\n        if fetch cached, this->eventNameCache[eventType] {\n            let type      = cached[0];\n            let eventName = cached[1];\n        } else {\n            let colonPos = strpos(eventType, \":\");\n\n            if unlikely colonPos === false {\n                throw new InvalidEventType(eventType);\n            }\n\n            let type      = substr(eventType, 0, colonPos);\n            let eventName = substr(eventType, colonPos + 1);\n\n            let this->eventNameCache[eventType] = [type, eventName];\n        }\n\n        let hasTypeQueue = isset this->events[type];\n        let hasFullQueue = isset this->events[eventType];\n\n        if !hasTypeQueue && !hasFullQueue {\n            if unlikely this->strict {\n                throw new NoListenersForEvent(eventType);\n            }\n\n            return [];\n        }","sourceCodeStart":571,"sourceCodeEnd":607,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Events/Manager.zep#L571-L607","documentation":"fireAll() splits the event type string on the first colon to derive the component type and the event name ('db' + 'beforeQuery'). Phalcon event names must follow the 'type:eventName' format; InvalidEventType is thrown when the string contains no colon at all, so the name cannot be decomposed.","triggerScenarios":"$eventsManager->fireAll('beforeQuery', $this) (missing component prefix); a dynamically built name whose prefix variable is empty: $em->fireAll($prefix . ':' . $name) with $prefix = '' still contains a colon, but $em->fireAll($name) alone does not; names copied from Symfony-style single-word events.","commonSituations":"Porting code from Symfony EventDispatcher (single names like kernel.request) to Phalcon; refactoring that drops the 'component:' prefix; configuration files listing bare event names that are passed straight to fireAll().","solutions":["Use the full 'type:eventName' form, e.g. 'db:beforeQuery', 'models:beforeCreate'","If the name is dynamic, validate it contains a colon before firing: if (strpos($eventType, ':') === false) { throw new InvalidArgumentException(...); }","Centralize event names in class constants so typos are caught once"],"exampleFix":"// before\n$em->fireAll('beforeQuery', $connection); // throws InvalidEventType\n\n// after\n$em->fireAll('db:beforeQuery', $connection);","handlingStrategy":"validation","validationCode":"function validEventType(string $eventType): bool\n{\n    return strpos($eventType, ':') !== false && strpos($eventType, ':') > 0;\n}\n\nif (!validEventType($eventType)) {\n    throw new InvalidArgumentException(\"Event type must be 'component:eventName', got '{$eventType}'\");\n}","typeGuard":"function assertEventType(string $eventType): string\n{\n    [$type, $name] = explode(':', $eventType, 2) + [null, null];\n    if ($type === null || $name === null || $type === '' || $name === '') {\n        throw new InvalidArgumentException(\"Event type must be 'component:eventName', got '{$eventType}'\");\n    }\n    return $eventType;\n}","tryCatchPattern":"use Phalcon\\Events\\Exceptions\\InvalidEventType;\ntry {\n    $em->fireAll($eventType, $source);\n} catch (InvalidEventType $e) {\n    // programmer error: fail fast, do not swallow\n    throw new InvalidArgumentException('Bad event name: ' . $eventType, 0, $e);\n}","preventionTips":["Define event names once as class constants ('db:beforeQuery') and reference only the constants","Reject constructed names that lack a colon at the boundary where they enter your system"],"tags":["phalcon","events","event-name","string-format"],"backgroundTag":"invalid-event-name","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}