Problem/Motivation

PHPStan at level 9 bleeding edge identifies some issues:

 ------ -------------------------------------------------------------------------
  Line   web/modules/contrib/firebase_php/src/Form/FirebasePhpConfigurationForm.php
 ------ -------------------------------------------------------------------------
  88     Cannot cast mixed to string.
         🪪  cast.string
  102    Cannot cast mixed to string.
         🪪  cast.string
 ------ -------------------------------------------------------------------------

 ------ ------------------------------------------------------------------------------------------------------------------------------
  Line   web/modules/contrib/firebase_php/src/Form/FirebasePhpSendTestMessageForm.php
 ------ ------------------------------------------------------------------------------------------------------------------------------
  98     Parameter #1 $device_token of method Drupal\firebase_php\FirebasePhpMessagingApiInterface::sendMessageSingleDevice() expects
         string, mixed given.
         🪪  argument.type
  99     Parameter #2 $notification_title of method Drupal\firebase_php\FirebasePhpMessagingApiInterface::sendMessageSingleDevice()
         expects string|null, mixed given.
         🪪  argument.type
  100    Parameter #3 $notification_body of method Drupal\firebase_php\FirebasePhpMessagingApiInterface::sendMessageSingleDevice()
         expects string|null, mixed given.
         🪪  argument.type
  104    Parameter #1 $value of function intval expects array|bool|float|GMP|int|resource|SimpleXMLElement|string|null, mixed given.
         🪪  argument.type
  110    No error to ignore is reported on line 110.
         🪪  ignore.unmatchedLine (non-ignorable)
 ------ ------------------------------------------------------------------------------------------------------------------------------

 ------ -------------------------------------------------------------------------------------------------------------------------------
  Line   web/modules/contrib/firebase_php/src/Form/FirebasePhpValidateTokenForm.php
 ------ -------------------------------------------------------------------------------------------------------------------------------
  78     Call to function array_filter() requires parameter #2 to be passed to avoid loose comparison semantics.
         🪪  arrayFilter.strict
  78     Cannot cast mixed to string.
         🪪  cast.string
  78     PHPDoc tag @var with type array<non-empty-string> is not subtype of type array<int<0, max>, non-falsy-string>.
         🪪  varTag.type
  79     Parameter #1 $registrationTokenOrTokens of method Kreait\Firebase\Contract\Messaging::validateRegistrationTokens() expects
         Kreait\Firebase\Messaging\RegistrationToken|Kreait\Firebase\Messaging\RegistrationTokens|list<Kreait\Firebase\Messaging\Regis
         trationToken|non-empty-string>|non-empty-string, array<non-empty-string> given.
         🪪  argument.type
         💡  Type #3 from the union: array<non-empty-string> might not be a list.
  94     No error to ignore is reported on line 94.
         🪪  ignore.unmatchedLine (non-ignorable)
 ------ -------------------------------------------------------------------------------------------------------------------------------

 ------ -------------------------------------------------------------------------------------------------------------------------------
  Line   web/modules/contrib/firebase_php/src/Service/FirebasePhpMessagingApi.php
 ------ -------------------------------------------------------------------------------------------------------------------------------
  99     Parameter #2 $registrationTokens of method Kreait\Firebase\Contract\Messaging::sendMulticast() expects
         Kreait\Firebase\Messaging\RegistrationToken|Kreait\Firebase\Messaging\RegistrationTokens|list<Kreait\Firebase\Messaging\Regis
         trationToken|string>|non-empty-string, array given.
         🪪  argument.type
         💡  Type #3 from the union: array might not be a list.
 ------ -------------------------------------------------------------------------------------------------------------------------------

 ------ ---------------------------------------------------------------------------------------------------------------------
  Line   web/modules/contrib/firebase_php/src/Service/FirebasePhpMessagingService.php
 ------ ---------------------------------------------------------------------------------------------------------------------
  77     Parameter #1 $value of static method Drupal\firebase_php\Enum\LoggingLevel::from() expects int|string, mixed given.
         🪪  argument.type
 ------ ---------------------------------------------------------------------------------------------------------------------

Let's fix these.

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:

  • phpstan-type-safety Comparechanges, plain diff MR !54
  • 1 hidden branch
  • 8.0.x Comparecompare

Comments

ptmkenny created an issue. See original summary.

ptmkenny changed the visibility of the branch 8.0.x to hidden.

ptmkenny’s picture

Title: Fix phpstan type-safety errors » Update to phpstan-drupal v2 and fix phpstan type-safety errors

  • ptmkenny committed bb073ebc on 8.0.x
    task: #3590990 Update to phpstan-drupal v2 and fix phpstan type-safety...
ptmkenny’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.