This is a follow-up to #3195223: Multiple string offset errors. 3.3 does fix all the warning messages. Thanks for the quick turnaround. Now any package I scan yields:

PHPStan failed 0 PHP API deprecations cannot be checked. Reason: Array ( )

Screenshot attached. I think this was expected, but doesn't seem like the error message offers much insight. I'll try to dig deeper when I can.

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

justcaldwell created an issue. See original summary.

gábor hojtsy’s picture

Status: Active » Postponed (maintainer needs more info)

Thanks for your input!

It is unfortunate that we are not getting a reason. The $output is expected to be the return value of phpstan. This is our related code snippet:

    $output = [];
    exec($this->binPath . '/phpstan analyse --error-format=json -c ' . $this->phpstanNeonPath . ' ' . $project_dir, $output);
    $json = json_decode(implode('', $output), TRUE);
    if (!isset($json['files']) || !is_array($json['files'])) {
       $this->logger->error('PHPStan failed: %results', ['%results' => print_r($output, TRUE)]);
       $json = [
         'files' => [
           // Add a failure message with the nonexistent 'PHPStan failed'
           // filename, so the error conforms to the expected format.
           'PHPStan failed' => [
             'messages' => [
               'message' => 'PHP API deprecations cannot be checked. Reason: ' . print_r($output, TRUE),
               'line' => 0,
             ],
           ]
         ],
         'totals' => [
           'errors' => 1,
           'file_errors' => 1,
         ],
       ];
    }

So either phpstan output is entirely empty (which is not expected in case of success) or the exec() cannot execute for some reason. Do you have any reports in your watchdog / dblog / whatever log you are using? The same error should be logged there as per the snippet above, but if there was an exec error, that should appear too I think.

justcaldwell’s picture

Sorry, no clues in dblog, just the same error: PHPStan failed: Array ( ).

Maybe something is wonky in my environment — I'll be curious to see if anyone else reports the same.

oasweb’s picture

I can tell that I do have the same. Seems to appear on any module, ranging from well maintained modules, via not so well maintained modules, to my small and simple module which isn't published.

ptmkenny’s picture

Also having the same error since the upgrade to 3.3. Unable to find further clues in my logs.

gábor hojtsy’s picture

@ptmkenny: did previous versions work? If so, feel free to downgrade (uninstall and install a previous version). Which version worked? That would help us debug the difference.

bagatto46 made their first commit to this issue’s fork.

berramou’s picture

@Gábor i have the same issue with 3.3 version after upgrading from 3.0.
I tested with older versions on (Drupal 8.9.13) here is the tests results:

  1. Version 3.3: error PHPStan failed - PHP API deprecations cannot be checked. Reason: Array ( )
  2. Version 3.2: Doesn't work the batch failed with error
    ResponseText: TypeError: Argument 1 passed to Drupal\upgrade_status\DeprecationAnalyzer::categorizeMessage() must be of the type string, null given, called in modules/contrib/upgrade_status/src/DeprecationAnalyzer.php on line 421 in Drupal\upgrade_status\DeprecationAnalyzer->categorizeMessage() (line 552 of modules/contrib/upgrade_status/src/DeprecationAnalyzer.php).
    
  3. Version 3.1: Works perfectly
ptmkenny’s picture

Like @berramou, I am on Drupal 8.9.13, and 3.3 gives the error; 3.1 (which I was using previously) works fine. I did not test 3.2.

gábor hojtsy’s picture

@ptmkenny, @berramou: First of all, terribly sorry for such a fundamental a regression with 3.3. To see if this was a regression in our code and not a third party dependency, can you try downgrading to 3.1 but with up to date dependencies? That is, uninstall the current version and install 3.1 fresh. Thanks! There's only been 7 commits since 3.1, so we'll be able to figure this out :) I unfortunately cannot reproduce the problem locally though, so need your help.

berramou’s picture

Hello @Gábor i just test it with fresh install:

  1. Fresh Drupal installation: version 8.9.13
  2. Upgrade Status: version 3.3
  3. Contrib modules to test with: Facebook Comments Social Plugin
  4. Custom module to test: Contain just .info.yml file:
    name: 'D8 api'
    type: module
    description: 'D8 api examples'
    core: 8.x
    package: 'Custom'

Results:
custom module test
facebook comment test

gábor hojtsy’s picture

@berramou does a fresh install of 3.1 result in the same thing? I am trying to tell apart if the problem is caused by updates in upgrade_status or the dependencies that a fresh install/update inevitably pulls in.

berramou’s picture

Yes fresh install with 3.1 version works fine.
It doesn’t show the error but still LOCAL SCAN RESULT wrong even if we have no problem still show there is 1 problem:
Upgrade status report
in the screen below show there is two problems in facebook comments but in reality there is only one:
facebook comments upgrade issues

I don't know if the other warning just hidden!

gábor hojtsy’s picture

@berramou: well, I would not call that fine :D There is still that PHPStan error, but before #3195223: Multiple string offset errors and #3193835: Warning: Illegal string offset 'messages' in Drupal\upgrade_status\ScanResultFormatter->formatResult() the phpstan error was not formatter properly for display. It would still be counted but would not display properly. So 3.3 is a step forward then, since we are displaying the problem now. Your setup did not have a properly running PHPStan in 3.1 either but now it shows.

berramou’s picture

Ah i see but i installed the module using composer and i checked the PHPStan is well installed with last version 0.12.70

$ composer show phpstan/phpstan
name     : phpstan/phpstan
descrip. : PHPStan - PHP Static Analysis Tool
keywords :
versions : * 0.12.70
type     : library
license  : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText
homepage :
source   : [git] https://github.com/phpstan/phpstan.git 07f0ef37f5f876e8cee44cc8ea0ec3fe80d499ee
dist     : [zip] https://api.github.com/repos/phpstan/phpstan/zipball/07f0ef37f5f876e8cee44cc8ea0ec3fe80d499ee 07f0ef37f5f876e8cee44cc8ea0ec3fe80d499ee
path     : /Users/azz-eddineberramou/Devs/drupal-8.9/vendor/phpstan/phpstan
names    : phpstan/phpstan

autoload
files

requires
php ^7.1|^8.0

conflicts
phpstan/phpstan-shim *

and also i test the phpStan

$ vendor/bin/phpstan analyse modules/contrib

 23/23 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 ------ --------------------------------------------------------------------
  Line   facebook_comments/src/Plugin/Block/FacebookCommentsBlock.php
 ------ --------------------------------------------------------------------
  34     Function _facebook_comments_get_language_code not found.
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
 ------ --------------------------------------------------------------------

 ------ ---------------------------------------------------------------------------------
  Line   facebook_comments/src/Plugin/Field/FieldFormatter/FacebookCommentsFormatter.php
 ------ ---------------------------------------------------------------------------------
  81     Function _facebook_comments_get_language_code not found.
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
 ------ ---------------------------------------------------------------------------------
gábor hojtsy’s picture

@berramou: great, those errors should be showing up in the upgrade_status report too if phpstan execution was successful. We do generate a custom phpstan config file that contains helper for Drupal code processing, to find more of the problems though, so its not simply about running phpstan as-is you did. It could be that the config goes wrong or exec() itself is wrong, or PHP's process does not have permission to execute phpstan. This is how we create the custom config:

  /**
   * Creates the final config file in the temporary directory.
   *
   * @throws \Exception
   *   If the PHPStan configuration file cannot be written.
   */
  protected function createModifiedNeonFile() {
    $module_path = DRUPAL_ROOT . '/' . drupal_get_path('module', 'upgrade_status');
    $config = file_get_contents($module_path . '/deprecation_testing.neon');
    $config = str_replace(
      'parameters:',
      "parameters:\n\ttmpDir: '" . $this->temporaryDirectory . '/phpstan' . "'\n" .
        "\tdrupal:\n\t\tdrupal_root: '" . DRUPAL_ROOT . "'",
      $config
    );

    if (!class_exists('PHPStan\ExtensionInstaller\GeneratedConfig')) {
      $extension_neon = $this->vendorPath . '/mglaman/phpstan-drupal/extension.neon';
      $rules_neon = $this->vendorPath . '/phpstan/phpstan-deprecation-rules/rules.neon';
      if (!file_exists($extension_neon) || !file_exists($rules_neon)) {
        throw new \Exception('Vendor source files were not found. You may need to configure a vendor-dir in composer.json. See https://getcomposer.org/doc/06-config.md#vendor-dir. Missing ' . $extension_neon . ' and ' . $rules_neon . '.');
      }
      $config .= "\nincludes:\n\t- '" . $extension_neon . "'\n\t- '" . $rules_neon . "'\n";
    }

    $success = file_put_contents($this->phpstanNeonPath, $config);
    if (!$success) {
      throw new \Exception('Unable to write configuration for PHPStan to ' . $this->phpstanNeonPath . '.');
    }
  }

Can you help debug further if the config gets created in your temporary location, and what happens if you run phpstan with that config? This is how we run it where project path is the project to run against:

    exec($this->binPath . '/phpstan analyse --error-format=json -c ' . $this->phpstanNeonPath . ' ' . $project_dir, $output);
gábor hojtsy’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new1.75 KB

Here is a patch to help debug and possibly to commit later on :) Catches the error output in a separate file and displays that as well as the command that we ran, so you can manually reproduce it outside of upgrade_status if there is an error inside it.

berramou’s picture

After applying patch here is the error i get with 3.3 version

PHP API deprecations cannot be checked. Reason: Command was: ---------- /Users/USER/Devs/drupal-8.9/vendor/bin/phpstan analyse --error-format=json -c /tmp/upgrade_status/deprecation_testing.neon /Users/USER/Devs/drupal-8.9/modules/custom/d8_api 2> /tmp/upgrade_status/phpstan_error_output Command output: ---------- Command error: ---------- Failed loading /Applications/DevDesktop/php7_3_x64/ext/opcache.so: dlopen(/Applications/DevDesktop/php7_3_x64/ext/opcache.so, 0x0009): code signature in (/Applications/DevDesktop/php7_3_x64/ext/opcache.so) not valid for use in process: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed. Failed loading /Applications/DevDesktop/php7_3_x64/ext/xdebug.so: dlopen(/Applications/DevDesktop/php7_3_x64/ext/xdebug.so, 0x0009): code signature in (/Applications/DevDesktop/php7_3_x64/ext/xdebug.so) not valid for use in process: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed. PHP Warning: Class 'PHPUnit\Framework\AssertionFailedError' not found in /Users/USER/Devs/drupal-8.9/core/tests/bootstrap.php on line 192 Warning: Class 'PHPUnit\Framework\AssertionFailedError' not found in /Users/USER/Devs/drupal-8.9/core/tests/bootstrap.php on line 192 PHP Warning: Class 'PHPUnit\Framework\Constraint\Count' not found in /Users/USER/Devs/drupal-8.9/core/tests/bootstrap.php on line 193 Warning: Class 'PHPUnit\Framework\Constraint\Count' not found in /Users/USER/Devs/drupal-8.9/core/tests/bootstrap.php on line 193 PHP Warning: Class 'PHPUnit\Framework\Error\Error' not found in /Users/USER/Devs/drupal-8.9/core/tests/bootstrap.php on line 194 Warning: Class 'PHPUnit\Framework\Error\Error' not found in /Users/USER/Devs/drupal-8.9/core/tests/bootstrap.php on line 194 PHP Warning: Class 'PHPUnit\Framework\Error\Warning' not found in /Users/USER/Devs/drupal-8.9/core/tests/bootstrap.php on line 195 Warning: Class 'PHPUnit\Framework\Error\Warning' not found in /Users/USER/Devs/drupal-8.9/core/tests/bootstrap.php on line 195 PHP Warning: Class 'PHPUnit\Framework\ExpectationFailedException' not found in /Users/USER/Devs/drupal-8.9/core/tests/bootstrap.php on line 196 Warning: Class 'PHPUnit\Framework\ExpectationFailedException' not found in /Users/USER/Devs/drupal-8.9/core/tests/bootstrap.php on line 196 PHP Warning: Class 'PHPUnit\Framework\Exception' not found in /Users/USER/Devs/drupal-8.9/core/tests/bootstrap.php on line 197 Warning: Class 'PHPUnit\Framework\Exception' not found in /Users/USER/Devs/drupal-8.9/core/tests/bootstrap.php on line 197 PHP Warning: Class 'PHPUnit\Framework\MockObject\Matcher\InvokedRecorder' not found in /Users/USER/Devs/drupal-8.9/core/tests/bootstrap.php on line 198 Warning: Class 'PHPUnit\Framework\MockObject\Matcher\InvokedRecorder' not found in /Users/USER/Devs/drupal-8.9/core/tests/bootstrap.php on line 198 PHP Warning: Class 'PHPUnit\Framework\SkippedTestError' not found in /Users/USER/Devs/drupal-8.9/core/tests/bootstrap.php on line 199 Warning: Class 'PHPUnit\Framework\SkippedTestError' not found in /Users/USER/Devs/drupal-8.9/core/tests/bootstrap.php on line 199 PHP Warning: Class 'PHPUnit\Framework\TestCase' not found in /Users/USER/Devs/drupal-8.9/core/tests/bootstrap.php on line 200 Warning: Class 'PHPUnit\Framework\TestCase' not found in /Users/USER/Devs/drupal-8.9/core/tests/bootstrap.php on line 200 PHP Warning: Class 'PHPUnit\Util\Test' not found in /Users/USER/Devs/drupal-8.9/core/tests/bootstrap.php on line 201 Warning: Class 'PHPUnit\Util\Test' not found in /Users/USER/Devs/drupal-8.9/core/tests/bootstrap.php on line 201 PHP Warning: Class 'PHPUnit\Util\Xml' not found in /Users/USER/Devs/drupal-8.9/core/tests/bootstrap.php on line 202 Warning: Class 'PHPUnit\Util\Xml' not found in /Users/USER/Devs/drupal-8.9/core/tests/bootstrap.php on line 202 Error thrown in /Users/USER/Devs/drupal-8.9/core/tests/Drupal/TestTools/PhpUnitCompatibility/RunnerVersion.php on line 27 while loading bootstrap file /Users/USER/Devs/drupal-8.9/vendor/mglaman/phpstan-drupal/drupal-autoloader.php: Class 'PHPUnit\Runner\Version' not found

I use Acquia DevDesktop version 2

gábor hojtsy’s picture

@berramou: Looks like it is an error with xdebug and opcache extensions. https://community.komodoide.com/t/xdebug-code-signature-in-not-valid/4422 is a similar problem with xdebug.

berramou’s picture

Yes i did googled the error and i found that the issue with Xdebug and Opcache extensions on Mac environments.
So after all it's not Upgrade Status Module issue.
Thank you @Gábor for your time and your contributions.
I will keep looking if i find any workaround i will post it here.

gábor hojtsy’s picture

Re Dev Desktop, unfortunately I received this link: https://docs.acquia.com/dev-desktop/migrate-to-ide/ Notably this on the top of the page:

EOL notice! Acquia will no longer provide updates or support for Dev Desktop after June 30, 2021. Acquia recommends transitioning to the use of Acquia Cloud IDE for a managed development environment on Acquia Cloud Platform.

So you may find a local solution to it for now, but the problem will not be fixed in Acquia Dev Desktop unfortunately.

gábor hojtsy’s picture

@ptmkenny are you having the same experience with the patch above? Are you also using Dev Desktop or some other environment?

oasweb’s picture

I tried your patch in my dev-environment which is on Win10 with Xampp. (Guess there might be som comments on that, however, for my small project it works well enough.) As far as I know it is quite standard setup, given the platform.
In any case here is the output I got when scanning "Display Suite" which is otherwise D9-ready and reported as such.

PHP API deprecations cannot be checked. Reason: Command was: ---------- C:\xampp\htdocs/vendor/bin/phpstan analyse --error-format=json -c C:\xampp\tmp/upgrade_status/deprecation_testing.neon C:\xampp\htdocs\public_html/modules/contrib/ds 2> C:\xampp\tmp/upgrade_status/phpstan_error_output Command output: ---------- Command error: ---------- PHP Warning: Class 'PHPUnit\Framework\AssertionFailedError' not found in C:\xampp\htdocs\public_html\core\tests\bootstrap.php on line 192 Warning: Class 'PHPUnit\Framework\AssertionFailedError' not found in C:\xampp\htdocs\public_html\core\tests\bootstrap.php on line 192 PHP Warning: Class 'PHPUnit\Framework\Constraint\Count' not found in C:\xampp\htdocs\public_html\core\tests\bootstrap.php on line 193 Warning: Class 'PHPUnit\Framework\Constraint\Count' not found in C:\xampp\htdocs\public_html\core\tests\bootstrap.php on line 193 PHP Warning: Class 'PHPUnit\Framework\Error\Error' not found in C:\xampp\htdocs\public_html\core\tests\bootstrap.php on line 194 Warning: Class 'PHPUnit\Framework\Error\Error' not found in C:\xampp\htdocs\public_html\core\tests\bootstrap.php on line 194 PHP Warning: Class 'PHPUnit\Framework\Error\Warning' not found in C:\xampp\htdocs\public_html\core\tests\bootstrap.php on line 195 Warning: Class 'PHPUnit\Framework\Error\Warning' not found in C:\xampp\htdocs\public_html\core\tests\bootstrap.php on line 195 PHP Warning: Class 'PHPUnit\Framework\ExpectationFailedException' not found in C:\xampp\htdocs\public_html\core\tests\bootstrap.php on line 196 Warning: Class 'PHPUnit\Framework\ExpectationFailedException' not found in C:\xampp\htdocs\public_html\core\tests\bootstrap.php on line 196 PHP Warning: Class 'PHPUnit\Framework\Exception' not found in C:\xampp\htdocs\public_html\core\tests\bootstrap.php on line 197 Warning: Class 'PHPUnit\Framework\Exception' not found in C:\xampp\htdocs\public_html\core\tests\bootstrap.php on line 197 PHP Warning: Class 'PHPUnit\Framework\MockObject\Matcher\InvokedRecorder' not found in C:\xampp\htdocs\public_html\core\tests\bootstrap.php on line 198 Warning: Class 'PHPUnit\Framework\MockObject\Matcher\InvokedRecorder' not found in C:\xampp\htdocs\public_html\core\tests\bootstrap.php on line 198 PHP Warning: Class 'PHPUnit\Framework\SkippedTestError' not found in C:\xampp\htdocs\public_html\core\tests\bootstrap.php on line 199 Warning: Class 'PHPUnit\Framework\SkippedTestError' not found in C:\xampp\htdocs\public_html\core\tests\bootstrap.php on line 199 PHP Warning: Class 'PHPUnit\Framework\TestCase' not found in C:\xampp\htdocs\public_html\core\tests\bootstrap.php on line 200 Warning: Class 'PHPUnit\Framework\TestCase' not found in C:\xampp\htdocs\public_html\core\tests\bootstrap.php on line 200 PHP Warning: Class 'PHPUnit\Util\Test' not found in C:\xampp\htdocs\public_html\core\tests\bootstrap.php on line 201 Warning: Class 'PHPUnit\Util\Test' not found in C:\xampp\htdocs\public_html\core\tests\bootstrap.php on line 201 PHP Warning: Class 'PHPUnit\Util\Xml' not found in C:\xampp\htdocs\public_html\core\tests\bootstrap.php on line 202 Warning: Class 'PHPUnit\Util\Xml' not found in C:\xampp\htdocs\public_html\core\tests\bootstrap.php on line 202 Error thrown in C:\xampp\htdocs\public_html\core\tests\Drupal\TestTools\PhpUnitCompatibility\RunnerVersion.php on line 27 while loading bootstrap file C:\xampp\htdocs\vendor\mglaman\phpstan-drupal\drupal-autoloader.php: Class 'PHPUnit\Runner\Version' not found

If I run it on my private and tiny module to remove N/A from a radio-button, I get a very similar output. Could post that as well if you think it provides some info. (It's more natural to run a scan on that one for people as it is listed in the section where the user are asked to perform a scan...

gábor hojtsy’s picture

StatusFileSize
new117.41 KB

@oasweb: XAMMP on Windows 10 should be fine, no problem with that IMHO. https://www.drupal.org/blog/drupal-8-will-no-longer-include-dev-dependen... details how to install dev dependencies, so those phpunit classes will be present. In short, you'll need to run composer install --dev. This is explained on the project page for Upgrade Status too:

If you already did that, we need to figure out why is that not found.

oasweb’s picture

Thank you for your response. I was quite sure that I had used the - - dev option when I installed it. But it has been some back and forth lately, so I will verify that I picked the right composer set, and have a look in the evening.

gábor hojtsy’s picture

Title: PHPStan failed - PHP API deprecations cannot be checked. Reason: Array ( ) » Expose error output from phpstan command for debugging, standard output may be empty
Category: Bug report » Task
StatusFileSize
new1.77 KB

Slightly improved the formatting of the error, so that at least on the Upgrade Status UI it looks more readable. The logged string has the tags escaped and newlines are not effective either, so I avoided them going into the log. That is less readable, but still present. Retitled for what is happening in this issue now.

gábor hojtsy’s picture

Note that I also opened #3196065: Detect if Drupal developer dependencies were not installed properly for the possibly common scenario of missing developer dependencies. Posted an idea patch there but that does not yet work. Help welcome :D

gábor hojtsy’s picture

StatusFileSize
new1.8 KB

Also deal with the case of the error output being empty for the sake of consistency and clean reporting. Abstracted error filename so it is easier to follow.

oasweb’s picture

Well, now I went one step further back in my composer set and ensured to follow the steps

$ composer install --dev
$ composer require 'drupal/upgrade_status:^3.3'

And then applied the patch.

This is what I regard as the important part reported by composer during install:

Package operations: 9 installs, 0 updates, 0 removals
  - Installing laminas/laminas-servicemanager (3.6.3): Loading from cache
  - Installing laminas/laminas-text (2.8.0): Loading from cache
  - Installing mathieuviossat/arraytotexttable (v1.0.8): Loading from cache
  - Installing phpstan/phpstan (0.12.71): Downloading (100%)
  - Installing phpstan/phpstan-deprecation-rules (0.12.6): Loading from cache
  - Installing nette/utils (v3.2.1): Loading from cache
  - Installing nette/finder (v2.5.2): Loading from cache
  - Installing mglaman/phpstan-drupal (0.12.7): Loading from cache
  - Installing drupal/upgrade_status (3.3.0): Loading from cache
laminas/laminas-servicemanager suggests installing ocramius/proxy-manager (ProxyManager ^2.1.1 to handle lazy initialization of services)
nette/utils suggests installing ext-intl (to use Strings::webalize(), toAscii(), normalize() and compare())
Package container-interop/container-interop is abandoned, you should avoid using it. Use psr/container instead.

However, the results are the same as far as I can see, unless nicer formatted...
Anyhow, I think it is a good idea to pinpoint the --dev-part, as well as to remind if not enabled.
I looked into my require-dev-section of the composer.json, the only part in there is drush. Is that relevant?

gábor hojtsy’s picture

@oasweb: hm, core require-dev has a lot of stuff https://git.drupalcode.org/project/drupal/-/blob/9.2.x/composer.json -- is that not in the default Drupal project composer setup or do you have a custom setup?

eduardo morales alberti’s picture

I think it is is an error related with phpstan
I tried (composer 2)
composer require phpstan/phpstan:0.12.26 mglaman/drupal-check:1.1.3 -W --dev
And now works right.
Also here is an issue on drupal-check project https://github.com/mglaman/drupal-check/issues/202

gábor hojtsy’s picture

@Eduardo: well, "PHPUnit\Framework\TestCase not found " is not exactly the same problem as "PHPUnit\Framework\TestCase is not an interface". Looks like there are multiple problems.

  • Gábor Hojtsy committed 29f33c4 on 8.x-3.x
    Issue #3195476 by Gábor Hojtsy, berramou, justcaldwell, oasweb, ptmkenny...
gábor hojtsy’s picture

Category: Task » Support request
Status: Needs review » Active

I committed the patch and will release a new version, so people can get clear error reports. Not going to close this, since not all actual resulting errors were resolved yet, but they appear to be outside of the scope of the code of upgrade status for now, so moving to support request. Thanks all for testing the patch to help future users debug.

gábor hojtsy’s picture

alexdoma’s picture

just test last version on windows

PHPStan command failed:
/vendor/bin/phpstan analyse --error-format=json -c /tmp/upgrade_status/deprecation_testing.neon
/modules/custom/block_ajax 2> /tmp/upgrade_status/phpstan_error_output

Command output:
Empty.

Command error:
Warning: Class 'PHPUnit\Framework\AssertionFailedError' not found in \core\tests\bootstrap.php on line 192 Warning: Class 'PHPUnit\Framework\Constraint\Count' not found in \core\tests\bootstrap.php on line 193 Warning: Class 'PHPUnit\Framework\Error\Error' not found in \core\tests\bootstrap.php on line 194 Warning: Class 'PHPUnit\Framework\Error\Warning' not found in \core\tests\bootstrap.php on line 195 Warning: Class 'PHPUnit\Framework\ExpectationFailedException' not found in \core\tests\bootstrap.php on line 196 Warning: Class 'PHPUnit\Framework\Exception' not found in \core\tests\bootstrap.php on line 197 Warning: Class 'PHPUnit\Framework\MockObject\Matcher\InvokedRecorder' not found in \core\tests\bootstrap.php on line 198 Warning: Class 'PHPUnit\Framework\SkippedTestError' not found in \core\tests\bootstrap.php on line 199 Warning: Class 'PHPUnit\Framework\TestCase' not found in \core\tests\bootstrap.php on line 200 Warning: Class 'PHPUnit\Util\Test' not found in \core\tests\bootstrap.php on line 201 Warning: Class 'PHPUnit\Util\Xml' not found in \core\tests\bootstrap.php on line 202 Error thrown in \core\tests\Drupal\TestTools\PhpUnitCompatibility\RunnerVersion.php on line 27 while loading bootstrap file \vendor\mglaman\phpstan-drupal\drupal-autoloader.php: Class 'PHPUnit\Runner\Version' not found

gábor hojtsy’s picture

@alexdoma: do you have phpunit installed? See #24 above.

alexdoma’s picture

@gábor-hojtsy
I have run composer install --dev

You are using the deprecated option "dev". Dev packages are installed by default                             now.
Gathering patches for root package.
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update

Should i install phpunit in different way? or it depends on composer version?

oasweb’s picture

Thank you @Gábor! Your #30 helped me out. I thought I was on a standard setup, however my "require-dev" was for sure not. After what I now think is more standard, this PHPStan failed 0 PHP API deprecations cannot be checked. Reason: Array ( ), has disappeared completely. I do have some of those "PHPUnit\Framework\TestCase not found", but agree that those are a different case.

Could it be that this whole issue appeared due to that some of us doesn't have all their dependencies fully in place? (And for some reason isn't aware of it) And then the error is thrown? If so, then I would guess the best mitigation is either to throw an error, with a suggested list of things to verify "Have you verified your require-dev-dependencies? As a minimum xxx should be present". Or even better, if possible, to require whats needed during install. Being quite a newbie with composer and Drupal I am not fully aware of whats possible/feasible or best practise. Anyhow some people will be helped out by this thread I would guess.

The best thing, the upgrade_status-module has now helped me to be ready to move over to Drupal 9, thank you! :)

azinck’s picture

@Alexdoma: perhaps you're in my situation. I installed drupal using just drupal/core-recommended and didn't bring in drupal/core-dev. You'll need to do something like:
composer require --dev drupal/core-dev:[constraint for your version of drupal]

More info here: https://www.drupal.org/docs/develop/using-composer/starting-a-site-using...

chamilsanjeewa’s picture

@Gábor Hojtsy #30

This is not working( not a correct way to handle the situation). In My case, I am in drupal 8.9 and I need to catch the deprecated functions and issues in my module before I move to Drupal 9.x.
So its is not possible to run upgrade the site into D9 and run the upgrade status.

This is my configurations -

Drupal version : 8.9.13
"phpstan/phpstan": "^0.12.8",
"drupal/upgrade_status": "^3.4"

Really appreciate your comments about this.

gábor hojtsy’s picture

@chamilsanjeewa: sounds like you have a standalone question? That site should be able to run Upgrade Status. Please post in a new support request.

rjensen26’s picture

I ran into the same issue... this is what I did to resolve my problem.

1. composer require phpunit/phpunit:^6.5 --no-update
2. composer require drupal/core-dev:^8.9 --no-update
3. composer update

Hope this helps

gábor hojtsy’s picture

@rjensen26: we don't suggest adding phpunit directly to your project as a non-dev dependency that would end up in the deployed project likely. That said, if you don't (accidentally) commit this to your live project, it could be fine locally.

rjensen26’s picture

@Gábor Hojtsy, I wouldn't commit that to the project, thanks though

gábor hojtsy’s picture

Category: Support request » Task
Status: Active » Fixed

There is the first issue with underlying problems reported at #3200187: Web UI fails with /usr/bin/env: php: No such file or directory. I think at this point it would be better if people with underlying issues exposed thanks to the above open separate issues so we can discuss them there rather than intertwined here. There were different underlying problems reported here, which we expose now, but discussing them intermixed is hard.

Status: Fixed » Closed (fixed)

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

darkodev’s picture

FWIW, noting @Gábor Hojtsy warning to @ rjensen26 about adding phpunit independent of dev dependencies, the following cleared up my PHPstan issues:

composer require drupal/core-dev:^8.9 --no-update
composer update

kgeeraerts’s picture

I can confirm that #48 also fixed the problem for me!