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

Error from Nette\DI\Config\Adapters\PhpAdapter::load() #81

Closed
1 of 4 tasks
mike-potter opened this issue Jun 7, 2019 · 6 comments
Closed
1 of 4 tasks

Error from Nette\DI\Config\Adapters\PhpAdapter::load() #81

mike-potter opened this issue Jun 7, 2019 · 6 comments

Comments

@mike-potter
Copy link

mike-potter commented Jun 7, 2019

How is drupal-check installed?

  • drupal-check is installed using the phar
  • drupal-check is installed globally via Composer
  • drupal-check is installed globally using consolidation/cgr
  • drupal-check is installed as a dependency to my project

Environment:

  • OS: Linux
  • PHP Version: 7.1.26
  • Drupal core: 8.7.2

Describe the bug
After installing via composer require mglaman/drupal-check and then running from my Drupal root via ../../vendor/bin/drupal-check modules/custom I get the following error:

Fatal error: Uncaught TypeError: Return value of Nette\DI\Config\Adapters\PhpAdapter::load() must be of the type array, integer returned in /var/www/vendor/nette/di/src/DI/Config/Adapters/PhpAdapter.php:27
Stack trace:
#0 /var/www/vendor/nette/di/src/DI/Config/Loader.php(52): Nette\DI\Config\Adapters\PhpAdapter->load('/var/www/vendor...')
#1 /var/www/vendor/nette/di/src/DI/Config/Loader.php(60): Nette\DI\Config\Loader->load('/var/www/vendor...', NULL)
#2 /var/www/vendor/nette/di/src/DI/Config/Loader.php(60): Nette\DI\Config\Loader->load('/var/www/vendor...', NULL)
#3 /var/www/vendor/phpstan/phpstan/src/Command/CommandHelper.php(109): Nette\DI\Config\Loader->load('/var/www/vendor...', NULL)
#4 /var/www/vendor/mglaman/drupal-check/src/Command/CheckCommand.php(129): PHPStan\Command\CommandHelper::begin(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput), Array, NULL, NULL, NULL, '/var/www/vendor...', NULL)
#5 /var/www/vendor/symfony/console/Command/Command.php(255): Drupa in /var/www/vendor/nette/di/src/DI/Config/Adapters/PhpAdapter.php on line 27

Here is the output from composer to see what dependency versions were installed:

  - Installing ocramius/package-versions (1.4.0): Loading from cache
  - Installing phpstan/phpdoc-parser (0.3.4): Loading from cache
  - Installing nette/utils (v3.0.1): Loading from cache
  - Installing nette/schema (v1.0.0): Loading from cache
  - Installing composer/xdebug-handler (1.3.3): Loading from cache
  - Installing jean85/pretty-package-versions (1.2): Loading from cache
  - Installing nette/php-generator (v3.2.2): Loading from cache
  - Installing nette/neon (v3.0.0): Loading from cache
  - Installing nette/finder (v2.5.0): Loading from cache
  - Installing nette/robot-loader (v3.2.0): Loading from cache
  - Installing nette/di (v3.0.0): Loading from cache
  - Installing nette/bootstrap (v3.0.0): Loading from cache
  - Installing phpstan/phpstan (0.11.8): Loading from cache
  - Installing mglaman/phpstan-junit (0.11.2): Loading from cache
  - Installing phpstan/phpstan-deprecation-rules (0.11.2): Loading from cache
  - Installing mglaman/phpstan-drupal (0.11.8): Loading from cache
  - Installing mglaman/phpstan-drupal-deprecations (0.11.1): Loading from cache
  - Installing mglaman/drupal-check (1.0.9): Loading from cache

Any ideas?

Console output

$ ../../vendor/bin/drupal-check -vvv modules/custom
Current working directory: /var/www/build/docroot
Using Drupal root: /var/www/build/docroot
Using vendor root: /var/www/vendor
Using autoloader: /var/www/vendor/autoload.php

Fatal error: Uncaught TypeError: Return value of Nette\DI\Config\Adapters\PhpAdapter::load() must be of the type array, integer returned in /var/www/vendor/nette/di/src/DI/Config/Adapters/PhpAdapter.php:27
Stack trace:
#0 /var/www/vendor/nette/di/src/DI/Config/Loader.php(52): Nette\DI\Config\Adapters\PhpAdapter->load('/var/www/vendor...')
#1 /var/www/vendor/nette/di/src/DI/Config/Loader.php(60): Nette\DI\Config\Loader->load('/var/www/vendor...', NULL)
#2 /var/www/vendor/nette/di/src/DI/Config/Loader.php(60): Nette\DI\Config\Loader->load('/var/www/vendor...', NULL)
#3 /var/www/vendor/phpstan/phpstan/src/Command/CommandHelper.php(109): Nette\DI\Config\Loader->load('/var/www/vendor...', NULL)
#4 /var/www/vendor/mglaman/drupal-check/src/Command/CheckCommand.php(129): PHPStan\Command\CommandHelper::begin(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput), Array, NULL, NULL, NULL, '/var/www/vendor...', NULL)
#5 /var/www/vendor/symfony/console/Command/Command.php(255): Drupa in /var/www/vendor/nette/di/src/DI/Config/Adapters/PhpAdapter.php on line 27
@mike-potter
Copy link
Author

Looks like the problem is when loading the /var/www/vendor/mglaman/drupal-check/src/Command/../../phpstan/phpstan_drupal_extension.php file. Looking at the contents of this file:

<?php

if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
    return [
        'includes' => [
            '../vendor/mglaman/phpstan-drupal/extension.neon',
        ],
    ];
} elseif (file_exists(__DIR__ . '/../../../vendor/autoload.php')) {
    return [
        'includes' => [
            '../../../vendor/mglaman/phpstan-drupal/extension.neon',
        ],
    ];
}

It seems you are making assumptions for where the vendor directory is. You are handling .. and ../../.. but not the ../.. needed in our case. Seems like there needs to be a better way to detect this.

@mike-potter
Copy link
Author

Or not...adding the ../.. case didn't seem to fix the error, but seems like it's somehow related to the paths in that file.

@logickal
Copy link

logickal commented Jun 7, 2019

Same issue just discovered here - based on drupal-composer/drupal-project and running in containers based on amazee lagoon Drupal-cli. Same issue when installing with composer either globally or against the project. Downloading the phar and running it directly does work, however.

cli-drupal:/app/web$ ../vendor/bin/drupal-check -vvv modules/custom/
Current working directory: /app/web
Using Drupal root: /app/web
Using vendor root: /app/vendor
Using autoloader: /app/vendor/autoload.php
PHP Fatal error:  Uncaught TypeError: Return value of Nette\DI\Config\Adapters\PhpAdapter::load() must be of the type array, integer returned in /app/vendor/nette/di/src/DI/Config/Adapters/PhpAdapter.php:27
Stack trace:
#0 /app/vendor/nette/di/src/DI/Config/Loader.php(52): Nette\DI\Config\Adapters\PhpAdapter->load('/app/vendor/mgl...')
#1 /app/vendor/nette/di/src/DI/Config/Loader.php(60): Nette\DI\Config\Loader->load('/app/vendor/mgl...', NULL)
#2 /app/vendor/nette/di/src/DI/Config/Loader.php(60): Nette\DI\Config\Loader->load('/app/vendor/mgl...', NULL)
#3 /app/vendor/phpstan/phpstan/src/Command/CommandHelper.php(109): Nette\DI\Config\Loader->load('/app/vendor/mgl...', NULL)
#4 /app/vendor/mglaman/drupal-check/src/Command/CheckCommand.php(129): PHPStan\Command\CommandHelper::begin(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput), Array, NULL, NULL, NULL, '/app/vendor/mgl...', NULL)
#5 /app/vendor/symfony/console/Command/Command.php(255): DrupalCheck\Command\CheckCommand- in /app/vendor/nette/di/src/DI/Config/Adapters/PhpAdapter.php on line 27

@iainp999
Copy link

I'm having the same issue as @mike-potter - in my case, when " drupal-check is installed globally via Composer".

@mglaman mglaman added this to Needs triage in Issue triage Jun 12, 2019
@mglaman
Copy link
Owner

mglaman commented Jun 12, 2019

This should be fixed on dev, due to #85

@mglaman
Copy link
Owner

mglaman commented Jun 12, 2019

Fixed by #86. Will release shortly.

@mglaman mglaman closed this as completed Jun 12, 2019
Issue triage automation moved this from Needs triage to Closed Jun 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Issue triage
  
Closed
Development

No branches or pull requests

4 participants