Provide additional context in the DisallowedEmptyRule error message
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 35/100
Rechercherichtung
Start by locating the DisallowedEmptyRule implementation and the code that constructs its generic error message. Update the diagnostic so it includes the type passed to empty(), then verify that mixed-based cases can be targeted without broad path-based suppression.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
In doctrine/dbal, the Schema and Driver APIs use array<string,mixed> parameters heavily (e.g. as connection parameters and column definitions).
While overall the value type is mixed, each array element usually has a certain type.
Since most of the array elements are optional, the boolean values are checked like this:
if (isset($field['unique']) && $field['unique']) {
// this is a unique column
}
Or like this:
if (empty($column['fixed'])) {
// this is a fixed-length column
}
Before reimplementing these APIs using objects with well-defined properties, I want to suppress the error reporting of such cases.
The first case is suppressed nicely like this:
-
message: '~^Only booleans are allowed.*mixed given~'
paths:
- %currentWorkingDirectory%/src/Driver/*/Driver.php
- %currentWorkingDirectory%/src/Platforms/*Platform.php
- %currentWorkingDirectory%/src/Schema/*SchemaManager.php
However, the second cannot be pin-pointed since the error message is generic for all cases:
Construct empty() is not allowed. Use more strict comparison.
I could rework expressions like empty($array[$key]) to isset($array[$key]) && $array[$key] and suppress them as above but I'd rather do the opposite since the empty() approach is more compact and has exactly the same meaning.
Would it be possible to include the type passed to empty() so that instead of whitelisting all such cases in certain paths, I could only whitelist the cases where a mixed like the above is passed?
- 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
-
auto-fix "Call to function in_array() requires parameter #3 to be set/true."Evtl. vergeben @staabm hat das vor 3 Tagen übernommen. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 25/100
phpstan/phpstan-strict-rules#347 ·
Maintainer antworten meist innerhalb von 1 Tag
-
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
Alle Issues in phpstan/phpstan-strict-rules
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
shukiv/jabali-panel#2423 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 67/100
-
customer-reported enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
MagnaCapax/PMSS#1252 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 79/100
smarty-php/smarty#1220 ·
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
StarCitizenWiki/mediawiki-extensions-EmbedVideo#224 · 1 Kommentar ·