class Parser
{
protected $_messages = array();
public function parse($a)
{
$this->_messages['message key'] = 'some message ...';
/// some code;
return $b;
}
public function getMessages()
{
return $this->messages;
}
}
$parser = new Parser();
$parser->parse($a);
$messages = $parser->getMessages();