PHPStan: Cannot unset property Drupal\views\ViewExecutable::$row_index because it might have hooks in a subclass.

Created on 27 August 2025, about 1 month ago

Problem/Motivation

PHPStan flags an error in src/Plugin/views/style/Calendar.php (line ~697): unsetting Drupal\views\ViewExecutable::$row_index triggers rule unset.possiblyHookedProperty. This breaks static analysis/CI.

Steps to reproduce

  1. Install/enable the Calendar module.
  2. Run PHPStan on the module, e.g. ddev phpstan.
  3. Observe the reported error about unset($this->view->row_index).

Proposed resolution

Replace the unset of the object property with a safe assignment, avoiding magic __unset() hooks.

// Before
unset($this->view->row_index);

// After
$this->view->row_index = null; // Clear without invoking __unset hooks

<p>Rationale: PHPStan Drupal rule disallows unsetting object properties that may be hooked in subclasses. Setting to <code>null

preserves intent without side effects.

Remaining tasks

  • Apply the change and re-run PHPStan to confirm the error is resolved.
  • Search for and fix any similar unset() calls on object properties in the module.
  • Smoke-test Views rendering to ensure no behavioral regressions.
📌 Task
Status

Active

Version

1.0

Component

Code

Created by

🇨🇦Canada joelpittet Vancouver

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024