Provide additional context in the DisallowedEmptyRule error message
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 35/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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?
- Lenguaje dominante
- PHP
- Estrellas
- 711
- Forks
- 62
- Merge medio
- 3 d 14 h
- PR fusionados (30 d)
- 5
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de phpstan/phpstan-strict-rules
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
phpstan/phpstan-strict-rules#317 · 1 comentario ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
phpstan/phpstan-strict-rules#316 · 3 comentarios ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 52/100
phpstan/phpstan-strict-rules#298 · 2 comentarios · 1 reacción ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
phpstan/phpstan-strict-rules#289 · 1 comentario ·
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
phpstan/phpstan-strict-rules#283 · 6 comentarios ·
Todos los issues de phpstan/phpstan-strict-rules
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
Do not throw `WordPress.Security.EscapeOutput.OutputNotEscaped` on `apply_shortcodes()`Posiblemente ocupada @tbradsha la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
fe: spell out "Auto increment" in the table editor, "AI" reads as artificial intelligence todayAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
landsman/adminer-desktop#120 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
components-web-app/docs#227 ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100