diff --git a/includes/EditBox/EditBoxBuilderFactory.php b/includes/EditBox/EditBoxBuilderFactory.php index ccd929ae6..5887ed5ea 100644 --- a/includes/EditBox/EditBoxBuilderFactory.php +++ b/includes/EditBox/EditBoxBuilderFactory.php @@ -2,7 +2,7 @@ namespace MediaWiki\Extension\AbuseFilter\EditBox; -use BadMethodCallException; +use LogicException; use MediaWiki\Extension\AbuseFilter\AbuseFilterPermissionManager; use MediaWiki\Extension\AbuseFilter\KeywordsManager; use MediaWiki\Permissions\Authority; @@ -89,7 +89,7 @@ class EditBoxBuilderFactory { OutputPage $output ): AceEditBoxBuilder { if ( !$this->isCodeEditorLoaded ) { - throw new BadMethodCallException( 'Cannot create Ace box without CodeEditor' ); + throw new LogicException( 'Cannot create Ace box without CodeEditor' ); } return new AceEditBoxBuilder( $this->afPermManager, diff --git a/includes/Filter/MutableFilter.php b/includes/Filter/MutableFilter.php index d4628a83e..79421874a 100644 --- a/includes/Filter/MutableFilter.php +++ b/includes/Filter/MutableFilter.php @@ -2,7 +2,7 @@ namespace MediaWiki\Extension\AbuseFilter\Filter; -use BadMethodCallException; +use LogicException; /** * Value object representing a filter that can be mutated (i.e. provides setters); this representation can @@ -78,12 +78,12 @@ class MutableFilter extends Filter { } /** - * @throws BadMethodCallException if $actions are already set; use $this->setActions to update names + * @throws LogicException if $actions are already set; use $this->setActions to update names * @param string[] $actionsNames */ public function setActionsNames( array $actionsNames ): void { if ( $this->actions !== null ) { - throw new BadMethodCallException( 'Cannot set actions names with actions already set' ); + throw new LogicException( 'Cannot set actions names with actions already set' ); } $this->specs->setActionsNames( $actionsNames ); } diff --git a/includes/View/AbuseFilterViewEdit.php b/includes/View/AbuseFilterViewEdit.php index 2317e9b0a..de85cf276 100644 --- a/includes/View/AbuseFilterViewEdit.php +++ b/includes/View/AbuseFilterViewEdit.php @@ -2,11 +2,11 @@ namespace MediaWiki\Extension\AbuseFilter\View; -use BadMethodCallException; use Html; use HtmlArmor; use IContextSource; use Linker; +use LogicException; use MediaWiki\Extension\AbuseFilter\AbuseFilterPermissionManager; use MediaWiki\Extension\AbuseFilter\Consequences\ConsequencesRegistry; use MediaWiki\Extension\AbuseFilter\EditBox\EditBoxBuilderFactory; @@ -1200,7 +1200,7 @@ class AbuseFilterViewEdit extends AbuseFilterView { $request = $this->getRequest(); if ( !$request->wasPosted() ) { // Sanity - throw new BadMethodCallException( __METHOD__ . ' called without the request being POSTed.' ); + throw new LogicException( __METHOD__ . ' called without the request being POSTed.' ); } $origFilter = $this->loadFilterData( $filter ); @@ -1249,7 +1249,7 @@ class AbuseFilterViewEdit extends AbuseFilterView { $request = $this->getRequest(); if ( !$request->wasPosted() ) { // Sanity - throw new BadMethodCallException( __METHOD__ . ' called without the request being POSTed.' ); + throw new LogicException( __METHOD__ . ' called without the request being POSTed.' ); } try { diff --git a/tests/phpunit/unit/EditBoxBuilderFactoryTest.php b/tests/phpunit/unit/EditBoxBuilderFactoryTest.php index cb054bdd0..e9892e88c 100644 --- a/tests/phpunit/unit/EditBoxBuilderFactoryTest.php +++ b/tests/phpunit/unit/EditBoxBuilderFactoryTest.php @@ -2,7 +2,7 @@ namespace MediaWiki\Extension\AbuseFilter\Tests\Unit; -use BadMethodCallException; +use LogicException; use MediaWiki\Extension\AbuseFilter\AbuseFilterPermissionManager; use MediaWiki\Extension\AbuseFilter\EditBox\AceEditBoxBuilder; use MediaWiki\Extension\AbuseFilter\EditBox\EditBoxBuilderFactory; @@ -87,7 +87,7 @@ class EditBoxBuilderFactoryTest extends MediaWikiUnitTestCase { * @covers ::newAceBoxBuilder */ public function testNewAceBoxBuilder__invalid() { - $this->expectException( BadMethodCallException::class ); + $this->expectException( LogicException::class ); $this->getFactory( false )->newAceBoxBuilder( $this->createMock( MessageLocalizer::class ), $this->createMock( Authority::class ), diff --git a/tests/phpunit/unit/Filter/MutableFilterTest.php b/tests/phpunit/unit/Filter/MutableFilterTest.php index 60498dc72..00f2e00e9 100644 --- a/tests/phpunit/unit/Filter/MutableFilterTest.php +++ b/tests/phpunit/unit/Filter/MutableFilterTest.php @@ -2,7 +2,7 @@ namespace MediaWiki\Extension\AbuseFilter\Tests\Unit\Filter; -use BadMethodCallException; +use LogicException; use MediaWiki\Extension\AbuseFilter\Filter\Filter; use MediaWiki\Extension\AbuseFilter\Filter\Flags; use MediaWiki\Extension\AbuseFilter\Filter\LastEditInfo; @@ -86,7 +86,7 @@ class MutableFilterTest extends MediaWikiUnitTestCase { [ 'foo' => [] ], new LastEditInfo( 42, 'User', '12345' ) ); - $this->expectException( BadMethodCallException::class ); + $this->expectException( LogicException::class ); $filter->setActionsNames( [ 'x' ] ); }