Skip to content

FR: allow use class constant interpolation in strings #13888

@IVoyt

Description

@IVoyt

Description

For instance I have a class with public constant

class SomeClass
{
    public const int STATUS_ACTIVE = 1;
}

And I want to use the class constant in a string.Currently I have to use concatenation or assign the class constant's value to a variable and interpolate it in the string

// option 1
$query = QueryBuilder::where('status = ' . SomeClass::STATUS_ACTIVE);

// option 2
$statusValue = SomeClass::STATUS_ACTIVE;
$query = QueryBuilder::where("status = {$statusValue}");

Would be cool and convenient to be able use interpolation for constants as well.

$query = QueryBuilder::where("status = {SomeClass::STATUS_ACTIVE}")

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