Skip to content

False PHP2446 "Constant expression contains an invalid operation that can't be resolved in compile-time" #955

Closed

Description

@gremo

Constant expression contains an invalid operation that can't be resolved in compile-time.

/**
 * @var array<string, class-string>
 */
public const array discriminatorMap = [
    self::Annual->value => HolidayRuleAnnual::class,
    self::DateBased->value => HolidayRuleDateBased::class,
    self::ExpressionBased->value => HolidayRuleExpressionBased::class,
    self::Variable->value => HolidayRuleVariable::class,
];
Image
PHP 8.5.0 (cli) (built: Nov 20 2025 19:48:42) (ZTS)
Copyright (c) The PHP Group
Built by https://github.com/docker-library/php
Zend Engine v4.5.0, Copyright (c) Zend Technologies
    with Zend OPcache v8.5.0, Copyright (c), by Zend Technologies

Activity

  1. self-assigned this
    on Nov 28, 2025
  2. added theissue type on Nov 28, 2025
  3. jakubmisek commented on Nov 28, 2025

    @jakubmisek
    Member

    Thank you for the test case, you're right, this should not be marked as an error.

    Fixed in the upcoming update (and pre-release).

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