In StylePluginBase Rename Views properties to core standards

Created on 26 February 2023, over 1 year ago
Updated 2 August 2024, 4 months ago

Problem/Motivation

There are class properties in \Drupal\views\Plugin\views\style\StylePluginBase that violate the Drupal Coding standards. These properties are preceded by a phpcs ignore line, // phpcs:ignore Drupal.NamingConventions.ValidVariableName.LowerCamelName

Steps to reproduce

Proposed resolution

Rename each property
Deprecate. The Deprecation policy shows how to deprecate properties β†’ .

Remaining tasks

Create child issues

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Active

Version

11.0 πŸ”₯

Component
OtherΒ  β†’

Last updated about 6 hours ago

Created by

πŸ‡«πŸ‡·France andypost

Live updates comments and jobs are added and updated live.
  • Coding standards

    It involves compliance with, or the content of coding standards. Requires broad community agreement.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Issue created by @andypost
  • Status changed to Needs review over 1 year ago
  • πŸ‡«πŸ‡·France andypost

    Filed CR https://www.drupal.org/node/3344579 β†’

    patch initial attempt, looks better to introduce a trait for that like DeprecatedServicePropertyTrait

  • πŸ‡¬πŸ‡§United Kingdom longwave UK

    +1 to adding a DeprecatedPropertyTrait similar to the service one, if we are going to do this everywhere in Views.

  • πŸ‡«πŸ‡·France andypost

    Thanks! The only trick is that trait will provide only one link to change record but maybe it should be enough

  • πŸ‡¬πŸ‡§United Kingdom longwave UK

    Maybe $deprecatedProperties can include the change record ID? Something like:

      protected $deprecatedProperties = [
        'rendered_fields' => ['renderedFields', 3344579],
        'render_tokens' => ['renderTokens', 3344579],
      ];
    
  • πŸ‡«πŸ‡·France andypost

    Guess kinda it

  • πŸ‡«πŸ‡·France andypost

    property should not be defined in trait

  • Status changed to Needs work over 1 year ago
  • πŸ‡³πŸ‡±Netherlands Lendude Amsterdam
    1. +++ b/core/modules/views/src/Plugin/views/DeprecatedPropertyTrait.php
      @@ -0,0 +1,40 @@
      +namespace Drupal\views\Plugin\views;
      

      Feel useful outside Views to maybe? Currently not doing anything that would make this Views only, so maybe move it somewhere more generic?

    2. +++ b/core/modules/views/src/Plugin/views/DeprecatedPropertyTrait.php
      @@ -0,0 +1,40 @@
      +/**
      + * Provides a standard way to announce deprecated properties.
      + */
      

      Maybe expand on this that the 'deprecatedProperties' property must be set on all classes that implement this trait?

    3. +++ b/core/modules/views/src/Plugin/views/DeprecatedPropertyTrait.php
      @@ -0,0 +1,40 @@
      +   * Allows to get deprecated/removed properties.
      ...
      +   * Allows to set deprecated/removed properties.
      

      'Allows throwing an exception when a property is accessed that has been marked as deprecated.'

    4. +++ b/core/modules/views/src/Plugin/views/DeprecatedPropertyTrait.php
      @@ -0,0 +1,40 @@
      +    if (!isset($this->deprecatedProperties)) {
      +      throw new \LogicException('The deprecatedProperties property must be defined to use this trait.');
      +    }
      

      This bit is only in __get not __set, shouldn't it be in both?

    5. +++ b/core/modules/views/src/Plugin/views/DeprecatedPropertyTrait.php
      @@ -0,0 +1,40 @@
      +      @trigger_error("The property $name is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use $property instead. See https://www.drupal.org/node/$link", E_USER_DEPRECATED);
      

      Hardcoding the Drupal version means we can't use this in 10.2 without existing deprecation messages also changing, so I think that needs to be dynamic as well

  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

    Neat!

    1. +++ b/core/modules/views/src/Plugin/views/DeprecatedPropertyTrait.php
      @@ -0,0 +1,40 @@
      +    if (!isset($this->deprecatedProperties)) {
      

      any reason not to put deprecatedProperties on the trait and make it empty?

      I assume to prevent using the trait by accident?

    2. +++ b/core/modules/views/src/Plugin/views/DeprecatedPropertyTrait.php
      @@ -0,0 +1,40 @@
      +      @trigger_error("The property $name is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use $property instead. See https://www.drupal.org/node/$link", E_USER_DEPRECATED);
      

      What if it is deprecated in 10.2.0? Do we need more than $property and $link? Should we have a simple value object?

    3. +++ b/core/modules/views/src/Plugin/views/style/StylePluginBase.php
      @@ -109,6 +111,23 @@ abstract class StylePluginBase extends PluginBase {
      +   * Keyed array pf replacements where key is deprecated property name.
      

      of

  • Status changed to Active 4 months ago
  • πŸ‡³πŸ‡ΏNew Zealand quietone
  • πŸ‡³πŸ‡ΏNew Zealand quietone
Production build 0.71.5 2024