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
F14776245: D10687.id27043.diff
Fri, Jan 24, 3:55 AM
F14767233: D10687.id27043.diff
Thu, Jan 23, 5:33 PM
F14767232: D10687.id26933.diff
Thu, Jan 23, 5:32 PM
F14767230: D10687.id26919.diff
Thu, Jan 23, 5:32 PM
F14767227: D10687.id25656.diff
Thu, Jan 23, 5:32 PM
F14767224: D10687.id25655.diff
Thu, Jan 23, 5:32 PM
F14767223: D10687.id.diff
Thu, Jan 23, 5:32 PM
Unknown Object (File)
Thu, Jan 23, 5:12 AM

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
Branch
master
Lint
Lint Passed
Unit
Test Failures
Build Status
Buildable 3569
Build 3577: [Placeholder Plan] Wait for 30 Seconds

Unit TestsFailed

TimeTest
4,124 msArcanistXHPASTLinterTestCase::testLinter
435 msArcanistCSSLintLinterTestCase::testLinter
111 msArcanistCSSLintLinterTestCase::testVersion
220 msArcanistClosureLinterTestCase::testLinter
63 msArcanistClosureLinterTestCase::testVersion
View Full Test Results (1 Failed · 32 Passed · 14 Skipped)

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
2985

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