Page MenuHomePhorge

Fix wrong argument count in numerous calls' signatures
ClosedPublic

Authored by aklapper on Sun, Apr 27, 16:17.

Details

Summary

Fix incorrect method/function argument counts which are trivial:

  • /src/applications/config/controller/PhabricatorConfigController.php:13 Method PhabricatorFile::getBestURI() invoked with 1 parameter, 0 required.
  • /src/applications/conpherence/controller/ConpherenceListController.php:135 Method ConpherenceController::buildHeaderPaneContent() invoked with 2 parameters, 1 required.
  • /src/applications/differential/lipsum/PhabricatorDifferentialRevisionTestDataGenerator.php:74 Method PhutilContextFreeGrammar::generate() invoked with 2 parameters, 0 required.
  • /src/applications/differential/storage/DifferentialChangeset.php:589 Method LiskDAO::makeEphemeral() invoked with 1 parameter, 0 required.
  • /src/applications/diffusion/management/DiffusionRepositorySubversionManagementPanel.php:59 Method DiffusionRepositoryManagementPanel::newCurtainView() invoked with 1 parameter, 0 required.
  • /src/applications/diffusion/xaction/DiffusionCommitAuditTransaction.php:123 Method PhabricatorRepositoryCommit::hasAuditAuthority() invoked with 3 parameters, 2 required.
  • /src/applications/harbormaster/storage/build/HarbormasterBuildArtifact.php:165 Method HarbormasterBuildArtifact::releaseArtifact() invoked with 1 parameter, 0 required.
  • /src/applications/repository/engine/PhabricatorRepositoryPullEngine.php:457 Method PhabricatorRepository::getFetchRules() invoked with 1 parameter, 0 required.
  • /src/applications/search/menuitem/PhabricatorConpherenceProfileMenuItem.php:67 Method PhabricatorConpherenceProfileMenuItem::getConpherence() invoked with 1 parameter, 0 required.
  • /src/applications/search/menuitem/PhabricatorConpherenceProfileMenuItem.php:104 Method PhabricatorConpherenceProfileMenuItem::getConpherence() invoked with 1 parameter, 0 required.
  • /src/applications/search/query/PhabricatorSearchDocumentQuery.php:52 Static method PhabricatorSearchService::newResultSet() invoked with 2 parameters, 1 required.
  • /src/infrastructure/editor/PhabricatorEditorURIEngine.php:71 Method PhabricatorEditorURIEngine::getURITokensForRepository() invoked with 1 parameter, 0 required.
  • /src/infrastructure/editor/PhabricatorEditorURIEngine.php:84 Method PhabricatorEditorURIEngine::getURITokensForRepository() invoked with 1 parameter, 0 required.
Test Plan

Look up function/method definitions, compare with their calls. Run static code analysis.

Also, test the revision generator and it finally works as intended with 10-20 random description lines (not just 1):

./bin/lipsum generate revisions

Diff Detail

Repository
rP Phorge
Branch
argCounts (branched from master)
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 1993
Build 1993: arc lint + arc unit

Event Timeline

Partial review, will conclude (I hope asd)

src/applications/config/controller/PhabricatorConfigController.php
13

PhabricatorFile#getBestURI()

src/applications/conpherence/controller/ConpherenceListController.php
136–137

ConpherenceController#buildHeaderPaneContent(ConpherenceThread $conpherence)

src/applications/differential/lipsum/PhabricatorDifferentialRevisionTestDataGenerator.php
75

🔶 Probably the original intention was to generate 10-20 random strings for the description, so, generateSeveral().

Test case:

phorge/asd.php
require_once __DIR__.'/scripts/__init_script__.php';

$asd = new PhutilLipsumContextFreeGrammar();
echo $asd->generateSeveral(random_int(10, 20), "\n") . "\n";
src/applications/differential/storage/DifferentialChangeset.php
590

LiskDAO#makeEphemeral()

src/applications/diffusion/management/DiffusionRepositorySubversionManagementPanel.php
59

DiffusionRepositoryManagementPanel#newCurtainView()

src/applications/diffusion/xaction/DiffusionCommitAuditTransaction.php
122

PhabricatorRepositoryCommit#hasAuditAuthority(PhabricatorUser $user, PhabricatorRepositoryAuditRequest $audit)

src/applications/harbormaster/storage/build/HarbormasterBuildArtifact.php
165

HarbormasterBuildArtifact#releaseArtifact()

Make PhabricatorDifferentialRevisionTestDataGenerator::generateDescription() have more than one sentence

Use rand() as two other calls in the codebase already do. It's also faster per https://stackoverflow.com/questions/44228718/php-rand-vs-random-int

src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
457

src/applications/search/menuitem/PhabricatorConpherenceProfileMenuItem.php
67

104

src/applications/search/query/PhabricatorSearchDocumentQuery.php
52

src/infrastructure/cluster/search/PhabricatorElasticsearchHost.php
78 ↗(On Diff #3066)

🔶 Uhm probably this was correct, since $this is a PhabricatorElasticsearchHost and it makes sense with this:

PhabricatorElasticFulltextStorageEngine#indexIsSane(?PhabricatorElasticsearchHost $host = null)

https://we.phorge.it/source/phorge/browse/master/src/applications/search/fulltextstorage/PhabricatorElasticFulltextStorageEngine.php$400

I have no proposed solution. Maybe better to do not touch this.

With this line out of this patch I can quick approve.

src/infrastructure/editor/PhabricatorEditorURIEngine.php
71

84

aklapper marked an inline comment as done.
aklapper edited the summary of this revision. (Show Details)

You are correct. (And I am disappointed by PHPStan to not realize that.)

This revision is now accepted and ready to land.Mon, May 19, 14:12