devel_generate_commerce – compatibility and deprecation fixes

devel_generate_commerce – compatibility and deprecation fixes

Aligns the module with the current Devel Generate base API and PHP 8.2+ (no dynamic properties).

1. Composer

  • composer.json
    • drupal/commerce: *>=3.2
    • drupal/devel: ^4.1 || ^5.0>=4.1
    • drush/drush (require-dev): ^10 || ^11>=10
    • File re-indented for readability.

2. CommerceDevelGenerate plugin

Type and signature compatibility with parent/interface

  • $entityTypeManager
    Declared with the same type as the parent:
    protected EntityTypeManagerInterface $entityTypeManager;

  • create()

    • Added return type: : static.
    • Implementation updated to match the base: constructor only receives (array $configuration, $plugin_id, $plugin_definition); dependencies are set in create() after parent::create() instead of being injected in the constructor.
  • __construct()

    • Signature reduced to the three parameters required by DevelGenerateBaseInterface:
      __construct(array $configuration, $plugin_id, $plugin_definition).
    • Removed constructor parameters for EntityTypeManagerInterface, DateFormatterInterface, TimeInterface, WorkflowManagerInterface.
    • Default-store load/create logic moved from __construct() into create() and applied on the instance after setting dependencies.
  • settingsForm()
    Added return type: : array.

  • generateElements()
    Added return type: : void.

  • validateDrushParams()
    Added return type: : array.

PHP 8.2 deprecation (dynamic property)

  • $store
    Declared as a class property:
    protected ?StoreInterface $store = NULL;
    so it is no longer a dynamic property when set in create().

3. Summary

  • Plugin constructor and method signatures match DevelGenerateBase / DevelGenerateBaseInterface.
  • Dependency injection and default-store logic are handled in create(); constructor remains minimal.
  • Return types added where required by the base/interface.
  • Dynamic property removed by declaring $store.
  • Composer constraints updated to “equal or greater” style and file formatted.
header header
image image
Edited by Nick Murza

Merge request reports

Loading