Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method headerExists in documentation does not exist #243

Open
maxiwheat opened this issue Jun 6, 2023 · 2 comments
Open

Method headerExists in documentation does not exist #243

maxiwheat opened this issue Jun 6, 2023 · 2 comments
Labels
Bug Something isn't working Documentation

Comments

@maxiwheat
Copy link

maxiwheat commented Jun 6, 2023

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 maxiwheat added the Bug Something isn't working label Jun 6, 2023
@froschdesign
Copy link
Member

…it should be removed from the documentation.

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

@maxiwheat
Copy link
Author

maxiwheat commented Jun 7, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Documentation
Projects
None yet
Development

No branches or pull requests

2 participants