User talk:RMCD bot/botclasses.php

Latest comment: 1 month ago by Novem Linguae in topic Improved indentation and braces

Deprecated code needs to be updated in order to make it work again edit

See Wikipedia:Bots/Noticeboard/Archive 15#Heads up for CSRF token change. Some of the framework functions that I don't use have not been upgraded. function rollback still uses rvtoken and function userrights is still using ustoken.

Special:ApiFeatureUsagewbm1058 (talk) 19:57, 14 October 2021 (UTC)Reply

Wrong @return types edit

Hello wbm1058. I hope you're doing well. For botclasses.php, my code editor is throwing some warnings (red underlines of various variables) due to things like @return api, @return Api, @return The. It thinks these are variables of type api, Api, and The, respectively. This could be fixed by changing to something like @return array api, @return array Api, @return string The. Is this the right spot to request changes? Hope this helps. Thanks. –Novem Linguae (talk) 07:58, 1 December 2022 (UTC)Reply

Hi Novem Linguae. What code editor are you using? I just use Windows Notepad, which is primitive I guess but gets the job done for me. I've upgraded to PHP 8 which is throwing warnings that earlier PHP versions did not, and upgraded my code accordingly. The at sign only appears in the comments and as far as I know is not a special character in the PHP language. Are you just getting warnings from your code editor or are you getting PHP runtime errors as well? wbm1058 (talk) 11:59, 1 December 2022 (UTC)Reply
Only the code editor is giving warnings. Fancy code editors read the doc blocks and keep track of what types the variables are supposed to be, then alert you with red squiggle underlines when it thinks it's found a variable that is the wrong type. @return The page id of the page. tells the code editor that this method always returns a class of type "The". A little thing, but easily fixable, so I figured I'd mention it. I use VS Code. It's free, and you can start taking advantage of things like "search all files in a folder" and code highlighting without any complicated setup. –Novem Linguae (talk) 12:45, 1 December 2022 (UTC)Reply
Novem Linguae, feel free to update the doc blocks yourself and post your new version here to my subpage yourself. Thanks, wbm1058 (talk) 13:30, 1 December 2022 (UTC)Reply

Improved indentation and braces edit

Thanks for maintaining this. I've used it in NovemBot for a couple years now and it works great.

I just made some edits to improve indentation and braces, which should hopefully make the code easier to read and maintain. Not sure how bold to be on this user page. If too bold, feel free to revert. Or if you like me modernizing the code, let me know too and I can do more.

The edits were with an automated tool so should be less risky than doing them manually. I don't anticipate any problems. I did a quick test of login and getpage and things worked fine. –Novem Linguae (talk) 07:50, 2 April 2024 (UTC)Reply