Skip to content

Commit

Permalink
(tests) Fix Phan warnings in benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardspec committed Jan 4, 2025
1 parent bca5cac commit 8a57743
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .phan/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
# and we don't want it basing its assumptions on testsuite code when checking the main code.
$cfg['directory_list'][] = 'tests/phpunit';
$cfg['directory_list'][] = 'tests/common';
$cfg['directory_list'][] = 'tests/benchmark';
$cfg['directory_list'][] = 'tests/benchmarks';

# PHPUnit classes, etc. Should be parsed, but not analyzed.
$cfg['directory_list'][] = $IP . '/tests';
Expand Down
8 changes: 4 additions & 4 deletions tests/benchmarks/ModerationBenchmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function getUser() {

/**
* Returns Title object for testing.
* @param string $suffix Full text of the title, e.g. "Talk:Welsh corgi".
* @param string|int $suffix Full text of the title, e.g. "Talk:Welsh corgi".
* @return Title
*
* During this benchmark, same value is returned for same $suffix,
Expand All @@ -83,7 +83,7 @@ abstract public function doActualWork( $iterationNumber );

/**
* Initialize everything before the tests. Called once.
* @param int $numberOfLoops
* @param int $numberOfLoops @phan-unused-param
*/
public function beforeBenchmark( $numberOfLoops ) {
/* Nothing to do.
Expand All @@ -92,7 +92,7 @@ public function beforeBenchmark( $numberOfLoops ) {

/**
* Same as beforeBenchmark, but is called getDefaultLoops() times.
* @param int $iterationNumber Number of the loop (integer starting with 0).
* @param int $iterationNumber Number of the loop (integer starting with 0). @phan-unused-param
*/
public function beforeBenchmarkPrepareLoop( $iterationNumber ) {
/* Nothing to do.
Expand Down Expand Up @@ -206,7 +206,7 @@ public function fastEdit( Title $title, $newText = 'Whatever', $summary = '', Us
* @param string $newText
* @param string $summary
* @param User|null $user
* @return mod_id of the newly inserted row.
* @return int mod_id of the newly inserted row.
*/
public function fastQueue(
Title $title,
Expand Down
4 changes: 2 additions & 2 deletions tests/benchmarks/approveAll.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ public function beforeBenchmark( $numberOfUsers ) {
$editsPerUser = $this->getEditsPerUser();

for ( $i = 0; $i < $numberOfUsers; $i++ ) {
$fakeIP = IPUtils::formatHex( base_convert( $i, 10, 16 ) );
$fakeIP = IPUtils::formatHex( base_convert( "$i", 10, 16 ) );
$user = User::newFromName( $fakeIP, false );

$dbw->delete( 'moderation', [ 'mod_user_text' => $fakeIP ], __METHOD__ );

$modid = false;
$modid = 0;
for ( $j = 0; $j < $editsPerUser; $j++ ) {
$modid = $this->fastQueue(
$this->getTestTitle( $i + $j * $numberOfUsers ),
Expand Down
4 changes: 2 additions & 2 deletions tests/benchmarks/formatTimestamp.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ public function getDefaultLoops() {
}

/**
* @param int $numberOfUsers
* @param int $numberOfUsers @phan-unused-param
*/
public function beforeBenchmark( $numberOfUsers ) {
$this->context = RequestContext::getMain();
$this->timestampTools = new TimestampTools();
}

/**
* @param int $i
* @param int $i @phan-unused-param
*/
public function doActualWork( $i ) {
$this->timestampTools->format( '20180101000000', $this->context );
Expand Down
4 changes: 2 additions & 2 deletions tests/benchmarks/renderSpecial.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function getNumberOfEntries() {
}

/**
* @param int $numberOfLoops
* @param int $numberOfLoops @phan-unused-param
*/
public function beforeBenchmark( $numberOfLoops ) {
/* Prepopulate 'moderation' table */
Expand All @@ -60,7 +60,7 @@ public function beforeBenchmark( $numberOfLoops ) {
}

/**
* @param int $i
* @param int $i @phan-unused-param
*/
public function doActualWork( $i ) {
$this->runSpecialModeration( [
Expand Down
4 changes: 2 additions & 2 deletions tests/benchmarks/showEdit.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function getDefaultLoops() {
}

/**
* @param int $numberOfLoops
* @param int $numberOfLoops @phan-unused-param
*/
public function beforeBenchmark( $numberOfLoops ) {
$this->fastEdit( $this->getTestTitle(), self::TEXT_BEFORE );
Expand All @@ -58,7 +58,7 @@ public function beforeBenchmark( $numberOfLoops ) {
}

/**
* @param int $i
* @param int $i @phan-unused-param
*/
public function doActualWork( $i ) {
$html = $this->runSpecialModeration( [
Expand Down

0 comments on commit 8a57743

Please sign in to comment.