Problem/Motivation
PHPStan (level 5) reports an error in src/Controller/CollectionExportController.php:
------ ---------------------------------------------------------------------------------------------------- Line src/Controller/CollectionExportController.php ------ ---------------------------------------------------------------------------------------------------- 68 Using nullsafe method call on non-nullable type Drupal\search_api\ServerInterface. Use -> instead. nullsafe.neverNull ------ ----------------------------------------------------------------------------------------------------
In __invoke(), the server instance is fetched and then its backend is checked with an instanceof guard that throws when it is not the Typesense backend. Because a null server would yield a null backend (which is not an instance of SearchApiTypesenseBackend and therefore throws), PHPStan narrows $search_api_server to a non-nullable ServerInterface from that point on. The nullsafe operator on line 68 is consequently redundant, and PHPStan fails the build.
Steps to reproduce
Run static analysis on the module:
ddev phpstan srcProposed resolution
Drop the nullsafe operator on line 68.
Issue fork search_api_typesense-3600935
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:
Comments
Comment #3
pfrenssenComment #5
lussolucaReleased in 1.2.0-beta3, thanks!
Comment #7
nitinkumar_7 commentedI just finished testing and was writing up my review comment when it got marked as fixed : )
Comment #8
lussolucaCool :-),
Hopefully the fix works
Comment #9
nitinkumar_7 commentedYes, it's working perfectly. Thank you for the credit!