Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function libraries_get_path() not found #88

Closed
Sergey-Orlov opened this issue Jun 13, 2019 · 5 comments
Closed

Function libraries_get_path() not found #88

Sergey-Orlov opened this issue Jun 13, 2019 · 5 comments

Comments

@Sergey-Orlov
Copy link
Contributor

I'm using CKEditor with some contrib plugins.

And some of them have next construction in code of plugin:

  /**
   * Get path to library folder.
   */
  public function getLibraryPath() {
    $path = 'libraries/colorbutton';
    if (\Drupal::moduleHandler()->moduleExists('libraries')) {
      $path = libraries_get_path('colorbutton');
    }

    return $path;
  }

For example:

If I don't have libraries module in the project, I got next error from drupal-check:
Function libraries_get_path not found.

I have tried to add function_exists() condition there, but it doesn't help.

Is there any way to pass such cases? Cause I see no issue in code.

@Sergey-Orlov Sergey-Orlov changed the title Function not found Function libraries_get_path() not found Jun 13, 2019
@mglaman
Copy link
Owner

mglaman commented Jun 14, 2019

Yeah, there are problems with analyzing modules which use other modules. Drupal Commerce provides a Panelizer plugin and that freaks out.

There would have to be tricks done in phpstan-drupal to support this. I'm going to leave this open for others to find. I can't think of a straight forward fix beyond "ensure dev dependencies are installed"

@andypost
Copy link

Maybe there's a way to provide "exclude" config?

@mglaman
Copy link
Owner

mglaman commented Jun 14, 2019

In my opinion, should have all of your development dependencies when running static analysis. What if you had code within moduleExists or function_exists that uses deprecated code or bad method calls? It feels like too much work to fight this problem versus ensuring all conditional dependencies for conditional support are available.

@andypost
Copy link

I'm happy to see such "weak dependencies" are caught by analysis! if module require external library it must declare it, otoh sadly there's no strong opinion in https://www.drupal.org/project/drupal/issues/2873160

@mglaman
Copy link
Owner

mglaman commented Jun 17, 2019

I'm going to close this. I see this as "works as designed" because it is forcing the analysis of your code in its entirety.

@mglaman mglaman closed this as completed Jun 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants