Skip to content

Mail address email constructor argument type incorrect #25434

Closed
@DuckThom

Description

@DuckThom

Preconditions (*)

Magento 2.3.3

Steps to reproduce (*)

>>> $address = new \Magento\Framework\Mail\Address(null, null);
=> Magento\Framework\Mail\Address {#17559}
>>> $address->getName();
=> null
>>> $address->getEmail();
TypeError: Return value of Magento/Framework/Mail/Address::getEmail() must be of the type string, null returned

Expected result (*)

Either one of:

  • Instantiating the \Magento\Framework\Mail\Address class with a null value in the email parameter should not be possible, or;
  • the getEmail method's return type should be nullable, the same as the constructor argument ( ?string )

Actual result (*)

Instantiating the Address class with a null email address is possible which will always cause the getEmail method to throw an exception as it's only allowed to return string values

TypeError: Return value of Magento/Framework/Mail/Address::getEmail() must be of the type string, null returned

Metadata

Metadata

Assignees

Labels

Component: Framework/MailFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releasegood first issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions