Skip to content

PHP7103 hit convert to arrow function is sometimes inappropriate #949

Description

@gremo

AFAIK is not possibile to use arrow function in the new PHP 8.5 first-class callables. This extension suggest to do so:

#[Assert\When(
    expression: static function (self $o) { return $o->isFullDay; }, // Here PHP7103 suggests to use arrow fn
    constraints: new Assert\IsNull(),
    otherwise: new Assert\NotNull())
]
public ?Time $startTime = null;

But....

Fatal error: Constant expression contains invalid operations.

#[Assert\When(
    expression: static fn (self $o) => $o->isFullDay,
    constraints: new Assert\IsNull(),
    otherwise: new Assert\NotNull())
]
public ?Time $startTime = null;

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions