Problem/Motivation

See https://github.com/mglaman/phpstan-drupal/pull/754

It's not a true issue but more of a warning when folks extend non-API code.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

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

mglaman created an issue. See original summary.

mglaman’s picture

Status: Postponed » Needs review
bbrala’s picture

Status: Needs review » Reviewed & tested by the community

Assuming tests don't fail this is exactly what we need to improve project_analysis.

bbrala’s picture

Status: Reviewed & tested by the community » Needs work

Test did fail, guess review bot didnt find this one yet ;p

gorkagr’s picture

Hi!

Before applying the patch, i get the following error in one module:

Class Drupal\ieg_core\Form\BaseCreateNodeEventForm extends @internal class Drupal\node\NodeForm.

after applying the patch, i get the following error:

PHPStan command failed:

/usr/bin/php /var/www/html/vendor/bin/phpstan analyse --memory-limit=1500M --error-format=json --configuration=/tmp/upgrade_status/deprecation_testing.neon /var/www/html/web/modules/custom/ieg_core
Command output:

Empty.
Command error:

In NeonAdapter.php line 44: Error while loading /tmp/upgrade_status/deprecation_testing.neon: Duplicated key 'drupal_root' on line 6, column 3. analyse [-c|--configuration CONFIGURATION] [-l|--level LEVEL] [--no-progress] [--debug] [-a|--autoload-file AUTOLOAD-FILE] [--error-format ERROR-FORMAT] [-b|--generate-baseline [GENERATE-BASELINE]] [--allow-empty-baseline] [--memory-limit MEMORY-LIMIT] [--xdebug] [--fix] [--watch] [--pro] [--fail-without-result-cache] [--] [...]

I assume is due to these lines added:

    $config = str_replace(
      "\tdrupal:",
      "\tdrupal:\n\t\tdrupal_root: '" . DRUPAL_ROOT . "'",
      $config
    );

best

gábor hojtsy’s picture

Yeah I am not surprised as that is what this part of the diff would do (the drupal_root key is already added a bit above). The str_replace above this needs to be differently done, I think the drupal part removed from that, then this can add the root.

diff --git a/src/DeprecationAnalyzer.php b/src/DeprecationAnalyzer.php
index 56affa470c5b0922be0cd9d3522b04c2a63abb63..41026bdd28815493d862b9f98a9a6aa710a49ef6 100644
--- a/src/DeprecationAnalyzer.php
+++ b/src/DeprecationAnalyzer.php
@@ -548,6 +548,11 @@ final class DeprecationAnalyzer {
         "\tdrupal:\n\t\tdrupal_root: '" . DRUPAL_ROOT . "'",
       $config
     );
+    $config = str_replace(
+      "\tdrupal:",
+      "\tdrupal:\n\t\tdrupal_root: '" . DRUPAL_ROOT . "'",
+      $config
+    );
bbrala’s picture

Status: Needs work » Needs review

Fixed the issue, seems like he is happy? :)

gorkagr’s picture

Status: Needs review » Reviewed & tested by the community

All good now, update_status can analise the module and skip the @internal errors :)

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Thanks all, merged.

Status: Fixed » Closed (fixed)

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