fix phpstan warnings about variables that might not be defined

Created on 3 September 2025, 12 days ago

Problem/Motivation

phpstan reports,

------ ---------------------------------------------
Line src/ConditionalFieldsElementAlterHelper.php
------ ---------------------------------------------
140 Variable $parent might not be defined.
------ ---------------------------------------------
------ ----------------------------------------------------------------------
Line src/ConditionalFieldsFormHelper.php
------ ----------------------------------------------------------------------
346 \Drupal calls should be avoided in classes, use dependency injection
instead
359 Variable $first_field might not be defined.
362 Variable $storage might not be defined.
363 Variable $field_name might not be defined.
370 Variable $field_name might not be defined.
597 Variable $field_name might not be defined.
810 Variable $error_key_arr on left side of ?? always exists and is not
nullable.
------ ----------------------------------------------------------------------

Steps to reproduce

https://git.drupalcode.org/project/conditional_fields/-/jobs/3780550

Proposed resolution

Define the variables before they are used.

Remaining tasks

make a MR

πŸ“Œ Task
Status

Active

Version

4.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States BenStallings

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