Skip to content

Rule to convert ?? to ?: on non-nullable type #9730

Description

@samsonasik

Feature Request

when the expr is non-nullable, ?? should not be used, use ?: instead.

Diff

function run(string $a)
{
-	return $a ?? 'foo';
+	return $a ?: 'foo';
}

with ?? notice: https://phpstan.org/r/c97f6f8d-1c56-4b71-8064-0b9fa1ac9c4d
with ?: green: https://phpstan.org/r/307aca11-7797-4928-a675-89bbf7d49f8e

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions