phalcon/cphalcon · error · Phalcon\Messages\Exceptions\MessagesNotIterable
The messages must be iterable
Error message
The messages must be iterable
What it means
Messages::appendMessages() guard: the argument is neither an array nor a Traversable object. The method accepts arrays of MessageInterface or iterators yielding them; other types are rejected instead of causing a TypeError.
Solutions
- Pass an array of Message objects or an Iterator/ArrayIterator of them
- Convert generators/collections to an array before appending
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at phalcon/Messages/Messages.zep:85 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/fb6fed8819ee7b39.
Report an issue: GitHub.
Appendix: source
Thrown at phalcon/Messages/Messages.zep:85
* $messages->appendMessages($messagesArray);
*```
*
* Accepts an array of MessageInterface objects or an Iterator yielding
* them. The parameter stays untyped so that a non-iterable argument
* reaches the guard below and raises MessagesNotIterable rather than a
* TypeError.
*
* @param mixed $messages
*
* @return void
* @throws MessagesNotIterable
*/
public function appendMessages(var messages)
{
var currentMessages, finalMessages, message;
if typeof messages !== "array" && !(typeof messages === "object" && messages instanceof Traversable) {
throw new MessagesNotIterable();
}
let currentMessages = this->messages;
if typeof messages == "array" {
/**
* An array of messages is simply merged into the current one
*/
let finalMessages = array_merge(currentMessages, messages);
let this->messages = finalMessages;
} else {
/**
* A collection of messages is iterated and appended one-by-one to
* the current list
*/
messages->rewind();
View on GitHub (pinned to b7419de9cd)