Skip to content

Argument 4 of mkdir cannot be null #10796

@steal3rd

Description

@steal3rd

Psalm is reporting the fourth argument of the mkdir() function cannot be null, but the function works as expected if used anyway.

The full message is:

Argument 4 of mkdir cannot be null, null value provided to parameter with type resource

And can be see with this example:

https://psalm.dev/r/6c64902528

mkdir("home/sample", 0755, true); // Works
mkdir("home/sample", 0755, true, null); // Also works

It's difficult to find examples of how this parameter would be used, but PHP does support passing a null for this argument. The docs describe it that way as well.

https://www.php.net/manual/en/function.mkdir

mkdir(
	string $directory,
	int $permissions = 0777,
	bool $recursive = false,
	?resource $context = null
): bool

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions