#[non_exhaustive]pub enum ForbiddenRule {
Show 194 variants
ClassKeywordOutsideClass,
ParentWithoutParentClass,
ToStringReturnType,
MagicMethodReturnType,
AttributeTargetMismatch,
AttributeOnInvalidClass,
DeprecatedOnInvalidTarget,
AllowDynamicPropertiesOnInvalidClass,
MissingReturnValue,
GeneratorReturnType,
ReadonlyPropertyDefault,
DuplicateParameter,
ReassignThis,
UnclosedInterpolation,
EmptyInterpolationIndex,
EmptyInterpolationVariableName,
UnclosedInterpolationIndex,
ClassConstantInterpolation,
InvalidInterpolationOffset,
InvalidNumericLiteral,
InvalidCodepointEscape,
MixedHeredocIndentation,
HeredocBodyIndentation,
WhitespaceInNamespacedName,
MultipleVisibilityModifiers,
MultipleSetVisibilityModifiers,
DuplicateModifier,
AbstractFinalConflict,
InvalidConstantModifier,
ModifierNotAllowed,
KeywordAsDeclarationName,
ReservedClassName,
OutermostScopeOnly,
UnparenthesizedIntersectionInUnion,
ParenthesizedIntersectionOutsideUnion,
StaticTypePosition,
EmptyAttributeList,
CallTimePassByReference,
CurlyOffsetAccess,
VoidCastInExpression,
RealCast,
NonAssociativeChain,
IncDecAsAssignTarget,
InvalidAssignTarget,
CompoundAssignToDestructuring,
ReferenceAssignToDestructuring,
IncDecNonVariable,
InvalidDereference,
InvalidWriteContext,
ListOutsideDestructuring,
EmptyArrayElement,
ReferenceAssignNew,
HooksOnPropertyList,
InvalidInstanceofOperand,
SwitchLeadingSemicolons,
PartialApplicationInNew,
UnparenthesizedNewDereference,
StaticStandaloneExpression,
ReferenceToParenthesized,
ReferenceToNonReferenceable,
QualifiedClassKeyword,
ReservedClassReference,
ReservedEnumName,
TraitInInterface,
AbstractMemberInConcreteClass,
DuplicateProperty,
DuplicateMethod,
DuplicateClassConstant,
ClassConstantNamedClass,
ClassConstantValueType,
PrivateFinalConstant,
InvalidInterfaceConstantModifier,
InvalidInterfaceMethodModifier,
InvalidInterfacePropertyModifier,
InterfaceMethodBody,
MissingMethodBody,
AbstractMethodBody,
PrivateAbstractMethod,
AbstractAnonymousClassMethod,
AbstractEnumMethod,
MagicMethodArgumentCount,
MagicMethodByReference,
MagicMethodStatic,
MagicMethodParameterType,
StaticReadonlyProperty,
UntypedReadonlyProperty,
ReadonlyPropertyHooks,
UntypedAsymmetricProperty,
SetVisibilityWiderThanVisibility,
PrivateFinalProperty,
AbstractPropertyWithoutAbstractHook,
InterfacePropertyWithoutHooks,
StaticPropertyHooks,
VirtualPropertyDefault,
VirtualPropertyAsymmetricVisibility,
EmptyHookList,
DuplicateHook,
GetHookParameters,
SetHookParameterCount,
SetHookParameterByReference,
SetHookParameterVariadic,
SetHookParameterType,
ByReferenceGetHookWithSet,
MissingHookBody,
AbstractHookBody,
AbstractFinalHook,
PrivateAbstractHook,
PromotedPropertyOutsideConstructor,
PromotedPropertyInAbstractConstructor,
VariadicPromotedProperty,
InvalidEnumBackingType,
EnumCaseNamedClass,
MissingEnumCaseValue,
PureEnumCaseValue,
EnumProperty,
InvalidTraitAliasModifier,
UnterminatedComment,
NestedClassDeclaration,
MixedNamespaceStyles,
NamespaceNotFirst,
CodeOutsideNamespace,
NestedNamespace,
UseNameConflict,
SpecialClassNameAlias,
DeclareNotFirstStatement,
NonLiteralDeclareValue,
InvalidStrictTypes,
AttributesOnMultipleConstants,
AttributeArgumentUnpacking,
AttributeArgumentClosure,
VoidReturnValue,
NeverReturn,
VariadicParameterDefault,
VariadicParameterNotLast,
ThisAsDeclaredVariable,
SuperglobalAsDeclaredVariable,
DuplicateStaticVariable,
BreakOutOfLoop,
InvalidBreakOperand,
JumpAcrossFinally,
DuplicateLabel,
UndefinedGotoLabel,
GotoIntoLoop,
DuplicateSwitchDefault,
DuplicateMatchDefault,
ReferenceKey,
ListAsForeachKey,
ClassKeywordInCatch,
InvalidParentHookCall,
StaticClassInConstantExpression,
AppendOutsideWrite,
InvalidGlobalsWrite,
InvalidNullableType,
StandaloneTypeInComposite,
BuiltinTypeInIntersection,
RedundantType,
DuplicateType,
InvalidParameterType,
InvalidMemberType,
QualifiedBuiltinType,
ReservedTypeName,
IssetOnExpression,
ClosureForNew,
YieldOutsideFunction,
YieldFromInByReferenceGenerator,
PositionalAfterNamedArgument,
UnsetCast,
BuiltinResultWrite,
CallResultWrite,
TemporaryExpressionWrite,
NullsafeWrite,
ReferenceToNullsafe,
NullsafeClosureCreation,
UnwritableDestructuringElement,
UnsetThis,
ClosureUseShadowsParameter,
DuplicateClosureUseVariable,
LiteralClassName,
ClassFetchOnLiteral,
DynamicClassFetch,
InvalidConstantExpression,
EmptyList,
EmptyKeyedArrayEntry,
MixedKeyedEntries,
MixedListSyntax,
SpreadInDestructuring,
UnparenthesizedNestedTernary,
UnparenthesizedArrowInPipe,
InvalidCurlyInterpolation,
RepeatedAttribute,
NoDiscardOnInvalidTarget,
NoDiscardWithoutReturnValue,
UnexpectedCharacter,
Other,
}Expand description
The PHP rule a ParseError::Forbidden reports.
Rules and their identifiers are stable API; message wording is not.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
ClassKeywordOutsideClass
self, static or parent used outside a class.
ParentWithoutParentClass
parent used in a class that has no parent.
ToStringReturnType
__toString() declares a return type other than string.
MagicMethodReturnType
A magic method other than __toString() declares a return type it may not have.
AttributeTargetMismatch
An internal attribute is applied to a target it does not allow.
AttributeOnInvalidClass
#[Attribute] is applied to an interface, trait, enum or abstract class.
DeprecatedOnInvalidTarget
#[Deprecated] is applied to a class-like declaration.
AllowDynamicPropertiesOnInvalidClass
#[AllowDynamicProperties] is applied to an interface, trait, enum or readonly class.
MissingReturnValue
A bare return; in a function that declares a return type.
GeneratorReturnType
A generator declares a return type that Generator does not satisfy.
ReadonlyPropertyDefault
A readonly property has a default value.
DuplicateParameter
Two parameters share a name.
ReassignThis
$this is assigned or used as a catch variable.
UnclosedInterpolation
A [, { or ${ in an interpolated string is never closed.
EmptyInterpolationIndex
An interpolated array index is empty.
EmptyInterpolationVariableName
A ${} interpolation names no variable.
UnclosedInterpolationIndex
The index in a ${name[...]} interpolation is not closed.
ClassConstantInterpolation
A class constant is interpolated with {$...}.
InvalidInterpolationOffset
A simple interpolation "$a[...]" has an invalid offset.
InvalidNumericLiteral
A numeric literal has invalid digits, e.g. 08.
InvalidCodepointEscape
A \u{...} escape is empty or out of range.
MixedHeredocIndentation
A heredoc’s closing indentation mixes tabs and spaces.
HeredocBodyIndentation
A heredoc line is indented less than its closing marker.
WhitespaceInNamespacedName
A namespaced name contains whitespace.
MultipleVisibilityModifiers
A member has more than one visibility modifier.
MultipleSetVisibilityModifiers
A property has more than one set-visibility modifier.
DuplicateModifier
A modifier is repeated.
AbstractFinalConflict
A declaration is both abstract and final.
InvalidConstantModifier
A class constant has a modifier constants cannot have.
ModifierNotAllowed
A modifier is used where it cannot apply, e.g. static on a parameter.
KeywordAsDeclarationName
A reserved keyword names a declaration.
ReservedClassName
A reserved type name names a class.
OutermostScopeOnly
A statement that must be at the outermost scope is nested.
UnparenthesizedIntersectionInUnion
An intersection type is used in a union without parentheses.
ParenthesizedIntersectionOutsideUnion
A parenthesized intersection type is not part of a union.
StaticTypePosition
static is used as a type where it cannot be.
EmptyAttributeList
An attribute group #[] is empty.
CallTimePassByReference
An argument is passed as &$x.
CurlyOffsetAccess
An offset is read with curly braces, $a{0}.
VoidCastInExpression
A (void) cast is used as an expression.
RealCast
A (real) cast is used.
NonAssociativeChain
Non-associative operators are chained, e.g. 1 < 2 < 3.
IncDecAsAssignTarget
An increment or decrement is assigned to.
InvalidAssignTarget
An expression that cannot be assigned to is assigned to.
CompoundAssignToDestructuring
A destructuring pattern is used with a compound assignment.
ReferenceAssignToDestructuring
A destructuring pattern is assigned by reference.
IncDecNonVariable
++ or -- is applied to something other than a variable.
InvalidDereference
An expression that cannot be dereferenced is dereferenced.
InvalidWriteContext
An expression that cannot be written to is written to.
ListOutsideDestructuring
list() is used outside an assignment or foreach target.
EmptyArrayElement
An array literal has an empty element outside destructuring.
ReferenceAssignNew
A new expression is assigned by reference.
HooksOnPropertyList
A comma-separated property declaration has hooks.
InvalidInstanceofOperand
The right side of instanceof is not a class name, variable or parenthesized expression.
SwitchLeadingSemicolons
More than one ; precedes a switch’s first case.
PartialApplicationInNew
Partial function application is used in a new expression.
UnparenthesizedNewDereference
new A() is dereferenced without parentheses before PHP 8.4.
StaticStandaloneExpression
static is used as a standalone expression.
ReferenceToParenthesized
A parenthesized expression is assigned by reference.
ReferenceToNonReferenceable
A value that has no reference is assigned by reference.
QualifiedClassKeyword
self, parent or static is written fully qualified, e.g. \self.
ReservedClassReference
A reserved name is extended, implemented or used as a trait.
ReservedEnumName
A reserved type name names an enum.
TraitInInterface
An interface uses a trait.
AbstractMemberInConcreteClass
A class that is not abstract has an abstract method or hook.
DuplicateProperty
A class declares a property twice.
DuplicateMethod
A class declares a method twice.
DuplicateClassConstant
A class declares a constant or enum case twice.
ClassConstantNamedClass
A class constant is named class.
ClassConstantValueType
A typed class constant’s value does not match its type.
PrivateFinalConstant
A private class constant is final.
InvalidInterfaceConstantModifier
An interface constant is not public.
InvalidInterfaceMethodModifier
An interface method is not public, or is final or abstract.
InvalidInterfacePropertyModifier
An interface property is abstract, final, protected or private.
InterfaceMethodBody
An interface method has a body.
MissingMethodBody
A method that is not abstract has no body.
AbstractMethodBody
An abstract method has a body.
PrivateAbstractMethod
An abstract method is private.
AbstractAnonymousClassMethod
An anonymous class method is abstract.
AbstractEnumMethod
An enum method is abstract.
MagicMethodArgumentCount
A magic method takes the wrong number of parameters.
MagicMethodByReference
A magic method takes a parameter by reference.
MagicMethodStatic
A magic method is static when it must not be, or the reverse.
MagicMethodParameterType
A magic method declares a parameter type it may not have.
StaticReadonlyProperty
A static property is readonly.
UntypedReadonlyProperty
A readonly property has no type.
ReadonlyPropertyHooks
A readonly property has hooks.
UntypedAsymmetricProperty
A property with set visibility has no type.
SetVisibilityWiderThanVisibility
A property’s set visibility is wider than its visibility.
PrivateFinalProperty
A private property is final.
AbstractPropertyWithoutAbstractHook
An abstract property has no abstract hook.
InterfacePropertyWithoutHooks
An interface declares a property without hooks.
StaticPropertyHooks
A static property has hooks.
VirtualPropertyDefault
A virtual hooked property has a default value.
VirtualPropertyAsymmetricVisibility
A virtual property has set visibility.
EmptyHookList
A property hook list is empty.
DuplicateHook
A property declares the same hook twice.
GetHookParameters
A get hook has a parameter list.
SetHookParameterCount
A set hook does not have exactly one parameter.
SetHookParameterByReference
A set hook parameter is by reference.
SetHookParameterVariadic
A set hook parameter is variadic.
SetHookParameterType
A set hook parameter’s type does not accept the property’s type.
ByReferenceGetHookWithSet
A backed property with a set hook has a by-reference get hook.
MissingHookBody
A hook of a property that is not abstract has no body.
AbstractHookBody
An interface property hook has a body.
AbstractFinalHook
An abstract property hook is final.
PrivateAbstractHook
An abstract property hook is private.
PromotedPropertyOutsideConstructor
A parameter outside a constructor is promoted.
PromotedPropertyInAbstractConstructor
A parameter of an abstract constructor is promoted.
VariadicPromotedProperty
A promoted parameter is variadic.
InvalidEnumBackingType
An enum’s backing type is not int or string.
EnumCaseNamedClass
An enum case is named class.
MissingEnumCaseValue
A case of a backed enum has no value.
PureEnumCaseValue
A case of a pure enum has a value.
EnumProperty
An enum declares a property.
InvalidTraitAliasModifier
A trait alias is static or abstract.
UnterminatedComment
A /* comment is never closed.
NestedClassDeclaration
A named class-like is declared inside a class member.
MixedNamespaceStyles
Braced and unbraced namespace declarations are mixed.
NamespaceNotFirst
Code other than declare precedes the first namespace declaration.
CodeOutsideNamespace
Code follows a braced namespace declaration.
NestedNamespace
A namespace declaration is nested.
UseNameConflict
A use import reuses a name already imported.
SpecialClassNameAlias
A use import is aliased to a reserved class name.
DeclareNotFirstStatement
strict_types or encoding is not declared first.
NonLiteralDeclareValue
A declare directive’s value is not a literal.
InvalidStrictTypes
strict_types uses block mode or a value other than 0 or 1.
AttributesOnMultipleConstants
Attributes apply to a const statement declaring several constants.
AttributeArgumentUnpacking
An attribute argument list unpacks with ....
AttributeArgumentClosure
An attribute argument list is a first-class callable (...).
VoidReturnValue
A void function returns a value.
NeverReturn
A never function returns.
VariadicParameterDefault
A variadic parameter has a default value.
VariadicParameterNotLast
A parameter follows a variadic one.
ThisAsDeclaredVariable
$this is declared as a parameter, closure use, global or static variable.
SuperglobalAsDeclaredVariable
A superglobal is declared as a parameter or closure use variable.
DuplicateStaticVariable
A static variable is declared twice in one function.
BreakOutOfLoop
break or continue names more loop levels than enclose it.
InvalidBreakOperand
break or continue has an operand that is not a positive integer literal.
JumpAcrossFinally
break, continue or goto jumps into or out of a finally block.
DuplicateLabel
A goto label is defined twice.
UndefinedGotoLabel
goto names an undefined label.
GotoIntoLoop
goto jumps into a loop or switch.
DuplicateSwitchDefault
A switch has more than one default.
DuplicateMatchDefault
A match has more than one default arm.
ReferenceKey
A foreach key is taken by reference.
ListAsForeachKey
A foreach key is a destructuring list.
ClassKeywordInCatch
catch names self, parent or static.
InvalidParentHookCall
parent::$x::get() or ::set() is called outside the matching hook.
StaticClassInConstantExpression
static::class is used in a constant expression.
AppendOutsideWrite
$a[] is read or unset.
InvalidGlobalsWrite
$GLOBALS is written to as a whole, appended to or referenced.
InvalidNullableType
mixed or null is marked nullable.
StandaloneTypeInComposite
void, never or mixed is part of a nullable or union type.
BuiltinTypeInIntersection
A builtin type is part of an intersection type.
RedundantType
A type is redundant with another in the same declaration.
DuplicateType
A type appears twice in a union or intersection type.
InvalidParameterType
A parameter is typed void or never.
InvalidMemberType
A property or constant has a type it may not have, e.g. callable.
QualifiedBuiltinType
A builtin type is written with a namespace, e.g. \int.
ReservedTypeName
A qualified type name ends in a reserved name.
IssetOnExpression
isset() is applied to the result of an expression.
ClosureForNew
A new expression is turned into a first-class callable (...).
YieldOutsideFunction
yield is used outside a function.
YieldFromInByReferenceGenerator
yield from is used in a by-reference generator.
PositionalAfterNamedArgument
A positional argument follows a named one.
UnsetCast
An (unset) cast is used.
BuiltinResultWrite
The result of a builtin such as clone is written to.
CallResultWrite
The result of a function or method call is written to, e.g. f() = 1.
TemporaryExpressionWrite
A temporary value is written to, e.g. (1)[0] = 2.
NullsafeWrite
A nullsafe chain is written to.
ReferenceToNullsafe
A nullsafe chain is taken by reference.
NullsafeClosureCreation
A nullsafe call is turned into a first-class callable (...).
UnwritableDestructuringElement
A destructuring element cannot be assigned to.
UnsetThis
$this is unset.
ClosureUseShadowsParameter
A closure use variable has the name of a parameter.
DuplicateClosureUseVariable
A closure use list names a variable twice.
LiteralClassName
A numeric literal is used as a class name, e.g. (1)::A.
ClassFetchOnLiteral
::class is applied to true, false, null or an array literal.
DynamicClassFetch
::class is applied to a dynamic class name before PHP 8.0.
InvalidConstantExpression
A constant expression contains something PHP cannot evaluate at compile time.
EmptyList
A destructuring list is empty.
EmptyKeyedArrayEntry
A keyed destructuring list has an empty entry.
MixedKeyedEntries
A destructuring list mixes keyed and unkeyed entries.
MixedListSyntax
A destructuring pattern mixes [] and list().
SpreadInDestructuring
A destructuring list uses ....
UnparenthesizedNestedTernary
Nested ternaries are not parenthesized, e.g. a ? b : c ? d : e.
UnparenthesizedArrowInPipe
An arrow function on the right of |> is not parenthesized.
InvalidCurlyInterpolation
A {$...} interpolation is not a variable, property, index or call.
RepeatedAttribute
A non-repeatable attribute is applied twice.
NoDiscardOnInvalidTarget
#[\NoDiscard] is applied to a property hook or a method it cannot apply to.
NoDiscardWithoutReturnValue
#[\NoDiscard] is applied to a function that returns no value.
UnexpectedCharacter
A control character appears in code.
Other
Not yet classified.