Skip to content

New Rector rule to replace string literal argument values with class constants #9256

@JohJohan

Description

@JohJohan

I’d like to propose a new Rector rule (or at least start a discussion) to automatically replace certain string literal argument values with class constants.

Examples
Example 1: Symfony WebLink

-new Link('preload');
+new Link(Link::REL_PRELOAD);

Example 2: Symfony HttpFoundation Cookie

-return Cookie::create($name, $value, new DateTime('+1 month'), '/', null, true, false, false, 'strict');
+return Cookie::create($name, $value, new DateTime('+1 month'), '/', null, true, false, false, Cookie::SAMESITE_STRICT);

A recent Symfony commit that hints to use constants:
symfony/symfony-docs@abc8d69

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions