Skip to content

Passing an array of options to configure the \"FOS\\RestBundle\\Validator\\Constraints\\Regex\" constraint is deprecated, use named arguments instead. #2416

@dev-craftec

Description

@dev-craftec

In Symfony 7.3 a deprecation is triggered Passing an array of options to configure the \"FOS\\RestBundle\\Validator\\Constraints\\Regex\" constraint is deprecated, use named arguments instead.

The code causing the issue:

Controller/Annotations/AbstractScalarParam.php lines 44 to 51 and 53 to 56

            $constraints[] = new Regex([
                'pattern' => '#^(?:'.$this->requirements.')$#xsu',
                'message' => sprintf(
                    'Parameter \'%s\' value, does not match requirements \'%s\'',
                    $this->getName(),
                    $this->requirements
                ),
            ]);
        } elseif (is_array($this->requirements) && isset($this->requirements['rule']) && $this->requirements['error_message']) {
            $constraints[] = new Regex([
                'pattern' => '#^(?:'.$this->requirements['rule'].')$#xsu',
                'message' => $this->requirements['error_message'],
            ]);

The proposed fix:

            $constraints[] = new Regex(
                '#^(?:'.$this->requirements.')$#xsu',
                sprintf(
                    'Parameter \'%s\' value, does not match requirements \'%s\'',
                    $this->getName(),
                    $this->requirements
                ),
            );
        } elseif (is_array($this->requirements) && isset($this->requirements['rule']) && $this->requirements['error_message']) {
            $constraints[] = new Regex(
                '#^(?:'.$this->requirements['rule'].')$#xsu',
                $this->requirements['error_message'],
            );

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