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

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 @@ -126,7 +126,7 @@ protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $sta
$errorData = array($className.'::'.$methodName);

// Is this a magic method. i.e., is prefixed with "__" ?
if (preg_match('|^__|', $methodName) !== 0) {
if (preg_match('|^__[^_]|', $methodName) !== 0) {
$magicPart = strtolower(substr($methodName, 2));
if (isset($this->magicMethods[$magicPart]) === false
&& isset($this->methodsDoubleUnderscore[$magicPart]) === false
Expand Down Expand Up @@ -194,7 +194,7 @@ protected function processTokenOutsideScope(PHP_CodeSniffer_File $phpcsFile, $st
$errorData = array($functionName);

// Is this a magic function. i.e., it is prefixed with "__".
if (preg_match('|^__|', $functionName) !== 0) {
if (preg_match('|^__[^_]|', $functionName) !== 0) {
$magicPart = strtolower(substr($functionName, 2));
if (isset($this->magicFunctions[$magicPart]) === false) {
$error = 'Function name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,9 @@ function __debugInfo() {}
class Foo {
function __debugInfo() {}
}

function ___tripleUnderscore() {} // Ok.

class triple {
public function ___tripleUnderscore() {} // Ok.
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $sta
}

// Ignore magic methods.
if (preg_match('|^__|', $methodName) !== 0) {
if (preg_match('|^__[^_]|', $methodName) !== 0) {
$magicPart = strtolower(substr($methodName, 2));
if (isset($this->magicMethods[$magicPart]) === true
|| isset($this->methodsDoubleUnderscore[$magicPart]) === true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,10 @@ class Foo extends \SoapClient

function __() {}
}

function ___tripleUnderscore() {} // Ok.

class triple {
public function ___tripleUnderscore() {} // Ok.
}
?>