$defaultTheme being set via a Trait is not discovered.

Đang mở
#773 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
drupal, php
Lĩnh vực
devtools, testing

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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);
Ngôn ngữ chính
PHP
Star
208
Fork
88
Merge trung bình
2 ngày 17 giờ
Pull request đã merge (30 ngày)
15

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của mglaman/phpstan-drupal

Tất cả issue của mglaman/phpstan-drupal

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.