@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Task\Subtask; |
| 4 | 4 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | /** |
| 12 | 12 | * @inheritDoc |
| 13 | 13 | */ |
| 14 | - final public function getOperationName(): string { |
|
| 14 | + final public function getOperationName (): string { |
|
| 15 | 15 | return 'subtask'; |
| 16 | 16 | } |
| 17 | 17 | } |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Exception; |
| 4 | 4 | |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Task; |
| 4 | 4 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | /** |
| 15 | 15 | * @inheritDoc |
| 16 | 16 | */ |
| 17 | - public function runInternal() : int { |
|
| 17 | + public function runInternal () : int { |
|
| 18 | 18 | $orderedList = [ |
| 19 | 19 | 'create-pages', |
| 20 | 20 | 'open-updates', |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | /** |
| 33 | 33 | * @inheritDoc |
| 34 | 34 | */ |
| 35 | - protected function getSubtasksMap() : array { |
|
| 35 | + protected function getSubtasksMap () : array { |
|
| 36 | 36 | return [ |
| 37 | 37 | 'create-pages' => CreatePages::class, |
| 38 | 38 | 'open-updates' => OpenUpdates::class, |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Task; |
| 4 | 4 | |
@@ -14,15 +14,15 @@ discard block |
||
| 14 | 14 | /** |
| 15 | 15 | * @inheritDoc |
| 16 | 16 | */ |
| 17 | - protected function getSubtasksMap(): array { |
|
| 17 | + protected function getSubtasksMap (): array { |
|
| 18 | 18 | // Everything is done here. |
| 19 | - return []; |
|
| 19 | + return [ ]; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | 23 | * @inheritDoc |
| 24 | 24 | */ |
| 25 | - public function runInternal() : int { |
|
| 25 | + public function runInternal () : int { |
|
| 26 | 26 | $pages = $this->getDataProvider()->getOpenPages(); |
| 27 | 27 | |
| 28 | 28 | if ( !$pages ) { |
@@ -36,12 +36,12 @@ discard block |
||
| 36 | 36 | * @param PageRiconferma[] $pages |
| 37 | 37 | * @return int a STATUS_* constant |
| 38 | 38 | */ |
| 39 | - protected function processPages( array $pages ) : int { |
|
| 40 | - $donePages = []; |
|
| 39 | + protected function processPages ( array $pages ) : int { |
|
| 40 | + $donePages = [ ]; |
|
| 41 | 41 | foreach ( $pages as $page ) { |
| 42 | 42 | if ( $page->hasOpposition() && !$page->isVote() ) { |
| 43 | 43 | $this->openVote( $page ); |
| 44 | - $donePages[] = $page; |
|
| 44 | + $donePages[ ] = $page; |
|
| 45 | 45 | } |
| 46 | 46 | } |
| 47 | 47 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * |
| 60 | 60 | * @param PageRiconferma $page |
| 61 | 61 | */ |
| 62 | - protected function openVote( PageRiconferma $page ) { |
|
| 62 | + protected function openVote ( PageRiconferma $page ) { |
|
| 63 | 63 | $this->getLogger()->info( "Starting vote on $page" ); |
| 64 | 64 | |
| 65 | 65 | $content = $page->getContent(); |
@@ -98,12 +98,12 @@ discard block |
||
| 98 | 98 | * @see SimpleUpdates::updateVotazioni() |
| 99 | 99 | * @see OpenUpdates::addToVotazioni() |
| 100 | 100 | */ |
| 101 | - protected function updateVotazioni( array $pages ) { |
|
| 101 | + protected function updateVotazioni ( array $pages ) { |
|
| 102 | 102 | $votePage = $this->getPage( $this->getOpt( 'vote-page-title' ) ); |
| 103 | 103 | |
| 104 | - $users = []; |
|
| 104 | + $users = [ ]; |
|
| 105 | 105 | foreach ( $pages as $page ) { |
| 106 | - $users[] = $page->getUser(); |
|
| 106 | + $users[ ] = $page->getUser(); |
|
| 107 | 107 | } |
| 108 | 108 | $usersReg = Element::regexFromArray( $users ); |
| 109 | 109 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | * @see SimpleUpdates::updateNews() |
| 142 | 142 | * @see OpenUpdates::addToNews() |
| 143 | 143 | */ |
| 144 | - protected function updateNews( int $amount ) { |
|
| 144 | + protected function updateNews ( int $amount ) { |
|
| 145 | 145 | $this->getLogger()->info( "Turning $amount pages into votes" ); |
| 146 | 146 | $newsPage = $this->getPage( $this->getOpt( 'news-page-title' ) ); |
| 147 | 147 | |
@@ -156,8 +156,8 @@ discard block |
||
| 156 | 156 | throw new TaskException( 'Param "voto" not found in news page' ); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - $newTac = intval( $newsPage->getMatch( $regTac )[2] ) - $amount ?: ''; |
|
| 160 | - $newVot = intval( $newsPage->getMatch( $regVot )[2] ) + $amount ?: ''; |
|
| 159 | + $newTac = intval( $newsPage->getMatch( $regTac )[ 2 ] ) - $amount ?: ''; |
|
| 160 | + $newVot = intval( $newsPage->getMatch( $regVot )[ 2 ] ) + $amount ?: ''; |
|
| 161 | 161 | |
| 162 | 162 | $newContent = preg_replace( $regTac, '${1}' . $newTac, $content ); |
| 163 | 163 | $newContent = preg_replace( $regVot, '${1}' . $newVot, $newContent ); |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Request; |
| 4 | 4 | |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | * @inheritDoc |
| 13 | 13 | * @throws APIRequestException |
| 14 | 14 | */ |
| 15 | - protected function reallyMakeRequest( string $params ) : string { |
|
| 15 | + protected function reallyMakeRequest ( string $params ) : string { |
|
| 16 | 16 | $curl = curl_init(); |
| 17 | 17 | if ( $curl === false ) { |
| 18 | 18 | throw new APIRequestException( 'Cannot open cURL handler.' ); |
@@ -55,10 +55,10 @@ discard block |
||
| 55 | 55 | * @internal Only used as CB for cURL (CURLOPT_HEADERFUNCTION) |
| 56 | 56 | * @suppress PhanUnreferencedPublicMethod,PhanUnusedPublicNoOverrideMethodParameter |
| 57 | 57 | */ |
| 58 | - public function headersHandler( $ch, string $header ) : int { |
|
| 58 | + public function headersHandler ( $ch, string $header ) : int { |
|
| 59 | 59 | $bits = explode( ':', $header, 2 ); |
| 60 | - if ( trim( $bits[0] ) === 'Set-Cookie' ) { |
|
| 61 | - $this->newCookies[] = $bits[1]; |
|
| 60 | + if ( trim( $bits[ 0 ] ) === 'Set-Cookie' ) { |
|
| 61 | + $this->newCookies[ ] = $bits[ 1 ]; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | return strlen( $header ); |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme; |
| 4 | 4 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @param int $status One of the Task::STATUS_* constants |
| 22 | 22 | * @param string[] $errors |
| 23 | 23 | */ |
| 24 | - public function __construct( int $status, array $errors = [] ) { |
|
| 24 | + public function __construct ( int $status, array $errors = [ ] ) { |
|
| 25 | 25 | $this->status = $status; |
| 26 | 26 | $this->errors = $errors; |
| 27 | 27 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | /** |
| 30 | 30 | * @return int |
| 31 | 31 | */ |
| 32 | - public function getStatus() : int { |
|
| 32 | + public function getStatus () : int { |
|
| 33 | 33 | return $this->status; |
| 34 | 34 | } |
| 35 | 35 | |
@@ -37,14 +37,14 @@ discard block |
||
| 37 | 37 | * @return string[] |
| 38 | 38 | * @suppress PhanUnreferencedPublicMethod |
| 39 | 39 | */ |
| 40 | - public function getErrors() { |
|
| 40 | + public function getErrors () { |
|
| 41 | 41 | return $this->errors; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | 45 | * @param TaskResult $that |
| 46 | 46 | */ |
| 47 | - public function merge( TaskResult $that ) { |
|
| 47 | + public function merge ( TaskResult $that ) { |
|
| 48 | 48 | $this->status |= $that->status; |
| 49 | 49 | $this->errors = array_merge( $this->errors, $that->errors ); |
| 50 | 50 | } |
@@ -52,15 +52,15 @@ discard block |
||
| 52 | 52 | /** |
| 53 | 53 | * @return string |
| 54 | 54 | */ |
| 55 | - public function __toString() { |
|
| 55 | + public function __toString () { |
|
| 56 | 56 | if ( $this->isOK() ) { |
| 57 | 57 | $stat = 'OK'; |
| 58 | 58 | $errs = "\tNo errors."; |
| 59 | 59 | } else { |
| 60 | 60 | $stat = 'ERROR'; |
| 61 | - $formattedErrs = []; |
|
| 61 | + $formattedErrs = [ ]; |
|
| 62 | 62 | foreach ( $this->errors as $err ) { |
| 63 | - $formattedErrs[] = "\t - $err"; |
|
| 63 | + $formattedErrs[ ] = "\t - $err"; |
|
| 64 | 64 | } |
| 65 | 65 | $errs = implode( "\n", $formattedErrs ); |
| 66 | 66 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @return bool |
| 74 | 74 | */ |
| 75 | - public function isOK() : bool { |
|
| 75 | + public function isOK () : bool { |
|
| 76 | 76 | return ( $this->status | self::STATUS_GOOD ) === self::STATUS_GOOD; |
| 77 | 77 | } |
| 78 | 78 | } |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Task\Subtask; |
| 4 | 4 | |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | /** |
| 14 | 14 | * @inheritDoc |
| 15 | 15 | */ |
| 16 | - public function runInternal() : int { |
|
| 16 | + public function runInternal () : int { |
|
| 17 | 17 | $pages = $this->getDataProvider()->getCreatedPages(); |
| 18 | 18 | |
| 19 | 19 | if ( !$pages ) { |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * |
| 36 | 36 | * @param PageRiconferma[] $pages |
| 37 | 37 | */ |
| 38 | - protected function addToMainPage( array $pages ) { |
|
| 38 | + protected function addToMainPage ( array $pages ) { |
|
| 39 | 39 | $this->getLogger()->info( |
| 40 | 40 | 'Adding the following to main: ' . implode( ', ', $pages ) |
| 41 | 41 | ); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * |
| 69 | 69 | * @param PageRiconferma[] $pages |
| 70 | 70 | */ |
| 71 | - protected function addToVotazioni( array $pages ) { |
|
| 71 | + protected function addToVotazioni ( array $pages ) { |
|
| 72 | 72 | $this->getLogger()->info( |
| 73 | 73 | 'Adding the following to votes: ' . implode( ', ', $pages ) |
| 74 | 74 | ); |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | * @param int $amount |
| 106 | 106 | * @throws TaskException |
| 107 | 107 | */ |
| 108 | - protected function addToNews( int $amount ) { |
|
| 108 | + protected function addToNews ( int $amount ) { |
|
| 109 | 109 | $this->getLogger()->info( "Increasing the news counter by $amount" ); |
| 110 | 110 | $newsPage = $this->getPage( $this->getOpt( 'news-page-title' ) ); |
| 111 | 111 | |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | $matches = $newsPage->getMatch( $reg ); |
| 120 | 120 | |
| 121 | - $newNum = (int)$matches[2] + $amount; |
|
| 121 | + $newNum = (int)$matches[ 2 ] + $amount; |
|
| 122 | 122 | $newContent = preg_replace( $reg, '${1}' . $newNum, $content ); |
| 123 | 123 | |
| 124 | 124 | $summary = $this->msg( 'news-page-summary' ) |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Wiki\Page; |
| 4 | 4 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * @param string $title |
| 20 | 20 | * @param Wiki $wiki For the site where the page lives |
| 21 | 21 | */ |
| 22 | - public function __construct( string $title, Wiki $wiki ) { |
|
| 22 | + public function __construct ( string $title, Wiki $wiki ) { |
|
| 23 | 23 | parent::__construct( $wiki ); |
| 24 | 24 | $this->title = $title; |
| 25 | 25 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | /** |
| 28 | 28 | * @return string |
| 29 | 29 | */ |
| 30 | - public function getTitle() : string { |
|
| 30 | + public function getTitle () : string { |
|
| 31 | 31 | return $this->title; |
| 32 | 32 | } |
| 33 | 33 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * @param int|null $section A section number to retrieve the content of that section |
| 38 | 38 | * @return string |
| 39 | 39 | */ |
| 40 | - public function getContent( int $section = null ) : string { |
|
| 40 | + public function getContent ( int $section = null ) : string { |
|
| 41 | 41 | if ( $this->content === null ) { |
| 42 | 42 | $this->content = $this->wiki->getPageContent( $this->title, $section ); |
| 43 | 43 | } |
@@ -50,18 +50,18 @@ discard block |
||
| 50 | 50 | * @param array $params |
| 51 | 51 | * @throws \LogicException |
| 52 | 52 | */ |
| 53 | - public function edit( array $params ) { |
|
| 53 | + public function edit ( array $params ) { |
|
| 54 | 54 | $params = [ |
| 55 | 55 | 'title' => $this->getTitle() |
| 56 | 56 | ] + $params; |
| 57 | 57 | |
| 58 | 58 | $this->wiki->editPage( $params ); |
| 59 | - if ( isset( $params['text'] ) ) { |
|
| 60 | - $this->content = $params['text']; |
|
| 61 | - } elseif ( isset( $params['appendtext'] ) ) { |
|
| 62 | - $this->content .= $params['appendtext']; |
|
| 63 | - } elseif ( isset( $params['prependtext'] ) ) { |
|
| 64 | - $this->content = $params['prependtext'] . $this->content; |
|
| 59 | + if ( isset( $params[ 'text' ] ) ) { |
|
| 60 | + $this->content = $params[ 'text' ]; |
|
| 61 | + } elseif ( isset( $params[ 'appendtext' ] ) ) { |
|
| 62 | + $this->content .= $params[ 'appendtext' ]; |
|
| 63 | + } elseif ( isset( $params[ 'prependtext' ] ) ) { |
|
| 64 | + $this->content = $params[ 'prependtext' ] . $this->content; |
|
| 65 | 65 | } else { |
| 66 | 66 | throw new \LogicException( |
| 67 | 67 | 'Unrecognized text param for edit. Params: ' . var_export( $params, true ) |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @return bool |
| 76 | 76 | */ |
| 77 | - public function exists() : bool { |
|
| 77 | + public function exists () : bool { |
|
| 78 | 78 | $res = RequestBase::newFromParams( [ |
| 79 | 79 | 'action' => 'query', |
| 80 | 80 | 'titles' => $this->getTitle() |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * @param string $regex |
| 90 | 90 | * @return bool |
| 91 | 91 | */ |
| 92 | - public function matches( string $regex ) : bool { |
|
| 92 | + public function matches ( string $regex ) : bool { |
|
| 93 | 93 | return (bool)preg_match( $regex, $this->getContent() ); |
| 94 | 94 | } |
| 95 | 95 | |
@@ -101,8 +101,8 @@ discard block |
||
| 101 | 101 | * @return string[] |
| 102 | 102 | * @throws \Exception |
| 103 | 103 | */ |
| 104 | - public function getMatch( string $regex ) : array { |
|
| 105 | - $ret = []; |
|
| 104 | + public function getMatch ( string $regex ) : array { |
|
| 105 | + $ret = [ ]; |
|
| 106 | 106 | if ( preg_match( $regex, $this->getContent(), $ret ) === 0 ) { |
| 107 | 107 | throw new \Exception( "The content of $this does not match the given regex $regex" ); |
| 108 | 108 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | * |
| 115 | 115 | * @inheritDoc |
| 116 | 116 | */ |
| 117 | - public function getRegex() : string { |
|
| 117 | + public function getRegex () : string { |
|
| 118 | 118 | return str_replace( ' ', '[ _]', preg_quote( $this->title ) ); |
| 119 | 119 | } |
| 120 | 120 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | * |
| 124 | 124 | * @return string |
| 125 | 125 | */ |
| 126 | - public function __toString() { |
|
| 126 | + public function __toString () { |
|
| 127 | 127 | return $this->getTitle(); |
| 128 | 128 | } |
| 129 | 129 | } |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Wiki; |
| 4 | 4 | |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | /** |
| 13 | 13 | * @param Wiki $wiki |
| 14 | 14 | */ |
| 15 | - public function __construct( Wiki $wiki ) { |
|
| 15 | + public function __construct ( Wiki $wiki ) { |
|
| 16 | 16 | $this->wiki = $wiki; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @return string |
| 23 | 23 | */ |
| 24 | - abstract public function getRegex() : string; |
|
| 24 | + abstract public function getRegex () : string; |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * Get a regex matching any element in the given array |
@@ -30,10 +30,10 @@ discard block |
||
| 30 | 30 | * @return string |
| 31 | 31 | * @todo Is this the right place? |
| 32 | 32 | */ |
| 33 | - public static function regexFromArray( array $elements ) : string { |
|
| 34 | - $bits = []; |
|
| 33 | + public static function regexFromArray ( array $elements ) : string { |
|
| 34 | + $bits = [ ]; |
|
| 35 | 35 | foreach ( $elements as $el ) { |
| 36 | - $bits[] = $el->getRegex(); |
|
| 36 | + $bits[ ] = $el->getRegex(); |
|
| 37 | 37 | } |
| 38 | 38 | return '(?:' . implode( '|', $bits ) . ')'; |
| 39 | 39 | } |