assertRequiredOptions( self::CONSTRUCTOR_OPTIONS ); $this->options = $options; $this->logger = $logger; $this->blockUserFactory = $blockUserFactory; $this->userGroupManager = $userGroupManager; $this->mainStash = $mainStash; $this->changeTagger = $changeTagger; $this->blockAutopromoteStore = $blockAutopromoteStore; $this->filterUser = $filterUser; $this->session = $session; $this->requestIP = $requestIP; } // Each class has its factory method for better type inference and static analysis /** * @param Parameters $params * @param string $expiry * @param bool $preventsTalk * @return Block */ public function newBlock( Parameters $params, string $expiry, bool $preventsTalk ) : Block { return new Block( $params, $expiry, $preventsTalk, $this->blockUserFactory, $this->filterUser ); } /** * @param Parameters $params * @param string $expiry * @return RangeBlock */ public function newRangeBlock( Parameters $params, string $expiry ) : RangeBlock { return new RangeBlock( $params, $expiry, $this->blockUserFactory, $this->filterUser, $this->options->get( 'AbuseFilterRangeBlockSize' ), $this->options->get( 'BlockCIDRLimit' ), $this->requestIP ); } /** * @param Parameters $params * @param \AbuseFilterVariableHolder $vars * @return Degroup */ public function newDegroup( Parameters $params, \AbuseFilterVariableHolder $vars ) : Degroup { return new Degroup( $params, $vars, $this->userGroupManager, $this->filterUser ); } /** * @param Parameters $params * @param int $duration * @return BlockAutopromote */ public function newBlockAutopromote( Parameters $params, int $duration ) : BlockAutopromote { return new BlockAutopromote( $params, $duration, $this->blockAutopromoteStore, $this->logger ); } /** * @param Parameters $params * @param array $throttleParams * @phan-param array{id:int|string,count:int,period:int,groups:string[]} $throttleParams * @return Throttle */ public function newThrottle( Parameters $params, array $throttleParams ) : Throttle { return new Throttle( $params, $throttleParams, $this->mainStash, $this->logger, $this->requestIP, $this->options->get( 'AbuseFilterIsCentral' ), $this->options->get( 'AbuseFilterCentralDB' ) ); } /** * @param Parameters $params * @param string $message * @return Warn */ public function newWarn( Parameters $params, string $message ) : Warn { return new Warn( $params, $message, $this->session ); } /** * @param Parameters $params * @param string $message * @return Disallow */ public function newDisallow( Parameters $params, string $message ) : Disallow { return new Disallow( $params, $message ); } /** * @param Parameters $params * @param string|null $accountName * @param string[] $tags * @return Tag */ public function newTag( Parameters $params, ?string $accountName, array $tags ) : Tag { return new Tag( $params, $accountName, $tags, $this->changeTagger ); } }