Support for deprecated preprocess variables

Đang mở
#776 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
43/100
Loại issue
Tính năng
Độ 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-qa

Hướng nghiên cứu

Read the linked Drupal issue 3458183 and its predecessor 3458587, then inspect how phpstan-drupal analyzes Drupal preprocess hooks. The issue suggests detecting direct $variables['teaser'] access using a list of deprecated variable names, while avoiding matches such as $variables['view_mode'] === 'teaser'. Done means adding useful detection for deprecated preprocess variables with limited false positives; the issue does not name files or tests.

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

Mô tả

enhancement

Feature request

Core added support for deprecating Twig variables a couple of years ago, it has not been used much yet, CR is here: https://www.drupal.org/node/3334622

In https://www.drupal.org/project/drupal/issues/3458587 and sub-issues I'm actually trying to use it, of course this immediately runs into limitations.

The support we added in core supports detecting when a deprecated variable is used in a twig template, so that the template author can remove it.

However a lot of custom/contrib preprocess implementations check the value of one preprocess variable to then set the value of another, or overwrite preprocess variables etc. - we don't have any detection for that because it's just array keys.

Alex Pott suggested a phpstan-drupal issue to see if we can add detection. Because the support relies on values of $variables['deprecations'] which is also set in preprocess, it would be extremely difficult for php-stan drupal to dynamically determine this, but we wondered about hardcoding specific variable names like 'teaser' in a list then looking for $variables['teaser'] in any node preprocess hook and notifying if it's found. If we only look for $variables['teaser'] that would reduce false positives like $variables['view_mode'] === 'teaser'. This support would not be perfect, but we could detect the most disruptive changes which would be better than nothing.

https://www.drupal.org/project/drupal/issues/3458183 is the first issue to actually land from the latest round so there is something to try against.

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.