Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Provide additional context in the DisallowedEmptyRule error message

Abierto
#103 4 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
php
Área
devtools

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

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de phpstan/phpstan-strict-rules

Todos los issues de phpstan/phpstan-strict-rules

Issues similares

Más issues de PHP

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.