Page MenuHomePhabricator

Fix some method signatures
ClosedPublic

Authored by joshuaspence on May 9 2015, 7:50 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Dec 17, 10:11 PM
Unknown Object (File)
Sun, Dec 15, 6:48 AM
Unknown Object (File)
Fri, Dec 13, 5:09 AM
Unknown Object (File)
Wed, Dec 11, 12:10 PM
Unknown Object (File)
Sun, Dec 8, 1:00 PM
Unknown Object (File)
Sat, Dec 7, 1:01 AM
Unknown Object (File)
Wed, Dec 4, 3:57 AM
Unknown Object (File)
Wed, Dec 4, 3:57 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
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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.