Skip to content
Snippets Groups Projects

Draft: Issue #3458110: Phpstan fixes, refactor dependency injection and enhance documentation

Open Draft: Issue #3458110: Phpstan fixes, refactor dependency injection and enhance documentation
1 unresolved thread
1 unresolved thread

Refactored dependency injection to use more appropriate services, specifically replacing direct service calls with class properties.

Closes #3458110

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • 26 * The cached discovery clearer.
    28 27 *
    29 28 * @var \Drupal\Core\Plugin\CachedDiscoveryClearerInterface
    30 29 */
    31 protected $pluginCacheClearer;
    30 protected $cachedDiscoveryClearer;
    32 31
    33 32 /**
    34 33 * {@inheritdoc}
    35 34 */
    36 public static function create(ContainerInterface $container, PluginCacheClearerInterface $pluginCacheClearer) {
    37 $this->pluginCacheClearer = $pluginCacheClearer;
    38 return new static(
    39 $container->get('renderer')
    40 );
    35 public static function create(ContainerInterface $container) {
    • Are we sure about this change not breaking any functionality for existing user?

      Edited by Ankit Pathak
    • Thanks, I think that changing the CachedDiscoveryClearer property name could well be breaking for classes extending DynamicLayoutForm and using this service, so I've changed this back to pluginCacheClearer.

      With regards to moving the pluginCacheClearer out of the arguments and getting from the container in the method body, I'm more unsure. My thinking here was that I could not tell where this service was coming from as there is no services.yml. I guess that removing the argument could be breaking for code overridding the create method. I also could not find any PluginCacheClearerInterface to add a use statement for in order to resolve the phpstan check on the argument type.

       ------ --------------------------------------------------------------------------------------------------------------------- 
        Line   dynamic_layouts/src/Form/DynamicLayoutForm.php                                                                       
       ------ --------------------------------------------------------------------------------------------------------------------- 
        35     Parameter #2 $pluginCacheClearer of method Drupal\dynamic_layouts\Form\DynamicLayoutForm::create() is not optional.  
        35     Parameter $pluginCacheClearer of method Drupal\dynamic_layouts\Form\DynamicLayoutForm::create() has invalid type     
               Drupal\dynamic_layouts\Form\PluginCacheClearerInterface.                                                             
       ------ --------------------------------------------------------------------------------------------------------------------- 
    • Please register or sign in to reply
  • added 1 commit

    • af938415 - Rename cache clearer property for consistency

    Compare with previous version

  • Sandip Poddar added 1 commit

    added 1 commit

    Compare with previous version

  • Daniel Johnson added 2 commits

    added 2 commits

    • 39aac28a - Rename cache clearer property for consistency
    • f22cc0f1 - Issue #3458110: Work on eslint issue to make the pipeline green.

    Compare with previous version

  • Daniel Johnson added 3 commits

    added 3 commits

    • c31dc3a7 - eslint: Apply eslint automatic fixes
    • 83dcffd8 - eslint: Add .eslintrc.yml with custom overrides for gulpfile.js
    • 11335399 - eslint: migrate functions to arrow syntax for consistency

    Compare with previous version

  • Please register or sign in to reply
    Loading