Skip to content

Deprecated: pathinfo() #130

@osworx

Description

@osworx
Deprecated: pathinfo(): Passing null to parameter #1 ($path) of type string is deprecated in 
..\imapengine\vendor\directorytree\imapengine\src\Attachment.php on line 84

Environment

  • PHP version: 8.4.3
  • ImapEngine version: latest
  • IMAP server: own (linux/plesk)

When using $extension = $attachment->extension(); without checking before if a filename is given, this message/error will be shown.

This happens e.g. at messages which have attachments, but they have no extension.
Like: Delivery Report and Undelivered Message which are added by (my) mailserver (maybe others will add such also ..).

So by doing like:

$filename = $attachment->filename();
	// check if filename exists, otherwise following functions will show error!
	if ($filename) {
		// get extension
		$extension = $attachment->extension();

Of course such a check could be done also inside the function

public function extension(): ?string

like:

public function extension(): ?string
    {
        if (!$this->filename) {
            return '';
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions