Merge "Replace BadMethodCallException with LogicException"

This commit is contained in:
jenkins-bot 2023-11-19 13:03:56 +00:00 committed by Gerrit Code Review
commit 22435fe600
5 changed files with 12 additions and 12 deletions

View file

@ -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,

View file

@ -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 );
}

View file

@ -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 {

View file

@ -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 ),

View file

@ -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' ] );
}