Giter VIP home page Giter VIP logo

drupal-check's Introduction

drupal-check Build CircleCI Latest release

Built on PHPStan, this static analysis tool will check for correctness (e.g. using a class that doesn't exist), deprecation errors, and more.

Why? While there are many static analysis tools out there, none of them run with the Drupal context in mind. This allows checking contrib modules for deprecation errors thrown by core.

Are you ready for Drupal 9? Check out our Drupal 9 Readiness instructions for details on how this tool can help.

Sponsors

undpaul undpaul

Would you like to sponsor?

Requirements

  • PHP >=7.2

Installation

You can install this in your project using Composer as a development dependency like so:

composer require mglaman/drupal-check --dev

You can also install this globally using Composer like so:

composer global require mglaman/drupal-check

Refer to Composer's documentation on how to ensure global binaries are in your PATH: https://getcomposer.org/doc/00-intro.md#manual-installation.

Usage

php vendor/bin/drupal-check [options] [--] <path>...

Arguments:

  • path - The Drupal code path(s) to inspect

Options:

  • --drupal-root[=DRUPAL-ROOT] - Path to Drupal root.
  • --format[=FORMAT] - Formatter to use: raw, table, checkstyle, json, or junit [default: "table"]
  • -d, --deprecations - Check for deprecations
  • -a, --analysis - Check code analysis
  • -s, --style - Check code style
  • --php8 - Set PHPStan phpVersion for 8.1 (Drupal 10 requirement)
  • --memory-limit[=MEMORY-LIMIT] - Memory limit for analysis
  • -e, --exclude-dir[=EXCLUDE-DIR] - Directories to exclude. Separate multiple directories with a comma, no spaces.
  • --no-progress - Do not show progress bar, only results
  • -h, --help - Display this help message
  • -q, --quiet - Do not output any message
  • -V, --version - Display this application version
  • --ansi - Force ANSI output
  • --no-ansi - Disable ANSI output
  • -n, --no-interaction - Do not ask any interactive question
  • -v|vv|vvv, --verbose - Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Examples:

  • Check the address contrib module:
php vendor/bin/drupal-check web/modules/contrib/address
  • Check the address contrib module for deprecations:
php vendor/bin/drupal-check -d web/modules/contrib/address
  • Check the address contrib module for analysis:
php vendor/bin/drupal-check -a web/modules/contrib/address

Rollback update to PHPStan level 2 for deprecation analysis

drupal-check:1.4.0 set PHPStan's analysis level to 2 for deprecations and 6 for analysis. This ensures basic analysis errors are fixed to provide the best deprecated code detection experience. You can read more about PHPStan's rule levels here: https://phpstan.org/user-guide/rule-levels

If you do not want to run PHPStan at level 2 and only report deprecation messages, use the following instructions

composer remove mglaman/drupal-check
composer require  --dev phpstan/phpstan \
  phpstan/extension-installer \
  mglaman/phpstan-drupal \
  phpstan/phpstan-deprecation-rules

Create a phpstan.neon file with the following:

parameters:
	customRulesetUsed: true
	ignoreErrors:
		- '#\Drupal calls should be avoided in classes, use dependency injection instead#'
		- '#Plugin definitions cannot be altered.#'
		- '#Missing cache backend declaration for performance.#'
		- '#Plugin manager has cache backend specified but does not declare cache tags.#'

	# FROM mglaman/drupal-check/phpstan/base_config.neon
	reportUnmatchedIgnoredErrors: false
	excludePaths:
		- */tests/Drupal/Tests/Listeners/Legacy/*
		- */tests/fixtures/*.php
		- */settings*.php
		- */bower_components/*
		- */node_modules/*

You can copy this from the Upgrade Status module directly https://git.drupalcode.org/project/upgrade_status/-/blob/8.x-3.x/deprecation_testing_template.neon

Drupal Check - VS Code Extension

You can run Drupal Check from VSCode using this extension: https://marketplace.visualstudio.com/items?itemName=bbeversdorf.drupal-check

The code can be found at: https://github.com/bbeversdorf/vscode-drupal-check

License

GPL v2

Issues

Submit issues and feature requests here: https://github.com/mglaman/drupal-check/issues.

Known Issues

There are conflicts with dependencies shared with other libraries that might be installed on a Drupal project:

  • This tool does not work with BLT 9: #9
  • If you run into issues with other libraries, please submit an issue to this project.

Contributing

See the CONTRIBUTING.md.

References

drupal-check's People

Contributors

arlina-espinoza avatar byrond avatar colinodell avatar dan612 avatar dependabot[bot] avatar erikfrerejean avatar gueguerreiro avatar imonroe avatar jean85 avatar joeparsons avatar josephdpurcell avatar kasperg avatar mallezie avatar markdorison avatar mglaman avatar mpparsley avatar mxr576 avatar opdavies avatar sergey-orlov avatar tormi avatar tyler36 avatar vijaycs85 avatar violinist-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

drupal-check's Issues

Not compatible with latest version of Drupal 8

When I try to install this package, I get the following error -

mglaman/drupal-check 1.0.0 requires symfony/console ^4.2 -> satisfiable by symfony/console[4.2.x-dev, 4.3.x-dev, v4.2.0, v4.2.0-BETA1, v4.2.0-BETA2, v4.2.0-RC1, v4.2.1, v4.2.2, v4.2.3, v4.2.4]

Drupal core 8.6.13 uses symfony/console ~3.4.0

Autoload issue with drupal-scaffold and phar

How is drupal-check installed?

  • [ x ] 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 (ubuntu)
  • PHP Version: 7.2
  • Drupal core: 8.6.16

Describe the bug
The drupal-check phar doesn't properly autoload classes in a Drupal application installed with drupal-scaffold. this became an issue when attempting to integrate drupal-check into our CI platform (GitLabCI).

In order to work around this, I created a standalone job to run drupal-check. I then ran the following commands:

    - cd docroot
    - composer install --no-interaction --no-progress --no-suggest
    - composer require 'drush/drush:^9.0'
    - cd ../
    - scripts/check-modified-files

(the check modified files script runs /usr/local/bin/drupal-check --format=raw --no-progress -d ${file} for each file changed.

Console output
The output below is from before the workaround listed above. When I run the CI job with the workaround listed above, it works just fine.

Performing deprecation checks
Current working directory: /builds/BIS/ESS/web/argonnecore/argonnecore
Using Drupal root: /builds/BIS/ESS/web/argonnecore/argonnecore/docroot
Using vendor root: /builds/BIS/ESS/web/argonnecore/argonnecore/docroot/vendor
Could not find autoload file.

This might be related to #15.

Check cannot find Drush classes and functions

In custom code, I get errors on:

  • Function drush_backend_batch_process not found. (in a drush command class)
  • Parameter $context of method updateChunk has invalid typehint type DrushBatchContext. This one is in a phpdoc like this:
  /**
   * ...snip...
   * @param \DrushBatchContext|array $context
   *   The batch context.
   */
  public static function updateChunk(
    /* ...snip ... */
    &$context) {

This function is in a service and receives context as an array in the web ui or a DrushBatchContext when used in Drush, hence the variant hint.

This is with a local composer-installed Drush 9.6.2.

One liner to download/install

Here's a one liner:

  curl -sO $(curl -s https://api.github.com/repos/mglaman/drupal-check/releases/latest | grep "browser_download_url.*phar" | cut -d : -f 2,3 | tr -d \") \
  && chmod 755 drupal-check.phar \
  && sudo mv drupal-check.phar /usr/local/bin/drupal-check

Ignore AssertLegacyTrait

From Drupal Slack via berdir:

maybe ignore stuff from AssertLegacyTrait like assertEqual() ? There are thousands of those and there's talk that we'll not actually remove that for d9

Feature Request: Check multiple paths

I would like the ability to check multiple paths at a time.

Currently, drupal-check only accepts a single path. If I want to check multiple paths I need to run this multiple times. For example:

drupal-check web/modules/contrib
drupal-check web/modules/custom
drupal-check web/themes/contrib
drupal-check web/themes/custom

This poses two challenges:

  1. CI runners will generally stop after a command returns a non-zero exit code. So if any deprecations are found in web/modules/contrib then none of my 3 other paths will be checked.
  2. The results for each command will be scattered in 4 places in the output - I'd rather see one single list of errors with a final error count at the very end of the output.

Override temporrary directory

Problem

After running phpstan, it tries to write itโ€™s cache to the temporary directory, which is by default sys_get_temp_dir() . '/phpstan'. This may be an issue on filesystems that only have specific directories that are writable.

Proposed Resolution

Allow overriding the phpstan tmp directory.

Update deprecation solution in Wiki: entity_get[_form]_display

Since https://www.drupal.org/node/2367933 / https://git.drupalcode.org/project/drupal/commit/da94d7fc6b6cd06a26c065ab8db640e9a0bb8671#7f7e72269405002d6602cb72b6155307148e699d_523_487 , the deprecation solution for usage of entity_get_display() and entity_get_form_display() have changed. The solutions should now be:

\Drupal::service('entity_display.repository')
  ->getViewDisplay($entity_type, $bundle, $view_mode);

and

\Drupal::service('entity_display.repository')
  ->getFormDisplay($entity_type, $bundle, $form_mode);

This ensures a valid display is returned even when it doesn't yet exist as saved configuration, just as entity_get_display() and entity_get_form_display() did.

Fatal Error for iframe module.

Running Drupal Check on a local project results in the following fatal error with the iframe module. iframe module version 8.x-1.9

Warning: Uncaught PHPStan\Broker\ClassAutoloadingException: Class Drupal\migrate\Entity\MigrationInterface not found and could not be autoloaded. in phar:///usr/local/bin/drupal-check/vendor/phpstan/phpstan/src/Broker/Broker.php:340
Stack trace:
#0 [internal function]: PHPStan\Broker\Broker->PHPStan\Broker\{closure}('Drupal\\migrate\\...')
#1 /Users/johnpicozzi/Sites/example.com/docroot/modules/contrib/iframe/src/Plugin/migrate/cckfield/IframeField.php(13): spl_autoload_call('Drupal\\migrate\\...')
#2 phar:///usr/local/bin/drupal-check/vendor/composer/ClassLoader.php(444): include('/Users/johnpico...')
#3 phar:///usr/local/bin/drupal-check/vendor/composer/ClassLoader.php(322): Composer\Autoload\includeFile('/Users/johnpico...')
#4 [internal function]: Composer\Autoload\ClassLoader->loadClass('Drupal\\iframe\\P...')
#5 [internal function]: spl_autoload_call('Drupal\\iframe\\P...')
#6 phar:///usr/local/bin/drupal-check/vendor/phpstan/phpstan/src/Broker/Broker.php(345): class_exists('Drupal\\iframe\\P...')
 in phar:///usr/local/bin/drupal-check/vendor/phpstan/phpstan/src/Broker/Broker.php on line 340

Fatal error: Declaration of Drupal\iframe\Plugin\migrate\cckfield\IframeField::processCckFieldValues(Drupal\migrate\Entity\MigrationInterface $migration, $field_name, $data) must be compatible with Drupal\migrate_drupal\Plugin\migrate\cckfield\CckFieldPluginBase::processCckFieldValues(Drupal\migrate\Plugin\MigrationInterface $migration, $field_name, $data) in /Users/johnpicozzi/Sites/example.com/docroot/modules/contrib/iframe/src/Plugin/migrate/cckfield/IframeField.php on line 13

Is it possible to check for use of deprecated classes?

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?

Support PHP Code Sniffer

Add the ability to run the drupal-check with a flag that checks for PHP Code Style using the drupal/coder project.

When running composer require on the project, it dies

When running composer require mglaman/drupal-check --dev on a Drupal project, it will crash. This is due to Drupal's minimum-stability:dev setting. This caused symfony/console to come in as 4.2.x and conflict city fired off.

Composer installs incompatible package versions

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.3.5
  • Drupal core: 8.7.2

Describe the bug

Invoking composer require mglaman/drupal-check installs 0.11.2 from mglaman/phpstan-drupal instead of the latest 0.11.7.

Tag 0.11.3 declare a conflict with nette/di >=3.0 The conflict appears to exist in 0.11.2, but as it's not declared (nette/di hadn't released 3.0.0 at that point), rather than installing the latest version of drupal-check and installing nette/di 2.4.15, it installs phpstan-drupal 0.11.2 and nette/di 3.0.0.

I'm not sure what the preferred resolution would be:

  • Unpublishing phpstan-drupal below 0.11.2?
  • Marking versions <= 0.11.2 as a conflict?
  • Something else?

Option --format=raw missing from --help

Steps

curl -O -L https://github.com/mglaman/drupal-check/releases/download/1.0.7/drupal-check.phar \
chmod +x drupal-check.phar \

Observed result # 1

./drupal-check.phar --help returns :

(...)
Options:
      --format[=FORMAT]  Formatter to use: table, json, or junit [default: "table"]
(...)

Observed result # 2

./drupal-check.phar web/modules/custom/ --format=string returns :
Error formatter "string" not found. Available error formatters are: raw, table, checkstyle, json, prettyJson, junit

./drupal-check.phar --help part related to format is not up to date with accepted options

Todo

Update --help format option description

PHP parse error under PHP 7.0.33

Hi,

I am getting PHP Parse error: syntax error, unexpected 'const' (T_CONST), expecting variable (T_VARIABLE) in phar:///usr/local/bin/drupal-check/vendor/phpstan/phpstan/src/Command/ErrorsConsoleStyle.php on line 12. The error went away after I upgraded PHP, but a version check would be fine.

Fixes for issues discovered during MidCamp 2019

During MidCamp 2019 contribution day, a number of issues were surfaced that seem related to the checker. Those were documented here: https://docs.google.com/spreadsheets/d/1-W0k4vhdmw7ugzRdSa9orEc43_D5l6PPvUcrB8bw_-0/edit#gid=0

This ticket is to track resolution to those issues.

  • Module redirect: PHP Warning: Uncaught PHPStan\Broker\ClassAutoloadingException: Class Symfony\Component\Validator\ExecutionContextInterface not found and could not be autoloaded.
  • Module devel Class Drupal\Tests\devel_generate\DevelGenerateManagerTest was not found while trying to analyse it - autoloading is probably not configured properly.
  • Module backup_migrate Class BackupMigrate\Core\Destination\NodeSquirrelDestination contains 1 abstract method and must therefore be declared abstract or implement the remaining methods
  • Module libraries PHP Fatal error: Trait method getLibrary has not been applied, because there are collisions with other trait methods on Drupal\libraries\ExternalLibrary\Exception\InvalidLibraryDependencyException
  • Module page_manager Fatal error: Declaration of Drupal\page_manager_ui\Wizard\RouteParameters::getOperations() must be compatible with Drupal\ctools\Wizard\FormWizardInterface::getOperations($cached_values)
  • Module slick_views Fatal error: Cannot redeclare token_theme() (previously declared in web/modules/contrib/blazy/tests/modules/blazy_test/blazy_test.module:112) in web/modules/contrib/token/token.module on line 71
  • Module draggableviews Warning: Uncaught PHPStan\Broker\ClassAutoloadingException: Class Drupal\migrate\Entity\MigrationInterface not found and could not be autoloaded
  • Module video Fatal error: Cannot redeclare Drupal\video_transcode\TranscoderInterface::createJob()

Looking through the rest of the list I'm wondering if some of these are not issues with drupal-check but actually issues with the modules?

Perhaps the next step here then is to go through the "Problems with Drupal Checker" column of the spreadsheet and submit d.o tickets?

Feature Request: CI-friendly progress bar

The progress bar looks really nice when running this locally, but during CI execution it redraws the progress bar on a new line each time a new file is checked:

image

This makes the output unnecessarily long.

Perhaps there could be an option like --no-progress to disable this completely, or maybe we auto-detect this situation and use a PHPUnit-style progress bar where we output multiple . characters in a row, one for each file checked?

Error: Class was not found while trying to analyse it - autoloading is probably not configured properly.

Problem

drupal-checker modules/contrib/[module name] throws Class [Class name] was not found while trying to analyse it - autoloading is probably not configured properly.

Environment details

  • drupal-chcker (v 1.0.8) installed globally (composer global require mglaman/drupal-checker)
  • Drupal installation with core 8.7.x
  • Contrib module installed via composer (composer require --prefer-source drupal/cloudflare)
  • Module is enabled and functional.

Output

  drupal8 git:(8.7.x) โœ— drupal-check modules/contrib/cloudflare
 ------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  Line   modules/cloudflarepurger/src/EventSubscriber/CloudFlareCacheTagHeaderGenerator.php
 ------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------
         Class Drupal\cloudflarepurger\EventSubscriber\CloudFlareCacheTagHeaderGenerator was not found while trying to analyse it - autoloading is probably not configured
         properly.
 ------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------

 ------ ----------------------------------------------------------------------------------------------------------------------------------------------------------------
  Line   modules/cloudflarepurger/src/Plugin/Purge/DiagnosticCheck/ApiRateLimitCheck.php
 ------ ----------------------------------------------------------------------------------------------------------------------------------------------------------------
         Class Drupal\cloudflarepurger\Plugin\Purge\DiagnosticCheck\ApiRateLimitCheck was not found while trying to analyse it - autoloading is probably not configured
         properly.
 ------ ----------------------------------------------------------------------------------------------------------------------------------------------------------------

 ------ -------------------------------------------------------------------------------------------------------------------------------------------------------------
  Line   modules/cloudflarepurger/src/Plugin/Purge/DiagnosticCheck/ComposerDependenciesCheck.php
 ------ -------------------------------------------------------------------------------------------------------------------------------------------------------------
         Class Drupal\cloudflarepurger\Plugin\Purge\DiagnosticCheck\ComposerDependenciesCheck was not found while trying to analyse it - autoloading is probably not
         configured properly.
 ------ -------------------------------------------------------------------------------------------------------------------------------------------------------------

 ------ --------------------------------------------------------------------------------------------------------------------------------------------------------------
  Line   modules/cloudflarepurger/src/Plugin/Purge/DiagnosticCheck/CredentialCheck.php
 ------ --------------------------------------------------------------------------------------------------------------------------------------------------------------
         Class Drupal\cloudflarepurger\Plugin\Purge\DiagnosticCheck\CredentialCheck was not found while trying to analyse it - autoloading is probably not configured
         properly.
 ------ --------------------------------------------------------------------------------------------------------------------------------------------------------------

 ------ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
  Line   modules/cloudflarepurger/src/Plugin/Purge/DiagnosticCheck/DailyTagPurgeLimitCheck.php
 ------ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
         Class Drupal\cloudflarepurger\Plugin\Purge\DiagnosticCheck\DailyTagPurgeLimitCheck was not found while trying to analyse it - autoloading is probably not configured
         properly.
 ------ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------

running on dgo.to/xhprof causes fatal error

Did not check deeper but log is

core8$ drupal-check.phar -d -vvv modules/XHProf/
Performing deprecation checks
Current working directory: /home/andypost/www/core8
Using Drupal root: /home/andypost/www/core8
Using vendor root: /home/andypost/www/core8/vendor
Using autoloader: /home/andypost/www/core8/vendor/autoload.php
PHPStan crashed in the previous run probably because of excessive memory consumption.
It consumed around 26 MB of memory.


To avoid this issue, allow to use more memory with the --memory-limit option.
/home/andypost/www/core8/modules/XHProf/xhprof.drush.inc
/home/andypost/www/core8/modules/XHProf/modules/xhprof_mongodb/MongodbXHProfRuns.inc
/home/andypost/www/core8/modules/XHProf/modules/xhprof_mongodb/xhprof_mongodb.module
/home/andypost/www/core8/modules/XHProf/src/StorageFactory.php
/home/andypost/www/core8/modules/XHProf/src/Routing/RunConverter.php
/home/andypost/www/core8/modules/XHProf/src/ProfilerInterface.php
/home/andypost/www/core8/modules/XHProf/src/Form/ConfigForm.php
/home/andypost/www/core8/modules/XHProf/src/DataCollector/XHProfDataCollector.php
/home/andypost/www/core8/modules/XHProf/src/Compiler/StoragePass.php
/home/andypost/www/core8/modules/XHProf/src/XhprofServiceProvider.php
/home/andypost/www/core8/modules/XHProf/src/RequestMatcher/XHProfRequestMatcher.php
/home/andypost/www/core8/modules/XHProf/src/EventSubscriber/XHProfEventSubscriber.php
/home/andypost/www/core8/modules/XHProf/src/Profiler.php
/home/andypost/www/core8/modules/XHProf/src/Extension/UprofilerExtension.php
/home/andypost/www/core8/modules/XHProf/src/Extension/TidewaysXHProfExtension.php
/home/andypost/www/core8/modules/XHProf/src/Extension/TidewaysExtension.php
/home/andypost/www/core8/modules/XHProf/src/Extension/ExtensionInterface.php
/home/andypost/www/core8/modules/XHProf/src/Extension/XHProfExtension.php
/home/andypost/www/core8/modules/XHProf/src/Controller/XHProfController.php
/home/andypost/www/core8/modules/XHProf/src/XHProfLib/Parser/BaseParser.php
/home/andypost/www/core8/modules/XHProf/src/XHProfLib/Parser/Parser.php
/home/andypost/www/core8/modules/XHProf/src/XHProfLib/Parser/ParserInterface.php
/home/andypost/www/core8/modules/XHProf/src/XHProfLib/Parser/DiffParser.php
/home/andypost/www/core8/modules/XHProf/src/XHProfLib/Parser/SymbolsSorter.php
/home/andypost/www/core8/modules/XHProf/src/XHProfLib/Symbol/Symbol.php
/home/andypost/www/core8/modules/XHProf/src/XHProfLib/Aggregator.php
/home/andypost/www/core8/modules/XHProf/src/XHProfLib/Report/ReportEngine.php
PHP Fatal error:  Class Drupal\xhprof\XHProfLib\Report\DiffReport contains 6 abstract methods and must therefore be declared abstract or implement the remaining methods (Drupal\xhprof\XHProfLib\Report\ReportInterface::getSymbols, Drupal\xhprof\XHProfLib\Report\ReportInterface::getSummary, Drupal\xhprof\XHProfLib\Report\ReportInterface::getTotals, ...) in /home/andypost/www/core8/modules/XHProf/src/XHProfLib/Report/DiffReport.php on line 8

Fatal error: Class Drupal\xhprof\XHProfLib\Report\DiffReport contains 6 abstract methods and must therefore be declared abstract or implement the remaining methods (Drupal\xhprof\XHProfLib\Report\ReportInterface::getSymbols, Drupal\xhprof\XHProfLib\Report\ReportInterface::getSummary, Drupal\xhprof\XHProfLib\Report\ReportInterface::getTotals, ...) in /home/andypost/www/core8/modules/XHProf/src/XHProfLib/Report/DiffReport.php on line 8

The reserved indicator "@" cannot start a plain scalar; you need to quote the scalar at line 10 (near "- @config.factory").

$ drupal-check -d docroot/modules/contrib/imce

In Inline.php line 301:

  The reserved indicator "@" cannot start a plain scalar; you need to quote the scalar at line 10 (near "- @config.factory").

Running 1.0.6 on PHP 7.2. Every command I try produces the same cryptic error message.

Running with -vvv :

$ drupal-check -d docroot/modules/contrib/imce -vvv
Performing deprecation checks
Current working directory: /Users/sean.hamlin/Sites/Corvette
Using Drupal root: /Users/sean.hamlin/Sites/Corvette/docroot
Using vendor root: /Users/sean.hamlin/Sites/Corvette/vendor
Using autoloader: /Users/sean.hamlin/Sites/Corvette/vendor/autoload.php
PHP Fatal error:  Uncaught Symfony\Component\Yaml\Exception\ParseException: The reserved indicator "@" cannot start a plain scalar; you need to quote the scalar at line 10 (near "- @config.factory"). in phar:///usr/local/bin/drupal-check/vendor/symfony/yaml/Inline.php:301
Stack trace:
#0 phar:///usr/local/bin/drupal-check/vendor/symfony/yaml/Inline.php(94): Symfony\Component\Yaml\Inline::parseScalar('@config.factory', 0, NULL, 15, true, Array)
#1 phar:///usr/local/bin/drupal-check/vendor/symfony/yaml/Parser.php(719): Symfony\Component\Yaml\Inline::parse('@config.factory', 0, Array)
#2 phar:///usr/local/bin/drupal-check/vendor/symfony/yaml/Parser.php(201): Symfony\Component\Yaml\Parser->parseValue('@config.factory', 0, 'sequence')
#3 phar:///usr/local/bin/drupal-check/vendor/symfony/yaml/Parser.php(464): Symfony\Component\Yaml\Parser->doParse('- @config.facto...', 0)
#4 phar:///usr/local/bin/drupal-check/vendor/symfony/yaml/Parser.php(323): Symfony\Component\Yaml\Parser->parseBlock(9, '- @config.facto...', 0)
#5 phar:///usr/loc in phar:///usr/local/bin/drupal-check/vendor/symfony/yaml/Inline.php on line 301

Fatal error: Uncaught Symfony\Component\Yaml\Exception\ParseException: The reserved indicator "@" cannot start a plain scalar; you need to quote the scalar at line 10 (near "- @config.factory"). in phar:///usr/local/bin/drupal-check/vendor/symfony/yaml/Inline.php:301
Stack trace:
#0 phar:///usr/local/bin/drupal-check/vendor/symfony/yaml/Inline.php(94): Symfony\Component\Yaml\Inline::parseScalar('@config.factory', 0, NULL, 15, true, Array)
#1 phar:///usr/local/bin/drupal-check/vendor/symfony/yaml/Parser.php(719): Symfony\Component\Yaml\Inline::parse('@config.factory', 0, Array)
#2 phar:///usr/local/bin/drupal-check/vendor/symfony/yaml/Parser.php(201): Symfony\Component\Yaml\Parser->parseValue('@config.factory', 0, 'sequence')
#3 phar:///usr/local/bin/drupal-check/vendor/symfony/yaml/Parser.php(464): Symfony\Component\Yaml\Parser->doParse('- @config.facto...', 0)
#4 phar:///usr/local/bin/drupal-check/vendor/symfony/yaml/Parser.php(323): Symfony\Component\Yaml\Parser->parseBlock(9, '- @config.facto...', 0)
#5 phar:///usr/loc in phar:///usr/local/bin/drupal-check/vendor/symfony/yaml/Inline.php on line 301

ContainerNotInitializedException for every class I check

Cool and very useful script. Thanks for that! Unfortunately, I get (among many quite useful hints) this message for every(?) class/file I check:

Drupal\Core\DependencyInjection\ContainerNotInitializedException (\Drupal::$container is not initialized yet. \Drupal::setContainer() must be called with a real container.) thrown while autoloading class static.

Undefined property: PhpParser\Node\Stmt\Property::$type

I have been trying to set this up in my gitlab CI and also tried running this locally on my macbook, and in both circumstances I get a lot of notices thrown to the screen/console like this:

Macbook:

Notice: Undefined property: PhpParser\Node\Stmt\Property::$type in phar:///Users/xxxxxx/www.xxxxx.com/drupal-check.phar/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/NameResolver.php on line 98

Gitlab:

Notice: Undefined property: PhpParser\Node\Stmt\Property::$type in phar:///home/gitlab-runner/builds/e67c5a4b/0/xxxx/xxxx/drupal-check.phar/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/NameResolver.php on line 97

Any ideas what I may be doing wrong? In both circumstances we are using PHP 7.2

Autoloading is broken when added as a project dependency

Related to #55 but for custom modules, not contrib.

While running drupal-check docroot/modules/custom, I am getting <class> was not found while trying to analyse it - autoloading is probably not configured properly. for each of my custom modules.

I understand for contrib why this might be a thing, but for the custom modules I don't expect them to ever be autoloaded (since they weren't adding with composter).

I have tried to do this both from the project level and globally. I know @mglaman suggests doing it globally. It would be really nice if we could require this library at the project level, so that it is one less global dependency that everyone has to install, CI has to install, etc. composer install at the project level would be a really ideal way to pull in this library!

Drupal vendor directory not discovered

I downloaded drupal-check.phar , doing php drupal-check.phar -V results in Drupal Check 1.0.5. But when I attempt to run it from docroot I get a Could not find autoload file. error message. I did an ln -s ../vendor which made it work. We have a drupal-project install with docroot and vendor in the repo root. Running from the repo didn't fix this.

Thanks for super useful utility!

Error with TestBlockDisplayVariant Class

Hi, I'm trying run drupal-check inside a Drupal project, but I'm unable to get the right feedback. This is giving me back a PHP Fatal error constantly.

PHP Fatal error: Cannot declare class Drupal\Tests\ctools\Unit\TestBlockDisplayVariant, because the name is already in use in /var/www/html/ctpdandalucia/web/modules/contrib/ctools/tests/src/Unit/BlockDisplayVariantTest.php on line 90
Launching drupal-check -ad web/modules/contrib/ return a message:
"PHPStan crashed in the previous run probably because of excessive memory consumption."
but I have the PHP memory limit set to -1 in cli and Apache...so what can I do?

My Drupal (output from drush status):
Drupal version : 8.6.14
PHP binary : /usr/bin/php7.2
PHP config : /etc/php/7.2/cli/php.ini

Greetings,
David.

Try to use a Symfony Console version inline with Drupal and Drush version constraints

Currently, Symfony Console is tagged at "symfony/console": "^4.2",.

  • Drush is set to "symfony/console": "^3.4",.
  • Drupal core is set to `"symfony/console": "~3.4.0",``.

The current problems exist:

  • If Drush is required globally and then drupal-check is, it'll freak out over the major version jump. If drupal-check was installed first, Drush wouldn't care.
  • We can't be installed alongside Drupal at all.

Add fixability grade to the deprecations output

In http://hojtsy.hu/blog/2019-may-24/analysis-top-uses-deprecated-code-drupal-contributed-projects-may-2019 I graded each deprecation into 4 categories:

  1. Don't know
  2. Only in dev version of core (should not be fixed yet)
  3. In supported version of core (should be fixed for custom code, not for d.o projects)
  4. In unsupported version of core (should be fixable, unless you have a really old core)

Now that phpstan provides the deprecation version number in the output, we can grade each one automatically. Especially once https://www.drupal.org/project/drupal/issues/3048498 is fixed this grading will become even more accurate.

Solution probably should not be in drupal-check, but some layer above it so other consumers of the libraries can use it. Eg. Upgrade status, the d.o drupalci integration, etc.

drupal-check fails when some modules exist

I found that having the examples module installed in a Drupal instance (even if not enabled) will cause drupal-check to fail with an opaque error and no other output:

\Drupal::$container is not initialized yet. \Drupal::setContainer() must be called with a real container.

This can be replicated by creating brand-new install of Drupal built via the composer command in the readme, then installing the examples module with composer before running drupal-check:

composer create-project drupal-composer/drupal-project:8.x-dev drupal --no-interaction --stability=dev
cd drupal
composer require 'drupal/examples:1.x-dev'
drupal-check ./

Here is a portion of the backtrace where the exception was being generated:

#0  Drupal::getContainer() called at [/home/afranco/drupal/web/core/lib/Drupal.php:159]
#1  Drupal::service(extension.list.module) called at [/home/afranco/drupal/web/core/includes/bootstrap.inc:241]
#2  drupal_get_filename(module, tabledrag_example) called at [/home/afranco/drupal/web/core/includes/bootstrap.inc:293]
#3  drupal_get_path(module, tabledrag_example) called at [/home/afranco/drupal/web/core/includes/module.inc:134]
#4  module_load_include(inc, tabledrag_example, tabledrag_example.data) called at [/home/afranco/drupal/web/modules/contrib/examples/tabledrag_example/tabledrag_example.install:14]
#5  require(/home/afranco/drupal/web/modules/contrib/examples/tabledrag_example/tabledrag_example.install) called at [/home/afranco/.composer/vendor/mglaman/drupal-check/vendor/mglaman/phpstan-drupal/src/Drupal/Bootstrap.php:100]
#6  PHPStan\Drupal\Bootstrap->register() called at [/home/afranco/.composer/vendor/mglaman/drupal-check/vendor/mglaman/phpstan-drupal/phpstan-bootstrap.php:3]
#7  require_once(/home/afranco/.composer/vendor/mglaman/drupal-check/vendor/mglaman/phpstan-drupal/phpstan-bootstrap.php) called at [/home/afranco/.composer/vendor/mglaman/drupal-check/vendor/phpstan/phpstan/src/Command/CommandHelper.php:209]
#8  PHPStan\Command\CommandHelper::PHPStan\Command\{closure}(/home/afranco/.composer/vendor/mglaman/drupal-check/vendor/mglaman/phpstan-drupal/phpstan-bootstrap.php) called at [/home/afranco/.composer/vendor/mglaman/drupal-check/vendor/phpstan/phpstan/src/Command/CommandHelper.php:210]
#9  PHPStan\Command\CommandHelper::begin(Symfony\Component\Console\Input\ArgvInput Object ([Symfony\Component\Console\Input\ArgvInputtokens] =>

While drupal-check can't be responsible for all modules, it would be helpful to at least catch exceptions in the Bootstrap process and output a message indicating which module or theme is the offending one.

Functions from .install complains

For some reason functions in install files mentions autoloader using 1.0.6
Version 1.0.5 does not complain about it

Ref https://www.drupal.org/project/better_normalizers/issues/3042791

drupal-check.phar -ad -vv -n --no-progress better_normalizers 
 ------ --------------------------------------------------------------------------------------------------------------------------------- 
  Line   better_normalizers.install                                                                                                       
 ------ --------------------------------------------------------------------------------------------------------------------------------- 
  11     Function better_normalizers_update_8001 not found while trying to analyse it - autoloading is probably not configured properly.  
 ------ --------------------------------------------------------------------------------------------------------------------------------- 

Dependency issues if you have other Drupal related packages required in composer global

$ composer global require mglaman/drupal-check
Changed current directory to /Users/nikunj/.composer
Using version ^1.0 for mglaman/drupal-check
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install mglaman/drupal-check 1.0.5
    - Conclusion: don't install mglaman/drupal-check 1.0.4
    - Conclusion: don't install mglaman/drupal-check 1.0.3
    - Conclusion: don't install mglaman/drupal-check 1.0.2
    - Conclusion: don't install mglaman/drupal-check 1.0.1
    - Conclusion: remove symfony/console v3.4.21
    - Installation request for mglaman/drupal-check ^1.0 -> satisfiable by mglaman/drupal-check[1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.0.5].
    - Conclusion: don't install symfony/console v3.4.21
    - mglaman/drupal-check 1.0.0 requires symfony/console ^4.2 -> satisfiable by symfony/console[v4.2.0, v4.2.1, v4.2.2, v4.2.3, v4.2.4].
    - Can only install one of: symfony/console[v4.2.0, v3.4.21].
    - Can only install one of: symfony/console[v4.2.1, v3.4.21].
    - Can only install one of: symfony/console[v4.2.2, v3.4.21].
    - Can only install one of: symfony/console[v4.2.3, v3.4.21].
    - Can only install one of: symfony/console[v4.2.4, v3.4.21].
    - Installation request for symfony/console (locked at v3.4.21) -> satisfiable by symfony/console[v3.4.21].


Installation failed, reverting ./composer.json to its original content.

Contents of ~/.composer/composer.json

{
    "require": {
        "hirak/prestissimo": "^0.3.8",
        "drush/drush-launcher": "^0.6.0",
        "zaporylie/composer-drupal-optimizations": "^1.0",
        "drupal/coder": "^8.3"
    }
}

composer global require - requirements issue

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: macOS
  • PHP Version: 7.3.1
  • Drupal core: -
  • Composer : 1.8.5

Describe the bug
Installing drupal-check as global fail. See output.

Console output

composer global require mglaman/drupal-check -vvv
Changed current directory to /Users/goz/.composer
Reading ./composer.json
Loading config file ./composer.json
Checked CA file /private/etc/ssl/cert.pem: valid
Executing command (/Users/goz/.composer): git branch --no-color --no-abbrev -v
Executing command (/Users/goz/.composer): git describe --exact-match --tags
Executing command (/Users/goz/.composer): git log --pretty="%H" -n1 HEAD
Executing command (/Users/goz/.composer): hg branch
Executing command (/Users/goz/.composer): fossil branch list
Executing command (/Users/goz/.composer): fossil tag list
Executing command (/Users/goz/.composer): svn info --xml
Reading /Users/goz/.composer/vendor/composer/installed.json
Running 1.8.5 (2019-04-09 17:46:47) with PHP 7.3.1 on Darwin / 18.5.0
Downloading https://repo.packagist.org/packages.json
Downloading http://repo.packagist.org/p/provider-2013%24b3da6f2b27dbfcdf447a7b4483dcc074e6ab91c361bca291a8b88a86514230cf.json
Downloading http://repo.packagist.org/p/provider-2014%24732e185495a1403e91f732f48e9b6cdf784183d0efbedbabe4c87662b043ed4b.json
Downloading http://repo.packagist.org/p/provider-2015%2417e8338fce4052deb73bb50e2d286d2edb841f36541acfa478b741fcf12df598.json
Downloading http://repo.packagist.org/p/provider-2016%24bf3593a81eb0a29493f44372adfb24454a9e614868dd1e127938995e129aaa6d.json
Downloading http://repo.packagist.org/p/provider-2017%24174461ba01a501f18c1fc9fa99b0d57cb370f01734b61ce8469d8c6c2ba60296.json
Downloading http://repo.packagist.org/p/provider-2018%24e5fa8ecedfa2b9819bc9f427121ba1bb55e9576b5b573dd7b6d4615ddc998c85.json
Downloading http://repo.packagist.org/p/provider-2018-07%24c27356fc766641685729b3887e1b33d0ddbae9f8f1c21e7b5949651e737c56a5.json
Downloading http://repo.packagist.org/p/provider-2018-10%242997e1cb93285c06badc08eca0c89d9885e6277c188ce0b92ff9f6cce6e580ed.json
Downloading http://repo.packagist.org/p/provider-2019-01%2465adda5004fd855e74e1ca82b8641ad91a3ca431b9e0a2be6f45a79f31684ff6.json
Downloading http://repo.packagist.org/p/provider-2019-04%24c860bdc01e671907b09dd65ef57c21f253393dec1533aca6111560d3d27e4b12.json
Downloading http://repo.packagist.org/p/provider-archived%243e10e08a20be27b649b65179d3adbdcebd10095bf207b505692c33de091f86d0.json
Downloading http://repo.packagist.org/p/provider-latest%24a0a8ee7de737537d19e0643c30d4a1e3c5241637187cec5042c4ecc8d145f017.json
Downloading http://repo.packagist.org/p/mglaman/drupal-check%2496c68f2a9085de85225a7433adc9500506d1eaef2890226bb4f7832b016694b4.json
Using version ^1.0 for mglaman/drupal-check
./composer.json has been updated
Reading ./composer.json
Loading config file ./composer.json
Executing command (/Users/goz/.composer): git branch --no-color --no-abbrev -v
Executing command (/Users/goz/.composer): git describe --exact-match --tags
Executing command (/Users/goz/.composer): git log --pretty="%H" -n1 HEAD
Executing command (/Users/goz/.composer): hg branch
Executing command (/Users/goz/.composer): fossil branch list
Executing command (/Users/goz/.composer): fossil tag list
Executing command (/Users/goz/.composer): svn info --xml
Reading /Users/goz/.composer/vendor/composer/installed.json
Reading ./composer.lock
Loading composer repositories with package information
Downloading https://repo.packagist.org/packages.json
Updating dependencies (including require-dev)
Downloading http://repo.packagist.org/p/provider-2013%24b3da6f2b27dbfcdf447a7b4483dcc074e6ab91c361bca291a8b88a86514230cf.json
Downloading http://repo.packagist.org/p/provider-2014%24732e185495a1403e91f732f48e9b6cdf784183d0efbedbabe4c87662b043ed4b.json
Downloading http://repo.packagist.org/p/provider-2015%2417e8338fce4052deb73bb50e2d286d2edb841f36541acfa478b741fcf12df598.json
Downloading http://repo.packagist.org/p/provider-2016%24bf3593a81eb0a29493f44372adfb24454a9e614868dd1e127938995e129aaa6d.json
Downloading http://repo.packagist.org/p/provider-2017%24174461ba01a501f18c1fc9fa99b0d57cb370f01734b61ce8469d8c6c2ba60296.json
Downloading http://repo.packagist.org/p/provider-2018%24e5fa8ecedfa2b9819bc9f427121ba1bb55e9576b5b573dd7b6d4615ddc998c85.json
Downloading http://repo.packagist.org/p/provider-2018-07%24c27356fc766641685729b3887e1b33d0ddbae9f8f1c21e7b5949651e737c56a5.json
Downloading http://repo.packagist.org/p/provider-2018-10%242997e1cb93285c06badc08eca0c89d9885e6277c188ce0b92ff9f6cce6e580ed.json
Downloading http://repo.packagist.org/p/provider-2019-01%2465adda5004fd855e74e1ca82b8641ad91a3ca431b9e0a2be6f45a79f31684ff6.json
Downloading http://repo.packagist.org/p/provider-2019-04%24c860bdc01e671907b09dd65ef57c21f253393dec1533aca6111560d3d27e4b12.json
Downloading http://repo.packagist.org/p/provider-archived%243e10e08a20be27b649b65179d3adbdcebd10095bf207b505692c33de091f86d0.json
Downloading http://repo.packagist.org/p/provider-latest%24a0a8ee7de737537d19e0643c30d4a1e3c5241637187cec5042c4ecc8d145f017.json
Downloading http://repo.packagist.org/p/nikic/php-parser%24b16220099f74ba4a9be80cf9215db93040ba825d89a7a46f65b61f1eb6bd4f1b.json
Downloading http://repo.packagist.org/p/squizlabs/php_codesniffer%24fe34e78fcad23d42d683a3fb415593e6c9bc6a41ffc4b465d98222601687a6e2.json
Downloading http://repo.packagist.org/p/pheromone/phpcs-security-audit%24432fe24130b1399ad9f8378967efc12924a17360c5ae46c990889d86acf71a72.json
Downloading http://repo.packagist.org/p/symfony/console%2478e96b153cb9aec9eb5404526bf176539bab7a25a52b61d81db2fbd5768508e5.json
Downloading http://repo.packagist.org/p/symfony/event-dispatcher%2421e370d53b8b0ae59244204dcedcb68c5488ccaeb064018a9896cb4edc7a157e.json
Downloading http://repo.packagist.org/p/psecio/parse%249030aaa2c39084e089b06fa91c7b31c3def0aa91718d3e03e63ac178628bb4bc.json
Downloading http://repo.packagist.org/p/symfony/debug%242401795b4a8f89e35768610d870ebecd82d29a86e9534e5804b7991ca0b3ad50.json
Downloading http://repo.packagist.org/p/symfony/polyfill-mbstring%245d4ac827e3d4bc9b127c90d5e4b040fdea7fc705addf168c53753de13aed0266.json
Downloading http://repo.packagist.org/p/psr/log%241411a93c6d456c0e8b5556ca331e6c1c6ff40506b83cbcb9432dea9c3fa036a9.json
Downloading http://repo.packagist.org/p/mglaman/drupal-check%2496c68f2a9085de85225a7433adc9500506d1eaef2890226bb4f7832b016694b4.json
Downloading http://repo.packagist.org/p/composer/xdebug-handler%2492067993aabc99bac15b8bc935cf17b5c27ad60ac3b045175b264d31c1aeab0a.json
Downloading http://repo.packagist.org/p/mglaman/phpstan-drupal-deprecations%246b560bb6731e9acf4f52667ae7703986688142fbceb8afb1cf512aa408ff395a.json
Downloading http://repo.packagist.org/p/mglaman/phpstan-junit%24dda8cef75ec82337654ca7dac3516f491865ac4698ff2854b61a75ac3a863863.json
Downloading http://repo.packagist.org/p/webflo/drupal-finder%24be19e0aee9c0fc0d532a1bdae56ce82070b166ea286b6e5880747307f39718dd.json
Downloading http://repo.packagist.org/p/mglaman/phpstan-drupal%247d75d3fa05763b3c03b811314dff178d81a852a60bf6f245ae241cddf63db36a.json
Downloading http://repo.packagist.org/p/phpstan/phpstan-deprecation-rules%245661621a6115ae902de7f42ad78ee878a83adedbbf6731278c2186e4200c984b.json
Downloading http://repo.packagist.org/p/phpstan/phpstan%2451f7e81a4c26995554d7411307f6b40bfb0d2edf676a3a8551e6999b649d1441.json
Downloading http://repo.packagist.org/p/symfony/contracts%24e21e5295ce33b82f042efaaadc8e9e57e8e414500b7857474036339280c86d22.json
Downloading http://repo.packagist.org/p/symfony/yaml%24cc87d0d1851c4203c36847f57901981b3026f7933645a503d5170a45aad9830a.json
Downloading http://repo.packagist.org/p/jean85/pretty-package-versions%2426b60c5b9b7bb85ab73fc6e12acb5a1499def1bd0f2e00716aae3d80557ef3cc.json
Downloading http://repo.packagist.org/p/nette/bootstrap%24d1254f00a339ebd3d21e6fe44c681d736175550fc68a442584ad4a47b069befa.json
Downloading http://repo.packagist.org/p/nette/di%246b332dc833a23bfd15b2b82b578d26b9afe050a9557bc43783147ad5fd8d695b.json
Downloading http://repo.packagist.org/p/nette/robot-loader%24195dc7dcaa72d93893570b4bcae75556ac02b7512c9d627d367551116278b588.json
Downloading http://repo.packagist.org/p/nette/utils%243e77c1927e49a238e3318e366624ddd59529e5657bbf88364bb71e1effc9ac70.json
Downloading http://repo.packagist.org/p/phpstan/phpdoc-parser%24cbad319574baef7252bce0adbe2d4414caec87f2fffba3fc744f39f2229cf193.json
Downloading http://repo.packagist.org/p/symfony/finder%24515a0fc5c3dbff8bd905170dee16dce2c792f16736c6191b5ceeb4f0ca55df97.json
Downloading http://repo.packagist.org/p/nette/schema%24052ae1fb7245f970d62eef08a99e88690e19f8d5e07dcfb8b2f68a01278709c2.json
Downloading http://repo.packagist.org/p/symfony/polyfill-ctype%24ede16305ccc7c7f96469d909dc4aaed31d7051e7e866811f12b8877df9ba3128.json
Downloading http://repo.packagist.org/p/ocramius/package-versions%2451a41f72eaadd8982df50c67d2a79229f339eceb9e7290fb5dc8aab9d9c826d7.json
Downloading http://repo.packagist.org/p/nette/neon%2493bfbe0d3b52f0fc835188bec7389bbb217fc0817546b392c50511625e356659.json
Downloading http://repo.packagist.org/p/nette/php-generator%240f9d3549e831d65b9fa2ab48ce9f26f8cbf135d34483ff089ca804efdcb736ed.json
Downloading http://repo.packagist.org/p/nette/finder%243ddbc140b41df41f492131ad1e31c87886ff2b7f7e5e145b38b9a827ea424194.json
Resolving dependencies through SAT

Dependency resolution completed in 0.004 seconds
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for nikic/php-parser (locked at v2.1.1) -> satisfiable by nikic/php-parser[v2.1.1].
    - mglaman/drupal-check 1.0.0 requires mglaman/phpstan-drupal-deprecations ^0.11.1 -> satisfiable by mglaman/phpstan-drupal-deprecations[0.11.1].
    - mglaman/drupal-check 1.0.1 requires mglaman/phpstan-drupal-deprecations ^0.11.1 -> satisfiable by mglaman/phpstan-drupal-deprecations[0.11.1].
    - mglaman/drupal-check 1.0.2 requires mglaman/phpstan-drupal-deprecations ^0.11.1 -> satisfiable by mglaman/phpstan-drupal-deprecations[0.11.1].
    - mglaman/drupal-check 1.0.3 requires mglaman/phpstan-drupal-deprecations ^0.11.1 -> satisfiable by mglaman/phpstan-drupal-deprecations[0.11.1].
    - mglaman/drupal-check 1.0.4 requires mglaman/phpstan-drupal-deprecations ^0.11.1 -> satisfiable by mglaman/phpstan-drupal-deprecations[0.11.1].
    - mglaman/drupal-check 1.0.5 requires mglaman/phpstan-drupal-deprecations ^0.11.1 -> satisfiable by mglaman/phpstan-drupal-deprecations[0.11.1].
    - mglaman/drupal-check 1.0.6 requires mglaman/phpstan-drupal-deprecations ^0.11.1 -> satisfiable by mglaman/phpstan-drupal-deprecations[0.11.1].
    - mglaman/drupal-check 1.0.7 requires mglaman/phpstan-drupal-deprecations ^0.11.1 -> satisfiable by mglaman/phpstan-drupal-deprecations[0.11.1].
    - mglaman/drupal-check 1.0.8 requires mglaman/phpstan-drupal-deprecations ^0.11.1 -> satisfiable by mglaman/phpstan-drupal-deprecations[0.11.1].
    - mglaman/drupal-check 1.0.9 requires mglaman/phpstan-drupal-deprecations ^0.11.1 -> satisfiable by mglaman/phpstan-drupal-deprecations[0.11.1].
    - Conclusion: don't install mglaman/phpstan-drupal-deprecations 0.11.1
    - Installation request for mglaman/drupal-check ^1.0 -> satisfiable by mglaman/drupal-check[1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.0.5, 1.0.6, 1.0.7, 1.0.8, 1.0.9].


Installation failed, reverting ./composer.json to its original content.

symfont/console dependency conflicts with other packages

This is split from #23 that was closed.

Basically, the:
"symfony/console": "~3.2 || ~4.0",
in composer.json is causing drupal-check to conflict with some popular packages when trying to install locally within a project.

Some packages that require ^3.4 are:
drush/drush: "symfony/console": "^3.4",
behat/behat: "symfony/console": "~2.7.40||^2.8.33||~3.3.15||^3.4.3||^4.0.3"

Unless there is a specific reason 3.4 is being excluded from drupal-check, I recommend changing the composer.json to:
"symfony/console": "~3.2 || ~3.4 || ~4.0"

The more compatibility we can get here, the more we can encourage people to start checking their existing code to make projects ready for Drupal 9.

Undefined class constant 'KIND_FLOAT'

Running drupal-check web/modules/custom/charts, I get the following:

Line src/Plugin/views/style/ChartsPluginStyleChart.php


     Internal error: Undefined class constant 'KIND_FLOAT'
     Run PHPStan with --debug option and post the stack trace to:
     https://github.com/phpstan/phpstan/issues/new

the words KIND_FLOAT don't exist in the codebase. I do have a constant in use like this:

ChartsInterface::CHARTS_SINGLE_AXIS

Is it a problem with my code or with PHPStan?

Address Box recommendations for phar compilation.

๐Ÿ’ก  4 recommendations found:
    - The "dump-autoload" setting can be omitted since is set to its default value
    - The "main" setting can be omitted since is set to its default value
    - The "output" setting can be omitted since is set to its default value
    - The "chmod" setting can be omitted since is set to its default value

These are in box.json

Document working around conflicts of nikic/php-parser:~3

Drush requires psy which allows v2, v3, v4 of php parser. The problem is a Drupal site may have v3 installed because there is no hard requirement.

After research, this seems to be a legacy problem for sites that were set up before the v4 branch was opened. We need to find a decent workaround beyond "well, remove composer.lock and the vendor directory for your project"

PHP-Parser 4.0.0 on Feb 28, 2018

This means any Drupal 8 project created before Drupal 8.5.0 (7 Mar 2018) probably has the v3 branch of the PHP-Parser.

Drupal Check can probably do some detection against that Drupal project and provide helpful information for a solution.

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

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

Support Request - How to install on Windows

Could I get some help on how to run this tool in a Windows environment?

Our projects are inside docker containers using lando/lando, not sure if that is relevant.

Would be awesome if it was possible to install this on Windows so it is project independent.
I know how to install PHP and add things to PATH, but not entirely sure how to get started with this one.

Release version is wrong

Looks released phar file does not pick version from tag

$ drupal-check.phar -V
Drupal Check dev-master@22a00c6

That's using file from 1.0.4 release

Ignore settings.php file

Putting in a feature request here to have Drupal Check ignore settings.php.

For more info getting the following error when updating settings.php using the VS Code plugin.

[Error - 10:08:10 AM] Request textDocument/completion failed.
  Message: Unhandled method textDocument/completion
  Code: -32601 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.