Rules
custos ships 178 rules in 12 groups. Rules marked off only run when enabled in custos.json or with --all; rules with a quick-fix are applied by custos fix and offered as code actions by the language server. Every rule also answers to its PhpStorm inspection name (<ID>Inspection), in @noinspection comments, --rule and custos.json.
Architecture
| Rule | Severity | Default | Quick-fix | PHP |
|---|---|---|---|---|
| BadExceptionsProcessing | info | off | any | |
| CallableParameterUseCaseInTypeContext | warning | on | any | |
| ClassOverridesFieldOfSuperClass | warning | off | any | |
| ClassReImplementsParentInterface | warning | on | ✓ | any |
| EfferentObjectCoupling | info | off | any | |
| EmptyClass | info | off | any | |
| LongInheritanceChain | warning | off | any | |
| MultipleReturnStatements | warning | off | any | |
| PropertyCanBeStatic | info | off | any |
Code style
Compatibility
| Rule | Severity | Default | Quick-fix | PHP |
|---|---|---|---|---|
| DeprecatedIniOptions | warning | on | any | |
| FopenBinaryUnsafeUsage | warning | on | ✓ | any |
| MktimeUsage | warning | on | ✓ | any |
| RandomApiMigration | warning | on | ✓ | any |
Confusing constructs
| Rule | Severity | Default | Quick-fix | PHP |
|---|---|---|---|---|
| ClassMethodNameMatchesFieldName | info | on | any | |
| NestedTernaryOperator | warning | on | any | |
| ReferencingObjects | warning | on | ✓ | any |
| SenselessTernaryOperator | warning | on | ✓ | any |
| UselessReturn | info | on | ✓ | any |
Control flow
| Rule | Severity | Default | Quick-fix | PHP |
|---|---|---|---|---|
| ArraySearchUsedAsInArray | warning | on | ✓ | any |
| ArrayUniqueCanBeUsed | info | on | ✓ | PHP ≥ 7.2 |
| CompactCanBeUsed | info | off | ✓ | any |
| DegradedSwitch | info | on | any | |
| DisconnectedForeachInstruction | info | off | any | |
| ForeachInvariants | warning | on | ✓ | any |
| GetTypeMissUse | warning | on | ✓ | any |
| IfReturnReturnSimplification | warning | on | ✓ | any |
| InvertedIfElseConstructs | info | off | ✓ | any |
| IssetConstructsCanBeMerged | info | on | ✓ | any |
| LoopWhichDoesNotLoop | warning | on | any | |
| MultiAssignmentUsage | info | on | any | |
| NotOptimalIfConditions | warning | on | any | |
| ObGetCleanCanBeUsed | warning | on | ✓ | any |
| OneTimeUseVariables | warning | on | ✓ | any |
| PdoApiUsage | info | on | ✓ | any |
| RedundantElseClause | warning | on | ✓ | any |
| StrTrUsageAsStrReplace | info | on | ✓ | any |
| StringCaseManipulation | info | on | ✓ | any |
| StringNormalization | info | on | ✓ | any |
| StrlenInEmptyStringCheckContext | info | on | ✓ | any |
| SubStrUsedAsStrPos | info | on | ✓ | any |
| TernaryOperatorSimplify | info | on | ✓ | any |
| ThrowRawException | info | on | ✓ | any |
| UnSafeIsSetOverArray | warning | on | ✓ | any |
Language level migration
| Rule | Severity | Default | Quick-fix | PHP |
|---|---|---|---|---|
| AliasFunctionsUsage | warning | on | ✓ | any |
| ArgumentUnpackingCanBeUsed | warning | on | ✓ | PHP ≥ 5.6 |
| ArrayIsListCanBeUsed | info | on | ✓ | PHP ≥ 8.0 |
| CascadingDirnameCalls | warning | on | ✓ | PHP ≥ 7.0 |
| ClassConstantCanBeUsed | info | on | ✓ | PHP ≥ 5.5 |
| ConstantCanBeUsed | info | on | ✓ | any |
| DeprecatedConstructorStyle | error | on | ✓ | any |
| DirectoryConstantCanBeUsed | warning | on | ✓ | any |
| DynamicCallsToScopeIntrospection | warning | on | PHP ≥ 7.1 | |
| ElvisOperatorCanBeUsed | info | on | ✓ | any |
| GetClassUsage | warning | on | PHP ≥ 7.1 | |
| GetDebugTypeCanBeUsed | info | on | PHP ≥ 8.0 | |
| InstanceofCanBeUsed | warning | on | ✓ | any |
| IsCountableCanBeUsed | info | on | PHP ≥ 7.4 | |
| IsIterableCanBeUsed | info | on | PHP ≥ 7.1 | |
| NullCoalescingOperatorCanBeUsed | info | on | ✓ | PHP ≥ 7.0 |
| PowerOperatorCanBeUsed | warning | on | ✓ | PHP ≥ 5.6 |
| ReturnTypeCanBeDeclared | info | on | ✓ | PHP ≥ 7.0 |
| ShortListSyntaxCanBeUsed | info | on | ✓ | PHP ≥ 7.1 |
| StrContainsCanBeUsed | info | on | ✓ | PHP ≥ 8.0 |
| StrEndsWithCanBeUsed | info | on | ✓ | PHP ≥ 8.0 |
| StrStartsWithCanBeUsed | info | on | ✓ | PHP ≥ 8.0 |
| TypesCastingCanBeUsed | info | on | ✓ | any |
| UnsupportedEmptyListAssignments | error | on | PHP ≥ 7.0 | |
| UnsupportedStringOffsetOperations | error | on | PHP ≥ 7.1 |
PHPUnit
| Rule | Severity | Default | Quick-fix | PHP |
|---|---|---|---|---|
| MockingMethodsCorrectness | warning | on | ✓ | any |
| PhpUnitDeprecations | info | on | ✓ | any |
| PhpUnitTests | info | on | ✓ | any |
| UnnecessaryAssertion | info | on | ✓ | any |
Performance
| Rule | Severity | Default | Quick-fix | PHP |
|---|---|---|---|---|
| AlterInForeach | warning | on | any | |
| AmbiguousMethodsCallsInArrayMapping | warning | on | any | |
| ArrayPushMissUse | warning | on | ✓ | any |
| CascadeStringReplacement | warning | on | ✓ | any |
| CaseInsensitiveStringFunctionsMissUse | warning | on | ✓ | any |
| FixedTimeStartWith | warning | off | ✓ | any |
| InArrayMissUse | warning | on | ✓ | any |
| NotOptimalRegularExpressions | warning | on | ✓ | any |
| PackedHashtableOptimization | info | on | PHP ≥ 7.0 | |
| SlowArrayOperationsInLoop | error | on | ✓ | any |
| StrStrUsedAsStrPos | warning | on | ✓ | any |
| StrtotimeUsage | warning | on | ✓ | any |
| SubStrShortHandUsage | warning | on | ✓ | any |
| SubStrUsedAsArrayAccess | warning | on | ✓ | any |
| UnqualifiedReference | info | off | ✓ | PHP ≥ 7.0 |
| VariableFunctionsUsage | info | on | ✓ | any |
Probable bugs
Security
| Rule | Severity | Default | Quick-fix | PHP |
|---|---|---|---|---|
| BacktickOperatorUsage | warning | on | ✓ | any |
| CryptographicallySecureAlgorithms | error | on | any | |
| CryptographicallySecureRandomness | error | on | any | |
| CurlSslServerSpoofing | error | on | any | |
| EncryptionInitializationVectorRandomness | error | on | any | |
| HostnameSubstitution | error | on | any | |
| NonSecureParseStrUsage | error | on | any | |
| NonSecureUniqidUsage | error | on | ✓ | any |
| PotentialMalware | error | on | any | |
| SecurityAdvisories | warning | on | ✓ | any |
| UnserializeExploits | error | on | any | |
| UntrustedInclusion | error | off | any |
Type compatibility
| Rule | Severity | Default | Quick-fix | PHP |
|---|---|---|---|---|
| JsonEncodingApiUsage | info | on | ✓ | any |
| TypeUnsafeArraySearch | info | on | any | |
| TypeUnsafeComparison | warning | on | ✓ | any |
Unused
| Rule | Severity | Default | Quick-fix | PHP |
|---|---|---|---|---|
| DateUsage | info | on | ✓ | any |
| OnlyWritesOnParameter | info | on | any | |
| PropertyInitializationFlaws | info | on | ✓ | any |
| SenselessMethodDuplication | info | on | ✓ | any |
| SenselessProxyMethod | warning | on | ✓ | any |
| UnnecessaryIssetArguments | info | on | ✓ | any |
| UnusedConstructorDependencies | info | on | any | |
| UnusedGotoLabel | info | on | ✓ | any |
| UselessUnset | info | on | any |
