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

Is it possible to check for use of deprecated classes? #43

Closed
FatherShawn opened this issue Apr 20, 2019 · 4 comments
Closed

Is it possible to check for use of deprecated classes? #43

FatherShawn opened this issue Apr 20, 2019 · 4 comments
Labels
phpstan-deprecation-rules Issue related to the Deprecation Rules extension upstream Ticket involves dependencies

Comments

@FatherShawn
Copy link

So I ran this on one of my contrib modules:

drupal-check docroot/modules/formassembly
 27/27 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%


 [OK] No errors

But I know that I have overridden constructors populating parameters with deprecated services, such as:

class FormAssemblyEntityViewBuilder extends EntityViewBuilder {

  ...

  /**
   * {@inheritdoc}
   */
  public function __construct(
    EntityTypeInterface $entity_type,
    EntityManagerInterface $entity_manager,
    LanguageManagerInterface $language_manager,
    Registry $theme_registry = NULL,
    ApiMarkup $markup,
    LoggerInterface $loggerChannel,
    KillSwitch $killSwitch
  ) {
    parent::__construct($entity_type, $entity_manager, $language_manager,
      $theme_registry);
    $this->markup = $markup;
    $this->logger = $loggerChannel;
    $this->killSwitch = $killSwitch;
  }
}

phpStorm lines out EntityManagerInterface and I learned at DruaplCon and via Slack from Alex Pott that this should be refactored to drop the constructor entirely, putting the custom service population in create() Can we catch instantiation or passing of deprecated objects in addition to deprecated methods?

@mglaman
Copy link
Owner

mglaman commented Apr 26, 2019

Ah, interesting. This definitely needs to be moved to phpstan-drupal. Or kept here and a mirror opened (I need to decide how I want to manage that.)

The root detection is phpstan-deprecation-rules. The investigation would need to check there for passing deprecated classes into a constructor.

@mglaman mglaman added upstream Ticket involves dependencies phpstan-deprecation-rules Issue related to the Deprecation Rules extension labels Apr 26, 2019
@mglaman
Copy link
Owner

mglaman commented Apr 27, 2019

See mglaman/phpstan-drupal#321 as well

@FatherShawn
Copy link
Author

So should this issue be in mglaman/phpstan-drupal ??

@mglaman
Copy link
Owner

mglaman commented Feb 4, 2022

This got fixed a while ago in phpstan-drupal

@mglaman mglaman closed this as completed Feb 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
phpstan-deprecation-rules Issue related to the Deprecation Rules extension upstream Ticket involves dependencies
Projects
None yet
Development

No branches or pull requests

2 participants