@@ -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 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @param string $username |
| 16 | 16 | * @param string $password |
| 17 | 17 | */ |
| 18 | - public function __construct( string $username, string $password ) { |
|
| 18 | + public function __construct ( string $username, string $password ) { |
|
| 19 | 19 | $this->username = $username; |
| 20 | 20 | $this->password = $password; |
| 21 | 21 | } |
@@ -23,14 +23,14 @@ discard block |
||
| 23 | 23 | /** |
| 24 | 24 | * @return string |
| 25 | 25 | */ |
| 26 | - public function getUsername(): string { |
|
| 26 | + public function getUsername (): string { |
|
| 27 | 27 | return $this->username; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * @return string |
| 32 | 32 | */ |
| 33 | - public function getPassword(): string { |
|
| 33 | + public function getPassword (): string { |
|
| 34 | 34 | return $this->password; |
| 35 | 35 | } |
| 36 | 36 | } |
@@ -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 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * @param Wiki $centralWiki |
| 19 | 19 | * @param Wiki $privateWiki |
| 20 | 20 | */ |
| 21 | - public function __construct( Wiki $mainWiki, Wiki $centralWiki, Wiki $privateWiki ) { |
|
| 21 | + public function __construct ( Wiki $mainWiki, Wiki $centralWiki, Wiki $privateWiki ) { |
|
| 22 | 22 | $this->mainWiki = $mainWiki; |
| 23 | 23 | $this->centralWiki = $centralWiki; |
| 24 | 24 | $this->privateWiki = $privateWiki; |
@@ -27,21 +27,21 @@ discard block |
||
| 27 | 27 | /** |
| 28 | 28 | * @return Wiki |
| 29 | 29 | */ |
| 30 | - public function getMainWiki(): Wiki { |
|
| 30 | + public function getMainWiki (): Wiki { |
|
| 31 | 31 | return $this->mainWiki; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * @return Wiki |
| 36 | 36 | */ |
| 37 | - public function getCentralWiki(): Wiki { |
|
| 37 | + public function getCentralWiki (): Wiki { |
|
| 38 | 38 | return $this->centralWiki; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | 42 | * @return Wiki |
| 43 | 43 | */ |
| 44 | - public function getPrivateWiki(): Wiki { |
|
| 44 | + public function getPrivateWiki (): Wiki { |
|
| 45 | 45 | return $this->privateWiki; |
| 46 | 46 | } |
| 47 | 47 | } |
@@ -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 | |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * @param UserInfo $ui |
| 24 | 24 | * @param Wiki $wiki |
| 25 | 25 | */ |
| 26 | - public function __construct( UserInfo $ui, Wiki $wiki ) { |
|
| 26 | + public function __construct ( UserInfo $ui, Wiki $wiki ) { |
|
| 27 | 27 | $this->wiki = $wiki; |
| 28 | 28 | $this->name = $ui->getName(); |
| 29 | 29 | $this->ui = $ui; |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | /** |
| 33 | 33 | * @return string |
| 34 | 34 | */ |
| 35 | - public function getName(): string { |
|
| 35 | + public function getName (): string { |
|
| 36 | 36 | return $this->name; |
| 37 | 37 | } |
| 38 | 38 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * |
| 42 | 42 | * @return string[] |
| 43 | 43 | */ |
| 44 | - public function getGroups(): array { |
|
| 44 | + public function getGroups (): array { |
|
| 45 | 45 | return $this->ui->extractGroups(); |
| 46 | 46 | } |
| 47 | 47 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @return string[] [ group => date ] |
| 52 | 52 | */ |
| 53 | - public function getGroupsWithDates(): array { |
|
| 53 | + public function getGroupsWithDates (): array { |
|
| 54 | 54 | return $this->ui->extractGroupsWithDates(); |
| 55 | 55 | } |
| 56 | 56 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * @param string $groupName |
| 61 | 61 | * @return bool |
| 62 | 62 | */ |
| 63 | - public function inGroup( string $groupName ): bool { |
|
| 63 | + public function inGroup ( string $groupName ): bool { |
|
| 64 | 64 | return in_array( $groupName, $this->getGroups(), true ); |
| 65 | 65 | } |
| 66 | 66 | |
@@ -69,9 +69,9 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @inheritDoc |
| 71 | 71 | */ |
| 72 | - public function getRegex( string $delimiter = '/' ): string { |
|
| 72 | + public function getRegex ( string $delimiter = '/' ): string { |
|
| 73 | 73 | $bits = $this->getAliases(); |
| 74 | - $bits[] = $this->name; |
|
| 74 | + $bits[ ] = $this->name; |
|
| 75 | 75 | $regexify = static function ( string $el ) use ( $delimiter ): string { |
| 76 | 76 | return str_replace( ' ', '[ _]', preg_quote( $el, $delimiter ) ); |
| 77 | 77 | }; |
@@ -83,14 +83,14 @@ discard block |
||
| 83 | 83 | * |
| 84 | 84 | * @return string[] |
| 85 | 85 | */ |
| 86 | - public function getAliases(): array { |
|
| 86 | + public function getAliases (): array { |
|
| 87 | 87 | return $this->ui->getAliases(); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | 91 | * @return Page |
| 92 | 92 | */ |
| 93 | - public function getTalkPage(): Page { |
|
| 93 | + public function getTalkPage (): Page { |
|
| 94 | 94 | return new Page( "User talk:{$this->name}", $this->wiki ); |
| 95 | 95 | } |
| 96 | 96 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | * Get the default base page, e.g. WP:A/Riconferma annuale/XXX |
| 99 | 99 | * @return Page |
| 100 | 100 | */ |
| 101 | - public function getBasePage(): Page { |
|
| 101 | + public function getBasePage (): Page { |
|
| 102 | 102 | $prefix = Config::getInstance()->get( 'main-page-title' ); |
| 103 | 103 | return new Page( "$prefix/$this", $this->wiki ); |
| 104 | 104 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * @throws MissingPageException |
| 111 | 111 | * @return Page |
| 112 | 112 | */ |
| 113 | - public function getExistingBasePage(): Page { |
|
| 113 | + public function getExistingBasePage (): Page { |
|
| 114 | 114 | $basePage = $this->getBasePage(); |
| 115 | 115 | if ( !$basePage->exists() ) { |
| 116 | 116 | $basePage = null; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | /** |
| 135 | 135 | * @return string |
| 136 | 136 | */ |
| 137 | - public function __toString(): string { |
|
| 137 | + public function __toString (): string { |
|
| 138 | 138 | return $this->name; |
| 139 | 139 | } |
| 140 | 140 | } |
@@ -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 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @param array $info |
| 22 | 22 | * @phan-param array<string,string|string[]> $info |
| 23 | 23 | */ |
| 24 | - public function __construct( string $name, array $info ) { |
|
| 24 | + public function __construct ( string $name, array $info ) { |
|
| 25 | 25 | $this->name = $name; |
| 26 | 26 | $this->info = $info; |
| 27 | 27 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | /** |
| 30 | 30 | * @return string |
| 31 | 31 | */ |
| 32 | - public function getName(): string { |
|
| 32 | + public function getName (): string { |
|
| 33 | 33 | return $this->name; |
| 34 | 34 | } |
| 35 | 35 | |
@@ -37,28 +37,28 @@ discard block |
||
| 37 | 37 | * @return array |
| 38 | 38 | * @phan-return array<string,string|string[]> |
| 39 | 39 | */ |
| 40 | - public function getInfo(): array { |
|
| 40 | + public function getInfo (): array { |
|
| 41 | 41 | return $this->info; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | 45 | * @return string[] |
| 46 | 46 | */ |
| 47 | - public function extractGroups(): array { |
|
| 47 | + public function extractGroups (): array { |
|
| 48 | 48 | return array_keys( $this->extractGroupsWithDates() ); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | 52 | * @return string[] |
| 53 | 53 | */ |
| 54 | - public function extractGroupsWithDates(): array { |
|
| 54 | + public function extractGroupsWithDates (): array { |
|
| 55 | 55 | return array_intersect_key( $this->getInfo(), array_fill_keys( self::GROUP_KEYS, 1 ) ); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | 59 | * @return string[] |
| 60 | 60 | */ |
| 61 | - public function getAliases(): array { |
|
| 62 | - return $this->getInfo()['aliases'] ?? []; |
|
| 61 | + public function getAliases (): array { |
|
| 62 | + return $this->getInfo()[ 'aliases' ] ?? [ ]; |
|
| 63 | 63 | } |
| 64 | 64 | } |
@@ -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 | |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | /** |
| 35 | 35 | * @param CLI $cli |
| 36 | 36 | */ |
| 37 | - public function __construct( CLI $cli ) { |
|
| 37 | + public function __construct ( CLI $cli ) { |
|
| 38 | 38 | $this->cli = $cli; |
| 39 | 39 | $this->initialize(); |
| 40 | 40 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | /** |
| 43 | 43 | * Initialize all members. |
| 44 | 44 | */ |
| 45 | - private function initialize(): void { |
|
| 45 | + private function initialize (): void { |
|
| 46 | 46 | $simpleLogger = new SimpleLogger(); |
| 47 | 47 | $this->createWikiGroup( $simpleLogger ); |
| 48 | 48 | $this->messageProvider = new MessageProvider( |
@@ -56,14 +56,14 @@ discard block |
||
| 56 | 56 | /** |
| 57 | 57 | * Main entry point |
| 58 | 58 | */ |
| 59 | - public function run(): void { |
|
| 59 | + public function run (): void { |
|
| 60 | 60 | $taskOpt = $this->cli->getTaskOpt(); |
| 61 | 61 | $type = current( array_keys( $taskOpt ) ); |
| 62 | 62 | try { |
| 63 | 63 | if ( $type === 'tasks' ) { |
| 64 | - $this->runInternal( TaskManager::MODE_TASK, explode( ',', $taskOpt['tasks'] ) ); |
|
| 64 | + $this->runInternal( TaskManager::MODE_TASK, explode( ',', $taskOpt[ 'tasks' ] ) ); |
|
| 65 | 65 | } elseif ( $type === 'subtasks' ) { |
| 66 | - $this->runInternal( TaskManager::MODE_SUBTASK, explode( ',', $taskOpt['subtasks'] ) ); |
|
| 66 | + $this->runInternal( TaskManager::MODE_SUBTASK, explode( ',', $taskOpt[ 'subtasks' ] ) ); |
|
| 67 | 67 | } else { |
| 68 | 68 | $this->runInternal(); |
| 69 | 69 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | /** |
| 78 | 78 | * @param LoggerInterface $baseLogger |
| 79 | 79 | */ |
| 80 | - private function createWikiGroup( LoggerInterface $baseLogger ): void { |
|
| 80 | + private function createWikiGroup ( LoggerInterface $baseLogger ): void { |
|
| 81 | 81 | // FIXME Hardcoded |
| 82 | 82 | $url = $this->cli->getURL() ?? 'https://it.wikipedia.org/w/api.php'; |
| 83 | 83 | $localUserIdentifier = '@itwiki'; |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * |
| 116 | 116 | * @param IFlushingAwareLogger $baseLogger |
| 117 | 117 | */ |
| 118 | - private function createMainLogger( IFlushingAwareLogger $baseLogger ): void { |
|
| 118 | + private function createMainLogger ( IFlushingAwareLogger $baseLogger ): void { |
|
| 119 | 119 | $mainWiki = $this->wikiGroup->getMainWiki(); |
| 120 | 120 | $mp = $this->messageProvider; |
| 121 | 121 | $errTitle = $this->cli->getOpt( 'error-title' ); |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | /** |
| 143 | 143 | * Create the Config |
| 144 | 144 | */ |
| 145 | - private function initConfig(): void { |
|
| 145 | + private function initConfig (): void { |
|
| 146 | 146 | $wiki = $this->wikiGroup->getMainWiki(); |
| 147 | 147 | try { |
| 148 | 148 | $confValues = json_decode( $wiki->getPageContent( $this->cli->getSetOpt( 'config-title' ) ), true ); |
@@ -159,9 +159,9 @@ discard block |
||
| 159 | 159 | * @param string $mode |
| 160 | 160 | * @param string[] $taskNames |
| 161 | 161 | */ |
| 162 | - private function runInternal( |
|
| 162 | + private function runInternal ( |
|
| 163 | 163 | string $mode = TaskManager::MODE_COMPLETE, |
| 164 | - array $taskNames = [] |
|
| 164 | + array $taskNames = [ ] |
|
| 165 | 165 | ): void { |
| 166 | 166 | $activity = $mode === TaskManager::MODE_COMPLETE |
| 167 | 167 | ? 'full process' |
@@ -181,8 +181,7 @@ discard block |
||
| 181 | 181 | $base = "Execution of $activity"; |
| 182 | 182 | if ( $res->isOK() ) { |
| 183 | 183 | $msg = $res->getStatus() === TaskResult::STATUS_NOTHING ? |
| 184 | - ': nothing to do' : |
|
| 185 | - ' completed successfully'; |
|
| 184 | + ': nothing to do' : ' completed successfully'; |
|
| 186 | 185 | $this->mainLogger->info( $base . $msg ); |
| 187 | 186 | } else { |
| 188 | 187 | $this->mainLogger->error( "$base failed.\n$res" ); |
@@ -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 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | * @param string $title |
| 23 | 23 | * @param Wiki $wiki For the site where the page lives |
| 24 | 24 | */ |
| 25 | - public function __construct( string $title, Wiki $wiki ) { |
|
| 25 | + public function __construct ( string $title, Wiki $wiki ) { |
|
| 26 | 26 | $this->wiki = $wiki; |
| 27 | 27 | $this->title = $title; |
| 28 | 28 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | /** |
| 31 | 31 | * @return string |
| 32 | 32 | */ |
| 33 | - public function getTitle(): string { |
|
| 33 | + public function getTitle (): string { |
|
| 34 | 34 | return $this->title; |
| 35 | 35 | } |
| 36 | 36 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * @param int|null $section A section number to retrieve the content of that section |
| 41 | 41 | * @return string |
| 42 | 42 | */ |
| 43 | - public function getContent( int $section = null ): string { |
|
| 43 | + public function getContent ( int $section = null ): string { |
|
| 44 | 44 | if ( $this->content === null ) { |
| 45 | 45 | $this->content = $this->wiki->getPageContent( $this->title, $section ); |
| 46 | 46 | } |
@@ -54,18 +54,18 @@ discard block |
||
| 54 | 54 | * @phan-param array<int|string|bool> $params |
| 55 | 55 | * @throws LogicException |
| 56 | 56 | */ |
| 57 | - public function edit( array $params ): void { |
|
| 57 | + public function edit ( array $params ): void { |
|
| 58 | 58 | $params = [ |
| 59 | 59 | 'title' => $this->getTitle() |
| 60 | 60 | ] + $params; |
| 61 | 61 | |
| 62 | 62 | $this->wiki->editPage( $params ); |
| 63 | - if ( isset( $params['text'] ) ) { |
|
| 64 | - $this->content = $params['text']; |
|
| 65 | - } elseif ( isset( $params['appendtext'] ) ) { |
|
| 66 | - $this->content .= $params['appendtext']; |
|
| 67 | - } elseif ( isset( $params['prependtext'] ) ) { |
|
| 68 | - $this->content = $params['prependtext'] . $this->content; |
|
| 63 | + if ( isset( $params[ 'text' ] ) ) { |
|
| 64 | + $this->content = $params[ 'text' ]; |
|
| 65 | + } elseif ( isset( $params[ 'appendtext' ] ) ) { |
|
| 66 | + $this->content .= $params[ 'appendtext' ]; |
|
| 67 | + } elseif ( isset( $params[ 'prependtext' ] ) ) { |
|
| 68 | + $this->content = $params[ 'prependtext' ] . $this->content; |
|
| 69 | 69 | } else { |
| 70 | 70 | throw new LogicException( |
| 71 | 71 | 'Unrecognized text param for edit. Params: ' . var_export( $params, true ) |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * |
| 79 | 79 | * @return bool |
| 80 | 80 | */ |
| 81 | - public function exists(): bool { |
|
| 81 | + public function exists (): bool { |
|
| 82 | 82 | $pages = $this->wiki->getRequestFactory()->createStandaloneRequest( [ |
| 83 | 83 | 'action' => 'query', |
| 84 | 84 | 'titles' => $this->getTitle() |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | * @param string $regex |
| 93 | 93 | * @return bool |
| 94 | 94 | */ |
| 95 | - public function matches( string $regex ): bool { |
|
| 95 | + public function matches ( string $regex ): bool { |
|
| 96 | 96 | return (bool)preg_match( $regex, $this->getContent() ); |
| 97 | 97 | } |
| 98 | 98 | |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | * @return string[] |
| 105 | 105 | * @throws MissingMatchException |
| 106 | 106 | */ |
| 107 | - public function getMatch( string $regex ): array { |
|
| 108 | - $ret = []; |
|
| 107 | + public function getMatch ( string $regex ): array { |
|
| 108 | + $ret = [ ]; |
|
| 109 | 109 | if ( preg_match( $regex, $this->getContent(), $ret ) === 0 ) { |
| 110 | 110 | throw new MissingMatchException( "The content of $this does not match the given regex $regex" ); |
| 111 | 111 | } |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | * |
| 118 | 118 | * @inheritDoc |
| 119 | 119 | */ |
| 120 | - public function getRegex( string $delimiter = '/' ): string { |
|
| 120 | + public function getRegex ( string $delimiter = '/' ): string { |
|
| 121 | 121 | return str_replace( ' ', '[ _]', preg_quote( $this->title, $delimiter ) ); |
| 122 | 122 | } |
| 123 | 123 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * |
| 127 | 127 | * @return string |
| 128 | 128 | */ |
| 129 | - public function __toString(): string { |
|
| 129 | + public function __toString (): string { |
|
| 130 | 130 | return $this->getTitle(); |
| 131 | 131 | } |
| 132 | 132 | } |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\TaskHelper; |
| 4 | 4 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | /** @var User[]|null */ |
| 16 | 16 | private $processUsers; |
| 17 | 17 | /** @var PageRiconferma[] */ |
| 18 | - private $createdPages = []; |
|
| 18 | + private $createdPages = [ ]; |
|
| 19 | 19 | /** @var PageRiconferma[]|null */ |
| 20 | 20 | private $openPages; |
| 21 | 21 | /** @var PageRiconferma[]|null */ |
@@ -26,9 +26,9 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @return User[] |
| 28 | 28 | */ |
| 29 | - public function getUsersToProcess(): array { |
|
| 29 | + public function getUsersToProcess (): array { |
|
| 30 | 30 | if ( $this->processUsers === null ) { |
| 31 | - $this->processUsers = []; |
|
| 31 | + $this->processUsers = [ ]; |
|
| 32 | 32 | foreach ( $this->getBotList()->getAdminsList() as $name => $userInfo ) { |
| 33 | 33 | if ( $this->shouldAddUser( $userInfo ) ) { |
| 34 | 34 | $this->processUsers[ $name ] = new User( $userInfo, $this->getWiki() ); |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * @param UserInfo $ui |
| 46 | 46 | * @return bool |
| 47 | 47 | */ |
| 48 | - private function shouldAddUser( UserInfo $ui ): bool { |
|
| 48 | + private function shouldAddUser ( UserInfo $ui ): bool { |
|
| 49 | 49 | $timestamp = $this->getBotList()->getOverrideTimestamp( $ui ); |
| 50 | 50 | $override = $timestamp !== null; |
| 51 | 51 | |
@@ -63,9 +63,9 @@ discard block |
||
| 63 | 63 | * |
| 64 | 64 | * @return PageRiconferma[] |
| 65 | 65 | */ |
| 66 | - public function getOpenPages(): array { |
|
| 66 | + public function getOpenPages (): array { |
|
| 67 | 67 | if ( $this->openPages === null ) { |
| 68 | - $this->openPages = []; |
|
| 68 | + $this->openPages = [ ]; |
|
| 69 | 69 | $mainTitle = $this->getOpt( 'main-page-title' ); |
| 70 | 70 | $params = [ |
| 71 | 71 | 'action' => 'query', |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | $pages = $this->getWiki()->getRequestFactory()->createStandaloneRequest( $params )->executeAsQuery(); |
| 80 | 80 | foreach ( $pages->current()->templates as $page ) { |
| 81 | 81 | if ( preg_match( "!$titleReg/[^/]+/\d!", $page->title ) ) { |
| 82 | - $this->openPages[] = new PageRiconferma( $page->title, $this->getWiki() ); |
|
| 82 | + $this->openPages[ ] = new PageRiconferma( $page->title, $this->getWiki() ); |
|
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | } |
@@ -92,12 +92,12 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @return PageRiconferma[] |
| 94 | 94 | */ |
| 95 | - public function getPagesToClose(): array { |
|
| 95 | + public function getPagesToClose (): array { |
|
| 96 | 96 | if ( $this->pagesToClose === null ) { |
| 97 | - $this->pagesToClose = []; |
|
| 97 | + $this->pagesToClose = [ ]; |
|
| 98 | 98 | foreach ( $this->getOpenPages() as $page ) { |
| 99 | 99 | if ( time() > $page->getEndTimestamp() ) { |
| 100 | - $this->pagesToClose[] = $page; |
|
| 100 | + $this->pagesToClose[ ] = $page; |
|
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | } |
@@ -109,21 +109,21 @@ discard block |
||
| 109 | 109 | * |
| 110 | 110 | * @param string $name |
| 111 | 111 | */ |
| 112 | - public function removeUser( string $name ): void { |
|
| 112 | + public function removeUser ( string $name ): void { |
|
| 113 | 113 | unset( $this->processUsers[ $name ] ); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
| 117 | 117 | * @return PageRiconferma[] |
| 118 | 118 | */ |
| 119 | - public function getCreatedPages(): array { |
|
| 119 | + public function getCreatedPages (): array { |
|
| 120 | 120 | return $this->createdPages; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
| 124 | 124 | * @param PageRiconferma $page |
| 125 | 125 | */ |
| 126 | - public function addCreatedPage( PageRiconferma $page ): void { |
|
| 127 | - $this->createdPages[] = $page; |
|
| 126 | + public function addCreatedPage ( PageRiconferma $page ): void { |
|
| 127 | + $this->createdPages[ ] = $page; |
|
| 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\Task\Subtask; |
| 4 | 4 | |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | /** |
| 18 | 18 | * @inheritDoc |
| 19 | 19 | */ |
| 20 | - public function runInternal(): int { |
|
| 20 | + public function runInternal (): int { |
|
| 21 | 21 | $users = $this->getDataProvider()->getUsersToProcess(); |
| 22 | 22 | |
| 23 | 23 | if ( !$users ) { |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * |
| 37 | 37 | * @param User $user |
| 38 | 38 | */ |
| 39 | - protected function processUser( User $user ): void { |
|
| 39 | + protected function processUser ( User $user ): void { |
|
| 40 | 40 | $this->getLogger()->info( "Processing user $user" ); |
| 41 | 41 | try { |
| 42 | 42 | $num = $this->getLastPageNum( $user ) + 1; |
@@ -71,14 +71,14 @@ discard block |
||
| 71 | 71 | * @return int |
| 72 | 72 | * @throws TaskException |
| 73 | 73 | */ |
| 74 | - protected function getLastPageNum( User $user ): int { |
|
| 74 | + protected function getLastPageNum ( User $user ): int { |
|
| 75 | 75 | $this->getLogger()->info( "Retrieving previous pages for $user" ); |
| 76 | 76 | |
| 77 | - $unprefixedTitle = explode( ':', $this->getOpt( 'main-page-title' ), 2 )[1]; |
|
| 77 | + $unprefixedTitle = explode( ':', $this->getOpt( 'main-page-title' ), 2 )[ 1 ]; |
|
| 78 | 78 | |
| 79 | 79 | $prefixes = [ "$unprefixedTitle/$user/" ]; |
| 80 | 80 | foreach ( $user->getAliases() as $alias ) { |
| 81 | - $prefixes[] = "$unprefixedTitle/$alias/"; |
|
| 81 | + $prefixes[ ] = "$unprefixedTitle/$alias/"; |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | $params = [ |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | ]; |
| 91 | 91 | $pagesIterator = new AppendIterator(); |
| 92 | 92 | foreach ( $prefixes as $prefix ) { |
| 93 | - $params['apprefix'] = $prefix; |
|
| 93 | + $params[ 'apprefix' ] = $prefix; |
|
| 94 | 94 | $res = $this->getWiki()->getRequestFactory()->createStandaloneRequest( $params )->executeAsQuery(); |
| 95 | 95 | $pagesIterator->append( new NoRewindIterator( $res ) ); |
| 96 | 96 | } |
@@ -116,14 +116,14 @@ discard block |
||
| 116 | 116 | * @param string $title |
| 117 | 117 | * @param User $user |
| 118 | 118 | */ |
| 119 | - protected function createPage( string $title, User $user ): void { |
|
| 119 | + protected function createPage ( string $title, User $user ): void { |
|
| 120 | 120 | $this->getLogger()->info( "Creating page $title" ); |
| 121 | 121 | $groups = $user->getGroupsWithDates(); |
| 122 | 122 | $textParams = [ |
| 123 | 123 | '$user' => $user->getName(), |
| 124 | - '$date' => $groups['sysop'], |
|
| 125 | - '$burocrate' => $groups['bureaucrat'] ?? '', |
|
| 126 | - '$checkuser' => $groups['checkuser'] ?? '' |
|
| 124 | + '$date' => $groups[ 'sysop' ], |
|
| 125 | + '$burocrate' => $groups[ 'bureaucrat' ] ?? '', |
|
| 126 | + '$checkuser' => $groups[ 'checkuser' ] ?? '' |
|
| 127 | 127 | ]; |
| 128 | 128 | |
| 129 | 129 | $params = [ |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | * @param Page $basePage |
| 142 | 142 | * @param string $newText |
| 143 | 143 | */ |
| 144 | - protected function createBasePage( Page $basePage, string $newText ): void { |
|
| 144 | + protected function createBasePage ( Page $basePage, string $newText ): void { |
|
| 145 | 145 | $this->getLogger()->info( "Creating base page $basePage" ); |
| 146 | 146 | |
| 147 | 147 | $params = [ |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @param Page $basePage |
| 158 | 158 | * @param string $newText |
| 159 | 159 | */ |
| 160 | - protected function updateBasePage( Page $basePage, string $newText ): void { |
|
| 160 | + protected function updateBasePage ( Page $basePage, string $newText ): void { |
|
| 161 | 161 | $this->getLogger()->info( "Updating base page $basePage" ); |
| 162 | 162 | |
| 163 | 163 | $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 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * @param MessageProvider $mp |
| 38 | 38 | * @param PageBotList $pbl |
| 39 | 39 | */ |
| 40 | - public function __construct( |
|
| 40 | + public function __construct ( |
|
| 41 | 41 | LoggerInterface $logger, |
| 42 | 42 | WikiGroup $wikiGroup, |
| 43 | 43 | MessageProvider $mp, |
@@ -53,14 +53,14 @@ discard block |
||
| 53 | 53 | /** |
| 54 | 54 | * @return LoggerInterface |
| 55 | 55 | */ |
| 56 | - protected function getLogger(): LoggerInterface { |
|
| 56 | + protected function getLogger (): LoggerInterface { |
|
| 57 | 57 | return $this->logger; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * @inheritDoc |
| 62 | 62 | */ |
| 63 | - public function setLogger( LoggerInterface $logger ): void { |
|
| 63 | + public function setLogger ( LoggerInterface $logger ): void { |
|
| 64 | 64 | $this->logger = $logger; |
| 65 | 65 | } |
| 66 | 66 | |
@@ -70,21 +70,21 @@ discard block |
||
| 70 | 70 | * @param string $optname |
| 71 | 71 | * @return mixed |
| 72 | 72 | */ |
| 73 | - protected function getOpt( string $optname ) { |
|
| 73 | + protected function getOpt ( string $optname ) { |
|
| 74 | 74 | return $this->getConfig()->get( $optname ); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
| 78 | 78 | * @return Config |
| 79 | 79 | */ |
| 80 | - protected function getConfig(): Config { |
|
| 80 | + protected function getConfig (): Config { |
|
| 81 | 81 | return $this->config; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * @param Config $cfg |
| 86 | 86 | */ |
| 87 | - protected function setConfig( Config $cfg ): void { |
|
| 87 | + protected function setConfig ( Config $cfg ): void { |
|
| 88 | 88 | $this->config = $cfg; |
| 89 | 89 | } |
| 90 | 90 | |
@@ -92,35 +92,35 @@ discard block |
||
| 92 | 92 | * Shorthand |
| 93 | 93 | * @return Wiki |
| 94 | 94 | */ |
| 95 | - protected function getWiki(): Wiki { |
|
| 95 | + protected function getWiki (): Wiki { |
|
| 96 | 96 | return $this->getWikiGroup()->getMainWiki(); |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | 100 | * @return WikiGroup |
| 101 | 101 | */ |
| 102 | - protected function getWikiGroup(): WikiGroup { |
|
| 102 | + protected function getWikiGroup (): WikiGroup { |
|
| 103 | 103 | return $this->wikiGroup; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
| 107 | 107 | * @param WikiGroup $wikiGroup |
| 108 | 108 | */ |
| 109 | - protected function setWikiGroup( WikiGroup $wikiGroup ): void { |
|
| 109 | + protected function setWikiGroup ( WikiGroup $wikiGroup ): void { |
|
| 110 | 110 | $this->wikiGroup = $wikiGroup; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
| 114 | 114 | * @return MessageProvider |
| 115 | 115 | */ |
| 116 | - protected function getMessageProvider(): MessageProvider { |
|
| 116 | + protected function getMessageProvider (): MessageProvider { |
|
| 117 | 117 | return $this->messageProvider; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
| 121 | 121 | * @param MessageProvider $mp |
| 122 | 122 | */ |
| 123 | - protected function setMessageProvider( MessageProvider $mp ): void { |
|
| 123 | + protected function setMessageProvider ( MessageProvider $mp ): void { |
|
| 124 | 124 | $this->messageProvider = $mp; |
| 125 | 125 | } |
| 126 | 126 | |
@@ -130,14 +130,14 @@ discard block |
||
| 130 | 130 | * @param string $key |
| 131 | 131 | * @return Message |
| 132 | 132 | */ |
| 133 | - protected function msg( string $key ): Message { |
|
| 133 | + protected function msg ( string $key ): Message { |
|
| 134 | 134 | return $this->messageProvider->getMessage( $key ); |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
| 138 | 138 | * @return PageBotList |
| 139 | 139 | */ |
| 140 | - public function getBotList(): PageBotList { |
|
| 140 | + public function getBotList (): PageBotList { |
|
| 141 | 141 | return $this->pageBotList; |
| 142 | 142 | } |
| 143 | 143 | |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | * @param string $title |
| 148 | 148 | * @return Page |
| 149 | 149 | */ |
| 150 | - protected function getPage( string $title ): Page { |
|
| 150 | + protected function getPage ( string $title ): Page { |
|
| 151 | 151 | return new Page( $title, $this->getWiki() ); |
| 152 | 152 | } |
| 153 | 153 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @param string $name |
| 158 | 158 | * @return User |
| 159 | 159 | */ |
| 160 | - protected function getUser( string $name ): User { |
|
| 160 | + protected function getUser ( string $name ): User { |
|
| 161 | 161 | $ui = $this->getBotList()->getUserInfo( $name ); |
| 162 | 162 | return new User( $ui, $this->getWiki() ); |
| 163 | 163 | } |