@@ -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 | |
@@ -11,14 +11,14 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | const VERSION = 1.0; |
| 13 | 13 | |
| 14 | - public function __construct() { |
|
| 14 | + public function __construct () { |
|
| 15 | 15 | $this->logger = new Logger; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Entry point for the whole process |
| 20 | 20 | */ |
| 21 | - public function run() { |
|
| 21 | + public function run () { |
|
| 22 | 22 | $this->logger->info( 'Starting full process.' ); |
| 23 | 23 | $manager = new TaskManager; |
| 24 | 24 | $res = $manager->run( TaskManager::MODE_COMPLETE ); |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * |
| 36 | 36 | * @param string $task |
| 37 | 37 | */ |
| 38 | - public function runSingle( string $task ) { |
|
| 38 | + public function runSingle ( string $task ) { |
|
| 39 | 39 | $this->logger->info( "Starting single task $task." ); |
| 40 | 40 | $manager = new TaskManager; |
| 41 | 41 | $res = $manager->run( TaskManager::MODE_SINGLE, $task ); |
@@ -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 | const STATUS_OK = 0; |
| 15 | 15 | const STATUS_ERROR = 1; |
| 16 | 16 | /** @var string[] */ |
| 17 | - protected $errors = []; |
|
| 17 | + protected $errors = [ ]; |
|
| 18 | 18 | /** @var TaskDataProvider */ |
| 19 | 19 | private $dataProvider; |
| 20 | 20 | |
@@ -23,14 +23,14 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @param TaskDataProvider $dataProvider |
| 25 | 25 | */ |
| 26 | - final public function __construct( TaskDataProvider $dataProvider ) { |
|
| 26 | + final public function __construct ( TaskDataProvider $dataProvider ) { |
|
| 27 | 27 | set_exception_handler( [ $this, 'handleException' ] ); |
| 28 | 28 | set_error_handler( [ $this, 'handleError' ] ); |
| 29 | 29 | parent::__construct(); |
| 30 | 30 | $this->dataProvider = $dataProvider; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - public function __destruct() { |
|
| 33 | + public function __destruct () { |
|
| 34 | 34 | restore_error_handler(); |
| 35 | 35 | restore_exception_handler(); |
| 36 | 36 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @return TaskResult |
| 42 | 42 | */ |
| 43 | - abstract public function run() : TaskResult; |
|
| 43 | + abstract public function run () : TaskResult; |
|
| 44 | 44 | |
| 45 | 45 | /** |
| 46 | 46 | * Exception handler. |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * @param \Throwable $ex |
| 49 | 49 | * @protected |
| 50 | 50 | */ |
| 51 | - public function handleException( \Throwable $ex ) { |
|
| 51 | + public function handleException ( \Throwable $ex ) { |
|
| 52 | 52 | $this->getLogger()->error( |
| 53 | 53 | get_class( $ex ) . ': ' . |
| 54 | 54 | $ex->getMessage() . "\nTrace:\n" . |
@@ -65,14 +65,14 @@ discard block |
||
| 65 | 65 | * @param int $errline |
| 66 | 66 | * @protected |
| 67 | 67 | */ |
| 68 | - public function handleError( $errno, $errstr, $errfile, $errline ) { |
|
| 68 | + public function handleError ( $errno, $errstr, $errfile, $errline ) { |
|
| 69 | 69 | throw new \ErrorException( $errstr, 0, $errno, $errfile, $errline ); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
| 73 | 73 | * @return TaskDataProvider |
| 74 | 74 | */ |
| 75 | - protected function getDataProvider() : TaskDataProvider { |
|
| 75 | + protected function getDataProvider () : TaskDataProvider { |
|
| 76 | 76 | return $this->dataProvider; |
| 77 | 77 | } |
| 78 | 78 | } |
@@ -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 | |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | /** |
| 14 | 14 | * @inheritDoc |
| 15 | 15 | */ |
| 16 | - public function run() : TaskResult { |
|
| 16 | + public function run () : TaskResult { |
|
| 17 | 17 | $this->getLogger()->info( 'Starting task CreatePages' ); |
| 18 | 18 | $users = $this->getDataProvider()->getUsersToProcess(); |
| 19 | 19 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * @param string $user |
| 36 | 36 | * @param array $groups |
| 37 | 37 | */ |
| 38 | - protected function processUser( string $user, array $groups ) { |
|
| 38 | + protected function processUser ( string $user, array $groups ) { |
|
| 39 | 39 | try { |
| 40 | 40 | $num = $this->getLastPageNum( $user ) + 1; |
| 41 | 41 | } catch ( TaskException $e ) { |
@@ -65,9 +65,9 @@ discard block |
||
| 65 | 65 | * @return int |
| 66 | 66 | * @throws TaskException |
| 67 | 67 | */ |
| 68 | - protected function getLastPageNum( string $user ) : int { |
|
| 68 | + protected function getLastPageNum ( string $user ) : int { |
|
| 69 | 69 | $this->getLogger()->debug( "Retrieving previous pages for $user" ); |
| 70 | - $unprefixedTitle = explode( ':', $this->getConfig()->get( 'ric-main-page' ), 2 )[1]; |
|
| 70 | + $unprefixedTitle = explode( ':', $this->getConfig()->get( 'ric-main-page' ), 2 )[ 1 ]; |
|
| 71 | 71 | $params = [ |
| 72 | 72 | 'action' => 'query', |
| 73 | 73 | 'list' => 'allpages', |
@@ -102,14 +102,14 @@ discard block |
||
| 102 | 102 | * @param string $user |
| 103 | 103 | * @param array $groups |
| 104 | 104 | */ |
| 105 | - protected function createPage( string $title, string $user, array $groups ) { |
|
| 105 | + protected function createPage ( string $title, string $user, array $groups ) { |
|
| 106 | 106 | $this->getLogger()->info( "Creating page $title" ); |
| 107 | 107 | $text = $this->getConfig()->get( 'ric-page-text' ); |
| 108 | 108 | $textParams = [ |
| 109 | 109 | '$user' => $user, |
| 110 | - '$date' => $groups['sysop'], |
|
| 111 | - '$burocrate' => $groups['bureaucrat'] ?? '', |
|
| 112 | - '$checkuser' => $groups['checkuser'] ?? '' |
|
| 110 | + '$date' => $groups[ 'sysop' ], |
|
| 111 | + '$burocrate' => $groups[ 'bureaucrat' ] ?? '', |
|
| 112 | + '$checkuser' => $groups[ 'checkuser' ] ?? '' |
|
| 113 | 113 | ]; |
| 114 | 114 | $text = strtr( $text, $textParams ); |
| 115 | 115 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | * @param string $title |
| 129 | 129 | * @param string $newText |
| 130 | 130 | */ |
| 131 | - protected function createBasePage( string $title, string $newText ) { |
|
| 131 | + protected function createBasePage ( string $title, string $newText ) { |
|
| 132 | 132 | $this->getLogger()->info( "Creating base page $title" ); |
| 133 | 133 | |
| 134 | 134 | $params = [ |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | * @param string $title |
| 146 | 146 | * @param string $newText |
| 147 | 147 | */ |
| 148 | - protected function updateBasePage( string $title, string $newText ) { |
|
| 148 | + protected function updateBasePage ( string $title, string $newText ) { |
|
| 149 | 149 | $this->getLogger()->info( "Updating base page $title" ); |
| 150 | 150 | |
| 151 | 151 | $params = [ |
@@ -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 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | /** @var WikiController */ |
| 19 | 19 | private $controller; |
| 20 | 20 | |
| 21 | - public function __construct() { |
|
| 21 | + public function __construct () { |
|
| 22 | 22 | $this->setLogger( new Logger ); |
| 23 | 23 | $this->setConfig( Config::getInstance() ); |
| 24 | 24 | $this->setController( new WikiController ); |
@@ -27,42 +27,42 @@ discard block |
||
| 27 | 27 | /** |
| 28 | 28 | * @return LoggerInterface |
| 29 | 29 | */ |
| 30 | - protected function getLogger() : LoggerInterface { |
|
| 30 | + protected function getLogger () : LoggerInterface { |
|
| 31 | 31 | return $this->logger; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * @inheritDoc |
| 36 | 36 | */ |
| 37 | - public function setLogger( LoggerInterface $logger ) { |
|
| 37 | + public function setLogger ( LoggerInterface $logger ) { |
|
| 38 | 38 | $this->logger = $logger; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | 42 | * @return Config |
| 43 | 43 | */ |
| 44 | - protected function getConfig() : Config { |
|
| 44 | + protected function getConfig () : Config { |
|
| 45 | 45 | return $this->config; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * @param Config $cfg |
| 50 | 50 | */ |
| 51 | - protected function setConfig( Config $cfg ) { |
|
| 51 | + protected function setConfig ( Config $cfg ) { |
|
| 52 | 52 | $this->config = $cfg; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | 56 | * @return WikiController |
| 57 | 57 | */ |
| 58 | - protected function getController() : WikiController { |
|
| 58 | + protected function getController () : WikiController { |
|
| 59 | 59 | return $this->controller; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * @param WikiController $controller |
| 64 | 64 | */ |
| 65 | - protected function setController( WikiController $controller ) { |
|
| 65 | + protected function setController ( WikiController $controller ) { |
|
| 66 | 66 | $this->controller = $controller; |
| 67 | 67 | } |
| 68 | 68 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * @param string $key |
| 73 | 73 | * @return Message |
| 74 | 74 | */ |
| 75 | - protected function msg( string $key ) : Message { |
|
| 75 | + protected function msg ( string $key ) : Message { |
|
| 76 | 76 | return new Message( $key ); |
| 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; |
| 4 | 4 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | /** |
| 15 | 15 | * @param string $key |
| 16 | 16 | */ |
| 17 | - public function __construct( string $key ) { |
|
| 17 | + public function __construct ( string $key ) { |
|
| 18 | 18 | $this->key = $key; |
| 19 | 19 | $this->value = Config::getInstance()->getWikiMessage( $key ); |
| 20 | 20 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * @param array $args |
| 24 | 24 | * @return self |
| 25 | 25 | */ |
| 26 | - public function params( array $args ) : self { |
|
| 26 | + public function params ( array $args ) : self { |
|
| 27 | 27 | $this->value = strtr( $this->value, $args ); |
| 28 | 28 | return $this; |
| 29 | 29 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | /** |
| 32 | 32 | * @return string |
| 33 | 33 | */ |
| 34 | - public function text() : string { |
|
| 34 | + public function text () : string { |
|
| 35 | 35 | $this->parsePlurals(); |
| 36 | 36 | return $this->value; |
| 37 | 37 | } |
@@ -39,11 +39,11 @@ discard block |
||
| 39 | 39 | /** |
| 40 | 40 | * Replace {{$plur|<amount>|sing|plur}} |
| 41 | 41 | */ |
| 42 | - protected function parsePlurals() { |
|
| 42 | + protected function parsePlurals () { |
|
| 43 | 43 | $this->value = preg_replace_callback( |
| 44 | 44 | '!\{\{$plur|(?P<amount>\d+)|(?P<sing>[^}|]+)|(?P<plur>[^|}]+)}}!', |
| 45 | 45 | function ( $matches ) { |
| 46 | - return intval( $matches['amount'] ) > 1 ? trim( $matches['plur'] ) : trim( $matches['sing'] ); |
|
| 46 | + return intval( $matches[ 'amount' ] ) > 1 ? trim( $matches[ 'plur' ] ) : trim( $matches[ 'sing' ] ); |
|
| 47 | 47 | }, |
| 48 | 48 | $this->value |
| 49 | 49 | ); |
@@ -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 | |
@@ -11,13 +11,13 @@ discard block |
||
| 11 | 11 | /** |
| 12 | 12 | * @inheritDoc |
| 13 | 13 | */ |
| 14 | - public function run() : TaskResult { |
|
| 14 | + public function run () : TaskResult { |
|
| 15 | 15 | $this->getLogger()->info( 'Starting task UserNotice' ); |
| 16 | 16 | |
| 17 | 17 | $pages = $this->getDataProvider()->getCreatedPages(); |
| 18 | 18 | $users = $this->getDataProvider()->getUsersToProcess(); |
| 19 | 19 | if ( $pages && $users ) { |
| 20 | - $ricNums = []; |
|
| 20 | + $ricNums = [ ]; |
|
| 21 | 21 | foreach ( $pages as $page ) { |
| 22 | 22 | $ricNums[ $page->getUser() ] = $page->getNum(); |
| 23 | 23 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * @param string $user |
| 40 | 40 | * @param int $ricNum |
| 41 | 41 | */ |
| 42 | - protected function addMsg( string $user, int $ricNum ) { |
|
| 42 | + protected function addMsg ( string $user, int $ricNum ) { |
|
| 43 | 43 | $this->getLogger()->info( "Leaving msg to $user" ); |
| 44 | 44 | $msg = $this->msg( 'user-notice-msg' )->params( [ '$num' => $ricNum ] )->text(); |
| 45 | 45 | |
@@ -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,8 +21,8 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @return string |
| 23 | 23 | */ |
| 24 | - public function getUser() : string { |
|
| 25 | - return explode( '/', $this->title )[2]; |
|
| 24 | + public function getUser () : string { |
|
| 25 | + return explode( '/', $this->title )[ 2 ]; |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return int |
| 32 | 32 | */ |
| 33 | - public function getNum() : int { |
|
| 33 | + public function getNum () : int { |
|
| 34 | 34 | $bits = explode( '/', $this->getTitle() ); |
| 35 | 35 | return intval( end( $bits ) ); |
| 36 | 36 | } |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @return string |
| 42 | 42 | */ |
| 43 | - public function getUserNum() : string { |
|
| 44 | - return explode( '/', $this->getTitle(), 3 )[2]; |
|
| 43 | + public function getUserNum () : string { |
|
| 44 | + return explode( '/', $this->getTitle(), 3 )[ 2 ]; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * |
| 50 | 50 | * @return string |
| 51 | 51 | */ |
| 52 | - public function getBaseTitle() : string { |
|
| 52 | + public function getBaseTitle () : string { |
|
| 53 | 53 | // @phan-suppress-next-line PhanTypeMismatchArgumentInternal Phan bug |
| 54 | 54 | return substr( $this->getTitle(), 0, strrpos( $this->getTitle(), '/' ) ); |
| 55 | 55 | } |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * |
| 60 | 60 | * @return int |
| 61 | 61 | */ |
| 62 | - public function getOpposingCount() : int { |
|
| 62 | + public function getOpposingCount () : int { |
|
| 63 | 63 | return $this->getCountForSection( self::SECTION_OPPOSE ); |
| 64 | 64 | } |
| 65 | 65 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * |
| 69 | 69 | * @return int |
| 70 | 70 | */ |
| 71 | - public function getSupportCount() : int { |
|
| 71 | + public function getSupportCount () : int { |
|
| 72 | 72 | return $this->getCountForSection( self::SECTION_SUPPORT ); |
| 73 | 73 | } |
| 74 | 74 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * @param int $secNum |
| 79 | 79 | * @return int |
| 80 | 80 | */ |
| 81 | - protected function getCountForSection( int $secNum ) : int { |
|
| 81 | + protected function getCountForSection ( int $secNum ) : int { |
|
| 82 | 82 | $content = $this->controller->getPageContent( $this->title, $secNum ); |
| 83 | 83 | // Let's hope that this is good enough... |
| 84 | 84 | return substr_count( $content, "\n\# *(?![#*])" ); |
@@ -89,11 +89,11 @@ discard block |
||
| 89 | 89 | * |
| 90 | 90 | * @return int |
| 91 | 91 | */ |
| 92 | - protected function getQuorum() : int { |
|
| 92 | + protected function getQuorum () : int { |
|
| 93 | 93 | $reg = "!soddisfare il \[\[[^|\]]+\|quorum]] di '''(\d+) voti'''!"; |
| 94 | - $matches = []; |
|
| 94 | + $matches = [ ]; |
|
| 95 | 95 | preg_match( $reg, $this->getContent(), $matches ); |
| 96 | - return intval( $matches[1] ); |
|
| 96 | + return intval( $matches[ 1 ] ); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /** |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * |
| 102 | 102 | * @return bool |
| 103 | 103 | */ |
| 104 | - public function hasOpposition() : bool { |
|
| 104 | + public function hasOpposition () : bool { |
|
| 105 | 105 | return $this->getOpposingCount() >= 15; |
| 106 | 106 | } |
| 107 | 107 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * @return int One of the OUTCOME_* constants |
| 112 | 112 | * @throws \BadMethodCallException |
| 113 | 113 | */ |
| 114 | - public function getOutcome() : int { |
|
| 114 | + public function getOutcome () : int { |
|
| 115 | 115 | if ( !$this->isVote() ) { |
| 116 | 116 | throw new \BadMethodCallException( 'Cannot get outcome for a non-vote page.' ); |
| 117 | 117 | } |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * @return string |
| 131 | 131 | * @throws \BadMethodCallException |
| 132 | 132 | */ |
| 133 | - public function getOutcomeText() : string { |
|
| 133 | + public function getOutcomeText () : string { |
|
| 134 | 134 | if ( !$this->isVote() ) { |
| 135 | 135 | throw new \BadMethodCallException( 'No need for an outcome text.' ); |
| 136 | 136 | } |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | * |
| 163 | 163 | * @return bool |
| 164 | 164 | */ |
| 165 | - public function isVote() : bool { |
|
| 165 | + public function isVote () : bool { |
|
| 166 | 166 | $sectionReg = '/<!-- SEZIONE DA UTILIZZARE PER/'; |
| 167 | 167 | return preg_match( $sectionReg, $this->getContent() ) === false; |
| 168 | 168 | } |
@@ -172,9 +172,9 @@ discard block |
||
| 172 | 172 | * |
| 173 | 173 | * @return int |
| 174 | 174 | */ |
| 175 | - public function getEndTimestamp() : int { |
|
| 175 | + public function getEndTimestamp () : int { |
|
| 176 | 176 | if ( $this->isVote() ) { |
| 177 | - $matches = []; |
|
| 177 | + $matches = [ ]; |
|
| 178 | 178 | $reg = "!La votazione ha inizio il.+ e ha termine.+ '''([^']+)''' alle ore '''([^']+)'''!"; |
| 179 | 179 | preg_match( $reg, $this->getContent(), $matches ); |
| 180 | 180 | list( , $day, $hours ) = $matches; |
@@ -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 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * @inheritDoc |
| 17 | 17 | */ |
| 18 | - public function run() : TaskResult { |
|
| 18 | + public function run () : TaskResult { |
|
| 19 | 19 | $this->getLogger()->info( 'Starting task UpdatesAround' ); |
| 20 | 20 | |
| 21 | 21 | $pages = $this->getDataProvider()->getCreatedPages(); |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * |
| 40 | 40 | * @param PageRiconferma[] $pages |
| 41 | 41 | */ |
| 42 | - protected function addToMainPage( array $pages ) { |
|
| 42 | + protected function addToMainPage ( array $pages ) { |
|
| 43 | 43 | $this->getLogger()->info( |
| 44 | 44 | 'Adding the following to main: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 45 | 45 | ); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * |
| 67 | 67 | * @param PageRiconferma[] $pages |
| 68 | 68 | */ |
| 69 | - protected function addVote( array $pages ) { |
|
| 69 | + protected function addVote ( array $pages ) { |
|
| 70 | 70 | $this->getLogger()->info( |
| 71 | 71 | 'Adding the following to votes: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 72 | 72 | ); |
@@ -87,14 +87,14 @@ discard block |
||
| 87 | 87 | $newContent = preg_replace( $introReg, '$0' . "\n$newLines", $content, 1 ); |
| 88 | 88 | } else { |
| 89 | 89 | // Start section |
| 90 | - $matches = []; |
|
| 90 | + $matches = [ ]; |
|
| 91 | 91 | if ( preg_match( $introReg, $content, $matches ) === false ) { |
| 92 | 92 | throw new TaskException( 'Intro not found in vote page' ); |
| 93 | 93 | } |
| 94 | 94 | $beforeReg = '!INSERIRE LA NOTIZIA PIÙ NUOVA IN CIMA.+!m'; |
| 95 | 95 | // Replace semicolon with full stop |
| 96 | 96 | $newLines = substr( $newLines, 0, -2 ) . ".\n"; |
| 97 | - $newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[0]}\n$newLines", $content, 1 ); |
|
| 97 | + $newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[ 0 ]}\n$newLines", $content, 1 ); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | $summary = $this->msg( 'ric-vote-page-summary' ) |
@@ -113,19 +113,19 @@ discard block |
||
| 113 | 113 | * |
| 114 | 114 | * @param int $amount |
| 115 | 115 | */ |
| 116 | - protected function addNews( int $amount ) { |
|
| 116 | + protected function addNews ( int $amount ) { |
|
| 117 | 117 | $this->getLogger()->info( "Increasing the news counter by $amount" ); |
| 118 | 118 | $newsPage = new Page( $this->getConfig()->get( 'ric-news-page' ) ); |
| 119 | 119 | |
| 120 | 120 | $content = $newsPage->getContent(); |
| 121 | 121 | $reg = '!(\| *riconferme[ _]tacite[ _]amministratori *= *)(\d+)!'; |
| 122 | 122 | |
| 123 | - $matches = []; |
|
| 123 | + $matches = [ ]; |
|
| 124 | 124 | if ( preg_match( $reg, $content, $matches ) === false ) { |
| 125 | 125 | throw new TaskException( 'Param not found in news page' ); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - $newNum = (int)$matches[2] + $amount; |
|
| 128 | + $newNum = (int)$matches[ 2 ] + $amount; |
|
| 129 | 129 | $newContent = preg_replace( $reg, '${1}' . $newNum, $content ); |
| 130 | 130 | |
| 131 | 131 | $summary = $this->msg( 'ric-news-page-summary' ) |