0

I have a module Decoupled Passkeys that adds JSON-RPC module endpoints, so it depends on JSON-RPC.

When I run tests with a custom phpstan.neon, I'm getting a lot of errors because phpstan cannot find the JSON-RPC module:

  130    Call to static method internalError() on an unknown class                                
         Drupal\jsonrpc\Object\Error.                                                             
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols   

Here's a failed pipeline.

The JSON-RPC module is required in composer.json:

{
  "name": "drupal/decoupled_passkeys",
  "description": "Enables passkey login/registration via JSON:RPC and Webauthn.",
  "type": "drupal-module",
  "require": {
    "php": ">=8.2",
    "ext-json":  "*",
    "drupal/jsonrpc": "^2",
    "drupal/public_key_credential_source": "^1.0@alpha"
  },

The phpstan.neon looks like this:

parameters:
        checkGenericClassInNonGenericObjectType: false
        # Sometimes Drupal gets it wrong.
        treatPhpDocTypesAsCertain: false
        level: 9
        ignoreErrors:
          # Drupal does not define its own arrays.
          - '#no value type specified in iterable type array#'
          - '#no value type specified in iterable type Drupal\\Core\\Field\\FieldItemListInterface#'
          # Level 9 has lots of annoying offset errors.
          - '#Cannot access offset#'

When running phpstan from Gitlab CI via Drupal.org, how do I tell phpstan where the dependent modules are installed? I don't want to check the dependencies for errors with phpstan, but I need phpstan to be able to access the classes in the dependencies to see what is being extended.

1 Answer 1

1

The composer file is correct; drupal/jsonrpc

The info.yml file is not correct. Only modules provided by core are prefixed with drupal, e.g. drupal:comment. All other modules are prefixed with the project name, e.g. jsonrpc:jsonrpc

1
  • Huh, despite using Drupal 8 since the launch, I somehow missed that, but the docs clearly say so. The reason I missed it is because you can define dependencies incorrectly prefixed with drupal/ and drush pm-enable mymodule still enables them as expected. Commented Mar 25 at 12:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.