Skip to content

NonRepeatableAttributeRepeated ​

error native on by default PHP ≥ 8.0

Group: Probable bugs

Remove the repeated attribute.

Example ​

Finding:

php
<?php
#[Attribute] class Label {} #[Label, Label] class Parcel {}

Reported:

  • line 2: Remove the repeated attribute.

Detection ​

  • Within one attribute-bearing declaration, resolve attribute class identities; report the second and subsequent use of a class whose Attribute flags prove IS_REPEATABLE absent. This predicts failure on ReflectionAttribute::newInstance.
  • Emit one finding per violating operation. Flow facts require a reachable path with no intervening mutation, escaped alias, unknown call involving the tracked value or analysis-budget exhaustion. Uncertain facts cannot prove a violation.

Exceptions (no report) ​

  • Aliases of the same class count as identical. Different attribute classes, separate declarations and unknown repeatability are excluded.
  • Exclude shadowed builtin symbols, unresolved required types, incomplete syntax and unsupported PHP versions.

Fix ​

No automatic fix. Choosing a repair requires runtime information, error-handling policy or a semantic decision.

All edits use exact byte ranges, preserve comments and evaluation order, and require syntax supported by the target PHP version. A fix must never add an evaluation or silently change unrelated arguments.

PHP versions ​

Minimum PHP 8.0.

Configure ​

In custos.json:

json
{
  "rules": {
    "NonRepeatableAttributeRepeated": {
      "enabled": false
    }
  }
}

Suppress ​

Before the statement or declaration (or the first statement of the file):

php
// @custos-ignore NonRepeatableAttributeRepeated

Released under the MIT License. Native rules and rules modeled on Php Inspections (EA Extended); independent clean-room implementation.