Open ptmkenny opened 1 year ago
Hi! Have you checked out this issue? https://github.com/mortenson/psalm-plugin-drupal/issues/11
@mortenson Thanks, embarrassingly I missed that issue.
I read through the issue and I updated psalm.xml
:
<module name="app_log" />
<module name="language" />
<module name="locale" />
This fixes the error, but now I get a different error:
➜ web git:(psalm) ✗ php ../vendor/mortenson/psalm-plugin-drupal/scripts/dump_script.php && ../vendor/bin/psalm .
Drupal\Core\Database\ConnectionNotDefinedException: The specified database connection is not defined: default in /Users/private/d/d10/web/core/lib/Drupal/Core/Database/Database.php on line 436 #0 /Users/private/d/d10/web/core/lib/Drupal/Core/Database/Database.php(188): Drupal\Core\Database\Database::openConnection('default', 'default')
#1 /Users/private/d/d10/web/core/lib/Drupal/Core/Config/BootstrapConfigStorageFactory.php(40): Drupal\Core\Database\Database::getConnection()
#2 /Users/private/d/d10/web/core/lib/Drupal/Core/Config/BootstrapConfigStorageFactory.php(31): Drupal\Core\Config\BootstrapConfigStorageFactory::getDatabaseStorage()
#3 /Users/private/d/d10/web/core/modules/language/src/LanguageServiceProvider.php(72): Drupal\Core\Config\BootstrapConfigStorageFactory::get()
#4 /Users/private/d/d10/web/core/modules/language/src/LanguageServiceProvider.php(23): Drupal\language\LanguageServiceProvider->isMultilingual()
#5 /Users/private/d/d10/web/core/lib/Drupal/Core/DrupalKernel.php(1277): Drupal\language\LanguageServiceProvider->register(Object(Drupal\Core\DependencyInjection\ContainerBuilder))
#6 /Users/private/d/d10/vendor/mortenson/psalm-plugin-drupal/scripts/PsalmDrupalKernel.php(35): Drupal\Core\DrupalKernel->compileContainer()
#7 /Users/private/d/d10/vendor/mortenson/psalm-plugin-drupal/scripts/PsalmDrupalKernel.php(40): PsalmDrupalKernel->compilePsalmContainer(Array)
#8 /Users/private/d/d10/vendor/mortenson/psalm-plugin-drupal/scripts/dump_script.php(13): PsalmDrupalKernel->dumpContainerXml(Array)
#9 {main}
Drupal\Core\Database\ConnectionNotDefinedException: The specified database connection is not defined: default in Drupal\Core\Database\Database::openConnection() (line 436 of /Users/private/d/d10/web/core/lib/Drupal/Core/Database/Database.php).
In addition, this site is a default standard install profile of Drupal 10, so the language
and locale
modules are not installed. And my module, app_log
, does not even have any php code yet (this is the simplest possible module I could make to test the configuration here). So if there are modules that need to be required even if they aren't installed on the site and aren't dependencies of the custom modules being scanned, I think that should really be documented in the README.
Hi,
If this may help.
Even without PHP code, as soon as the t function or the related translation service is used. In PHP or maybe with t function in Twig template, the "locale" and "language" modules needs to be listed and it calls the database. So even for static analysis, you need a database connection setup in the settings.php of the environment executing the code analysis.
This is my first time using psalm, so I might be missing something obvious, but I can't get it to work.
I created a new Drupal 10 site in ddev. My host is on macOS Venture and I have php 8.2 installed locally via homebrew.
I added a very simple module called
app_log
(info.yml + module.php) and then addedpsalm.xml
and set themodule_name
in that file. I then ran psalm as described in the documentation and got the following error:I made a sample repo here: https://github.com/ptmkenny/drupal10/tree/psalm
Drupal 10.0.3 PHP 8.2 local on macOS (Also tried PHP 8.1 from the ddev container-- same error)
The Drupal site was installed via the CMS quickstart instructions in ddev: https://ddev.readthedocs.io/en/latest/users/quickstart/#drupal
If anyone can point me in the right direction, I'd greatly appreciate it.