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

"Header\IHeader" does not contain "getEmail()" #233

Open
ghnp5 opened this issue Mar 19, 2024 · 2 comments
Open

"Header\IHeader" does not contain "getEmail()" #233

ghnp5 opened this issue Mar 19, 2024 · 2 comments

Comments

@ghnp5
Copy link

ghnp5 commented Mar 19, 2024

$message = Message::from($raw_email, true);
$from = $message->getHeader('From');
$email = mb_strtolower($from->getEmail());

getHeader returns IHeader, but IHeader does not contain getEmail.

The code works, but my IDE complains :)

Thanks!

@zbateson
Copy link
Owner

Hi @ghnp5 -- you're not wrong, getEmail is part of AddressHeader which is what's returned if you call getHeader('From') -- a class that implements IHeader.

I don't know what makes the most sense here, maybe in documentation I can specify all the concrete classes returned so IDEs are happy. Another option could be to put a docblock before the $from line, or actually specify all classes that could be returned in the function's signature. Open to suggestions if anyone has any.

/** @var AddressHeader $from */

@postme
Copy link

postme commented Mar 19, 2024

I apply the docblock approach, it keeps phpstorm happy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants