laminas-mail icon indicating copy to clipboard operation
laminas-mail copied to clipboard

Method headerExists in documentation does not exist

Open maxiwheat opened this issue 1 year ago • 2 comments

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

maxiwheat avatar Jun 06 '23 20:06 maxiwheat

…it should be removed from the documentation.

Before deleting, alternatives should be checked. And if these exist, they must be inserted into the documentation.

froschdesign avatar Jun 07 '23 06:06 froschdesign

…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";
    }
}

maxiwheat avatar Jun 07 '23 12:06 maxiwheat