FreshRSS / Extensions

A repository containing all the official FreshRSS extensions
GNU Affero General Public License v3.0
378 stars 59 forks source link

Add Wallabag extension #254

Closed Joedmin closed 1 month ago

Alkarex commented 1 month ago

Thanks 👍🏻 I would like to encourage you to run PHPStan on your extension, on the model of what we do for the extensions hosted in https://github.com/FreshRSS/Extensions

That would spot several problems. Check also the deprecations:

image

Example for level 3 (out of 9):

------ ---------------------------------------------------------------------------------------------------------- 
  Line   Extensions/third-party/efa6cebe6aedee2fa9cf94bde3d20c5883571c07/Controllers/wallabagButtonController.php  
 ------ ---------------------------------------------------------------------------------------------------------- 
  :8     Access to an undefined property Minz_View::$wallabag_button_vars.                                         
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                      
  :9     Access to an undefined property FreshRSS_UserConfiguration::$wallabag_instance_url.                       
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                      
  :10    Access to an undefined property FreshRSS_UserConfiguration::$wallabag_keyboard_shortcut.                  
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                      
  :36    Access to an undefined property FreshRSS_UserConfiguration::$wallabag_instance_url.                       
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                      
  :37    Access to an undefined property FreshRSS_UserConfiguration::$wallabag_username.                           
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                      
  :38    Access to an undefined property FreshRSS_UserConfiguration::$wallabag_client_id.                          
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                      
  :50    Access to an undefined property FreshRSS_UserConfiguration::$wallabag_client_secret.                      
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                      
  :64    Access to an undefined property FreshRSS_UserConfiguration::$wallabag_access_token_expires_at.            
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                      
  :69    Access to an undefined property FreshRSS_UserConfiguration::$wallabag_client_id.                          
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                      
  :70    Access to an undefined property FreshRSS_UserConfiguration::$wallabag_client_secret.                      
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                      
  :71    Access to an undefined property FreshRSS_UserConfiguration::$wallabag_refresh_token.                      
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                      
  :90    Access to an undefined property FreshRSS_UserConfiguration::$wallabag_instance_url.                       
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                      
  :91    Access to an undefined property FreshRSS_UserConfiguration::$wallabag_username.                           
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                      
  :92    Access to an undefined property FreshRSS_UserConfiguration::$wallabag_client_id.                          
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                      
  :93    Access to an undefined property FreshRSS_UserConfiguration::$wallabag_client_secret.                      
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                      
  :94    Access to an undefined property FreshRSS_UserConfiguration::$wallabag_access_token.                       
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                      
  :95    Access to an undefined property FreshRSS_UserConfiguration::$wallabag_refresh_token.                      
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                      
  :96    Access to an undefined property FreshRSS_UserConfiguration::$wallabag_access_token_expires_at.            
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                      
  :133   Access to an undefined property FreshRSS_UserConfiguration::$wallabag_access_token.                       
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                      
  :161   Access to an undefined property FreshRSS_UserConfiguration::$wallabag_instance_url.                       
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                      
  :181   Access to an undefined property FreshRSS_UserConfiguration::$wallabag_instance_url.                       
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                      
  :228   Access to an undefined property FreshRSS_UserConfiguration::$wallabag_access_token.                       
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                      
  :229   Access to an undefined property FreshRSS_UserConfiguration::$wallabag_refresh_token.                      
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                      
  :230   Access to an undefined property FreshRSS_UserConfiguration::$wallabag_access_token_expires_at.            
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property                      
 ------ ---------------------------------------------------------------------------------------------------------- 

 ------ ------------------------------------------------------------------------------------------ 
  Line   Extensions/third-party/efa6cebe6aedee2fa9cf94bde3d20c5883571c07/configure.phtml           
 ------ ------------------------------------------------------------------------------------------ 
  :2     Access to an undefined property FreshRSS_UserConfiguration::$wallabag_instance_url.       
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :3     Access to an undefined property FreshRSS_UserConfiguration::$wallabag_client_id.          
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :4     Access to an undefined property FreshRSS_UserConfiguration::$wallabag_client_secret.      
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :5     Access to an undefined property FreshRSS_UserConfiguration::$wallabag_username.           
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :6     Access to an undefined property FreshRSS_UserConfiguration::$wallabag_access_token.       
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :7     Access to an undefined property FreshRSS_UserConfiguration::$wallabag_refresh_token.      
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :8     Access to an undefined property FreshRSS_UserConfiguration::$wallabag_keyboard_shortcut.  
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :11    Variable $this might not be defined.                                                      
  :27    Variable $this might not be defined.                                                      
  :43    Variable $password might not be defined.                                                  
  :67    Variable $this might not be defined.                                                      
 ------ ------------------------------------------------------------------------------------------ 

 ------ ------------------------------------------------------------------------------------------ 
  Line   Extensions/third-party/efa6cebe6aedee2fa9cf94bde3d20c5883571c07/extension.php             
 ------ ------------------------------------------------------------------------------------------ 
  :23    Access to an undefined property FreshRSS_UserConfiguration::$wallabag_keyboard_shortcut.  
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
 ------ ------------------------------------------------------------------------------------------ 

 [ERROR] Found 36 errors                                                                                                
Joedmin commented 1 month ago

I've seen those warnings in VS Code yet I decided to ignore them since I saw them in the original Pocker Extension, which I used as a base.

How can I give my code (and thus PHPStan) the context of FreshRSS so it does not show these errors? May I ask you for guidance, please? 🙏

Alkarex commented 1 month ago

@Joedmin See https://github.com/Joedmin/xExtension-wallabag-button/pull/1 The initial code was severely outdated, so there were plenty of fixes to do just to pass the initial quality levels. If you are motivated enough, it would be excellent to make the same changes to other extensions you encounter

Alkarex commented 1 month ago

How can I give my code (and thus PHPStan) the context of FreshRSS

You should have the FreshRSS folder alongside your extension folder, and tell your editor tools about its path.

For instance, for the Intelephense extension for PHP in VSCode, you can set the following in your .vscode/settings.json:

{
    "intelephense.environment.includePaths": [
        "../FreshRSS/"
    ]
}
Joedmin commented 1 month ago

Thank you very much @Alkarex! I'll take a look on it