Skip to main content

ForbiddenRule

Enum ForbiddenRule 

Source
#[non_exhaustive]
pub enum ForbiddenRule {
Show 190 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, 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, ClassKeywordInCatch, InvalidParentHookCall, StaticClassInConstantExpression, AppendOutsideWrite, InvalidGlobalsWrite, InvalidNullableType, StandaloneTypeInComposite, BuiltinTypeInIntersection, RedundantType, DuplicateType, InvalidParameterType, InvalidMemberType, QualifiedBuiltinType, ReservedTypeName, IssetOnExpression, ClosureForNew, YieldOutsideFunction, YieldFromInByReferenceGenerator, PositionalAfterNamedArgument, UnsetCast, BuiltinResultWrite, TemporaryExpressionWrite, NullsafeWrite, ReferenceToNullsafe, NullsafeClosureCreation, UnwritableDestructuringElement, UnsetThis, ClosureUseShadowsParameter, DuplicateClosureUseVariable, LiteralClassName, ClassFetchOnLiteral, DynamicClassFetch, InvalidConstantExpression, EmptyList, EmptyKeyedArrayEntry, MixedKeyedEntries, MixedListSyntax, SpreadInDestructuring, UnparenthesizedNestedTernary, UnparenthesizedArrowInPipe, InvalidCurlyInterpolation, RepeatedAttribute, NoDiscardOnInvalidTarget, NoDiscardWithoutReturnValue, 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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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.

§

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.

§

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.

§

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.

§

Other

Not yet classified.

Implementations§

Source§

impl ForbiddenRule

Source

pub const ALL: &'static [ForbiddenRule]

Every rule, in declaration order.

Source

pub fn as_str(self) -> &'static str

Stable kebab-case identifier, e.g. "reassign-this".

Source

pub fn phase(self) -> Phase

When PHP reports the rule.

Trait Implementations§

Source§

impl Clone for ForbiddenRule

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ForbiddenRule

Source§

impl Debug for ForbiddenRule

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ForbiddenRule

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ForbiddenRule

Source§

impl FromStr for ForbiddenRule

Source§

type Err = UnknownForbiddenRule

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for ForbiddenRule

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ForbiddenRule

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ForbiddenRule

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.