Page MenuHomePhabricator

Add a linter rule to detect implict method visibility
ClosedPublic

Authored by joshuaspence on Oct 12 2014, 12:29 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 6, 12:18 PM
Unknown Object (File)
Fri, Apr 5, 11:18 PM
Unknown Object (File)
Fri, Mar 29, 5:16 AM
Unknown Object (File)
Feb 15 2024, 5:05 PM
Unknown Object (File)
Feb 14 2024, 1:24 AM
Unknown Object (File)
Jan 28 2024, 12:18 AM
Unknown Object (File)
Jan 27 2024, 10:06 PM
Unknown Object (File)
Jan 25 2024, 1:30 PM

Details

Summary

I'm not sure whether this is in any coding standards, but it seems to be an unspoken rule that methods should have a visiblity modifier (public, protected or private) explicitly specified. According to the PHP documentation, methods declared without any explicit visibility keyword are defined as public.

Test Plan

Added a test case.

Diff Detail

Repository
rARC Arcanist
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

joshuaspence retitled this revision from to Add a linter rule to detect implict method visibility.
joshuaspence updated this object.
joshuaspence edited the test plan for this revision. (Show Details)
joshuaspence added a reviewer: epriestley.

I think the unit test is not working as expected because of a bug in XHPAST. See https://secure.phabricator.com/xhpast/view/621/ for an example. It seems that in public function bar() {}, T_FUNCTION belongs to n_METHOD_DECLARATION but in function baz() {} this is not the case.

joshuaspence edited edge metadata.

Handle properties as well

epriestley edited edge metadata.
This revision is now accepted and ready to land.Jan 4 2015, 11:27 PM

This doesn't actually work yet :P

I need to make some changes to XHPAST I think :(

joshuaspence edited edge metadata.

Working now (after D11215)

This revision was automatically updated to reflect the committed changes.
richardvanvelzen added inline comments.
src/lint/linter/ArcanistXHPASTLinter.php
3014

Shouldn't abstract or static methods have an explicit visibility?