ArrayFlipInvalidValueType
warning native on by defaultGroup: Probable bugs
Detect array_flip of a literal array containing a value proven neither string nor integer.
Example
php
<?php
array_flip([true]);Reported:
- line 2: Supply only string or integer values to array_flip.
Detection
- Report array_flip of a literal array containing a value proven neither string nor integer.
- Resolve builtin calls and named arguments before checking the contract. Project-local callees are considered only when their bodies or immutable summaries establish the required facts. The default is enabled, with positive proof required.
- For flow-dependent conditions, require a reachable source-to-use path with no intervening invalidation. Unknown calls, ambiguous aliases or recursion cannot establish definite facts. When the proof is inconclusive, nothing is reported.
Exceptions (no report)
- Unknown values are not evidence; resolved user functions named array_flip are excluded.
- Unresolved targets, incomplete required facts, suppressed findings and PHP versions lacking the referenced API or language feature produce no report. User declarations shadowing builtin names are not builtin contracts.
Fix
No automatic fix: conversion changes key meaning and may collide.
PHP versions
Apply only on PHP versions supporting the referenced APIs and syntax (within PHP 5.3–8.5). Builtin behavior and argument contracts follow the configured PHP version. Extension-specific calls require resolved extension API symbols; do not treat same-named application functions as extension calls.
Options
None. Enable or disable this rule through normal rule configuration.
Configure
In custos.json:
json
{
"rules": {
"ArrayFlipInvalidValueType": {
"enabled": false
}
}
}Suppress
Before the statement or declaration (or the first statement of the file):
php
// @custos-ignore ArrayFlipInvalidValueType