laminas-mail
laminas-mail copied to clipboard
Method headerExists in documentation does not exist
Bug Report
Q | A |
---|---|
Version(s) | 2.23.0 |
Summary
The method headerExists
on a Message object does not exist, it should be removed from the documentation.
See documentation here: https://docs.laminas.dev/laminas-mail/read/
Current behavior
The method headerExists
on a Message object does not exist, it should be removed from the documentation.
How to reproduce
N/A
Expected behavior
N/A
…it should be removed from the documentation.
Before deleting, alternatives should be checked. And if these exist, they must be inserted into the documentation.
…it should be removed from the documentation.
Before deleting, alternatives should be checked. And if these exist, they must be inserted into the documentation.
I should have included it in my bug report, I found it by reading the code, we can use $message->getHeaders()->has('header-name')
to check if an header exists.
I also noted this part in the same doc page which does not work as intended:
foreach ($message->getHeaders() as $name => $value) {
if (is_string($value)) {
echo "$name: $value\n";
continue;
}
foreach ($value as $entry) {
echo "$name: $entry\n";
}
}
$name
does not get populated with the header name, but with an index of the header. I used this instead to loop using foreach and retrieve the the header name and value :
foreach ($message->getHeaders() as $header) {
$name = $header->getFieldName();
$value = $header->getFieldValue();
if (is_string($value)) {
echo "$name: $value\n";
continue;
}
foreach ($value as $entry) {
echo "$name: $entry\n";
}
}