+
Skip to content

Compile Error: Constant expression contains invalid operations #961

@oleg-andreyev

Description

@oleg-andreyev

Bug Report

Compile Error: Constant expression contains invalid operations

Q A
BC Break no
Version 2.11.2

Summary

Entity with following method

class A {
    public function getActivePriceOverrideForCompany(
        Company $company,
        DateTimeImmutable $activeAt = new DateTimeImmutable('today')
    ): ?PriceOverride { ... }
}

as result getting proxy like this:

public function getActivePriceOverrideForCompany(\App\Entity\Company $company, \DateTimeImmutable $activeAt = DateTimeImmutable::__set_state(array(
   'date' => '2022-05-03 00',
   'timezone_type' => 3,
   'timezone' => 'UTC',
))): ?\App\Entity\PriceOverride { ... }
  1. Proxy is invalid
  2. Even if the code will be correct, proxy will be invalid on the next day.

This will work:

class A {
    public function getActivePriceOverrideForCompany(
        Company $company,
        ?DateTimeImmutable $activeAt = null
    ): ?PriceOverride { ... }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载