Page MenuHomePhabricator

Fix some method signatures
ClosedPublic

Authored by joshuaspence on May 9 2015, 7:50 AM.
Tags
None
Referenced Files
F14058008: D12782.diff
Sun, Nov 17, 8:43 AM
F14052078: D12782.id30854.diff
Fri, Nov 15, 6:22 AM
F13975725: D12782.id30856.diff
Oct 18 2024, 11:22 AM
F13967548: D12782.id30801.diff
Oct 16 2024, 2:25 PM
F13962804: D12782.id31059.diff
Oct 15 2024, 12:25 PM
F13962061: D12782.diff
Oct 15 2024, 7:50 AM
F13960843: D12782.id30727.diff
Oct 15 2024, 1:48 AM
Unknown Object (File)
Oct 12 2024, 6:38 AM

Details

Reviewers
hach-que
epriestley
Group Reviewers
Blessed Reviewers
Commits
Restricted Diffusion Commit
rPf3d382cec4d3: Fix some method signatures
Summary

Fix some method signatures so that arguments with default values are at the end of the argument list (see D12418).

Test Plan

Eyeballed the callsites.

Diff Detail

Repository
rP Phabricator
Branch
master
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 5932
Build 5952: [Placeholder Plan] Wait for 30 Seconds

Event Timeline

joshuaspence retitled this revision from to Fix some method signatures.
joshuaspence updated this object.
joshuaspence edited the test plan for this revision. (Show Details)
joshuaspence added a reviewer: epriestley.
hach-que requested changes to this revision.May 9 2015, 9:25 AM
hach-que added a reviewer: hach-que.
hach-que added inline comments.
src/applications/drydock/blueprint/DrydockBlueprintImplementation.php
355–356

These nulls are required to allow null to be passed into the first two parameters, otherwise you'll get an exception.

It's probably better to just make $message nullable.

src/applications/phragment/storage/PhragmentFragment.php
80

Again, optional null is required here due to type checks.

This revision now requires changes to proceed.May 9 2015, 9:25 AM
joshuaspence added inline comments.
src/applications/phragment/storage/PhragmentFragment.php
80

I don't quite follow... from what I can tell this function is always called with > 2 arguments.

joshuaspence edited edge metadata.

Fix DrydockBlueprintImplementation

src/applications/phragment/storage/PhragmentFragment.php
80

It's always called with two arguments, but the second argument may be null (as per the $file === null check for directories).

In PHP if you specify the type of a parameter, and it does not have an optional specifier, then that argument can not be null. If you pass null into it, you'll get a type check failure (because null is not of the required type).

To allow null values to be passed into type checked parameters you need to add the optional specifier = null.

src/applications/phragment/storage/PhragmentFragment.php
80

Ah. I did not know this. Based on this, I wonder if ArcanistXHPASTLinter::LINT_DEFAULT_PARAMETER is valid? Maybe it should be relaxed.

src/applications/phragment/storage/PhragmentFragment.php
80

Yeah this PHP syntax caught me out a few times, especially since KDevelop (the IDE I use) highlights non-optional parameters after optional parameters as an error (even though it's perfectly fine in PHP).

epriestley edited edge metadata.

I think it's fine/desirable to require all arguments to have defaults after the first argument with a default. The handful of cases where we violate this are bizarre and probably better written differently.

This revision now requires changes to proceed.May 13 2015, 3:03 PM
epriestley edited edge metadata.
epriestley added inline comments.
src/applications/people/storage/PhabricatorUserLog.php
89

Does this definitely have no callsites where the parameter is null?

src/applications/people/storage/PhabricatorUserLog.php
89

Hmm, it possibly does actually... I guess $request->getUser() could return null

joshuaspence edited edge metadata.

Allow $actor to be null

hach-que edited edge metadata.
This revision is now accepted and ready to land.May 16 2015, 2:07 AM
This revision was automatically updated to reflect the committed changes.