FreshRSS / Extensions

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

Address phpstan ImageProxy complaints #209

Closed Frenzie closed 8 months ago

Frenzie commented 8 months ago

Re. https://github.com/FreshRSS/Extensions/pull/208#issuecomment-1971845385

Alkarex commented 8 months ago

Please run:

vendor/bin/phpstan analyse --level 9 .

or remove the lines from https://github.com/FreshRSS/Extensions/blob/master/tests/phpstan-next.txt and then run the full tests:

make test-all
Alkarex commented 8 months ago
$ vendor/bin/phpstan analyse --level 9 .
Note: Using configuration file /home/alex/GitHub/Extensions/phpstan.neon.
 41/41 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 ------ ------------------------------------------------------------------------------------------ 
  Line   xExtension-ImageProxy/configure.phtml                                                     
 ------ ------------------------------------------------------------------------------------------ 
  :10    Access to an undefined property FreshRSS_UserConfiguration::$image_proxy_url.             
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :16    Access to an undefined property FreshRSS_UserConfiguration::$image_proxy_scheme_http.     
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :22    Access to an undefined property FreshRSS_UserConfiguration::$image_proxy_scheme_https.    
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :29    Access to an undefined property FreshRSS_UserConfiguration::$image_proxy_scheme_default.  
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :29    Access to an undefined property FreshRSS_UserConfiguration::$image_proxy_scheme_default.  
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :40    Access to an undefined property FreshRSS_UserConfiguration::$image_proxy_scheme_include.  
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :46    Access to an undefined property FreshRSS_UserConfiguration::$image_proxy_url_encode.      
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
 ------ ------------------------------------------------------------------------------------------ 

 ------ ------------------------------------------------------------------------------------------ 
  Line   xExtension-ImageProxy/extension.php                                                       
 ------ ------------------------------------------------------------------------------------------ 
  :24    Access to an undefined property FreshRSS_UserConfiguration::$image_proxy_url.             
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :28    Access to an undefined property FreshRSS_UserConfiguration::$image_proxy_scheme_http.     
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :32    Access to an undefined property FreshRSS_UserConfiguration::$image_proxy_scheme_https.    
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :35    Access to an undefined property FreshRSS_UserConfiguration::$image_proxy_force.           
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :41    Access to an undefined property FreshRSS_UserConfiguration::$image_proxy_scheme_default.  
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :45    Access to an undefined property FreshRSS_UserConfiguration::$image_proxy_scheme_include.  
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :49    Access to an undefined property FreshRSS_UserConfiguration::$image_proxy_url_encode.      
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :62    Access to an undefined property FreshRSS_UserConfiguration::$image_proxy_url.             
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :63    Access to an undefined property FreshRSS_UserConfiguration::$image_proxy_scheme_http.     
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :64    Access to an undefined property FreshRSS_UserConfiguration::$image_proxy_scheme_https.    
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :65    Access to an undefined property FreshRSS_UserConfiguration::$image_proxy_scheme_default.  
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :66    Access to an undefined property FreshRSS_UserConfiguration::$image_proxy_scheme_include.  
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :67    Access to an undefined property FreshRSS_UserConfiguration::$image_proxy_url_encode.      
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :76    Access to an undefined property FreshRSS_UserConfiguration::$image_proxy_scheme_http.     
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :79    Access to an undefined property FreshRSS_UserConfiguration::$image_proxy_scheme_include.  
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :83    Access to an undefined property FreshRSS_UserConfiguration::$image_proxy_scheme_https.    
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :86    Access to an undefined property FreshRSS_UserConfiguration::$image_proxy_scheme_include.  
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :90    Access to an undefined property FreshRSS_UserConfiguration::$image_proxy_scheme_default.  
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :91    Access to an undefined property FreshRSS_UserConfiguration::$image_proxy_scheme_include.  
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :95    Access to an undefined property FreshRSS_UserConfiguration::$image_proxy_scheme_include.  
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :104   Access to an undefined property FreshRSS_UserConfiguration::$image_proxy_url_encode.      
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
  :107   Access to an undefined property FreshRSS_UserConfiguration::$image_proxy_url.             
         💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property      
 ------ ------------------------------------------------------------------------------------------ 

 [ERROR] Found 29 errors
Alkarex commented 8 months ago

Explanations in https://github.com/FreshRSS/Extensions/issues/202

Alkarex commented 8 months ago

I had forgotten about https://github.com/FreshRSS/Extensions/pull/201 Merged, sorry for the mess :-)

Frenzie commented 8 months ago

As stated, when I run vendor/bin/phpstan analyse --level 9 . it shows this. On all files.

------ ----------------------------------------------------------------------------------------- 
  Line   xExtension-ImageProxy/extension.php                                                      
 ------ ----------------------------------------------------------------------------------------- 
  5      Class ImageProxyExtension extends unknown class Minz_Extension.                          
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  15     Access to static property $system_conf on an unknown class FreshRSS_Context.             
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  16     Instantiated class FreshRSS_Context_Exception not found.                                 
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  16     Throwing object of an unknown class FreshRSS_Context_Exception.                          
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  18     Call to an undefined method ImageProxyExtension::registerHook().                         
  24     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  25     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  28     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  29     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  32     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  33     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  35     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  36     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  36     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  37     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  41     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  42     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  45     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  46     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  49     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  50     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  54     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  59     Call to an undefined method ImageProxyExtension::registerTranslates().                   
  61     Call to static method isPost() on an unknown class Minz_Request.                         
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  62     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  62     Call to static method paramString() on an unknown class Minz_Request.                    
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  63     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  63     Call to static method paramString() on an unknown class Minz_Request.                    
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  64     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  64     Call to static method paramString() on an unknown class Minz_Request.                    
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  65     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  65     Call to static method paramString() on an unknown class Minz_Request.                    
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  66     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  66     Call to static method paramString() on an unknown class Minz_Request.                    
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  67     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  67     Call to static method paramString() on an unknown class Minz_Request.                    
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  68     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  76     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  79     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  83     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  86     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  90     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  91     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  94     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  95     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  96     Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  104    Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  107    Access to static property $user_conf on an unknown class FreshRSS_Context.               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  142    Method ImageProxyExtension::setImageProxyHook() has invalid return type FreshRSS_Entry.  
  142    Parameter $entry of method ImageProxyExtension::setImageProxyHook() has invalid type     
         FreshRSS_Entry.                                                                          
  143    Call to method _content() on an unknown class FreshRSS_Entry.                            
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
  144    Call to method content() on an unknown class FreshRSS_Entry.                             
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                      
 ------ ----------------------------------------------------------------------------------------- 
Alkarex commented 8 months ago

when I run vendor/bin/phpstan analyse --level 9 . it shows this. On all files.

To run the tests, PHPStan needs to have access to the FreshRSS repo as well, which is by convention at the same level than the Extensions folder:

https://github.com/FreshRSS/Extensions/blob/265fd0bb5c443915e6de00a7ff5e081ae26cca7f/phpstan.neon#L9

Frenzie commented 8 months ago

I had forgotten about #201 Merged, sorry for the mess :-)

I did notice the wrong type was introduced in #185 but I figured that was just a typo.

I am still curious how to make phpstan not complain about all the classes it doesn't know though?

Frenzie commented 8 months ago

when I run vendor/bin/phpstan analyse --level 9 . it shows this. On all files.

To run the tests, PHPStan needs to have access to the FreshRSS repo as well, which is by convention at the same level than the Extensions folder:

Thanks, it would be useful if it complained that folder didn't exist or something. :-)

Alkarex commented 8 months ago

it would be useful if it complained that folder didn't exist or something. :-)

Indeed, that would be a nice improvement, and can probably be done with a shell test

Frenzie commented 8 months ago

Actually, that changes nothing. It still says it can't find anything.

Alkarex commented 8 months ago

Do you have a structure with the two repos along side each other?

If so, maybe rm -fr /tmp/phpstan/

Frenzie commented 8 months ago
~/src/feeds$ ls
Extensions  FreshRSS
~/src/feeds$ cd Extensions/
~/src/feeds/Extensions$ vendor/bin/phpstan analyse --level 9 .
Note: Using configuration file /home/frans/src/feeds/Extensions/phpstan.neon.
 36/36 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 ------ --------------------------------------------------------------------- 
  Line   xExtension-ColorfulList/extension.php                                
 ------ --------------------------------------------------------------------- 
  5      Class ColorfulListExtension extends unknown class Minz_Extension.    
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols  
  8      Call to an undefined method ColorfulListExtension::getFileUrl().     
  8      Call to static method appendScript() on an unknown class Minz_View.  
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
[snip]
Frenzie commented 8 months ago

If so, maybe rm -fr /tmp/phpstan/

Yes, that did the trick. Thanks!