Fix issues raised by phpstan.

Issue fork charts-3518027

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

liam morland created an issue. See original summary.

liam morland’s picture

The commit adding drupal:views_ui to test_dependencies was intended to fix this error: "Function views_ui_build_form_url not found." It does not fix it.

The other phpstan issues are all about adding dependency injection.

bluegeek9’s picture

I have a question about: src/Form/ChartsConfigForm.php

Is the form referenced in other projects? I only see the form used once. I am not sure how it could be called and the services would be null.

    $this->chartPluginManager = $chart_plugin_manager ?: \Drupal::service('plugin.manager.charts');
    $this->chartTypePluginManager = $chart_type_plugin_manager ?: \Drupal::service('plugin.manager.charts_type');
    $this->moduleExtensionList = $module_extension_list ?: \Drupal::service('extension.list.module');
nikathone’s picture

@bluegeek9 we did that to make the config form backwards compatible in case another user/module have extended the module before we add those dependencies.

In the future major version upgrade of chart we will remove the ternary operators.

bluegeek9’s picture

Assigned: Unassigned » bluegeek9

I need to add tests.

andileco’s picture

@bluegeek9, I see everything is green. Is there more you wanted to do on this, or is it ready for review?

bluegeek9’s picture

I want to add tests. I also want to add the file system service as a dependency to the form. I want to replace file_exists with the service so it can be mocked/tested.

It should need review by end of day.

P.S. I was able to resolve "Function views_ui_build_form_url not found." by adding views_ui to the phpstan.neon. It worked locally, but to work in gitlab it needed the full, not relative path. The full path changes with each issue. I resorted to using phpstan-ignore.

bluegeek9’s picture

Assigned: bluegeek9 » Unassigned
Status: Active » Needs review

andileco’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.