$defaultTheme being set via a Trait is not discovered.

Abierto
#773 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
drupal, php
Área
devtools, testing

Línea de trabajo

Start by reading the trait example in the issue and the phpstan-drupal rule that checks tests for $defaultTheme; the issue does not name the rule's file or a test. Trace how the analysis discovers that property when it is assigned at runtime through a trait. Done means the rule recognizes this assignment, with a regression test demonstrating the case.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug

Bug report

First, let me say that I think this is an edge case, so I really don't know if there's value in trying to solve this... would be totally OK if this gets closed as "wontfix".

In my particular issue, when Drupal announced that $defaultTheme must be set for all tests, in my project we started setting this via a trait, but the trait sets the property at runtime. Given this is a very unique use case, I would be happy to just ignore this rule, so I opened #772 which would help me ignore it.

I'm not totally sure if this is a useful bug report for other reasons.. just to consider that the property may be set outside the test itself...?

Code snippet that reproduces the problem

Here is how I set $defaultTheme via trait...

trait ThemeTestTrait {

  /**
   * {@inheritdoc}
   *
   * Set all custom tests to use stark by default.
   *
   * This was introduced in Drupal core v9 where all tests switched from the
   * classy theme to an undefined theme.
   *
   * @see https://www.drupal.org/node/3083055
   */
  protected function installDefaultThemeFromClassProperty(ContainerInterface $container): void {
    if (!isset($this->defaultTheme)) {
      $this->defaultTheme = 'stark';
    }

    parent::installDefaultThemeFromClassProperty($container);
Lenguaje dominante
PHP
Estrellas
208
Forks
88
Merge medio
2 d 17 h
PR fusionados (30 d)
15

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 mglaman/phpstan-drupal

Todos los issues de mglaman/phpstan-drupal

Issues similares

Más issues de PHP

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.