Commit graph

75 commits

Author SHA1 Message Date
Fomafix 5d52baf48b ParserFunctions: Use Parser::msg instead of wfMessage
Change-Id: Icb9fd404d7702922d7d9f4ae5eceb41887be8b97
2024-10-28 20:42:25 +00:00
Fomafix 43ea305f33 Use PHP type hints
* Add PHP type hints where possible.
* Remove @var, @param and @return if redundant to type declaration.
* Use explite type cast to int for boolean array index.

Change-Id: I3531b3f735327b5c427f1fc434adfb495b1c743f
2024-10-21 10:56:12 +00:00
Umherirrender 36d44c823f Use namespaced classes
Changes to the use statements done automatically via script

Change-Id: Ica9e853f7e19f0f60960ac76d7ee71cba74d0346
2024-10-20 11:15:08 +02:00
Fomafix 4bcd4ac8cb Use namespaced PHP classes for extension Scribunto
This change depends on the Scribunto change
I74fd43f7920c8772e9078f745ac6062d5461a7f1 included in REL1_40.

Depends-On: I74fd43f7920c8772e9078f745ac6062d5461a7f1
Change-Id: Id4156a8934583971df6b449d13f3d8eb6cee6368
2024-10-13 12:52:04 +00:00
James D. Forrester 211f7e0a5d Replace moved Title class uses, now MediaWiki\Title\Title
This raises compatibility to MediaWiki 1.40+.

Change-Id: I85ffdd312ee3017c2197dd0375178d49115072a4
2024-09-23 16:50:37 -04:00
Umherirrender 7352d40891 Add missing documentation to class properties
Change-Id: I904de853c11209749b7b31e52e99a1dc5ac46aaa
2024-08-19 21:08:44 +02:00
Tim Starling 06f07b0000 Add parser functions giving access to standard date/time formats
Add parser functions #timef and #timefl, giving access to the standard
date/time formats of any language.

StubObject::unstub() is no longer required since the user language is
unstubbed in ParserOptions::__construct().

Bug: T223772
Change-Id: If158f45aad67ff017f9cd15889915b226e03f50c
2024-07-23 13:10:59 +10:00
Umherirrender ad83bc2f76 Replace isset() with null check in ParserFunctions
Found usage of isset() on expression self::$mExprParser that appears to
be always set. isset() should only be used to suppress errors. Check
whether the expression is null instead.
See https://www.mediawiki.org/wiki/Manual:Coding_conventions/PHP#isset

Change-Id: Idcc51fc215fb727e84aaba5ac2510c052ce6b4d6
2024-03-27 23:06:57 +00:00
Umherirrender ef40cf4a67 build: Upgrade mediawiki/mediawiki-codesniffer to v43.0.0
Change-Id: I137fe0fe2d6486b6a2a90d57582d837ec22bd1e0
2024-03-11 20:42:17 +01:00
Sophivorus 3fc8f0a129 Fix implicit conversion to int
Bug: T351312
Change-Id: Ie4094ffa304b2a301dc32690a89adcd847f43779
2023-11-21 12:50:38 -08:00
jenkins-bot 163ad3f824 Merge "Use HookHandlers for Scribunto hook" 2023-11-06 21:49:27 +00:00
Fomafix 825485042a Remove else after return
This reduces indenting.

Change-Id: I02454fa40cc38a47d146256948decc3d9027cf80
2023-11-02 20:29:24 +00:00
Fomafix d332bcbccd Inject service HookContainer
Change-Id: I4a6292890c4cdad0d8e192e0c9fdc1c24abcd580
2023-11-01 21:34:40 +00:00
Fomafix 0e3cb3e009 Inject services
* LanguageConverterFactory
* LanguageFactory
* LanguageNameUtils

Change-Id: Ifabb61a6cc64bc00ff27aec7048c940df0d81bad
2023-11-01 21:33:33 +00:00
Fomafix 0f4984dc86 Inject service LinkCache
Change-Id: I254a4a20bac60eb505c30ddbf0fd1f5aea9bdd04
2023-11-01 20:29:36 +00:00
Fomafix 4cf0a84ebd Inject service SpecialPageFactory
Change-Id: I8ed6478cc2db8598177d06ed7a5562581f4bc9f9
2023-11-01 20:22:25 +00:00
Fomafix aa79f43d54 Inject service RepoGroup
Change-Id: I37f91c762f4ce22bee13ee8cdd0e2859f76441ec
2023-11-01 20:21:22 +00:00
Fomafix 99507e193d Inject service Config and replace global variables
Change-Id: I67d7b2314d3d519953ad95d18154962252412a8a
2023-11-01 20:04:23 +00:00
Umherirrender 72e956c82a Use HookHandlers for Scribunto hook
Cannot use the interface as the required version is not reached yet.
Cannot bump due to use in fundraising

Bug: T271022
Change-Id: I78771f948d4d1e03fc7565525f562c61af9d749a
2023-11-01 14:10:30 +01:00
Umherirrender 433b5b3788 Remove check for return value false from pow()
phan under php8.1 reports this as impossible
the message is still in use and not removed.

Change-Id: I6dcb7d7f76a659ec20476530ba02a201926a00dd
2023-10-06 19:21:01 +02:00
Umherirrender bae978d140 Rethrow TimeoutException when handling {{#time:}} parser function
timeout while converting timestamps should be a timeout for the whole
parse of that wikitext and not hidden by a invalid time.
Just let the exception bubble up to the caller
See ca71e69f for more information

Change-Id: I0d0decdeb5f4c14d009c6df2ff37920100ba320f
2023-10-02 21:03:18 +02:00
thiemowmde 3a20f81f31 Reduce very deep indention in some larger if/elseif blocks
Change-Id: I176f3cd5d28fde83bb2e243cc72d9e7c77ca6f51
2023-01-10 11:56:28 +01:00
jenkins-bot acb8030591 Merge "Replace Parser::getFunctionLang() with ::getTargetLanguage()" 2022-11-16 21:50:41 +00:00
jenkins-bot c72e162c96 Merge "Use HookContainer to register hooks on the fly." 2022-11-09 14:49:06 +00:00
jenkins-bot e02ad426b8 Merge "Remove dead code from #titleparts implementation" 2022-11-08 22:46:18 +00:00
daniel f97da7df26 Use HookContainer to register hooks on the fly.
Manipulating $wgHooks is deprecated and unreliable.
Use HookContainer instead.

Needed-By: Iddcb760cf8961316d6527e81b9aa968657d8354c
Change-Id: I413cd2ae43fe4b13917d61a50e190b536fce7279
2022-11-05 20:02:09 +00:00
thiemowmde 928a21605a Remove dead code from #titleparts implementation
It's impossible that explode() returns an empty array. This is dead
code.

Also add tests for the previously untested #titleparts function to
make sure this patch doesn't change any behavior. Including weird
usages with negative numbers.

Change-Id: Ib0d2503fdb0900bf6db3ebbc26d2ff648dbfc86d
2022-11-03 18:30:49 +01:00
thiemowmde ee66f0bfff Simplify weirdly complex ParserFunctions::ifexistInternal()
Personally I find the code much more readable when the private
helper method returns a bool.

Note this patch is intentionally tiny and focusses exclusively on
this one detail. There are many parser tests to prove that nothing
changed.

Change-Id: Ibe07c27aab9cbfc4705769820be679cd54acb79b
2022-11-03 17:50:41 +01:00
thiemowmde 129745609b Remove unused default values from method parameters
These methods are private and never called without these parameters.
These values are dead code.

Change-Id: I422f2d28f60cf3caf6234e5421b3613f80c1e6f1
2022-11-03 07:32:04 +00:00
libraryupgrader 57d87a2e33 build: Updating mediawiki/mediawiki-phan-config to 0.12.0
Change-Id: Ica980c2a25fb00feb6f9775ecb2d7830a3559a95
2022-10-10 21:05:20 +00:00
C. Scott Ananian f11b1099d0 Replace Parser::getFunctionLang() with ::getTargetLanguage()
Parser::getFunctionLang() is being deprecated.  These two functions
have been identical since 7df3473cfea59df53debb7a9eefffed8a7f20fb3
in MW 1.19 (2012) and this extension already requires MW >= 1.35.

Bug: T318860
Change-Id: I87a7ceedce173f6de4bb6722ffe594273c7b0359
2022-09-28 15:59:38 -04:00
Fomafix 6468bf9ebb Replace deprecated Language::isValidBuiltInCode and Language::factory
Change-Id: I4c5bf4d68bcb79da33864dbffe395e3818050eb4
2022-09-17 10:00:50 +00:00
Reedy f647423039 Correct namespacing to match best practices
Bug: T303105
Change-Id: Ic09ed23c4248e74f93e5807212fe73d241251281
2022-03-05 15:06:59 +00:00
jenkins-bot 7fce8ab74b Merge "Fix and update PHPDoc type hints" 2021-11-21 00:09:47 +00:00
Thiemo Kreuz ce22d48123 Fix and update PHPDoc type hints
The parameters passed to these parser hook handler functions have
guaranteed types. They are either strings or an array of PPNode
objects, depending on the SFH_OBJECT_ARGS flag. When a parameter is
missing the default value from the function header is used.

Change-Id: Ie0196f43f94cf002110c07ad2de30adfa6b77179
2021-11-20 08:52:38 +00:00
Thiemo Kreuz dbe77d7edf Use more IDE-friendly callback syntax for parser hooks
This way my IDE (in this case PHPStorm) can actually follow these
references. Strg+click brings me straight to the function, and back.
I assume other tools, linters and such might benefit the same way.

I think this is worth having a bit more duplication.

Change-Id: I16260443e0f1513b9a4715874a513c7a399b5d92
2021-11-19 18:25:10 +01:00
libraryupgrader 5b572a6f6a build: Updating mediawiki/mediawiki-codesniffer to 37.0.0
Change-Id: I1f93907a1f7b9f3dace4b2e65f7532cedc11800f
2021-07-23 06:43:57 +00:00
TChin 66f7d36e68 Record #ifexist media in imagelinks table
`#ifexist` used to only record media links if the file existed, now it does it either way.

Bug: T245965
Change-Id: Ida5dd30669fbc3471d792fd4c202bb0ff74737ec
2021-07-01 19:33:50 +00:00
libraryupgrader 7df8411050 build: Updating composer dependencies
* mediawiki/mediawiki-codesniffer: 35.0.0 → 36.0.0
  The following sniffs now pass and were enabled:
  * MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationPublic

* php-parallel-lint/php-parallel-lint: 1.2.0 → 1.3.0

Change-Id: Ifaca144ccfd753ea00d1dbba0d12941b0050e2a4
2021-05-04 08:49:27 +00:00
Umherirrender 4213826c4d Convert define() to class const in ExprParser
All are only used in this class, making it private

Change-Id: I83b5be672e12c42a34aed621e1c2571beee84abb
2021-04-04 23:17:27 +02:00
Umherirrender e36977934e build: Swap deprecated @codingStandardsIgnore to phpcs:ignore
Bug: T278594
Change-Id: I5845b9a421aa6dc1bda0469e4b13b5abc2b7b12d
2021-04-03 23:29:19 +02:00
Umherirrender d8a18b0878 Use HookHandlers for core hooks
Change-Id: I340caf0904b04dec04d218dc6813aa752ca5e9c4
2021-03-06 19:32:52 +01:00
C. Scott Ananian ff89dae8ff Replace use of Parser::$mOutput, deprecated in 1.35
The replacement, Parser::getOutput(), has been in MediaWiki for over a
decade (since 1.12.2 in 2008).

Bug: T275160
Change-Id: I4f4f7b0118470741a6cdaba562f858e425fcf350
2021-02-18 18:51:56 -05:00
Umherirrender 5fee8a2c9b Usage of Yoda conditions is not allowed; switch the expression order
Change-Id: I87fe0930cb9bc2f6af75ba8fabd4391ba4a2d7e2
2020-11-19 22:42:50 +01:00
Reedy 3767db25f7 Fix PSR12.Properties.ConstantVisibility.NotFound
Bug: T253169
Change-Id: If4de0fff2886961481faeefe3f8021ae6760e116
2020-05-30 01:27:32 +01:00
ArtBaltai a3706c0d42 Use LanguageConverter::findVariantLink() instead of Language::findVariantLink()
Bug: T226832
Change-Id: I6d7e9019def4bbccdbffcdcfd523e614902fe1e6
2020-05-06 04:11:23 +03:00
DannyS712 6a9432647e PHP coding conventions: reorder doxygen tags
See https://www.mediawiki.org/wiki/Manual:Coding_conventions/PHP#Doxygen_tags

Change-Id: Id8fc6d999ace1f222cbb6cc91e70652f60cf4f8b
2020-03-26 15:49:31 +00:00
Umherirrender b00143f151 Use MediaWikiServices::getLinkCache()
Since 1.28

Change-Id: I502726983b7ebddcf887d377a1c87740441b0a12
2020-03-14 21:25:00 +01:00
Umherirrender 2c97d15088 Use MediaWikiServices::getRepoGroup
This required MediaWiki 1.34

Change-Id: I1578dffaa20d80696378827397a0593d1c634477
2020-03-14 14:45:29 +01:00
libraryupgrader b718f1bf1a build: Updating mediawiki/mediawiki-codesniffer to 29.0.0
Additional changes:
* Also sorted "composer fix" command to run phpcbf last.

Change-Id: Id96905c5755a2705e434b3d1755827d2788c0efb
2020-01-14 09:00:15 +00:00