auto-fix "Call to function in_array() requires parameter #3 to be set/true."
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 25/100
Rechercherichtung
Read the linked pull request #349 first; it already has this issue in progress. The issue describes the fixer behavior for in_array(), array_search() and eligible array_keys() calls, including named arguments, splat calls, and types inferred from PHPDoc. Done means only calls whose strict equivalence can be proven are changed, while base64_decode() and array_keys() calls without a search value remain unaffected.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
if we know native haystack and needle types for a in_array, array_keys or array_search call, it would be great we could fix add a true as 3rd parameter in case its missing or can always be true. we should only fix when haystacks' iterable type is a super type of needle (strict comparison). the fixer must not change calls where equivalence cannot be proven.
Example: in_array($needle, X::VALS) into its strict counterpart in_array($needle, X::VALS, true).
https://phpstan.org/r/e288cf2a-08e5-4c06-9255-1a98eefc99fe
named arguments should be supported and calls using the splat operator should be skipped.
we should not fix calls which get their iterable-value type from a phpdoc, e.g.:
/** @return int[] */
function getArray(): array {}
function doFoo(int $i):bool {
return in_array($i, getArray());
}
For array_keys(), only consider calls with at least two arguments, since the strictness flag matters only when a search value is supplied. Calls without a search value should remain unchanged.
The rule also reports calls to other functions, such as base64_decode(). Those calls should not be made fixable by this change.
- Vorherrschende Sprache
- PHP
- Sterne
- 714
- Forks
- 63
- Ø Merge
- 1 T. 11 Std.
- Gemergte PRs (30 T.)
- 8
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus phpstan/phpstan-strict-rules
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
phpstan/phpstan-strict-rules#317 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
phpstan/phpstan-strict-rules#316 · 4 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 52/100
phpstan/phpstan-strict-rules#298 · 2 Kommentare · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
phpstan/phpstan-strict-rules#283 · 6 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
phpstan/phpstan-strict-rules#276 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in phpstan/phpstan-strict-rules
Ähnliche Issues
-
claude
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
sprain/sprainocchio#26 ·
-
sync-en
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 84/100
Maintainer antworten meist innerhalb von 1 Tag
-
sync-en
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 83/100
GSA/digital-gov-drupal#569 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
feature-request-triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
Codeinwp/wp-menu-icons#360 ·