Multiple %s modifiers are not allowed

Description

A single modifier keyword (final, static, readonly, or a visibility keyword such as public, protected, private) is enough to apply that property to a class member. Repeating the same kind of modifier twice in a declaration is redundant and rejected by the parser.

This is a generic, templated message: the concrete modifier name takes the place of %s. There are dedicated, more specific messages for each modifier family: final, static, readonly, and the access-type (visibility) modifiers.

Example

<?php

class X {
    final final function foo() {}
}

?>

Literal Examples

  • Multiple final modifiers are not allowed

  • Multiple static modifiers are not allowed

  • Multiple readonly modifiers are not allowed

  • Multiple access type modifiers are not allowed

Solutions

  • Remove the duplicate modifier, keeping only one occurrence.

Changed Behavior

This error may appear following an evolution in behavior, in previous versions. See ` <https://php-changed-behaviors.readthedocs.io/en/latest/behavior/.html>`_.