Skip to content

PHP 8.2 Deprecation Warning: Dynamic property creation in MarkdownField class #1

Description

@Martinhessmann

Bug Report

Environment

  • PHP Version: 8.2+
  • WordPress Version: [your version]
  • Plugin Version: [current version]

Issue

Getting a deprecation warning in PHP 8.2:

Deprecated: Creation of dynamic property Fresh\ACFMarkdownField\MarkdownField::$settings is
deprecated in
/var/www/html/wp-content/plugins/wp-acf-markdown-field-main/src/MarkdownField.php on line
45

Root Cause

The $settings property is being assigned on line 45 without being declared in the class
definition.

Fix

Add property declaration to the MarkdownField class:

class MarkdownField extends acf_field
{
    /** @var \Fresh\ACFMarkdownField\Helpers $helpers */
    protected $helpers;

    /** @var array $settings Plugin settings */
    protected $settings;  // Add this line

    // ... rest of class
}

This resolves the PHP 8.2 deprecation warning while maintaining backward compatibility.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions