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
2 changes: 1 addition & 1 deletion MO4/Library/PregLibrary.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class PregLibrary
*/
public static function mo4_preg_split($pattern, $subject, $limit=-1, $flags=0): array
{
$pregSplitResult = preg_split($pattern, $subject, $limit, $flags);
$pregSplitResult = \preg_split($pattern, $subject, $limit, $flags);
// @phan-suppress-next-line PhanTypeComparisonToArray
if (false === $pregSplitResult) {
throw new RuntimeException('Unexpected Error in MO4 Coding Standard.');
Expand Down
8 changes: 4 additions & 4 deletions MO4/Sniffs/Arrays/ArrayDoubleArrowAlignmentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ public function process(File $phpcsFile, $stackPtr): void
}
} else {
// Remove current and previous '=>' from array for further processing.
array_pop($assignments);
array_pop($assignments);
\array_pop($assignments);
\array_pop($assignments);
$phpcsFile->addError($msg, $i, 'OneAssignmentPerLine');
}
}
Expand Down Expand Up @@ -183,9 +183,9 @@ public function process(File $phpcsFile, $stackPtr): void

$phpcsFile->fixer->beginChangeset();
if ($tokens[$beforeArrowPtr]['code'] === T_WHITESPACE) {
$phpcsFile->fixer->replaceToken($beforeArrowPtr, str_repeat(' ', $correctIndent));
$phpcsFile->fixer->replaceToken($beforeArrowPtr, \str_repeat(' ', $correctIndent));
} else {
$phpcsFile->fixer->addContent($beforeArrowPtr, str_repeat(' ', $correctIndent));
$phpcsFile->fixer->addContent($beforeArrowPtr, \str_repeat(' ', $correctIndent));
}

$phpcsFile->fixer->endChangeset();
Expand Down
4 changes: 2 additions & 2 deletions MO4/Sniffs/Arrays/MultiLineArraySniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function process(File $phpcsFile, $stackPtr): void

if ($tokens[($start + 2)]['line'] === $tokens[$start]['line']) {
$fixable = $phpcsFile->addFixableError(
sprintf(
\sprintf(
'opening %s of multi line array must be followed by newline',
$arrayType
),
Expand All @@ -96,7 +96,7 @@ public function process(File $phpcsFile, $stackPtr): void

if ($tokens[($end - 2)]['line'] === $tokens[$end]['line']) {
$fixable = $phpcsFile->addFixableError(
sprintf(
\sprintf(
'closing %s of multi line array must in own line',
$arrayType
),
Expand Down
4 changes: 2 additions & 2 deletions MO4/Sniffs/Commenting/PropertyCommentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ protected function processTokenWithinScope(
$commentEnd = (int) $phpcsFile->findPrevious($find, ($stackPtr - 1));

$conditions = $tokens[$commentEnd]['conditions'];
$lastCondition = array_pop($conditions);
$lastCondition = \array_pop($conditions);
if ($lastCondition !== T_CLASS) {
return;
}
Expand Down Expand Up @@ -190,7 +190,7 @@ protected function processTokenWithinScope(
$phpcsFile->fixer->addContent($commentStart, "\n *");
$phpcsFile->fixer->replaceToken(
($commentEnd - 1),
rtrim($tokens[($commentEnd - 1)]['content'])
\rtrim($tokens[($commentEnd - 1)]['content'])
);
$phpcsFile->fixer->addContentBefore($commentEnd, "\n ");
$phpcsFile->fixer->endChangeset();
Expand Down
14 changes: 7 additions & 7 deletions MO4/Sniffs/Formatting/AlphabeticalUseStatementsSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ class AlphabeticalUseStatementsSniff extends UseDeclarationSniff
public function process(File $phpcsFile, $stackPtr): void
{
if (\in_array($this->order, self::SUPPORTED_ORDERING_METHODS, true) === false) {
$error = sprintf(
$error = \sprintf(
"'%s' is not a valid order function for %s! Pick one of: %s",
$this->order,
Common::getSniffCode(self::class),
implode(', ', self::SUPPORTED_ORDERING_METHODS)
\implode(', ', self::SUPPORTED_ORDERING_METHODS)
);

$phpcsFile->addError($error, $stackPtr, 'InvalidOrder');
Expand Down Expand Up @@ -335,11 +335,11 @@ private function compareString(string $a, string $b): int
{
switch ($this->order) {
case 'string':
return strcmp($a, $b);
return \strcmp($a, $b);
case 'string-locale':
return strcoll($a, $b);
return \strcoll($a, $b);
case 'string-case-insensitive':
return strcasecmp($a, $b);
return \strcasecmp($a, $b);
default:
// Default is 'dictionary'.
return $this->dictionaryCompare($a, $b);
Expand All @@ -364,7 +364,7 @@ private function compareString(string $a, string $b): int
*/
private function dictionaryCompare(string $a, string $b): int
{
$min = min(\strlen($a), \strlen($b));
$min = \min(\strlen($a), \strlen($b));

for ($i = 0; $i < $min; $i++) {
if ($a[$i] === $b[$i]) {
Expand All @@ -388,7 +388,7 @@ private function dictionaryCompare(string $a, string $b): int
}
}//end for

return strcmp(substr($a, $min), substr($b, $min));
return \strcmp(\substr($a, $min), \substr($b, $min));

}//end dictionaryCompare()

Expand Down
6 changes: 3 additions & 3 deletions MO4/Sniffs/Formatting/UnnecessaryNamespaceUsageSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,8 @@ private function checkShorthandPossible(
);

$replaceClassName = true;
} else if ($namespace !== '' && strpos($fullClassName, $namespace) === 0) {
$replacement = substr($fullClassName, \strlen($namespace));
} else if ($namespace !== '' && \strpos($fullClassName, $namespace) === 0) {
$replacement = \substr($fullClassName, \strlen($namespace));

$data = [
$className,
Expand All @@ -394,7 +394,7 @@ private function checkShorthandPossible(
if (true === $isDocBlock) {
$tokens = $phpcsFile->getTokens();
$oldContent = $tokens[$startPtr]['content'];
$newContent = str_replace($className, $replacement, $oldContent);
$newContent = \str_replace($className, $replacement, $oldContent);
$phpcsFile->fixer->replaceToken($startPtr, $newContent);
} else {
for ($i = $startPtr; $i < $endPtr; $i++) {
Expand Down
16 changes: 8 additions & 8 deletions MO4/Sniffs/Strings/VariableInDoubleQuotedStringSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,22 @@ public function process(File $phpcsFile, $stackPtr): void

$matches = [];

preg_match_all($varRegExp, $content, $matches, PREG_OFFSET_CAPTURE);
\preg_match_all($varRegExp, $content, $matches, PREG_OFFSET_CAPTURE);

foreach ($matches as $match) {
foreach ($match as [$var, $pos]) {
if ($pos === 1 || $content[($pos - 1)] !== '{') {
if (strpos(substr($content, 0, $pos), '{') > 0
&& strpos(substr($content, 0, $pos), '}') === false
if (\strpos(\substr($content, 0, $pos), '{') > 0
&& \strpos(\substr($content, 0, $pos), '}') === false
) {
continue;
}

$lastOpeningBrace = strrpos(substr($content, 0, $pos), '{');
$lastOpeningBrace = \strrpos(\substr($content, 0, $pos), '{');
if ($lastOpeningBrace !== false
&& $content[($lastOpeningBrace + 1)] === '$'
) {
$lastClosingBrace = strrpos(substr($content, 0, $pos), '}');
$lastClosingBrace = \strrpos(\substr($content, 0, $pos), '}');

if ($lastClosingBrace !== false
&& $lastClosingBrace < $lastOpeningBrace
Expand All @@ -97,7 +97,7 @@ public function process(File $phpcsFile, $stackPtr): void
}

$fix = $this->phpCsFile->addFixableError(
sprintf(
\sprintf(
'must surround variable %s with { }',
$var
),
Expand Down Expand Up @@ -131,8 +131,8 @@ public function process(File $phpcsFile, $stackPtr): void
*/
private function surroundVariableWithBraces(string $content, int $pos, string $var): string
{
$before = substr($content, 0, $pos);
$after = substr($content, ($pos + \strlen($var)));
$before = \substr($content, 0, $pos);
$after = \substr($content, ($pos + \strlen($var)));

return $before.'{'.$var.'}'.$after;

Expand Down