Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ protected function processMemberVar(File $phpcsFile, $stackPtr)
$memberName = ltrim($tokens[$stackPtr]['content'], '$');
$scope = $memberProps['scope'];
$scopeSpecified = $memberProps['scope_specified'];
if ($scopeSpecified === false && $memberProps['set_scope'] !== false) {
// Implicit `public` visibility for property with asymmetric visibility.
$scopeSpecified = true;
}

if ($memberProps['scope'] === 'private') {
$isPublic = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,17 @@ $util->setLogger(
private $varName = 'hello';
private $_varName = 'hello';
});

class AsymVisibility {
// The read scope is public, but not specified. Enforce the naming conventions anyway.
private(set) $asymPublicImplied = 'hello';
private(set) $_asymPublicImplied = 'hello';

// The read scope is private, so these properties should be handled as private properties.
private private(set) $asymPrivate = 'hello';
private(set) private $_asymPrivate = 'hello';

// The read scope is public/protected, so these properties should be handled as public properties.
public private(set) $asymPublicPrivate = 'hello';
private(set) protected $_asymPrivateProtected = 'hello';
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@ final class ValidVariableNameUnitTest extends AbstractSniffUnitTest
public function getErrorList()
{
return [
12 => 1,
17 => 1,
22 => 1,
92 => 1,
93 => 1,
94 => 1,
99 => 1,
12 => 1,
17 => 1,
22 => 1,
92 => 1,
93 => 1,
94 => 1,
99 => 1,
106 => 1,
109 => 1,
114 => 1,
];

}//end getErrorList()
Expand Down