PHPMailer::parseAddresses( string $addrstr, bool|null $useimap = null, string $charset = self::CHARSET_ISO88591 ): array
- Source
wp-includes/PHPMailer/PHPMailer.php:1301
Description
Uses the imap_rfc822_parse_adrlist function if the IMAP extension is available and the deprecated $useimap argument is truthy.
Note that quotes in the name part are removed.
Compatibility
- WordPress
- core
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$addrstrstring- The address list string
$useimapbool|nulloptional- Deprecated in PHPMailer 6.11.0.
Truthy values request the deprecated IMAP parser and trigger a deprecation warning.Default:null $charsetstringoptional- The charset to use when decoding the address list string.Default:
self::CHARSET_ISO88591
Return value
array
Performance profile
How much work a call to PHPMailer::parseAddresses() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Light
- Scaling
- Scales with input
- Instructions
- 14–31
- Plugin surface
- None
- Called by
- 0
Touches nothing outside its own arguments.
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 78.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What one call costs · 6 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost PHPMailer::parseAddresses() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
$useimap != true | 14 | ::parseSimplerAddresses() |
$useimap != true && $useimap == true && !function_exists() | 18 | function_exists(), ::parseSimplerAddresses() |
$useimap != true && $useimap == true && function_exists() | 22–23 | function_exists(), imap_rfc822_parse_adrlist(), imap_errors() |
$useimap == true && $useimap != true | 22 | ::lang(), trigger_error(), ::parseSimplerAddresses() |
$useimap == true && !function_exists() | 26 | ::lang(), trigger_error(), function_exists(), ::parseSimplerAddresses() |
$useimap == true && function_exists() | 30–31 | ::lang(), trigger_error(), function_exists(), imap_rfc822_parse_adrlist(), imap_errors() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 78 | 14–31 | 11 | |
| 8.5 | 78 | 14–31 | 11 | 2 more instructions than PHP 8.4 |
| 8.4 | 76 | 12–29 | 11 | 6 fewer instructions than PHP 8.3 |
| 8.3 | 82 | 12–29 | 11 | |
| 8.2 | 82 | 12–29 | 11 | |
| 8.1 | 82 | 12–29 | 11 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 83 | 12–29 | 11 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 4
- \PHPMailer\PHPMailer\PHPMailer::lang()
- static::validateAddress()
- static::decodeHeader()
- static::parseSimplerAddresses()
Source code
public static function parseAddresses($addrstr, $useimap = null, $charset = self::CHARSET_ISO88591) { if ($useimap == true) { trigger_error(self::lang('deprecated_argument') . '$useimap', E_USER_DEPRECATED); } $addresses = []; if ($useimap == true && function_exists('imap_rfc822_parse_adrlist')) { //Use this built-in parser if it's available // phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.imap_rfc822_parse_adrlistRemoved -- wrapped in function_exists() $list = imap_rfc822_parse_adrlist($addrstr, ''); // Clear any potential IMAP errors to get rid of notices being thrown at end of script. // phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.imap_errorsRemoved -- wrapped in function_exists() imap_errors(); foreach ($list as $address) { if ( '.SYNTAX-ERROR.' !== $address->host && static::validateAddress($address->mailbox . '@' . $address->host) ) { //Decode the name part if it's present and maybe encoded if ( property_exists($address, 'personal') && is_string($address->personal) && $address->personal !== '' ) { $address->personal = static::decodeHeader($address->personal, $charset); } $addresses[] = [ 'name' => (property_exists($address, 'personal') ? $address->personal : ''), 'address' => $address->mailbox . '@' . $address->host, ]; } } } else { //Use this simpler parser $addresses = static::parseSimplerAddresses($addrstr, $charset); } return $addresses; }Changelog
2 changes between 6.7.7 and 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
$useimap retyped from null to bool|null.verified against source$useimap retyped from bool to null.verified against sourceAbout this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/PHPMailer/PHPMailer.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.