From ca9f873e9fcedce35652e0ea109431d25d650225 Mon Sep 17 00:00:00 2001 From: Morne Alberts Date: Wed, 20 May 2026 16:28:46 +0200 Subject: [PATCH 01/11] Run CI on more versions of MediaWiki and PHP Update the CI matrix to cover the MediaWiki and PHP versions supported by the Bootstrap 5 release. Also disable Scrutinizer Ocular coverage upload (the upstream service is broken). Co-Authored-By: Claude Opus 4.7 --- .github/workflows/ci.yml | 24 ++++++++---------------- .scrutinizer.yml | 5 +++-- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index df5ea06..a0f15f4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,34 +13,26 @@ jobs: strategy: matrix: include: - - mw: 'REL1_39' - php: 8.0 - type: coverage - experimental: false - - mw: 'REL1_39' - php: 8.1 - type: normal - experimental: false - - mw: 'REL1_40' - php: 8.1 - type: normal - experimental: false - - mw: 'REL1_41' + - mw: 'REL1_43' php: 8.1 type: normal experimental: false - - mw: 'REL1_42' + - mw: 'REL1_44' php: 8.2 type: normal experimental: false - - mw: 'REL1_43' + - mw: 'REL1_45' php: 8.3 type: normal - experimental: true + experimental: false - mw: 'master' php: 8.4 type: normal experimental: true + - mw: 'master' + php: 8.5 + type: normal + experimental: true runs-on: ubuntu-latest continue-on-error: ${{ matrix.experimental }} diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 871b49f..c96ee8c 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -14,8 +14,9 @@ tools: php_loc: true php_analyzer: true sensiolabs_security_checker: true - external_code_coverage: - timeout: '1200' # timeout in seconds + # TODO: Scrutinizer Ocular coverage disabled due to https://github.com/scrutinizer-ci/ocular/issues/51 + # external_code_coverage: + # timeout: '1200' # timeout in seconds checks: php: From 5a02cdb1477e4a71c85f5939a589e3c5c88c3150 Mon Sep 17 00:00:00 2001 From: Morne Alberts Date: Wed, 20 May 2026 16:28:58 +0200 Subject: [PATCH 02/11] Modernise namespaced class imports With the floor at MediaWiki 1.43, the deprecated global-namespace fallbacks (e.g. \Html, \Title, \Parser) can be dropped in favour of the namespaced equivalents (MediaWiki\Html\Html, MediaWiki\Title\Title, MediaWiki\Parser\Parser). Replace deprecated aliases across the extension and tidy up unused / redundant use statements in passing. Co-Authored-By: Claude Opus 4.7 --- src/AbstractComponent.php | 2 +- src/BootstrapComponents.php | 1 - src/BootstrapComponentsService.php | 4 ++-- src/CarouselGallery.php | 4 ++-- src/ComponentLibrary.php | 3 +-- src/Components/Accordion.php | 2 +- src/Components/Alert.php | 2 +- src/Components/Badge.php | 2 +- src/Components/Button.php | 4 ++-- src/Components/Card.php | 6 +++--- src/Components/Carousel.php | 2 +- src/Components/Collapse.php | 6 +++--- src/Components/Jumbotron.php | 2 +- src/Components/Modal.php | 2 +- src/Components/Popover.php | 2 +- src/Components/Tooltip.php | 2 +- src/Hooks/OutputPageParserOutput.php | 5 ----- src/Hooks/ParserFirstCallInit.php | 2 +- src/HooksHandler.php | 6 ++---- src/ImageModal.php | 4 ++-- src/ImageModalTrigger.php | 15 +++++++-------- src/LuaLibrary.php | 10 +++++----- src/ModalBuilder.php | 3 +-- src/ParserOutputHelper.php | 9 --------- src/ParserRequest.php | 2 +- tests/PhpUnitEnvironment.php | 2 +- tests/phpunit/Fixtures/TestConfig.php | 4 ++-- .../Integration/I18nJsonFileIntegrityTest.php | 2 +- ...trapComponentsJsonTestCaseScriptRunnerTest.php | 2 +- .../Unit/BootstrapComponentServiceTest.php | 2 +- tests/phpunit/Unit/CarouselGalleryTest.php | 5 ++--- tests/phpunit/Unit/ComponentLibraryTest.php | 2 +- tests/phpunit/Unit/Components/AccordionTest.php | 4 ++-- tests/phpunit/Unit/Components/AlertTest.php | 2 +- tests/phpunit/Unit/Components/BadgeTest.php | 2 +- tests/phpunit/Unit/Components/ButtonTest.php | 2 +- tests/phpunit/Unit/Components/CardTest.php | 2 +- tests/phpunit/Unit/Components/CarouselTest.php | 2 +- tests/phpunit/Unit/Components/CollapseTest.php | 2 +- tests/phpunit/Unit/Components/JumbotronTest.php | 2 +- tests/phpunit/Unit/Components/ModalTest.php | 2 +- tests/phpunit/Unit/Components/PopoverTest.php | 2 +- tests/phpunit/Unit/Components/TooltipTest.php | 2 +- tests/phpunit/Unit/ComponentsTestBase.php | 2 +- .../Unit/Hooks/OutputPageParserOutputTest.php | 4 ++-- .../Unit/Hooks/ParserFirstCallInitTest.php | 4 ++-- tests/phpunit/Unit/HooksHandlerTest.php | 4 ++-- tests/phpunit/Unit/ImageModalTest.php | 6 +++--- tests/phpunit/Unit/ImageModalTriggerTest.php | 2 +- tests/phpunit/Unit/ParserOutputHelperTest.php | 7 +++---- tests/phpunit/Unit/ParserRequestTest.php | 4 ++-- 51 files changed, 78 insertions(+), 100 deletions(-) diff --git a/src/AbstractComponent.php b/src/AbstractComponent.php index 8e9dd2e..def8300 100644 --- a/src/AbstractComponent.php +++ b/src/AbstractComponent.php @@ -27,7 +27,7 @@ namespace MediaWiki\Extension\BootstrapComponents; use MediaWiki\MediaWikiServices; -use \MWException; +use MWException; /** * Class AbstractComponent diff --git a/src/BootstrapComponents.php b/src/BootstrapComponents.php index 9320e15..8c7b224 100644 --- a/src/BootstrapComponents.php +++ b/src/BootstrapComponents.php @@ -43,7 +43,6 @@ namespace MediaWiki\Extension\BootstrapComponents; -use ConfigException; use Exception; use MWException; diff --git a/src/BootstrapComponentsService.php b/src/BootstrapComponentsService.php index cc11ea9..15fe63e 100644 --- a/src/BootstrapComponentsService.php +++ b/src/BootstrapComponentsService.php @@ -2,8 +2,8 @@ namespace MediaWiki\Extension\BootstrapComponents; -use Config; -use RequestContext; +use MediaWiki\Config\Config; +use MediaWiki\Context\RequestContext; class BootstrapComponentsService { diff --git a/src/CarouselGallery.php b/src/CarouselGallery.php index dd05855..764b7b6 100644 --- a/src/CarouselGallery.php +++ b/src/CarouselGallery.php @@ -26,10 +26,10 @@ namespace MediaWiki\Extension\BootstrapComponents; -use MediaWiki\Extension\BootstrapComponents\Components\Carousel; use ImageGalleryBase; +use MediaWiki\Extension\BootstrapComponents\Components\Carousel; use MediaWiki\MediaWikiServices; -use Title; +use MediaWiki\Title\Title; /** * Class CarouselGallery diff --git a/src/ComponentLibrary.php b/src/ComponentLibrary.php index 382326c..c496968 100644 --- a/src/ComponentLibrary.php +++ b/src/ComponentLibrary.php @@ -26,8 +26,7 @@ namespace MediaWiki\Extension\BootstrapComponents; -use MediaWiki\MediaWikiServices; -use \MWException; +use MWException; /** * Class ComponentLibrary diff --git a/src/Components/Accordion.php b/src/Components/Accordion.php index 0bb5ce3..8674562 100644 --- a/src/Components/Accordion.php +++ b/src/Components/Accordion.php @@ -27,7 +27,7 @@ namespace MediaWiki\Extension\BootstrapComponents\Components; use MediaWiki\Extension\BootstrapComponents\AbstractComponent; -use \Html; +use MediaWiki\Html\Html; /** * Class Accordion diff --git a/src/Components/Alert.php b/src/Components/Alert.php index aa55c00..92a62d0 100644 --- a/src/Components/Alert.php +++ b/src/Components/Alert.php @@ -27,7 +27,7 @@ namespace MediaWiki\Extension\BootstrapComponents\Components; use MediaWiki\Extension\BootstrapComponents\AbstractComponent; -use \Html; +use MediaWiki\Html\Html; /** * Class Alert diff --git a/src/Components/Badge.php b/src/Components/Badge.php index 1267cf2..6dc1cd3 100644 --- a/src/Components/Badge.php +++ b/src/Components/Badge.php @@ -27,7 +27,7 @@ namespace MediaWiki\Extension\BootstrapComponents\Components; use MediaWiki\Extension\BootstrapComponents\AbstractComponent; -use \Html; +use MediaWiki\Html\Html; /** * Class Badge diff --git a/src/Components/Button.php b/src/Components/Button.php index e4e0597..9a93cbc 100644 --- a/src/Components/Button.php +++ b/src/Components/Button.php @@ -27,8 +27,8 @@ namespace MediaWiki\Extension\BootstrapComponents\Components; use MediaWiki\Extension\BootstrapComponents\AbstractComponent; -use \Html; -use \Title; +use MediaWiki\Html\Html; +use MediaWiki\Title\Title; /** * Class Button diff --git a/src/Components/Card.php b/src/Components/Card.php index 9d41e9a..61d97fb 100644 --- a/src/Components/Card.php +++ b/src/Components/Card.php @@ -26,12 +26,12 @@ namespace MediaWiki\Extension\BootstrapComponents\Components; -use MediaWiki\Extension\BootstrapComponents\ComponentLibrary; use MediaWiki\Extension\BootstrapComponents\AbstractComponent; +use MediaWiki\Extension\BootstrapComponents\ComponentLibrary; use MediaWiki\Extension\BootstrapComponents\NestingController; use MediaWiki\Extension\BootstrapComponents\ParserOutputHelper; -use \Html; -use \MWException; +use MediaWiki\Html\Html; +use MWException; /** * Class Card diff --git a/src/Components/Carousel.php b/src/Components/Carousel.php index 936ec79..63485cf 100644 --- a/src/Components/Carousel.php +++ b/src/Components/Carousel.php @@ -28,7 +28,7 @@ use MediaWiki\Extension\BootstrapComponents\AbstractComponent; use MediaWiki\Extension\BootstrapComponents\ParserRequest; -use \Html; +use MediaWiki\Html\Html; /** * Class Carousel diff --git a/src/Components/Collapse.php b/src/Components/Collapse.php index 838393c..ecd9aa5 100644 --- a/src/Components/Collapse.php +++ b/src/Components/Collapse.php @@ -26,11 +26,11 @@ namespace MediaWiki\Extension\BootstrapComponents\Components; -use MediaWiki\Extension\BootstrapComponents\ApplicationFactory; use MediaWiki\Extension\BootstrapComponents\AbstractComponent; +use MediaWiki\Extension\BootstrapComponents\ApplicationFactory; use MediaWiki\Extension\BootstrapComponents\ParserRequest; -use \Html; -use \MWException; +use MediaWiki\Html\Html; +use MWException; /** * Class Collapse diff --git a/src/Components/Jumbotron.php b/src/Components/Jumbotron.php index fc75de7..89d4739 100644 --- a/src/Components/Jumbotron.php +++ b/src/Components/Jumbotron.php @@ -27,7 +27,7 @@ namespace MediaWiki\Extension\BootstrapComponents\Components; use MediaWiki\Extension\BootstrapComponents\AbstractComponent; -use \Html; +use MediaWiki\Html\Html; /** * Class Jumbotron diff --git a/src/Components/Modal.php b/src/Components/Modal.php index 935bc61..f244d2c 100644 --- a/src/Components/Modal.php +++ b/src/Components/Modal.php @@ -29,7 +29,7 @@ use MediaWiki\Extension\BootstrapComponents\AbstractComponent; use MediaWiki\Extension\BootstrapComponents\ApplicationFactory; use MediaWiki\Extension\BootstrapComponents\ModalBuilder; -use \Html; +use MediaWiki\Html\Html; /** * Class Modal diff --git a/src/Components/Popover.php b/src/Components/Popover.php index 15b4195..1a5dc1d 100644 --- a/src/Components/Popover.php +++ b/src/Components/Popover.php @@ -27,7 +27,7 @@ namespace MediaWiki\Extension\BootstrapComponents\Components; use MediaWiki\Extension\BootstrapComponents\AbstractComponent; -use \Html; +use MediaWiki\Html\Html; /** * Class Popover diff --git a/src/Components/Tooltip.php b/src/Components/Tooltip.php index a73ba0e..a981fe4 100644 --- a/src/Components/Tooltip.php +++ b/src/Components/Tooltip.php @@ -27,7 +27,7 @@ namespace MediaWiki\Extension\BootstrapComponents\Components; use MediaWiki\Extension\BootstrapComponents\AbstractComponent; -use \Html; +use MediaWiki\Html\Html; /** * Class Tooltip diff --git a/src/Hooks/OutputPageParserOutput.php b/src/Hooks/OutputPageParserOutput.php index 7dd7350..3fc9248 100644 --- a/src/Hooks/OutputPageParserOutput.php +++ b/src/Hooks/OutputPageParserOutput.php @@ -27,13 +27,8 @@ namespace MediaWiki\Extension\BootstrapComponents\Hooks; use MediaWiki\Extension\BootstrapComponents\BootstrapComponentsService; -/* - * TODO switch to these, wehen we drop support for mw < 1.40 use MediaWiki\Output\OutputPage; use MediaWiki\Parser\ParserOutput; - */ -use \OutputPage; -use \ParserOutput; /** * Class OutputPageParserOutput diff --git a/src/Hooks/ParserFirstCallInit.php b/src/Hooks/ParserFirstCallInit.php index 0adbe14..888ce71 100644 --- a/src/Hooks/ParserFirstCallInit.php +++ b/src/Hooks/ParserFirstCallInit.php @@ -31,7 +31,7 @@ use MediaWiki\Extension\BootstrapComponents\ComponentLibrary; use MediaWiki\Extension\BootstrapComponents\NestingController; use MediaWiki\Extension\BootstrapComponents\ParserOutputHelper; -use Parser; +use MediaWiki\Parser\Parser; use ReflectionClass; /** diff --git a/src/HooksHandler.php b/src/HooksHandler.php index 7ff5bac..570dc1c 100644 --- a/src/HooksHandler.php +++ b/src/HooksHandler.php @@ -3,7 +3,7 @@ namespace MediaWiki\Extension\BootstrapComponents; use Bootstrap\BootstrapManager; -use Config; +use MediaWiki\Config\Config; use MediaWiki\Extension\BootstrapComponents\Hooks\OutputPageParserOutput; use MediaWiki\Extension\BootstrapComponents\Hooks\ParserFirstCallInit; use MediaWiki\Hook\GalleryGetModesHook; @@ -14,9 +14,7 @@ use MediaWiki\Hook\ParserFirstCallInitHook; use MediaWiki\Hook\SetupAfterCacheHook; use MediaWiki\MediaWikiServices; -use Parser; -// TODO switch to then when dropping support for mw < 1.40 -// use MediaWiki\Parser\Parser; +use MediaWiki\Parser\Parser; use SMW\Utils\File; use StripState; diff --git a/src/ImageModal.php b/src/ImageModal.php index 455f0cb..8b78d72 100644 --- a/src/ImageModal.php +++ b/src/ImageModal.php @@ -27,11 +27,11 @@ namespace MediaWiki\Extension\BootstrapComponents; use File; -use Html; use MediaTransformOutput; +use MediaWiki\Html\Html; use MediaWiki\MediaWikiServices; +use MediaWiki\Title\Title; use MWException; -use Title; /** * Class ImageModal diff --git a/src/ImageModalTrigger.php b/src/ImageModalTrigger.php index 0555c8b..dae337a 100644 --- a/src/ImageModalTrigger.php +++ b/src/ImageModalTrigger.php @@ -26,15 +26,14 @@ namespace MediaWiki\Extension\BootstrapComponents; -use Config; -use ConfigException; +use MediaWiki\Config\Config; +use MediaWiki\Config\ConfigException; use Exception; -use \Linker; -use \Html; -use \MediaWiki\MediaWikiServices; -use MediaWiki\User\UserOptionsLookup; -use \RequestContext; -use \Title; +use MediaWiki\Html\Html; +use MediaWiki\Linker\Linker; +use MediaWiki\MediaWikiServices; +use MediaWiki\Title\Title; +use MediaWiki\Context\RequestContext; /** * Class ImageModal diff --git a/src/LuaLibrary.php b/src/LuaLibrary.php index 0a0266a..73a4d0d 100644 --- a/src/LuaLibrary.php +++ b/src/LuaLibrary.php @@ -26,12 +26,12 @@ namespace MediaWiki\Extension\BootstrapComponents; +use MediaWiki\Extension\Scribunto\Engines\LuaCommon\LibraryBase; +use MediaWiki\Extension\Scribunto\Engines\LuaCommon\LuaEngine; use MediaWiki\MediaWikiServices; use MWException; use ReflectionClass; use ReflectionException; -use Scribunto_LuaEngine; -use Scribunto_LuaLibraryBase; /** * Class LuaLibrary @@ -40,7 +40,7 @@ * * @since 1.1 */ -class LuaLibrary extends Scribunto_LuaLibraryBase { +class LuaLibrary extends LibraryBase { /** * @var ApplicationFactory $applicationFactory; @@ -55,9 +55,9 @@ class LuaLibrary extends Scribunto_LuaLibraryBase { /** * LuaLibrary constructor. * - * @param Scribunto_LuaEngine $engine + * @param LuaEngine $engine */ - public function __construct( Scribunto_LuaEngine $engine ) { + public function __construct( LuaEngine $engine ) { parent::__construct( $engine ); $this->applicationFactory = ApplicationFactory::getInstance(); $this->bootstrapComponentService = MediaWikiServices::getInstance()->getService( 'BootstrapComponentsService' ); diff --git a/src/ModalBuilder.php b/src/ModalBuilder.php index 8c7506c..08f7e3f 100644 --- a/src/ModalBuilder.php +++ b/src/ModalBuilder.php @@ -26,8 +26,7 @@ namespace MediaWiki\Extension\BootstrapComponents; -use \Html; -use MediaWiki\MediaWikiServices; +use MediaWiki\Html\Html; /** * Class ModalBase diff --git a/src/ParserOutputHelper.php b/src/ParserOutputHelper.php index af7542c..077ff61 100644 --- a/src/ParserOutputHelper.php +++ b/src/ParserOutputHelper.php @@ -26,20 +26,11 @@ namespace MediaWiki\Extension\BootstrapComponents; -/* - * TODO: When dropping support for MW1.39, use these class imports: use MediaWiki\Html\Html; use MediaWiki\Message\Message; use MediaWiki\Parser\Parser; use MediaWiki\Parser\ParserOutput; use MediaWiki\Title\Title; -*/ - -use Html; -use Message; -use Parser; -use ParserOutput; -use Title; /** diff --git a/src/ParserRequest.php b/src/ParserRequest.php index 20dfa3f..691f9ae 100644 --- a/src/ParserRequest.php +++ b/src/ParserRequest.php @@ -26,8 +26,8 @@ namespace MediaWiki\Extension\BootstrapComponents; +use MediaWiki\Parser\Parser; use MWException; -use Parser; use PPFrame; /** diff --git a/tests/PhpUnitEnvironment.php b/tests/PhpUnitEnvironment.php index f4dbc06..e98be58 100644 --- a/tests/PhpUnitEnvironment.php +++ b/tests/PhpUnitEnvironment.php @@ -2,7 +2,7 @@ namespace MediaWiki\Extension\BootstrapComponents\Tests; -use \GitInfo; +use GitInfo; /** * @private diff --git a/tests/phpunit/Fixtures/TestConfig.php b/tests/phpunit/Fixtures/TestConfig.php index c4d5793..724143b 100644 --- a/tests/phpunit/Fixtures/TestConfig.php +++ b/tests/phpunit/Fixtures/TestConfig.php @@ -3,8 +3,8 @@ namespace MediaWiki\Extension\BootstrapComponents\Tests\Fixtures; use ArrayIterator; -use Config; -use ConfigException; +use MediaWiki\Config\Config; +use MediaWiki\Config\ConfigException; use MediaWiki\Config\IterableConfig; use MutableConfig; use Traversable; diff --git a/tests/phpunit/Integration/I18nJsonFileIntegrityTest.php b/tests/phpunit/Integration/I18nJsonFileIntegrityTest.php index 474dbb6..af5e1b3 100644 --- a/tests/phpunit/Integration/I18nJsonFileIntegrityTest.php +++ b/tests/phpunit/Integration/I18nJsonFileIntegrityTest.php @@ -2,7 +2,7 @@ namespace MediaWiki\Extension\BootstrapComponents\Tests\Integration; -use \MediaWiki\MediaWikiServices; +use MediaWiki\MediaWikiServices; use SMW\Tests\PHPUnitCompat; use SMW\Tests\Utils\UtilityFactory; diff --git a/tests/phpunit/Integration/JSONScript/BootstrapComponentsJsonTestCaseScriptRunnerTest.php b/tests/phpunit/Integration/JSONScript/BootstrapComponentsJsonTestCaseScriptRunnerTest.php index 574ccd2..e1e44d5 100644 --- a/tests/phpunit/Integration/JSONScript/BootstrapComponentsJsonTestCaseScriptRunnerTest.php +++ b/tests/phpunit/Integration/JSONScript/BootstrapComponentsJsonTestCaseScriptRunnerTest.php @@ -3,8 +3,8 @@ namespace MediaWiki\Extension\BootstrapComponents\Tests\Integration; use MediaWiki\Extension\BootstrapComponents\ApplicationFactory; -use MediaWiki\Extension\BootstrapComponents\Hooks\OutputPageParserOutput; use MediaWiki\Extension\BootstrapComponents\HookRegistry; +use MediaWiki\Extension\BootstrapComponents\Hooks\OutputPageParserOutput; use SMW\DIWikiPage; use SMW\Tests\JSONScriptTestCaseRunner; use SMW\Tests\Utils\JSONScript\JsonTestCaseFileHandler; diff --git a/tests/phpunit/Unit/BootstrapComponentServiceTest.php b/tests/phpunit/Unit/BootstrapComponentServiceTest.php index 2c1d8e8..2b4d5ce 100644 --- a/tests/phpunit/Unit/BootstrapComponentServiceTest.php +++ b/tests/phpunit/Unit/BootstrapComponentServiceTest.php @@ -2,7 +2,7 @@ namespace MediaWiki\Extension\BootstrapComponents\Tests\Unit; -use Config; +use MediaWiki\Config\Config; use MediaWiki\Extension\BootstrapComponents\BootstrapComponentsService; use MediaWiki\Extension\BootstrapComponents\Tests\Fixtures\TestConfig; use PHPUnit\Framework\TestCase; diff --git a/tests/phpunit/Unit/CarouselGalleryTest.php b/tests/phpunit/Unit/CarouselGalleryTest.php index be566f6..04b16d9 100644 --- a/tests/phpunit/Unit/CarouselGalleryTest.php +++ b/tests/phpunit/Unit/CarouselGalleryTest.php @@ -3,10 +3,9 @@ namespace MediaWiki\Extension\BootstrapComponents\Tests\Unit; use MediaWiki\Extension\BootstrapComponents\CarouselGallery; -use MediaWiki\Extension\BootstrapComponents\ParserRequest; -use \MWException; +use MediaWiki\Title\Title; +use MWException; use PHPUnit\Framework\TestCase; -use \Title; /** * @covers \MediaWiki\Extension\BootstrapComponents\CarouselGallery diff --git a/tests/phpunit/Unit/ComponentLibraryTest.php b/tests/phpunit/Unit/ComponentLibraryTest.php index 970aae4..ad3b531 100644 --- a/tests/phpunit/Unit/ComponentLibraryTest.php +++ b/tests/phpunit/Unit/ComponentLibraryTest.php @@ -2,7 +2,7 @@ namespace MediaWiki\Extension\BootstrapComponents\Tests\Unit; -use ConfigException; +use MediaWiki\Config\ConfigException; use MediaWiki\Extension\BootstrapComponents\ComponentLibrary; use PHPUnit\Framework\TestCase; diff --git a/tests/phpunit/Unit/Components/AccordionTest.php b/tests/phpunit/Unit/Components/AccordionTest.php index 657cc11..5c08871 100644 --- a/tests/phpunit/Unit/Components/AccordionTest.php +++ b/tests/phpunit/Unit/Components/AccordionTest.php @@ -2,9 +2,9 @@ namespace MediaWiki\Extension\BootstrapComponents\Tests\Unit\Components; -use MediaWiki\Extension\BootstrapComponents\Components\Accordion as Accordion; +use MediaWiki\Extension\BootstrapComponents\Components\Accordion; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use \MWException; +use MWException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Accordion diff --git a/tests/phpunit/Unit/Components/AlertTest.php b/tests/phpunit/Unit/Components/AlertTest.php index 55d7de8..192119d 100644 --- a/tests/phpunit/Unit/Components/AlertTest.php +++ b/tests/phpunit/Unit/Components/AlertTest.php @@ -4,7 +4,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Alert; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use \MWException; +use MWException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Alert diff --git a/tests/phpunit/Unit/Components/BadgeTest.php b/tests/phpunit/Unit/Components/BadgeTest.php index 1550ad4..c4bde3b 100644 --- a/tests/phpunit/Unit/Components/BadgeTest.php +++ b/tests/phpunit/Unit/Components/BadgeTest.php @@ -4,7 +4,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Badge; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use \MWException; +use MWException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Badge diff --git a/tests/phpunit/Unit/Components/ButtonTest.php b/tests/phpunit/Unit/Components/ButtonTest.php index da6e560..066545c 100644 --- a/tests/phpunit/Unit/Components/ButtonTest.php +++ b/tests/phpunit/Unit/Components/ButtonTest.php @@ -4,7 +4,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Button; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use \MWException; +use MWException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Button diff --git a/tests/phpunit/Unit/Components/CardTest.php b/tests/phpunit/Unit/Components/CardTest.php index f7d4563..e517929 100644 --- a/tests/phpunit/Unit/Components/CardTest.php +++ b/tests/phpunit/Unit/Components/CardTest.php @@ -6,7 +6,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Card; use MediaWiki\Extension\BootstrapComponents\NestingController; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use \MWException; +use MWException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Card diff --git a/tests/phpunit/Unit/Components/CarouselTest.php b/tests/phpunit/Unit/Components/CarouselTest.php index 5be1384..87b4850 100644 --- a/tests/phpunit/Unit/Components/CarouselTest.php +++ b/tests/phpunit/Unit/Components/CarouselTest.php @@ -4,7 +4,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Carousel; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use \MWException; +use MWException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Carousel diff --git a/tests/phpunit/Unit/Components/CollapseTest.php b/tests/phpunit/Unit/Components/CollapseTest.php index 04c4ba9..39c631c 100644 --- a/tests/phpunit/Unit/Components/CollapseTest.php +++ b/tests/phpunit/Unit/Components/CollapseTest.php @@ -4,7 +4,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Collapse; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use \MWException; +use MWException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Collapse diff --git a/tests/phpunit/Unit/Components/JumbotronTest.php b/tests/phpunit/Unit/Components/JumbotronTest.php index 024457b..323eef9 100644 --- a/tests/phpunit/Unit/Components/JumbotronTest.php +++ b/tests/phpunit/Unit/Components/JumbotronTest.php @@ -4,7 +4,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Jumbotron; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use \MWException; +use MWException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Jumbotron diff --git a/tests/phpunit/Unit/Components/ModalTest.php b/tests/phpunit/Unit/Components/ModalTest.php index 3dd6f4b..ed95860 100644 --- a/tests/phpunit/Unit/Components/ModalTest.php +++ b/tests/phpunit/Unit/Components/ModalTest.php @@ -4,7 +4,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Modal; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use \MWException; +use MWException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Modal diff --git a/tests/phpunit/Unit/Components/PopoverTest.php b/tests/phpunit/Unit/Components/PopoverTest.php index ef44556..4f3b39b 100644 --- a/tests/phpunit/Unit/Components/PopoverTest.php +++ b/tests/phpunit/Unit/Components/PopoverTest.php @@ -4,7 +4,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Popover; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use \MWException; +use MWException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Popover diff --git a/tests/phpunit/Unit/Components/TooltipTest.php b/tests/phpunit/Unit/Components/TooltipTest.php index 8fee9eb..002ce55 100644 --- a/tests/phpunit/Unit/Components/TooltipTest.php +++ b/tests/phpunit/Unit/Components/TooltipTest.php @@ -5,7 +5,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Tooltip; use MediaWiki\Extension\BootstrapComponents\NestingController; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use \MWException; +use MWException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Tooltip diff --git a/tests/phpunit/Unit/ComponentsTestBase.php b/tests/phpunit/Unit/ComponentsTestBase.php index c7ef2ab..fe87f60 100644 --- a/tests/phpunit/Unit/ComponentsTestBase.php +++ b/tests/phpunit/Unit/ComponentsTestBase.php @@ -6,8 +6,8 @@ use MediaWiki\Extension\BootstrapComponents\NestingController; use MediaWiki\Extension\BootstrapComponents\ParserOutputHelper; use MediaWiki\Extension\BootstrapComponents\ParserRequest; +use MediaWiki\Parser\Parser; use PHPUnit\Framework\TestCase; -use Parser; use PPFrame; /** diff --git a/tests/phpunit/Unit/Hooks/OutputPageParserOutputTest.php b/tests/phpunit/Unit/Hooks/OutputPageParserOutputTest.php index 99f4bd6..1563d56 100644 --- a/tests/phpunit/Unit/Hooks/OutputPageParserOutputTest.php +++ b/tests/phpunit/Unit/Hooks/OutputPageParserOutputTest.php @@ -4,8 +4,8 @@ use MediaWiki\Extension\BootstrapComponents\BootstrapComponentsService; use MediaWiki\Extension\BootstrapComponents\Hooks\OutputPageParserOutput; -use OutputPage; -use ParserOutput; +use MediaWiki\Output\OutputPage; +use MediaWiki\Parser\ParserOutput; use PHPUnit\Framework\TestCase; /** diff --git a/tests/phpunit/Unit/Hooks/ParserFirstCallInitTest.php b/tests/phpunit/Unit/Hooks/ParserFirstCallInitTest.php index e1b32ea..9254e33 100644 --- a/tests/phpunit/Unit/Hooks/ParserFirstCallInitTest.php +++ b/tests/phpunit/Unit/Hooks/ParserFirstCallInitTest.php @@ -2,9 +2,9 @@ namespace MediaWiki\Extension\BootstrapComponents\Tests\Unit\Hooks; -use MediaWiki\Extension\BootstrapComponents\Hooks\ParserFirstCallInit as ParserFirstCallInit; use MediaWiki\Extension\BootstrapComponents\ComponentLibrary; -use \Parser; +use MediaWiki\Extension\BootstrapComponents\Hooks\ParserFirstCallInit; +use MediaWiki\Parser\Parser; use PHPUnit\Framework\TestCase; /** diff --git a/tests/phpunit/Unit/HooksHandlerTest.php b/tests/phpunit/Unit/HooksHandlerTest.php index 3d9867e..2ec97ad 100644 --- a/tests/phpunit/Unit/HooksHandlerTest.php +++ b/tests/phpunit/Unit/HooksHandlerTest.php @@ -6,8 +6,8 @@ use MediaWiki\Extension\BootstrapComponents\ComponentLibrary; use MediaWiki\Extension\BootstrapComponents\HooksHandler; use MediaWiki\Extension\BootstrapComponents\NestingController; -use Parser; -use ParserOutput; +use MediaWiki\Parser\Parser; +use MediaWiki\Parser\ParserOutput; use PHPUnit\Framework\TestCase; /** diff --git a/tests/phpunit/Unit/ImageModalTest.php b/tests/phpunit/Unit/ImageModalTest.php index b103247..296600a 100644 --- a/tests/phpunit/Unit/ImageModalTest.php +++ b/tests/phpunit/Unit/ImageModalTest.php @@ -2,17 +2,17 @@ namespace MediaWiki\Extension\BootstrapComponents\Tests\Unit; +use MediaWiki\Config\ConfigException; use File; use LocalFile; use MediaWiki\Extension\BootstrapComponents\BootstrapComponentsService; use MediaWiki\Extension\BootstrapComponents\ImageModal; -use \ConfigException; use MediaWiki\Extension\BootstrapComponents\NestingController; use MediaWiki\Extension\BootstrapComponents\ParserOutputHelper; -use \MediaWiki\MediaWikiServices; +use MediaWiki\MediaWikiServices; +use MediaWiki\Title\Title; use PHPUnit\Framework\TestCase; use ThumbnailImage; -use Title; /** * @covers \MediaWiki\Extension\BootstrapComponents\ImageModal diff --git a/tests/phpunit/Unit/ImageModalTriggerTest.php b/tests/phpunit/Unit/ImageModalTriggerTest.php index f80e549..c151541 100644 --- a/tests/phpunit/Unit/ImageModalTriggerTest.php +++ b/tests/phpunit/Unit/ImageModalTriggerTest.php @@ -3,7 +3,7 @@ namespace MediaWiki\Extension\BootstrapComponents\Tests\Unit; use MediaWiki\Extension\BootstrapComponents\ImageModalTrigger; -use \MediaWiki\MediaWikiServices; +use MediaWiki\MediaWikiServices; use PHPUnit\Framework\TestCase; /** diff --git a/tests/phpunit/Unit/ParserOutputHelperTest.php b/tests/phpunit/Unit/ParserOutputHelperTest.php index 5fda1a2..a5c4b9c 100644 --- a/tests/phpunit/Unit/ParserOutputHelperTest.php +++ b/tests/phpunit/Unit/ParserOutputHelperTest.php @@ -4,10 +4,9 @@ use MediaWiki\Extension\BootstrapComponents\ComponentLibrary; use MediaWiki\Extension\BootstrapComponents\ParserOutputHelper; -use \MWException; -// TODO: when dropping 1.39, switch to MediaWiki\Parser\Parser and MediaWiki\Parser\ParserOutput -use Parser; -use ParserOutput; +use MediaWiki\Parser\Parser; +use MediaWiki\Parser\ParserOutput; +use MWException; use PHPUnit\Framework\TestCase; /** diff --git a/tests/phpunit/Unit/ParserRequestTest.php b/tests/phpunit/Unit/ParserRequestTest.php index a448625..28bfb50 100644 --- a/tests/phpunit/Unit/ParserRequestTest.php +++ b/tests/phpunit/Unit/ParserRequestTest.php @@ -3,9 +3,9 @@ namespace MediaWiki\Extension\BootstrapComponents\Tests\Unit; use MediaWiki\Extension\BootstrapComponents\ParserRequest; +use MediaWiki\Parser\Parser; use PHPUnit\Framework\TestCase; -use \Parser; -use \PPFrame; +use PPFrame; /** * @covers \MediaWiki\Extension\BootstrapComponents\ParserRequest From 2e3e07070deb3c018bdef8271557ec93daa24404 Mon Sep 17 00:00:00 2001 From: Morne Alberts Date: Thu, 21 May 2026 14:31:29 +0200 Subject: [PATCH 03/11] Raise MediaWiki floor to 1.43, PHP floor to 8.1 The Bootstrap 5 migration lands on top of this PR; both rely on a modern MediaWiki and PHP. 1.39 went EOL in late 2024 and 8.0 in November 2023, so neither floor is plausibly in use by current deployments. Co-Authored-By: Claude Opus 4.7 --- README.md | 4 ++-- composer.json | 6 +++--- extension.json | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b4683f7..006bd9c 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,8 @@ configuration it can add a new [gallery][Gallery] mode, and replace normal [image rendering][Image] with an image modal. ## Requirements -* PHP 8.0 or later -* MediaWiki 1.39 or later +* PHP 8.1 or later +* MediaWiki 1.43 or later ## Documentation - [Installation and configuration](docs/installation-configuration.md) diff --git a/composer.json b/composer.json index 3691d76..9dce3f9 100644 --- a/composer.json +++ b/composer.json @@ -25,15 +25,15 @@ "source": "https://github.com/oetterer/BootstrapComponents" }, "require": { - "php": ">=8.0", + "php": ">=8.1", "composer/installers": "^2|^1.0.1", "mediawiki/bootstrap": "^5.0" }, "require-dev": { "mediawiki/mediawiki-codesniffer": "46.0.0", - "mediawiki/mediawiki-phan-config": "0.15.1", + "mediawiki/mediawiki-phan-config": "0.15.1", "phpmd/phpmd": "~2.1", - "php": ">=8.0" + "php": ">=8.1" }, "suggest": { "mediawiki/scribunto": "Framework for embedding scripting languages into MediaWiki pages" diff --git a/extension.json b/extension.json index d1ae9c1..c099138 100644 --- a/extension.json +++ b/extension.json @@ -7,7 +7,7 @@ "license-name": "GPL-3.0-or-later", "type": "parserhook", "requires": { - "MediaWiki": ">= 1.39.0" + "MediaWiki": ">= 1.43.0" }, "ConfigRegistry": { "BootstrapComponents": "GlobalVarConfig::newInstance" From 940d3d367872c31e6bd3c87fd11c4211f6d1dec1 Mon Sep 17 00:00:00 2001 From: Morne Alberts Date: Thu, 21 May 2026 14:32:50 +0200 Subject: [PATCH 04/11] Drop pre-1.43 version guards With the floor at MediaWiki 1.43: * the `wgVersion < 1.39` init check in `BootstrapComponents::init()` is unreachable; remove it * PHPUnit 9+ ships with `assertMatchesRegularExpression()` on every supported version, so the `wgVersion < 1.40` branches that pick the deprecated `assertRegExp()` form across seven test files collapse to a single straight call Co-Authored-By: Claude Opus 4.7 --- src/BootstrapComponents.php | 6 ---- tests/phpunit/Unit/AbstractComponentTest.php | 10 ++----- tests/phpunit/Unit/Components/AlertTest.php | 16 +++------- tests/phpunit/Unit/Components/ButtonTest.php | 29 +++++-------------- tests/phpunit/Unit/ImageModalTest.php | 22 +++++--------- tests/phpunit/Unit/ImageModalTriggerTest.php | 16 +++------- tests/phpunit/Unit/ParserOutputHelperTest.php | 13 +++------ 7 files changed, 28 insertions(+), 84 deletions(-) diff --git a/src/BootstrapComponents.php b/src/BootstrapComponents.php index 8c7b224..df56707 100644 --- a/src/BootstrapComponents.php +++ b/src/BootstrapComponents.php @@ -86,12 +86,6 @@ public static function init( array $info ) { throw new MWException( 'This file is part of a Mediawiki Extension, it is not a valid entry point.' ); } - if ( version_compare( $GLOBALS[ 'wgVersion' ], '1.39', 'lt' ) ) { - echo 'Error: Bootstrap Components ' - . 'is only compatible with MediaWiki 1.39 or above. You need to upgrade MediaWiki first.' . PHP_EOL; - throw new MWException( 'BootstrapComponents detected an incompatible MediaWiki version. Exiting.' ); - } - // Using the constant as indicator to avoid class_exists if ( !\ExtensionRegistry::getInstance()->isLoaded('Bootstrap') ) { if ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' ) { diff --git a/tests/phpunit/Unit/AbstractComponentTest.php b/tests/phpunit/Unit/AbstractComponentTest.php index 22c3ee4..c7a102a 100644 --- a/tests/phpunit/Unit/AbstractComponentTest.php +++ b/tests/phpunit/Unit/AbstractComponentTest.php @@ -120,14 +120,8 @@ public function testSimpleOutput( string $component ) { } $this->assertIsString( $parsedString ); - // TODO when we drop support for MW1.39 - if ( version_compare( $GLOBALS['wgVersion'], '1.40', 'lt' ) ) { - $this->assertRegExp( '/class="[^"]*test-class"/', $parsedString ); - $this->assertRegExp( '/style="[^"]*color:black"/', $parsedString ); - } else { - $this->assertMatchesRegularExpression( '/class="[^"]*test-class"/', $parsedString ); - $this->assertMatchesRegularExpression( '/style="[^"]*color:black"/', $parsedString ); - } + $this->assertMatchesRegularExpression( '/class="[^"]*test-class"/', $parsedString ); + $this->assertMatchesRegularExpression( '/style="[^"]*color:black"/', $parsedString ); } /** diff --git a/tests/phpunit/Unit/Components/AlertTest.php b/tests/phpunit/Unit/Components/AlertTest.php index 192119d..60beba1 100644 --- a/tests/phpunit/Unit/Components/AlertTest.php +++ b/tests/phpunit/Unit/Components/AlertTest.php @@ -57,18 +57,10 @@ public function testCanRender( $input, $arguments, $expectedOutput ) { $generatedOutput = $instance->parseComponent( $parserRequest ); - // TODO when we drop support for MW1.39 - if ( version_compare( $GLOBALS['wgVersion'], '1.40', 'lt' ) ) { - $this->assertRegExp( - '~^' . $this->input . '()?$~', - $generatedOutput - ); - } else { - $this->assertMatchesRegularExpression( - '~^' . $this->input . '()?$~', - $generatedOutput - ); - } + $this->assertMatchesRegularExpression( + '~^' . $this->input . '()?$~', + $generatedOutput + ); $this->assertEquals( $expectedOutput, $generatedOutput ); } diff --git a/tests/phpunit/Unit/Components/ButtonTest.php b/tests/phpunit/Unit/Components/ButtonTest.php index 066545c..1f6a40f 100644 --- a/tests/phpunit/Unit/Components/ButtonTest.php +++ b/tests/phpunit/Unit/Components/ButtonTest.php @@ -60,12 +60,7 @@ public function testCanRender( $input, $arguments, $expectedOutputPattern ) { $generatedOutput = $generatedOutput[0]; } - // TODO when we drop support for MW1.39 - if ( version_compare( $GLOBALS['wgVersion'], '1.40', 'lt' ) ) { - $this->assertRegExp( $expectedOutputPattern, $generatedOutput ); - } else { - $this->assertMatchesRegularExpression( $expectedOutputPattern, $generatedOutput ); - } + $this->assertMatchesRegularExpression( $expectedOutputPattern, $generatedOutput ); } /** @@ -93,22 +88,12 @@ public function testCanInjectRawAttributes() { $generatedOutput = $generatedOutput[0]; } - // TODO when we drop support for MW1.39 - if ( version_compare( $GLOBALS['wgVersion'], '1.40', 'lt' ) ) { - $this->assertRegExp( - '~^' . $this->input . '$~', - $generatedOutput - ); - } else { - $this->assertMatchesRegularExpression( - '~^' . $this->input . '$~', - $generatedOutput - ); - } + $this->assertMatchesRegularExpression( + '~^' . $this->input . '$~', + $generatedOutput + ); } /** diff --git a/tests/phpunit/Unit/ImageModalTest.php b/tests/phpunit/Unit/ImageModalTest.php index 296600a..155a781 100644 --- a/tests/phpunit/Unit/ImageModalTest.php +++ b/tests/phpunit/Unit/ImageModalTest.php @@ -262,21 +262,13 @@ function( $component ) { $resultOfParseCall = $instance->parse( $fp, $hp, $time, $res ); - if ( version_compare( $GLOBALS['wgVersion'], '1.40', 'lt' ) ) { - $this->assertRegExp( - $expectedTrigger, - $resultOfParseCall ?: $res, - 'failed with test data:' . $this->generatePhpCodeForManualProviderDataOneCase( $fp, $hp ) - ); - } else { - $this->assertMatchesRegularExpression( - $expectedTrigger, - $resultOfParseCall ?: $res, - 'failed with test data:' . $this->generatePhpCodeForManualProviderDataOneCase( $fp, $hp ) - . '++ ' . $expectedTrigger . PHP_EOL - . '-- ' . ($resultOfParseCall ?: $res) - ); - } + $this->assertMatchesRegularExpression( + $expectedTrigger, + $resultOfParseCall ?: $res, + 'failed with test data:' . $this->generatePhpCodeForManualProviderDataOneCase( $fp, $hp ) + . '++ ' . $expectedTrigger . PHP_EOL + . '-- ' . ($resultOfParseCall ?: $res) + ); $this->assertStringContainsString( $expectedModal, $resultOfParseCall ?: $res, diff --git a/tests/phpunit/Unit/ImageModalTriggerTest.php b/tests/phpunit/Unit/ImageModalTriggerTest.php index c151541..99aabfd 100644 --- a/tests/phpunit/Unit/ImageModalTriggerTest.php +++ b/tests/phpunit/Unit/ImageModalTriggerTest.php @@ -107,18 +107,10 @@ function( $params ) { $resultOfParseCall = $instance->generate( $sfp, $hp ); foreach ( $expectedRegExp as $regExp ) { - // TODO when we drop support for MW1.39 - if ( version_compare( $GLOBALS['wgVersion'], '1.40', 'lt' ) ) { - $this->assertRegExp( - $regExp, $resultOfParseCall, - 'failed with test data:' . $this->generatePhpCodeForManualProviderDataOneCase( $sfp, $hp ) - ); - } else { - $this->assertMatchesRegularExpression( - $regExp, $resultOfParseCall, - 'failed with test data:' . $this->generatePhpCodeForManualProviderDataOneCase( $sfp, $hp ) - ); - } + $this->assertMatchesRegularExpression( + $regExp, $resultOfParseCall, + 'failed with test data:' . $this->generatePhpCodeForManualProviderDataOneCase( $sfp, $hp ) + ); } } diff --git a/tests/phpunit/Unit/ParserOutputHelperTest.php b/tests/phpunit/Unit/ParserOutputHelperTest.php index a5c4b9c..aaeeac9 100644 --- a/tests/phpunit/Unit/ParserOutputHelperTest.php +++ b/tests/phpunit/Unit/ParserOutputHelperTest.php @@ -89,15 +89,10 @@ public function testCanRenderErrorMessage( $messageText, string $renderedMessage $this->buildFullyEquippedParser( ( $renderedMessageRegExp != '~^$~' ) ) ); - // TODO when we drop support for MW1.39 - if ( version_compare( $GLOBALS['wgVersion'], '1.40', 'lt' ) ) { - $this->assertRegExp( $renderedMessageRegExp, $instance->renderErrorMessage( $messageText ) ); - } else { - $this->assertMatchesRegularExpression( - $renderedMessageRegExp, - $instance->renderErrorMessage( $messageText ) - ); - } + $this->assertMatchesRegularExpression( + $renderedMessageRegExp, + $instance->renderErrorMessage( $messageText ) + ); } From 2edc7d85427861a06916fbc61068ab96e4df8b1e Mon Sep 17 00:00:00 2001 From: Morne Alberts Date: Thu, 21 May 2026 14:33:19 +0200 Subject: [PATCH 05/11] Switch HooksHandler property declarations from var to private `var` was PHP 4 syntax kept around for back-compat; under PHP 5+ it behaves identically to `public`. The four fields here are only consumed through their accessor methods on the same class. Make that explicit with `private`, matching the rest of the codebase. Co-Authored-By: Claude Opus 4.7 --- src/HooksHandler.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/HooksHandler.php b/src/HooksHandler.php index 570dc1c..3a1df73 100644 --- a/src/HooksHandler.php +++ b/src/HooksHandler.php @@ -48,22 +48,22 @@ class HooksHandler implements /** * @var Config */ - var Config $config; + private Config $config; /** * @var BootstrapComponentsService */ - var BootstrapComponentsService $bootstrapComponentsService; + private BootstrapComponentsService $bootstrapComponentsService; /** * @var ComponentLibrary */ - var ComponentLibrary $componentLibrary; + private ComponentLibrary $componentLibrary; /** * @var NestingController */ - var NestingController $nestingController; + private NestingController $nestingController; public function __construct( BootstrapComponentsService $bootstrapComponentsService, ComponentLibrary $componentLibrary, From d0af5ed8c1da069b39760c04f8a5b8c466441c74 Mon Sep 17 00:00:00 2001 From: Morne Alberts Date: Thu, 21 May 2026 14:34:01 +0200 Subject: [PATCH 06/11] Drop leading backslash from remaining test import The namespace-modernisation commit migrated the bulk of `use \X;` imports to their unprefixed form; this is the one that was missed. Co-Authored-By: Claude Opus 4.7 --- tests/phpunit/Unit/LuaLibraryTestBase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/Unit/LuaLibraryTestBase.php b/tests/phpunit/Unit/LuaLibraryTestBase.php index 971548b..e7de6d3 100644 --- a/tests/phpunit/Unit/LuaLibraryTestBase.php +++ b/tests/phpunit/Unit/LuaLibraryTestBase.php @@ -3,7 +3,7 @@ namespace MediaWiki\Extension\BootstrapComponents\Tests\Unit; use MediaWiki\Extension\BootstrapComponents\LuaLibrary; -use \Scribunto_LuaEngineTestBase; +use Scribunto_LuaEngineTestBase; /** * @ingroup Test From 75371a066b8fa536ce635623b1e5170788194b04 Mon Sep 17 00:00:00 2001 From: Morne Alberts Date: Thu, 21 May 2026 14:36:00 +0200 Subject: [PATCH 07/11] Replace MWException with RuntimeException MWException has been deprecated since MediaWiki 1.40, with the recommendation to use native exception types or a domain-specific subclass. Replace every existing throw, catch, expectException, docblock, and import. The exception sites here are all programming-error cases (invalid arguments, broken invariants), so RuntimeException is the natural fit. Co-Authored-By: Claude Opus 4.7 --- src/AbstractComponent.php | 8 ++++---- src/ApplicationFactory.php | 16 +++++++-------- src/BootstrapComponents.php | 4 ++-- src/CarouselGallery.php | 4 ++-- src/ComponentLibrary.php | 20 +++++++++---------- src/Components/Card.php | 4 ++-- src/Components/Collapse.php | 4 ++-- src/Hooks/ParserFirstCallInit.php | 4 ++-- src/HooksHandler.php | 4 ++-- src/ImageModal.php | 6 +++--- src/LuaLibrary.php | 8 ++++---- src/NestingController.php | 12 +++++------ src/ParserRequest.php | 16 +++++++-------- ...ComponentsJsonTestCaseScriptRunnerTest.php | 2 +- tests/phpunit/Unit/AbstractComponentTest.php | 10 +++++----- tests/phpunit/Unit/ApplicationFactoryTest.php | 13 ++++++------ tests/phpunit/Unit/CarouselGalleryTest.php | 4 ++-- tests/phpunit/Unit/ComponentLibraryTest.php | 13 ++++++------ .../phpunit/Unit/Components/AccordionTest.php | 6 +++--- tests/phpunit/Unit/Components/AlertTest.php | 6 +++--- tests/phpunit/Unit/Components/BadgeTest.php | 6 +++--- tests/phpunit/Unit/Components/ButtonTest.php | 8 ++++---- tests/phpunit/Unit/Components/CardTest.php | 8 ++++---- .../phpunit/Unit/Components/CarouselTest.php | 6 +++--- .../phpunit/Unit/Components/CollapseTest.php | 6 +++--- .../phpunit/Unit/Components/JumbotronTest.php | 6 +++--- tests/phpunit/Unit/Components/ModalTest.php | 6 +++--- tests/phpunit/Unit/Components/PopoverTest.php | 6 +++--- tests/phpunit/Unit/Components/TooltipTest.php | 6 +++--- tests/phpunit/Unit/ImageModalTest.php | 12 +++++------ tests/phpunit/Unit/LuaLibraryTestBase.php | 2 +- tests/phpunit/Unit/NestingControllerTest.php | 15 +++++++------- tests/phpunit/Unit/ParserOutputHelperTest.php | 4 ++-- tests/phpunit/Unit/ParserRequestTest.php | 7 ++++--- 34 files changed, 133 insertions(+), 129 deletions(-) diff --git a/src/AbstractComponent.php b/src/AbstractComponent.php index def8300..53f8df7 100644 --- a/src/AbstractComponent.php +++ b/src/AbstractComponent.php @@ -27,7 +27,7 @@ namespace MediaWiki\Extension\BootstrapComponents; use MediaWiki\MediaWikiServices; -use MWException; +use RuntimeException; /** * Class AbstractComponent @@ -107,7 +107,7 @@ abstract protected function placeMe( $input ); * @param ParserOutputHelper $parserOutputHelper * @param NestingController $nestingController * - * @throws MWException cascading {@see ComponentLibrary::getNameFor} or {@see Component::extractAttribute} + * @throws RuntimeException cascading {@see ComponentLibrary::getNameFor} or {@see Component::extractAttribute} */ public function __construct( $componentLibrary, $parserOutputHelper, $nestingController ) { $this->componentLibrary = $componentLibrary; @@ -144,14 +144,14 @@ public function getId() { /** * @param ParserRequest $parserRequest ; * - * @throws MWException self or cascading from {@see Component::processArguments} + * @throws RuntimeException self or cascading from {@see Component::processArguments} * or {@see NestingController::close} * * @return string|array */ public function parseComponent( $parserRequest ) { if ( !is_a( $parserRequest, ParserRequest::class ) ) { - throw new MWException( 'Invalid ParserRequest supplied to component ' . $this->getComponentName() . '!' ); + throw new RuntimeException( 'Invalid ParserRequest supplied to component ' . $this->getComponentName() . '!' ); } $this->getNestingController()->open( $this ); MediaWikiServices::getInstance() diff --git a/src/ApplicationFactory.php b/src/ApplicationFactory.php index 852e38d..d8eff3b 100644 --- a/src/ApplicationFactory.php +++ b/src/ApplicationFactory.php @@ -28,7 +28,7 @@ use MediaWiki\Logger\LoggerFactory; use MediaWiki\MediaWikiServices; -use MWException; +use RuntimeException; use ReflectionClass; /** @@ -126,7 +126,7 @@ public function getNewModalBuilder( * * @see ParserRequest::__construct * - * @throws \MWException cascading {@see ParserRequest::__construct} + * @throws RuntimeException cascading {@see ParserRequest::__construct} * * @return ParserRequest */ @@ -141,7 +141,7 @@ public function getNewParserRequest( * * @see ParserOutputHelper * - * @throws MWException cascading {@see ApplicationFactory::getApplication} + * @throws RuntimeException cascading {@see ApplicationFactory::getApplication} * * @return ParserOutputHelper */ @@ -158,7 +158,7 @@ public function getParserOutputHelper( $parser = null ) { * @param string $name * @param string $class * - * @throws MWException when class to register does not exist + * @throws RuntimeException when class to register does not exist * * @return bool */ @@ -169,7 +169,7 @@ public function registerApplication( string $name, string $class ): bool { $this->applicationClassRegister[$application] = $applicationClass; return true; } elseif ( $application != '' ) { - throw new MWException( 'ApplicationFactory was requested to register non existing class "' . $applicationClass . '"!' ); + throw new RuntimeException( 'ApplicationFactory was requested to register non existing class "' . $applicationClass . '"!' ); } $this->getLogger()->error( 'ApplicationFactory was requested to register invalid application for class ' . $applicationClass . '!' ); return false; @@ -200,7 +200,7 @@ public function resetLookup( ?string $application = null ): bool { * * @param string $name * - * @throws MWException when no class is registered for the requested application or the creation of the object fails. + * @throws RuntimeException when no class is registered for the requested application or the creation of the object fails. * * @return object */ @@ -209,7 +209,7 @@ protected function getApplication( $name ): object { return $this->applicationStore[$name]; } if ( !isset( $this->applicationClassRegister[$name] ) ) { - throw new MWException( 'ApplicationFactory was requested to return application "' . $name . '". No appropriate class registered!' ); + throw new RuntimeException( 'ApplicationFactory was requested to return application "' . $name . '". No appropriate class registered!' ); } $args = func_get_args(); array_shift( $args ); # because, we already used the first argument $name @@ -217,7 +217,7 @@ protected function getApplication( $name ): object { try { $objectReflection = new ReflectionClass( $this->applicationClassRegister[$name] ); } catch ( \ReflectionException $e ) { - throw new MWException( + throw new RuntimeException( 'Error while trying to build application "' . $name . '" with class ' . $this->applicationClassRegister[$name] ); } diff --git a/src/BootstrapComponents.php b/src/BootstrapComponents.php index df56707..69ff801 100644 --- a/src/BootstrapComponents.php +++ b/src/BootstrapComponents.php @@ -44,7 +44,7 @@ namespace MediaWiki\Extension\BootstrapComponents; use Exception; -use MWException; +use RuntimeException; /** * Provides methods to register, when installed by composer @@ -83,7 +83,7 @@ public static function init( array $info ) { if ( !defined( 'MEDIAWIKI' ) ) { echo 'This file is part of the Mediawiki extension BootstrapComponents, it is not a valid entry point.' . PHP_EOL; - throw new MWException( 'This file is part of a Mediawiki Extension, it is not a valid entry point.' ); + throw new RuntimeException( 'This file is part of a Mediawiki Extension, it is not a valid entry point.' ); } // Using the constant as indicator to avoid class_exists diff --git a/src/CarouselGallery.php b/src/CarouselGallery.php index 764b7b6..bde9c1a 100644 --- a/src/CarouselGallery.php +++ b/src/CarouselGallery.php @@ -43,7 +43,7 @@ class CarouselGallery extends ImageGalleryBase { * * @param ParserOutputHelper $parserOutputHelper used for unit tests * - * @throws \MWException cascading {@see CarouselGallery::constructCarouselParserRequest} and {@see AbstractComponent::parseComponent} + * @throws RuntimeException cascading {@see CarouselGallery::constructCarouselParserRequest} and {@see AbstractComponent::parseComponent} * @return string */ public function toHTML( $parserOutputHelper = null ) { @@ -160,7 +160,7 @@ private function convertImages( $imageList, $parser = null, $hideBadImages = tru * From array of supplies images and some other object properties, this constructs a parser request object, * to be used in the carousel component. * - * @throws \MWException cascading {@see ApplicationFactory::getNewParserRequest} + * @throws RuntimeException cascading {@see ApplicationFactory::getNewParserRequest} * * @return false|ParserRequest returns false, if no valid images were detected */ diff --git a/src/ComponentLibrary.php b/src/ComponentLibrary.php index c496968..4ded55e 100644 --- a/src/ComponentLibrary.php +++ b/src/ComponentLibrary.php @@ -26,7 +26,7 @@ namespace MediaWiki\Extension\BootstrapComponents; -use MWException; +use RuntimeException; /** * Class ComponentLibrary @@ -136,7 +136,7 @@ public function compileMagicWordsArray(): array { * @param string $componentIdentifier * * @return array - * @throws MWException provided component is not known + * @throws RuntimeException provided component is not known */ public function getAliasesFor( string $componentIdentifier ): array { return $this->accessComponentDataStore( $componentIdentifier, 'aliases' ); @@ -148,7 +148,7 @@ public function getAliasesFor( string $componentIdentifier ): array { * @param string $componentIdentifier * * @return array - * @throws MWException provided component is not known + * @throws RuntimeException provided component is not known */ public function getAttributesFor( string $componentIdentifier ): array { return $this->accessComponentDataStore( $componentIdentifier, 'attributes' ); @@ -160,7 +160,7 @@ public function getAttributesFor( string $componentIdentifier ): array { * @param string $componentIdentifier * * @return string - * @throws MWException provided component is not known + * @throws RuntimeException provided component is not known */ public function getClassFor( string $componentIdentifier ): string { return $this->accessComponentDataStore( $componentIdentifier, 'class' ); @@ -180,7 +180,7 @@ public function getClassFor( string $componentIdentifier ): string { public function getHandlerTypeFor( string $componentIdentifier ): string { try { return $this->accessComponentDataStore( $componentIdentifier, 'handlerType' ); - } catch ( MWException $e ) { + } catch ( RuntimeException $e ) { return 'UNKNOWN'; } } @@ -205,7 +205,7 @@ public function getKnownComponents(): array { */ public function getModulesFor( string $componentIdentifier, ?string $skin = null ): array { if ( !$this->isKnown( $componentIdentifier ) ) { - // this prevents us from running into a MWException in the next call. + // this prevents us from running into a RuntimeException in the next call. return []; } $allModules = $this->accessComponentDataStore( $componentIdentifier, 'modules' ); @@ -227,7 +227,7 @@ public function getModulesFor( string $componentIdentifier, ?string $skin = null * * @param string $componentClass * - * @throws MWException if supplied class is not registered + * @throws RuntimeException if supplied class is not registered * * @return string */ @@ -241,7 +241,7 @@ public function getNameFor( string $componentClass ): string { } } if ( is_null( $component ) ) { - throw new MWException( 'Trying to get a component name for unregistered class "' . (string) $componentClass . '"!' ); + throw new RuntimeException( 'Trying to get a component name for unregistered class "' . (string) $componentClass . '"!' ); } return $this->accessComponentDataStore( $component, 'name' ); } @@ -301,13 +301,13 @@ public function isTagExtension( string $componentName ): bool { * @param string $componentIdentifier * @param string $field * - * @throws MWException on non-existing $componentIdentifier or $field + * @throws RuntimeException on non-existing $componentIdentifier or $field * * @return mixed */ protected function accessComponentDataStore( string $componentIdentifier, string $field ): mixed { if ( !isset( $this->getComponentDataStore()[$componentIdentifier][$field] ) ) { - throw new MWException( + throw new RuntimeException( 'Trying to access undefined field \'' . $field . '\' of component \'' . $componentIdentifier . '\'. Aborting' ); } diff --git a/src/Components/Card.php b/src/Components/Card.php index 61d97fb..d651584 100644 --- a/src/Components/Card.php +++ b/src/Components/Card.php @@ -31,7 +31,7 @@ use MediaWiki\Extension\BootstrapComponents\NestingController; use MediaWiki\Extension\BootstrapComponents\ParserOutputHelper; use MediaWiki\Html\Html; -use MWException; +use RuntimeException; /** * Class Card @@ -64,7 +64,7 @@ class Card extends AbstractComponent { * @param ParserOutputHelper $parserOutputHelper * @param NestingController $nestingController * - * @throws MWException + * @throws RuntimeException */ public function __construct( $componentLibrary, $parserOutputHelper, $nestingController ) { parent::__construct( $componentLibrary, $parserOutputHelper, $nestingController ); diff --git a/src/Components/Collapse.php b/src/Components/Collapse.php index ecd9aa5..2321f6d 100644 --- a/src/Components/Collapse.php +++ b/src/Components/Collapse.php @@ -30,7 +30,7 @@ use MediaWiki\Extension\BootstrapComponents\ApplicationFactory; use MediaWiki\Extension\BootstrapComponents\ParserRequest; use MediaWiki\Html\Html; -use MWException; +use RuntimeException; /** * Class Collapse @@ -69,7 +69,7 @@ protected function placeMe( $input ) { * * @param ParserRequest $parserRequest * - * @throws MWException cascading {@see \BootstrapComponents\Component::parseComponent} + * @throws RuntimeException cascading {@see \BootstrapComponents\Component::parseComponent} * @return string */ private function generateButton( ParserRequest $parserRequest ) { diff --git a/src/Hooks/ParserFirstCallInit.php b/src/Hooks/ParserFirstCallInit.php index 888ce71..007a292 100644 --- a/src/Hooks/ParserFirstCallInit.php +++ b/src/Hooks/ParserFirstCallInit.php @@ -72,7 +72,7 @@ class ParserFirstCallInit { * @param ComponentLibrary $componentLibrary * @param NestingController $nestingController * - * @throws \MWException cascading {@see \BootstrapComponents\ApplicationFactory::getParserOutputHelper} + * @throws RuntimeException cascading {@see \BootstrapComponents\ApplicationFactory::getParserOutputHelper} */ public function __construct( $parser, $componentLibrary, $nestingController ) { $this->componentLibrary = $componentLibrary; @@ -82,7 +82,7 @@ public function __construct( $parser, $componentLibrary, $nestingController ) { } /** - * @throws \MWException cascading {@see \Parser::setFunctionHook} and {@see Parser::setHook} + * @throws RuntimeException cascading {@see \Parser::setFunctionHook} and {@see Parser::setHook} * * @return bool */ diff --git a/src/HooksHandler.php b/src/HooksHandler.php index 3a1df73..94e7c3c 100644 --- a/src/HooksHandler.php +++ b/src/HooksHandler.php @@ -131,7 +131,7 @@ public function onGalleryGetModes( &$modeArray ): bool { * @param Parser $parser * @param string &$query * @param null|int &$widthOption - * @throws \MWException + * @throws RuntimeException */ public function onImageBeforeProduceHTML( $linker, &$title, &$file, &$frameParams, &$handlerParams, &$time, &$res, $parser, &$query, &$widthOption @@ -242,7 +242,7 @@ public function onParserAfterParse( $parser, &$text, $stripState ): bool { * @param Parser $parser * * @return bool - * @throws \MWException + * @throws RuntimeException */ public function onParserFirstCallInit( $parser ): bool { $hook = new ParserFirstCallInit( $parser, $this->getComponentLibrary(), $this->getNestingController() ); diff --git a/src/ImageModal.php b/src/ImageModal.php index 8b78d72..931f789 100644 --- a/src/ImageModal.php +++ b/src/ImageModal.php @@ -31,7 +31,7 @@ use MediaWiki\Html\Html; use MediaWiki\MediaWikiServices; use MediaWiki\Title\Title; -use MWException; +use RuntimeException; /** * Class ImageModal @@ -98,7 +98,7 @@ class ImageModal implements NestableInterface { * @param BootstrapComponentsService $bootstrapComponentService * @param ParserOutputHelper|null $parserOutputHelper DI for unit testing * - * @throws MWException cascading {@see ApplicationFactory} methods + * @throws RuntimeException cascading {@see ApplicationFactory} methods */ public function __construct( $null, Title $title, File $file, @@ -162,7 +162,7 @@ public function getId() { * @param string|bool $time Timestamp of the file, set as false for current * @param string $res Final HTML output, used if this returns false * - * @throws MWException cascading {@see NestingController::open} + * @throws RuntimeException cascading {@see NestingController::open} * @throws \ConfigException cascading {@see ImageModal::generateTrigger} * * @return bool diff --git a/src/LuaLibrary.php b/src/LuaLibrary.php index 73a4d0d..1f21d0e 100644 --- a/src/LuaLibrary.php +++ b/src/LuaLibrary.php @@ -29,7 +29,7 @@ use MediaWiki\Extension\Scribunto\Engines\LuaCommon\LibraryBase; use MediaWiki\Extension\Scribunto\Engines\LuaCommon\LuaEngine; use MediaWiki\MediaWikiServices; -use MWException; +use RuntimeException; use ReflectionClass; use ReflectionException; @@ -84,7 +84,7 @@ public function register(): array { * @return string[] * * Note: Please refrain from using Type hints in function signature. Will break tests! - *@throws MWException + *@throws RuntimeException * * @throws ReflectionException */ @@ -125,7 +125,7 @@ public function getSkin(): array { * @param null|string $component * * @return ParserRequest - *@throws MWException + *@throws RuntimeException * */ protected function buildParserRequest( @@ -142,7 +142,7 @@ protected function buildParserRequest( /** * @param string $componentClass * - * @throws MWException + * @throws RuntimeException * @throws ReflectionException * * @return AbstractComponent diff --git a/src/NestingController.php b/src/NestingController.php index b1b670b..3e84ddf 100644 --- a/src/NestingController.php +++ b/src/NestingController.php @@ -27,7 +27,7 @@ namespace MediaWiki\Extension\BootstrapComponents; use MediaWiki\MediaWikiServices; -use MWException; +use RuntimeException; /** * Class NestingController @@ -72,15 +72,15 @@ public function __construct() { * * @param string|false $id id of the current object we are trying to close * - * @throws MWException if current and closing component is different + * @throws RuntimeException if current and closing component is different */ public function close( $id ): void { $current = $this->getCurrentElement(); if ( !$current ) { - throw new MWException( 'Nesting error. Tried to close an empty stack.' ); + throw new RuntimeException( 'Nesting error. Tried to close an empty stack.' ); } if ( $id === false || ($current->getId() != $id) ) { - throw new MWException( 'Nesting error. Trying to close a component that is not the currently open one.' ); + throw new RuntimeException( 'Nesting error. Trying to close a component that is not the currently open one.' ); } array_pop( $this->componentStack ); } @@ -124,11 +124,11 @@ public function getStackSize(): int { * * @param NestableInterface $nestable * - * @throws MWException when open is called with an invalid object + * @throws RuntimeException when open is called with an invalid object */ public function open( mixed &$nestable ): void { if ( !$nestable instanceof NestableInterface ) { - throw new MWException( 'Nesting error. Trying to put an object other than a Component an the nesting stack.' ); + throw new RuntimeException( 'Nesting error. Trying to put an object other than a Component an the nesting stack.' ); } $this->componentStack[] = $nestable; } diff --git a/src/ParserRequest.php b/src/ParserRequest.php index 691f9ae..53341a8 100644 --- a/src/ParserRequest.php +++ b/src/ParserRequest.php @@ -27,7 +27,7 @@ namespace MediaWiki\Extension\BootstrapComponents; use MediaWiki\Parser\Parser; -use MWException; +use RuntimeException; use PPFrame; /** @@ -70,7 +70,7 @@ class ParserRequest { * * @see ApplicationFactory::getNewParserRequest * - * @throws MWException + * @throws RuntimeException */ public function __construct( array $argumentsPassedByParser, bool $isParserFunction, string $componentName = 'unknown' @@ -79,10 +79,10 @@ public function __construct( $this->processArguments( $argumentsPassedByParser, $isParserFunction, $componentName ); $this->attributes = (array)$attributes; if ( !$parser || !is_a( $parser, 'Parser' ) ) { - throw new MWException( 'Invalid parser object passed to component ' . $componentName . '!' ); + throw new RuntimeException( 'Invalid parser object passed to component ' . $componentName . '!' ); } if ( $frame && !is_a( $frame, 'PPFrame' ) ) { - throw new MWException( 'Invalid frame object passed to component ' . $componentName . '!' ); + throw new RuntimeException( 'Invalid frame object passed to component ' . $componentName . '!' ); } $this->parser = $parser; $this->frame = $frame; @@ -142,7 +142,7 @@ public function getParser(): Parser { * @param array $options * @param string $componentName * - * @throws MWException + * @throws RuntimeException * @return array $results */ private function extractParserFunctionOptions( array $options, string $componentName ): array { @@ -152,7 +152,7 @@ private function extractParserFunctionOptions( array $options, string $component $results = []; foreach ( $options as $option ) { if ( !is_string( $option ) ) { - throw new MWException( + throw new RuntimeException( 'Arguments passed to bootstrap component "' . $componentName . '" are invalid!' ); } @@ -194,7 +194,7 @@ private function getKeyValuePairFrom( string $option ): array { * @param bool $isParserFunction * @param string $componentName * - * @throws MWException if argument list does not match handler type or unknown handler type detected + * @throws RuntimeException if argument list does not match handler type or unknown handler type detected * @return array array consisting of (string) $input, (array) $options, (Parser) $parser, and optional (PPFrame) $frame */ private function processArguments( @@ -210,7 +210,7 @@ private function processArguments( return [ $input, $attributes, $parser, null ]; } else { if ( count( $argumentsPassedByParser ) != 4 ) { - throw new MWException( + throw new RuntimeException( 'Argument list passed to bootstrap tag component "' . $componentName . '" is invalid!' ); } diff --git a/tests/phpunit/Integration/JSONScript/BootstrapComponentsJsonTestCaseScriptRunnerTest.php b/tests/phpunit/Integration/JSONScript/BootstrapComponentsJsonTestCaseScriptRunnerTest.php index e1e44d5..bf19815 100644 --- a/tests/phpunit/Integration/JSONScript/BootstrapComponentsJsonTestCaseScriptRunnerTest.php +++ b/tests/phpunit/Integration/JSONScript/BootstrapComponentsJsonTestCaseScriptRunnerTest.php @@ -42,7 +42,7 @@ class BootstrapComponentsJSONScriptTestCaseRunnerTest extends JSONScriptTestCase /** * @throws \ConfigException - * @throws \MWException + * @throws RuntimeException */ protected function setUp(): void { wfDebugLog( 'BootstrapComponents', 'Running the JSONScriptTestCaseRunnerTest setup.' ); diff --git a/tests/phpunit/Unit/AbstractComponentTest.php b/tests/phpunit/Unit/AbstractComponentTest.php index c7a102a..7e03aa4 100644 --- a/tests/phpunit/Unit/AbstractComponentTest.php +++ b/tests/phpunit/Unit/AbstractComponentTest.php @@ -5,7 +5,7 @@ use MediaWiki\Extension\BootstrapComponents\AbstractComponent; use MediaWiki\Extension\BootstrapComponents\ComponentLibrary; use MediaWiki\Extension\BootstrapComponents\NestableInterface; -use MWException; +use RuntimeException; use PHPUnit\Framework\MockObject\Stub; /** @@ -75,7 +75,7 @@ public function testGetId() { } /** - * @throws MWException + * @throws RuntimeException */ public function testParseComponent() { $parserRequest = $this->buildParserRequest( @@ -96,7 +96,7 @@ public function testParseComponent() { /** * @param string $component * - * @throws MWException + * @throws RuntimeException * @dataProvider allComponentsProvider */ public function testSimpleOutput( string $component ) { @@ -127,7 +127,7 @@ public function testSimpleOutput( string $component ) { /** * @param string $component * - * @throws MWException + * @throws RuntimeException * @dataProvider allComponentsProvider */ public function testInvalidParserRequest( $component ) { @@ -138,7 +138,7 @@ public function testInvalidParserRequest( $component ) { $this->getParserOutputHelper(), $this->getNestingController() ); - $this->expectException( 'MWException' ); + $this->expectException( RuntimeException::class ); /** @noinspection PhpParamsInspection */ $instance->parseComponent( 'noParser' diff --git a/tests/phpunit/Unit/ApplicationFactoryTest.php b/tests/phpunit/Unit/ApplicationFactoryTest.php index b9c5da1..0af0eda 100644 --- a/tests/phpunit/Unit/ApplicationFactoryTest.php +++ b/tests/phpunit/Unit/ApplicationFactoryTest.php @@ -7,6 +7,7 @@ use MediaWiki\Extension\BootstrapComponents\ParserOutputHelper; use MediaWiki\Extension\BootstrapComponents\ParserRequest; use PHPUnit\Framework\TestCase; +use RuntimeException; /** * @covers \MediaWiki\Extension\BootstrapComponents\ApplicationFactory @@ -83,7 +84,7 @@ public function testGetNewModalBuilder() { * @param array $arguments * @param bool $isParserFunction * - * @throws \MWException + * @throws RuntimeException * * @dataProvider parserRequestProvider */ @@ -97,7 +98,7 @@ public function testGetNewParserRequest( $arguments, $isParserFunction ) { } /** - * @throws \MWException + * @throws RuntimeException */ public function testGetParserOutputHelper() { $instance = new ApplicationFactory(); @@ -120,13 +121,13 @@ public function testGetParserOutputHelper() { public function testFailingGetNewParserRequest( array $arguments, bool $isParserFunction ) { $instance = new ApplicationFactory(); - $this->expectException( 'MWException' ); + $this->expectException( RuntimeException::class ); $instance->getNewParserRequest( $arguments, $isParserFunction ); } /** - * @throws \MWException + * @throws RuntimeException */ public function testCanRegisterApplication() { $instance = new ApplicationFactory(); @@ -136,7 +137,7 @@ public function testCanRegisterApplication() { } /** - * @throws \MWException + * @throws RuntimeException */ public function testCanNotRegisterApplicationOnInvalidName() { $instance = new ApplicationFactory(); @@ -150,7 +151,7 @@ public function testCanNotRegisterApplicationOnInvalidName() { public function testCanNotRegisterApplicationOnInvalidClass() { $instance = new ApplicationFactory(); - $this->expectException( 'MWException' ); + $this->expectException( RuntimeException::class ); $instance->registerApplication( 'test', 'FooBar' ); } diff --git a/tests/phpunit/Unit/CarouselGalleryTest.php b/tests/phpunit/Unit/CarouselGalleryTest.php index 04b16d9..c6b134d 100644 --- a/tests/phpunit/Unit/CarouselGalleryTest.php +++ b/tests/phpunit/Unit/CarouselGalleryTest.php @@ -4,7 +4,7 @@ use MediaWiki\Extension\BootstrapComponents\CarouselGallery; use MediaWiki\Title\Title; -use MWException; +use RuntimeException; use PHPUnit\Framework\TestCase; /** @@ -35,7 +35,7 @@ public function testCanConstruct() { * @param array $additionalAttributes * @param string $expectedOutput * - * @throws MWException + * @throws RuntimeException * @dataProvider galleryDataProvider */ public function testToHtml( $imageList, $additionalAttributes, $expectedOutput ) { diff --git a/tests/phpunit/Unit/ComponentLibraryTest.php b/tests/phpunit/Unit/ComponentLibraryTest.php index ad3b531..a42251c 100644 --- a/tests/phpunit/Unit/ComponentLibraryTest.php +++ b/tests/phpunit/Unit/ComponentLibraryTest.php @@ -5,6 +5,7 @@ use MediaWiki\Config\ConfigException; use MediaWiki\Extension\BootstrapComponents\ComponentLibrary; use PHPUnit\Framework\TestCase; +use RuntimeException; /** * @covers \MediaWiki\Extension\BootstrapComponents\ComponentLibrary @@ -76,7 +77,7 @@ public function testIsRegistered( string $componentName ) { * @param string[] $expectedAliases * * @throws ConfigException - * @throws \MWException + * @throws RuntimeException * * @dataProvider componentAliasesProvider */ @@ -93,7 +94,7 @@ public function testGetAliasesFor( string $component, array $expectedAliases ) { * @param string[] $expectedAttributes * * @throws ConfigException - * @throws \MWException + * @throws RuntimeException * * @dataProvider componentAttributesProvider */ @@ -203,7 +204,7 @@ public function testGetModulesFor( string $componentName, ?string $skinName, arr * @param string $componentClass * * @throws ConfigException - * @throws \MWException + * @throws RuntimeException * * @dataProvider componentNameAndClassProvider */ @@ -242,7 +243,7 @@ public function testSetWhiteList( bool|array $whiteList, array $expectedComponen public function testFails( $method, $param ) { $instance = new ComponentLibrary(); - $this->expectException( 'MWException' ); + $this->expectException( RuntimeException::class ); call_user_func_array( [ $instance, $method ], [ $param ] ); } @@ -279,7 +280,7 @@ public function testRegisterVsKnown() { public function testUnknownComponentName() { $instance = new ComponentLibrary( true ); - $this->expectException( 'MWException' ); + $this->expectException( RuntimeException::class ); $instance->getClassFor( 'foobar' ); } @@ -289,7 +290,7 @@ public function testUnknownComponentName() { public function testUnknownComponentClass() { $instance = new ComponentLibrary( true ); - $this->expectException( 'MWException' ); + $this->expectException( RuntimeException::class ); $instance->getNameFor( '\BootstrapComponents\Components\Foobar' ); } diff --git a/tests/phpunit/Unit/Components/AccordionTest.php b/tests/phpunit/Unit/Components/AccordionTest.php index 5c08871..d57e07b 100644 --- a/tests/phpunit/Unit/Components/AccordionTest.php +++ b/tests/phpunit/Unit/Components/AccordionTest.php @@ -4,7 +4,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Accordion; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use MWException; +use RuntimeException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Accordion @@ -24,7 +24,7 @@ class AccordionTest extends ComponentsTestBase { private $input = 'Accordion test text'; /** - * @throws \MWException + * @throws RuntimeException */ public function testCanConstruct() { @@ -44,7 +44,7 @@ public function testCanConstruct() { * @param string $expectedOutput * * @dataProvider placeMeArgumentsProvider - * @throws MWException + * @throws RuntimeException */ public function testCanRender( $input, $arguments, $expectedOutput ) { $instance = new Accordion( diff --git a/tests/phpunit/Unit/Components/AlertTest.php b/tests/phpunit/Unit/Components/AlertTest.php index 60beba1..1046fa2 100644 --- a/tests/phpunit/Unit/Components/AlertTest.php +++ b/tests/phpunit/Unit/Components/AlertTest.php @@ -4,7 +4,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Alert; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use MWException; +use RuntimeException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Alert @@ -24,7 +24,7 @@ class AlertTest extends ComponentsTestBase { private $input = 'Alert test text'; /** - * @throws \MWException + * @throws RuntimeException */ public function testCanConstruct() { @@ -44,7 +44,7 @@ public function testCanConstruct() { * @param string $expectedOutput * * @dataProvider placeMeArgumentsProvider - * @throws MWException + * @throws RuntimeException */ public function testCanRender( $input, $arguments, $expectedOutput ) { $instance = new Alert( diff --git a/tests/phpunit/Unit/Components/BadgeTest.php b/tests/phpunit/Unit/Components/BadgeTest.php index c4bde3b..3c772b0 100644 --- a/tests/phpunit/Unit/Components/BadgeTest.php +++ b/tests/phpunit/Unit/Components/BadgeTest.php @@ -4,7 +4,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Badge; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use MWException; +use RuntimeException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Badge @@ -24,7 +24,7 @@ class BadgeTest extends ComponentsTestBase { private $input = 'Badge test text'; /** - * @throws \MWException + * @throws RuntimeException */ public function testCanConstruct() { @@ -44,7 +44,7 @@ public function testCanConstruct() { * @param string $expectedOutput * * @dataProvider placeMeArgumentsProvider - * @throws MWException + * @throws RuntimeException */ public function testCanRender( $input, $arguments, $expectedOutput ) { $instance = new Badge( diff --git a/tests/phpunit/Unit/Components/ButtonTest.php b/tests/phpunit/Unit/Components/ButtonTest.php index 1f6a40f..d7897da 100644 --- a/tests/phpunit/Unit/Components/ButtonTest.php +++ b/tests/phpunit/Unit/Components/ButtonTest.php @@ -4,7 +4,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Button; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use MWException; +use RuntimeException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Button @@ -24,7 +24,7 @@ class ButtonTest extends ComponentsTestBase { private $input = 'Button test text'; /** - * @throws \MWException + * @throws RuntimeException */ public function testCanConstruct() { @@ -44,7 +44,7 @@ public function testCanConstruct() { * @param string $expectedOutputPattern * * @dataProvider placeMeArgumentsProvider - * @throws MWException + * @throws RuntimeException */ public function testCanRender( $input, $arguments, $expectedOutputPattern ) { $instance = new Button( @@ -64,7 +64,7 @@ public function testCanRender( $input, $arguments, $expectedOutputPattern ) { } /** - * @throws MWException + * @throws RuntimeException */ public function testCanInjectRawAttributes() { diff --git a/tests/phpunit/Unit/Components/CardTest.php b/tests/phpunit/Unit/Components/CardTest.php index e517929..5792c45 100644 --- a/tests/phpunit/Unit/Components/CardTest.php +++ b/tests/phpunit/Unit/Components/CardTest.php @@ -6,7 +6,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Card; use MediaWiki\Extension\BootstrapComponents\NestingController; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use MWException; +use RuntimeException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Card @@ -26,7 +26,7 @@ class CardTest extends ComponentsTestBase { private $input = 'Card test text'; /** - * @throws \MWException + * @throws RuntimeException */ public function testCanConstruct() { @@ -45,7 +45,7 @@ public function testCanConstruct() { * @param array $arguments * @param string $expectedOutput * - * @throws MWException + * @throws RuntimeException * * @dataProvider placeMeArgumentsProvider */ @@ -69,7 +69,7 @@ public function testCanRender( $input, $arguments, $expectedOutput ) { * @param array $arguments * @param string $expectedOutput * - * @throws MWException + * @throws RuntimeException * * @dataProvider placeMeInsideAccordionArgumentsProvider */ diff --git a/tests/phpunit/Unit/Components/CarouselTest.php b/tests/phpunit/Unit/Components/CarouselTest.php index 87b4850..ea34e21 100644 --- a/tests/phpunit/Unit/Components/CarouselTest.php +++ b/tests/phpunit/Unit/Components/CarouselTest.php @@ -4,7 +4,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Carousel; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use MWException; +use RuntimeException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Carousel @@ -24,7 +24,7 @@ class CarouselTest extends ComponentsTestBase { private $input = 'Botched input'; /** - * @throws \MWException + * @throws RuntimeException */ public function testCanConstruct() { @@ -44,7 +44,7 @@ public function testCanConstruct() { * @param string $expectedOutput * * @dataProvider placeMeArgumentsProvider - * @throws MWException + * @throws RuntimeException */ public function testCanRender( $input, $arguments, $expectedOutput ) { $instance = new Carousel( diff --git a/tests/phpunit/Unit/Components/CollapseTest.php b/tests/phpunit/Unit/Components/CollapseTest.php index 39c631c..79dc909 100644 --- a/tests/phpunit/Unit/Components/CollapseTest.php +++ b/tests/phpunit/Unit/Components/CollapseTest.php @@ -4,7 +4,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Collapse; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use MWException; +use RuntimeException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Collapse @@ -24,7 +24,7 @@ class CollapseTest extends ComponentsTestBase { private $input = 'Collapse test text'; /** - * @throws \MWException + * @throws RuntimeException */ public function testCanConstruct() { @@ -44,7 +44,7 @@ public function testCanConstruct() { * @param string $expectedOutput * * @dataProvider placeMeArgumentsProvider - * @throws MWException + * @throws RuntimeException */ public function testCanRender( $input, $arguments, $expectedOutput ) { $instance = new Collapse( diff --git a/tests/phpunit/Unit/Components/JumbotronTest.php b/tests/phpunit/Unit/Components/JumbotronTest.php index 323eef9..9d73690 100644 --- a/tests/phpunit/Unit/Components/JumbotronTest.php +++ b/tests/phpunit/Unit/Components/JumbotronTest.php @@ -4,7 +4,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Jumbotron; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use MWException; +use RuntimeException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Jumbotron @@ -24,7 +24,7 @@ class JumbotronTest extends ComponentsTestBase { private $input = 'Jumbotron test text'; /** - * @throws \MWException + * @throws RuntimeException */ public function testCanConstruct() { @@ -44,7 +44,7 @@ public function testCanConstruct() { * @param string $expectedOutput * * @dataProvider placeMeArgumentsProvider - * @throws MWException + * @throws RuntimeException */ public function testCanRender( $input, $arguments, $expectedOutput ) { $instance = new Jumbotron( diff --git a/tests/phpunit/Unit/Components/ModalTest.php b/tests/phpunit/Unit/Components/ModalTest.php index ed95860..3bb715a 100644 --- a/tests/phpunit/Unit/Components/ModalTest.php +++ b/tests/phpunit/Unit/Components/ModalTest.php @@ -4,7 +4,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Modal; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use MWException; +use RuntimeException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Modal @@ -24,7 +24,7 @@ class ModalTest extends ComponentsTestBase { private $input = 'Modal test text'; /** - * @throws \MWException + * @throws RuntimeException */ public function testCanConstruct() { @@ -45,7 +45,7 @@ public function testCanConstruct() { * @param string $expectedModalOutput * * @dataProvider placeMeArgumentsProvider - * @throws MWException + * @throws RuntimeException */ public function testCanRender( $input, $arguments, $expectedTriggerOutput, $expectedModalOutput ) { diff --git a/tests/phpunit/Unit/Components/PopoverTest.php b/tests/phpunit/Unit/Components/PopoverTest.php index 4f3b39b..4bc20e9 100644 --- a/tests/phpunit/Unit/Components/PopoverTest.php +++ b/tests/phpunit/Unit/Components/PopoverTest.php @@ -4,7 +4,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Popover; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use MWException; +use RuntimeException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Popover @@ -24,7 +24,7 @@ class PopoverTest extends ComponentsTestBase { private $input = 'Popover test text'; /** - * @throws \MWException + * @throws RuntimeException */ public function testCanConstruct() { @@ -44,7 +44,7 @@ public function testCanConstruct() { * @param string $expectedOutput * * @dataProvider placeMeArgumentsProvider - * @throws MWException + * @throws RuntimeException */ public function testCanRender( $input, $arguments, $expectedOutput ) { $instance = new Popover( diff --git a/tests/phpunit/Unit/Components/TooltipTest.php b/tests/phpunit/Unit/Components/TooltipTest.php index 002ce55..810b0a3 100644 --- a/tests/phpunit/Unit/Components/TooltipTest.php +++ b/tests/phpunit/Unit/Components/TooltipTest.php @@ -5,7 +5,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Tooltip; use MediaWiki\Extension\BootstrapComponents\NestingController; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use MWException; +use RuntimeException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Tooltip @@ -25,7 +25,7 @@ class TooltipTest extends ComponentsTestBase { private $input = 'Tooltip test text'; /** - * @throws \MWException + * @throws RuntimeException */ public function testCanConstruct() { @@ -45,7 +45,7 @@ public function testCanConstruct() { * @param string $expectedOutput * * @dataProvider placeMeArgumentsProvider - * @throws MWException + * @throws RuntimeException */ public function testCanRender( $input, $arguments, $expectedOutput ) { $instance = new Tooltip( diff --git a/tests/phpunit/Unit/ImageModalTest.php b/tests/phpunit/Unit/ImageModalTest.php index 155a781..9d5a25a 100644 --- a/tests/phpunit/Unit/ImageModalTest.php +++ b/tests/phpunit/Unit/ImageModalTest.php @@ -34,7 +34,7 @@ public function setUp(): void { } /** - * @throws \MWException + * @throws RuntimeException */ public function testCanConstruct() { @@ -51,7 +51,7 @@ public function testCanConstruct() { } /** - * @throws \MWException + * @throws RuntimeException * @throws \ConfigException */ public function testCanParseOnFileNonExistent() { @@ -77,7 +77,7 @@ public function testCanParseOnFileNonExistent() { } /** - * @throws \MWException + * @throws RuntimeException * @throws \ConfigException */ public function testCanParseOnFileNoAllowInlineParse() { @@ -103,7 +103,7 @@ public function testCanParseOnFileNoAllowInlineParse() { } /** - * @throws \MWException + * @throws RuntimeException * @throws \ConfigException */ public function testCanParseOnOnInvalidManualThumb() { @@ -131,7 +131,7 @@ public function testCanParseOnOnInvalidManualThumb() { } /** - * @throws \MWException + * @throws RuntimeException * @throws \ConfigException */ public function testCanParseOnOnInvalidContentImage() { @@ -196,7 +196,7 @@ function( $params ) { * @param string $expectedTrigger * @param string $expectedModal * - * @throws \MWException + * @throws RuntimeException * @throws \ConfigException * * @dataProvider canParseDataProvider diff --git a/tests/phpunit/Unit/LuaLibraryTestBase.php b/tests/phpunit/Unit/LuaLibraryTestBase.php index e7de6d3..12a3953 100644 --- a/tests/phpunit/Unit/LuaLibraryTestBase.php +++ b/tests/phpunit/Unit/LuaLibraryTestBase.php @@ -23,7 +23,7 @@ abstract class LuaLibraryTestBase extends Scribunto_LuaEngineTestBase private $luaLibrary; /** - * @throws \MWException + * @throws RuntimeException */ protected function setUp(): void { parent::setUp(); diff --git a/tests/phpunit/Unit/NestingControllerTest.php b/tests/phpunit/Unit/NestingControllerTest.php index c187fb7..db16b7e 100644 --- a/tests/phpunit/Unit/NestingControllerTest.php +++ b/tests/phpunit/Unit/NestingControllerTest.php @@ -6,6 +6,7 @@ use MediaWiki\Extension\BootstrapComponents\ComponentLibrary; use MediaWiki\Extension\BootstrapComponents\NestingController; use PHPUnit\Framework\TestCase; +use RuntimeException; /** * @covers \MediaWiki\Extension\BootstrapComponents\NestingController @@ -86,23 +87,23 @@ public function testCanOpenAndClose( $componentName, $componentClass ) { } /** - * @throws \MWException + * @throws RuntimeException */ public function testCloseFailOnEmptyStack() { $instance = new NestingController(); - $this->expectException( 'MWException' ); + $this->expectException( RuntimeException::class ); $instance->close( 'invalid' ); } /** - * @throws \MWException + * @throws RuntimeException */ public function testOpenFail() { $instance = new NestingController(); - $this->expectException( 'MWException' ); + $this->expectException( RuntimeException::class ); $component = 'invalid'; /** @noinspection PhpParamsInspection */ @@ -110,12 +111,12 @@ public function testOpenFail() { } /** - * @throws \MWException + * @throws RuntimeException */ public function testCloseFailOnInvalidId() { $instance = new NestingController(); - $this->expectException( 'MWException' ); + $this->expectException( RuntimeException::class ); /** @var AbstractComponent $component */ $component = $this->getComponent( 'panel', 'MediaWiki\\Extension\\BootstrapComponents\\Components\\Card' ); @@ -147,7 +148,7 @@ private function doTestCanGenerateUniqueId( $instance, $testParams ) { * @return array[] * * @throws \ConfigException - * @throws \MWException + * @throws RuntimeException */ public function componentNameAndClassProvider() { $cl = new ComponentLibrary(); diff --git a/tests/phpunit/Unit/ParserOutputHelperTest.php b/tests/phpunit/Unit/ParserOutputHelperTest.php index aaeeac9..00f60fc 100644 --- a/tests/phpunit/Unit/ParserOutputHelperTest.php +++ b/tests/phpunit/Unit/ParserOutputHelperTest.php @@ -6,7 +6,7 @@ use MediaWiki\Extension\BootstrapComponents\ParserOutputHelper; use MediaWiki\Parser\Parser; use MediaWiki\Parser\ParserOutput; -use MWException; +use RuntimeException; use PHPUnit\Framework\TestCase; /** @@ -100,7 +100,7 @@ public function testCanRenderErrorMessage( $messageText, string $renderedMessage * @return array[] * * @throws \ConfigException - * @throws MWException + * @throws RuntimeException */ public function componentNameAndClassProvider() { $cl = new ComponentLibrary(); diff --git a/tests/phpunit/Unit/ParserRequestTest.php b/tests/phpunit/Unit/ParserRequestTest.php index 28bfb50..cac08b2 100644 --- a/tests/phpunit/Unit/ParserRequestTest.php +++ b/tests/phpunit/Unit/ParserRequestTest.php @@ -6,6 +6,7 @@ use MediaWiki\Parser\Parser; use PHPUnit\Framework\TestCase; use PPFrame; +use RuntimeException; /** * @covers \MediaWiki\Extension\BootstrapComponents\ParserRequest @@ -45,7 +46,7 @@ public function setUp(): void { * @param array $arguments * @param bool $isParserFunction * - * @throws \MWException + * @throws RuntimeException * * @dataProvider constructionProvider */ @@ -65,7 +66,7 @@ public function testCanConstruct( array $arguments, bool $isParserFunction ) { */ public function testCanNotConstruct( array $arguments, bool $isParserFunction ) { - $this->expectException( 'MWException' ); + $this->expectException( RuntimeException::class ); $this->assertInstanceOf( ParserRequest::class, @@ -79,7 +80,7 @@ public function testCanNotConstruct( array $arguments, bool $isParserFunction ) * @param string $expectedInput * @param array $expectedAttributes * - * @throws \MWException + * @throws RuntimeException * * @dataProvider constructionProvider */ From 3b1d3767c0733dee25f841290b27a76c763ba2ab Mon Sep 17 00:00:00 2001 From: Morne Alberts Date: Thu, 21 May 2026 14:39:21 +0200 Subject: [PATCH 08/11] Drop deprecated ctor params on ModalBuilder and OutputPageParserOutput 5.2.3 shipped @deprecated markers on: * `ModalBuilder::__construct( ..., $parserOutputHelper )` * `ApplicationFactory::getNewModalBuilder( ..., $parserOutputHelper )` * `OutputPageParserOutput::__construct( ..., $parserOutput, ... )` * `OutputPageParserOutput::getParserOutput()` (and the `$parserOutput` field it returns) These have been unused since the modal inline-emission fix in 5.2.3 gave both classes a path that no longer threads a ParserOutput or ParserOutputHelper through. Drop them and update every caller and test. Co-Authored-By: Claude Opus 4.7 --- src/ApplicationFactory.php | 13 ++++----- src/Components/Modal.php | 3 +-- src/Hooks/OutputPageParserOutput.php | 27 ++----------------- src/HooksHandler.php | 3 +-- src/ImageModal.php | 3 +-- src/ModalBuilder.php | 19 +++---------- ...ComponentsJsonTestCaseScriptRunnerTest.php | 4 ++- tests/phpunit/Unit/ApplicationFactoryTest.php | 4 +-- .../Unit/Hooks/OutputPageParserOutputTest.php | 14 ++-------- tests/phpunit/Unit/ModalBuilderTest.php | 15 ++--------- 10 files changed, 22 insertions(+), 83 deletions(-) diff --git a/src/ApplicationFactory.php b/src/ApplicationFactory.php index d8eff3b..d05d0c0 100644 --- a/src/ApplicationFactory.php +++ b/src/ApplicationFactory.php @@ -104,19 +104,16 @@ public function getNewAttributeManager( array $validAttributes, array $aliases ) } /** - * @param string $id - * @param string $trigger must be safe raw html (best run through {@see Parser::recursiveTagParse}) - * @param string $content must be safe raw html (best run through {@see Parser::recursiveTagParse}) - * @param ParserOutputHelper $parserOutputHelper @deprecated unused since the inline-emission modal fix; will be removed in the next major release. + * @param string $id + * @param string $trigger must be safe raw html (best run through {@see Parser::recursiveTagParse}) + * @param string $content must be safe raw html (best run through {@see Parser::recursiveTagParse}) * * @see ModalBuilder::__construct * * @return ModalBuilder */ - public function getNewModalBuilder( - string $id, string $trigger, string $content, ParserOutputHelper $parserOutputHelper - ): ModalBuilder { - return new ModalBuilder( $id, $trigger, $content, $parserOutputHelper ); + public function getNewModalBuilder( string $id, string $trigger, string $content ): ModalBuilder { + return new ModalBuilder( $id, $trigger, $content ); } /** diff --git a/src/Components/Modal.php b/src/Components/Modal.php index f244d2c..cd93556 100644 --- a/src/Components/Modal.php +++ b/src/Components/Modal.php @@ -63,8 +63,7 @@ protected function placeMe( $input ) { $modal = ApplicationFactory::getInstance()->getNewModalBuilder( $this->getId(), $text, - $safeInput, - $this->getParserOutputHelper() + $safeInput ); return $modal->setOuterClass( $this->arrayToString( $outerClass, ' ' ) diff --git a/src/Hooks/OutputPageParserOutput.php b/src/Hooks/OutputPageParserOutput.php index 3fc9248..6ec97af 100644 --- a/src/Hooks/OutputPageParserOutput.php +++ b/src/Hooks/OutputPageParserOutput.php @@ -28,7 +28,6 @@ use MediaWiki\Extension\BootstrapComponents\BootstrapComponentsService; use MediaWiki\Output\OutputPage; -use MediaWiki\Parser\ParserOutput; /** * Class OutputPageParserOutput @@ -52,31 +51,18 @@ class OutputPageParserOutput { private OutputPage $outputPage; /** - * @var ParserOutput $parserOutput - * - * @deprecated unused since the inline-emission modal fix; will be removed in the next major release. - */ - private ParserOutput $parserOutput; - - /** - * OutputPageParserOutput constructor. - * * @param OutputPage $outputPage - * @param ParserOutput $parserOutput @deprecated unused since the inline-emission modal fix; will be removed in the next major release. * @param BootstrapComponentsService $service */ - public function __construct( - OutputPage &$outputPage, ParserOutput $parserOutput, BootstrapComponentsService $service - ) { + public function __construct( OutputPage &$outputPage, BootstrapComponentsService $service ) { $this->outputPage = $outputPage; - $this->parserOutput = $parserOutput; $this->bootstrapComponentService = $service; } /** * @return void */ - public function process(): void { + public function process(): void { if ( $this->getBootstrapComponentsService()->vectorSkinInUse() ) { $this->getOutputPage()->addModules( [ 'ext.bootstrapComponents.vector-fix' ] ); } @@ -92,13 +78,4 @@ protected function getBootstrapComponentsService(): BootstrapComponentsService { protected function getOutputPage(): OutputPage { return $this->outputPage; } - - /** - * @deprecated unused since the inline-emission modal fix; will be removed in the next major release. - * - * @return ParserOutput - */ - protected function getParserOutput(): ParserOutput { - return $this->parserOutput; - } } diff --git a/src/HooksHandler.php b/src/HooksHandler.php index 94e7c3c..93c5a06 100644 --- a/src/HooksHandler.php +++ b/src/HooksHandler.php @@ -193,8 +193,7 @@ public function onInternalParseBeforeLinks( $parser, &$text, $stripState ): bool public function onOutputPageParserOutput( $outputPage, $parserOutput ): void { // @todo check, if we need to omit execution on actions edit, submit, or history // $action = $outputPage->parserOptions()->getUser()->getRequest()->getVal( "action" ); - $hook = - new OutputPageParserOutput( $outputPage, $parserOutput, $this->getBootstrapComponentsService() ); + $hook = new OutputPageParserOutput( $outputPage, $this->getBootstrapComponentsService() ); $hook->process(); } diff --git a/src/ImageModal.php b/src/ImageModal.php index 931f789..cca2ace 100644 --- a/src/ImageModal.php +++ b/src/ImageModal.php @@ -345,8 +345,7 @@ protected function turnParamsIntoModal( array $sanitizedFrameParams, array $hand $modal = ApplicationFactory::getInstance()->getNewModalBuilder( $this->getId(), $triggerString, - $content, - $this->getParserOutputHelper() + $content ); $modal->setHeader( $this->getTitle()->getBaseText() diff --git a/src/ModalBuilder.php b/src/ModalBuilder.php index 08f7e3f..7489ea2 100644 --- a/src/ModalBuilder.php +++ b/src/ModalBuilder.php @@ -99,13 +99,6 @@ class ModalBuilder { */ private $outerStyle; - /** - * @var ParserOutputHelper $parserOutputHelper - * - * @deprecated unused since the inline-emission modal fix; will be removed in the next major release. - */ - private $parserOutputHelper; - /** * @var string $trigger */ @@ -144,21 +137,17 @@ public static function wrapTriggerElement( $element, $id ) { * Do not instantiate directly, but use {@see ApplicationFactory::getNewModalBuilder} * instead. * - * @param string $id - * @param string $trigger must be safe raw html (best run through {@see Parser::recursiveTagParse}) - * @param string $content must be fully parsed html (use {@see Parser::recursiveTagParseFully}) - * @param ParserOutputHelper $parserOutputHelper @deprecated unused since the inline-emission modal fix; will be removed in the next major release. + * @param string $id + * @param string $trigger must be safe raw html (best run through {@see Parser::recursiveTagParse}) + * @param string $content must be fully parsed html (use {@see Parser::recursiveTagParseFully}) * * @see ApplicationFactory::getNewModalBuilder * @see Components\Modal::generateButton - * */ - - public function __construct( $id, $trigger, $content, $parserOutputHelper ) { + public function __construct( $id, $trigger, $content ) { $this->id = $id; $this->trigger = $trigger; $this->content = $content; - $this->parserOutputHelper = $parserOutputHelper; } /** diff --git a/tests/phpunit/Integration/JSONScript/BootstrapComponentsJsonTestCaseScriptRunnerTest.php b/tests/phpunit/Integration/JSONScript/BootstrapComponentsJsonTestCaseScriptRunnerTest.php index bf19815..705ef7e 100644 --- a/tests/phpunit/Integration/JSONScript/BootstrapComponentsJsonTestCaseScriptRunnerTest.php +++ b/tests/phpunit/Integration/JSONScript/BootstrapComponentsJsonTestCaseScriptRunnerTest.php @@ -3,6 +3,7 @@ namespace MediaWiki\Extension\BootstrapComponents\Tests\Integration; use MediaWiki\Extension\BootstrapComponents\ApplicationFactory; +use MediaWiki\Extension\BootstrapComponents\BootstrapComponentsService; use MediaWiki\Extension\BootstrapComponents\HookRegistry; use MediaWiki\Extension\BootstrapComponents\Hooks\OutputPageParserOutput; use SMW\DIWikiPage; @@ -196,8 +197,9 @@ private function assertParserOutputForCase( array $case ) { $outputPage = $this->getMockBuilder( 'OutputPage' ) ->disableOriginalConstructor() ->getMock(); + $bootstrapService = $this->createMock( BootstrapComponentsService::class ); /** @noinspection PhpParamsInspection */ - $hook = new OutputPageParserOutput( $outputPage, $parserOutput ); + $hook = new OutputPageParserOutput( $outputPage, $bootstrapService ); $hook->process(); } catch ( \Exception $e ) { // nothing diff --git a/tests/phpunit/Unit/ApplicationFactoryTest.php b/tests/phpunit/Unit/ApplicationFactoryTest.php index 0af0eda..1ee43e6 100644 --- a/tests/phpunit/Unit/ApplicationFactoryTest.php +++ b/tests/phpunit/Unit/ApplicationFactoryTest.php @@ -68,11 +68,9 @@ public function testGetNewAttributeManager() { } public function testGetNewModalBuilder() { - $parserOutputHelper = $this->createMock( ParserOutputHelper::class ); - $factory = new ApplicationFactory(); - $modalBuilder = $factory->getNewModalBuilder( '', '', '', $parserOutputHelper ); + $modalBuilder = $factory->getNewModalBuilder( '', '', '' ); $this->assertInstanceOf( ModalBuilder::class, diff --git a/tests/phpunit/Unit/Hooks/OutputPageParserOutputTest.php b/tests/phpunit/Unit/Hooks/OutputPageParserOutputTest.php index 1563d56..5098ece 100644 --- a/tests/phpunit/Unit/Hooks/OutputPageParserOutputTest.php +++ b/tests/phpunit/Unit/Hooks/OutputPageParserOutputTest.php @@ -5,7 +5,6 @@ use MediaWiki\Extension\BootstrapComponents\BootstrapComponentsService; use MediaWiki\Extension\BootstrapComponents\Hooks\OutputPageParserOutput; use MediaWiki\Output\OutputPage; -use MediaWiki\Parser\ParserOutput; use PHPUnit\Framework\TestCase; /** @@ -29,7 +28,6 @@ public function testCanConstruct() { $instance = new OutputPageParserOutput( $outputPage, - $this->createMock( ParserOutput::class ), $this->createMock( BootstrapComponentsService::class ) ); @@ -53,11 +51,7 @@ public function testHookOutputPageParserOutputLoadsVectorFixUnderVector() { ->method( 'vectorSkinInUse' ) ->willReturn( true ); - $instance = new OutputPageParserOutput( - $outputPage, - $this->createMock( ParserOutput::class ), - $bootstrapService - ); + $instance = new OutputPageParserOutput( $outputPage, $bootstrapService ); $instance->process(); } @@ -71,11 +65,7 @@ public function testHookDoesNothingWhenNotVector() { ->method( 'vectorSkinInUse' ) ->willReturn( false ); - $instance = new OutputPageParserOutput( - $outputPage, - $this->createMock( ParserOutput::class ), - $bootstrapService - ); + $instance = new OutputPageParserOutput( $outputPage, $bootstrapService ); $instance->process(); } } diff --git a/tests/phpunit/Unit/ModalBuilderTest.php b/tests/phpunit/Unit/ModalBuilderTest.php index e31e284..0a0cf80 100644 --- a/tests/phpunit/Unit/ModalBuilderTest.php +++ b/tests/phpunit/Unit/ModalBuilderTest.php @@ -21,12 +21,7 @@ class ModalBuilderTest extends TestCase { public function testCanConstruct() { - $parserOutputHelper = $this->getMockBuilder( 'MediaWiki\\Extension\\BootstrapComponents\\ParserOutputHelper' ) - ->disableOriginalConstructor() - ->getMock(); - - /** @noinspection PhpParamsInspection */ - $instance = new ModalBuilder( 'id', 'trigger', '', $parserOutputHelper ); + $instance = new ModalBuilder( 'id', 'trigger', '' ); $this->assertInstanceOf( 'MediaWiki\\Extension\\BootstrapComponents\\ModalBuilder', $instance @@ -48,13 +43,7 @@ public function testCanConstruct() { * @dataProvider parseDataProvider */ public function testCanParse( $id, $trigger, $content, $header, $footer, $outerClass, $outerStyle, $innerClass, $expectedTrigger, $expectedModal ) { - - $parserOutputHelper = $this->getMockBuilder( 'MediaWiki\\Extension\\BootstrapComponents\\ParserOutputHelper' ) - ->disableOriginalConstructor() - ->getMock(); - - /** @noinspection PhpParamsInspection */ - $instance = new ModalBuilder( $id, $trigger, $content, $parserOutputHelper ); + $instance = new ModalBuilder( $id, $trigger, $content ); if ( $header ) { $instance->setHeader( $header ); } From 520c744edab4ef9dc245072a6bd145cc2b91a0a2 Mon Sep 17 00:00:00 2001 From: Morne Alberts Date: Thu, 21 May 2026 16:53:18 +0200 Subject: [PATCH 09/11] Drop two orphan symbols in ParserOutputHelper / BootstrapComponents * `ParserOutputHelper::areImageModalsSuppressed()` is unreachable. Modal-suppression already flows through `BootstrapComponentsService::setModalsSuppressedByMagicWord()` (set in `HooksHandler::onInternalParseBeforeLinks` and read by `ImageModal` via the service), and no caller of `areImageModalsSuppressed()` remains. * `BootstrapComponents::EXTENSION_DATA_NO_IMAGE_MODAL` was only ever read inside `areImageModalsSuppressed()`, so it goes with it. The deprecated `ParserOutputHelper::addModules()` and its single caller in `AbstractComponent::augmentParserOutput()` look orphan- adjacent, but actually publish the vector skin's per-component module variants (modal.vector-fix, popover.vector-fix) under a hard-coded 'vector' key that everyone receives. Reshaping that path would change runtime module emission; leave it alone in this PR and clean it up separately. Co-Authored-By: Claude Opus 4.7 --- src/BootstrapComponents.php | 3 --- src/ParserOutputHelper.php | 15 --------------- 2 files changed, 18 deletions(-) diff --git a/src/BootstrapComponents.php b/src/BootstrapComponents.php index 69ff801..a75f70a 100644 --- a/src/BootstrapComponents.php +++ b/src/BootstrapComponents.php @@ -55,9 +55,6 @@ */ class BootstrapComponents { - const EXTENSION_DATA_NO_IMAGE_MODAL = 'bsc_no_image_modal'; - - /** * @var string $version */ diff --git a/src/ParserOutputHelper.php b/src/ParserOutputHelper.php index 077ff61..ea6682d 100644 --- a/src/ParserOutputHelper.php +++ b/src/ParserOutputHelper.php @@ -114,21 +114,6 @@ public function addTrackingCategory() { $this->articleTracked = true; } - /** - * Unless I find a solution for the integration test problem, I cannot use an instance of - * ParserOutputHelper in ImageModal to ascertain this. In integration tests, "we" use a - * different parser than the InternalParseBeforeLinks-Hook. At least, after I added - * Scribunto _unit_ tests. All messed up, I'm afraid. ImageModal better use global parser, and - * for the time being this method will be - * @deprecated - * - * @return bool|null - */ - public function areImageModalsSuppressed() { - return $this->getParser()->getOutput() - ->getExtensionData( BootstrapComponents::EXTENSION_DATA_NO_IMAGE_MODAL ); - } - /** * Formats a text as error text, so it can be added to the output. * From da6abadf3a6daa84375b7abf953d5dc7fe8e9e34 Mon Sep 17 00:00:00 2001 From: Morne Alberts Date: Thu, 21 May 2026 15:44:40 +0200 Subject: [PATCH 10/11] Make Linker image-emission patterns tolerant of HTML5 output The MediaWiki Linker (via RemexHtml's HTML5 serializer) stopped emitting `alt=""` for images that lack an explicit alt text, and dropped the XHTML self-closing slash on `` somewhere between REL1_43 and REL1_44. The four expected-output regexes in ImageModalTest and ImageModalTriggerTest that hard-coded the XHTML form now break on REL1_44+. Make `alt=""` and the trailing ` /` optional so the patterns match both forms across the supported MW range. While here, also drop the `()?` / `()?` optionality around the `` in ImageModalTest: current MW always wraps the thumb-rendered image in the `` pair. Co-Authored-By: Claude Opus 4.7 --- tests/phpunit/Unit/ImageModalTest.php | 4 ++-- tests/phpunit/Unit/ImageModalTriggerTest.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/Unit/ImageModalTest.php b/tests/phpunit/Unit/ImageModalTest.php index 9d5a25a..a66af68 100644 --- a/tests/phpunit/Unit/ImageModalTest.php +++ b/tests/phpunit/Unit/ImageModalTest.php @@ -346,7 +346,7 @@ public function canParseDataProvider(): array 'framed' => false, ], [], - '~
()?()?
~', + '~
~', '' . "\n", ], @@ -378,7 +378,7 @@ public function canParseDataProvider(): array 'manualthumb' => 'Shuttle.png', ], [], - '~
()?()?
~', + '~
~', '' . "\n", ], diff --git a/tests/phpunit/Unit/ImageModalTriggerTest.php b/tests/phpunit/Unit/ImageModalTriggerTest.php index 99aabfd..1ac28bb 100644 --- a/tests/phpunit/Unit/ImageModalTriggerTest.php +++ b/tests/phpunit/Unit/ImageModalTriggerTest.php @@ -254,7 +254,7 @@ public function canParseProvider() { [ '~