Commit 63741f33 authored by Luhur Abdi Rizal's avatar Luhur Abdi Rizal
Browse files

Issue #3263304 by el7cosmos: Use phpstan/phpstan-deprecation-rules

parent 52b40afc
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -17,7 +17,8 @@
        "drupal/webform": "^6.0",
        "mglaman/phpstan-drupal": "^1.1",
        "mockery/mockery": "^1.3",
        "phpmd/phpmd": "^2.8"
        "phpmd/phpmd": "^2.8",
        "phpstan/phpstan-deprecation-rules": "^1.0"
    },
    "suggest": {
        "drupal/token": "Provides additional tokens not supported by core (most notably fields), as well as a UI for browsing tokens.",
+0 −4
Original line number Diff line number Diff line
@@ -54,10 +54,6 @@ final class ExampleFieldEventSubscribers implements EventSubscriberInterface {
   */
  public static function getSubscribedEvents(): array {
    return [
      // For drupal 9.1.x and below.
      HookEventDispatcherInterface::WIDGET_FORM_ALTER => 'alterWidgetForm',
      'hook_event_dispatcher.widget_string_textfield.alter' => 'alterWidgetStringTextField',
      // For drupal 9.2.x and above.
      HookEventDispatcherInterface::WIDGET_SINGLE_ELEMENT_FORM_ALTER => 'alterWidgetForm',
      'hook_event_dispatcher.widget_single_element_string_textfield.alter' => 'alterWidgetStringTextField',
    ];
+2 −0
Original line number Diff line number Diff line
@@ -11,6 +11,8 @@ namespace Drupal\field_event_dispatcher\Event\Field;
 *
 * @see https://www.drupal.org/node/3180429
 * @see \Drupal\field_event_dispatcher\Event\Field\WidgetSingleElementTypeFormAlterEvent
 *
 * @phpstan-ignore-next-line
 */
class WidgetTypeFormAlterEvent extends WidgetFormAlterEvent {

+4 −13
Original line number Diff line number Diff line
@@ -81,18 +81,11 @@ class WidgetFormAlterEventTest extends KernelTestBase {
   * @throws \Exception
   */
  public function testWidgetSingleElementFormAlterEvent(): void {
    $deprecated = version_compare(\Drupal::VERSION, '9.2.0', '<');

    $this->listen([
      HookEventDispatcherInterface::WIDGET_FORM_ALTER,
      'hook_event_dispatcher.widget_text.alter',
      HookEventDispatcherInterface::WIDGET_SINGLE_ELEMENT_FORM_ALTER,
      'hook_event_dispatcher.widget_single_element_text.alter',
    ], 'onWidgetSingleElementFormAlter', $this->exactly($deprecated ? 2 : 4));
    $this->listen([
      HookEventDispatcherInterface::WIDGET_MULTIVALUE_FORM_ALTER,
      HookEventDispatcherInterface::WIDGET_COMPLETE_FORM_ALTER,
    ], 'onWidgetCompleteFormAlter', $this->exactly($deprecated ? 1 : 2));
    ], 'onWidgetSingleElementFormAlter', $this->exactly(2));
    $this->listen(HookEventDispatcherInterface::WIDGET_COMPLETE_FORM_ALTER, 'onWidgetCompleteFormAlter');

    $form = [];
    $formState = new FormState();
@@ -101,10 +94,8 @@ class WidgetFormAlterEventTest extends KernelTestBase {

    $this->assertArrayHasKey(self::TEST_DISPLAY_CONFIGURABLE, $form);

    if (!$deprecated) {
    $this->assertArrayHasKey('test', $form[self::TEST_DISPLAY_CONFIGURABLE]);
    $this->assertTrue($form[self::TEST_DISPLAY_CONFIGURABLE]['test']);
    }

    $widget = $form[self::TEST_DISPLAY_CONFIGURABLE]['widget'][0];
    $this->assertArrayHasKey('other', $widget);
+1 −0
Original line number Diff line number Diff line
includes:
  - %rootDir%/../../mglaman/phpstan-drupal/extension.neon
  - %rootDir%/../../phpstan/phpstan-deprecation-rules/rules.neon

parameters:
  level: 1