ankushgautam@GGN-199732-C02ZT1F1MD6V contrib % drupal-check -ad gamw
3/3 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
------ -------------------------------------------------------------------------------
Line src/Form/GamwSettingsForm.php
------ -------------------------------------------------------------------------------
117 Call to an undefined method Drupal\Core\Entity\EntityInterface::getFileUri().
------ -------------------------------------------------------------------------------
------ -------------------------------------------------------
Line src/Plugin/Block/Gamw.php
------ -------------------------------------------------------
38 Unsafe usage of new static().
💡 Consider making the class or the constructor final.
------ -------------------------------------------------------
[ERROR] Found 2 errors
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | gamw-drupal_check_issues-3115922-4.patch | 1.18 KB | vatsalkhanna |
| #2 | gamw-drupal_check_issues-3115922-2.patch | 1.52 KB | vatsalkhanna |
Comments
Comment #2
vatsalkhanna commentedHere's the patch
Comment #3
mradcliffeThere's not anything wrong. The report is a false negative.
However, if caching isn't used, then this will load the file twice.
It may be better to try loading the file outside of the if statement assigned to a variable. Then we check if the variable is truthy and if it is an instanceof FileInterface.
Inside the if, then $file_entity_uri can be assigned.
This also seems like a result of phpstan static analysis rather than Drupal 9 compatibility. If the maintainer doesn't want the class to ever be extended, final could be used, but I think this is a false negative.
I would probably run drupal-check with the -d not the -a command, but I don't think there is anything needed to make this compatible with Drupal 9. It already is compatible. I removed the Drupal 9 compatibility tag because it doesn't seem to matter. The Drupal 9 porting weekend tag should remain because this is work that was done during a virtual contribution event.
Comment #4
vatsalkhanna commentedThanks @mradcliffe for the suggestions. I have updated the patch with the changes. For #1, my bad, I didn't see that
$this->entityTypeManager->getStorage('file')->load($csv_file_id)was there in the if condition too. For #2, I removedfinalfrom the class. I made the changes as per your suggestions.Comment #5
kristen polAdding missing tag.
Comment #7
eliaspapa commented