Skip to content

Commit ea5897b

Browse files
committed
ACP2E-1946: Move PHPCompatibility/PHPCompatibility sniffs into separate namespace
1 parent 6e5c5a7 commit ea5897b

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

Magento2/Helpers/Assert.php

+11-9
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
class Assert
1818
{
1919
/**
20-
* Checks whether the function call is a built-in function call.
20+
* Checks whether it is a built-in function call.
2121
*
2222
* @param File $phpcsFile
2323
* @param int $stackPtr
@@ -35,17 +35,19 @@ public static function isBuiltinFunctionCall(File $phpcsFile, int $stackPtr): bo
3535
}
3636

3737
$prevPtr = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
38-
$ignorePrevToken = [\T_NEW => true] + Collections::objectOperators();
39-
if (isset($ignorePrevToken[$tokens[$prevPtr]['code']])) {
40-
return false;
41-
}
42-
43-
if ($tokens[$prevPtr]['code'] === \T_NS_SEPARATOR) {
44-
$prevPrevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($prevPtr - 1), null, true);
45-
if ($tokens[$prevPrevToken]['code'] === \T_STRING || $tokens[$prevPrevToken]['code'] === \T_NAMESPACE
38+
if ($prevPtr !== false) {
39+
if (isset(Collections::objectOperators()[$tokens[$prevPtr]['code']])
40+
|| $tokens[$prevPtr]['code'] === \T_NEW
4641
) {
4742
return false;
4843
}
44+
45+
if ($tokens[$prevPtr]['code'] === \T_NS_SEPARATOR) {
46+
$prevPrevPr = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($prevPtr - 1), null, true);
47+
if ($prevPrevPr !== false && \in_array($tokens[$prevPrevPr]['code'], [\T_STRING, \T_NAMESPACE], true)) {
48+
return false;
49+
}
50+
}
4951
}
5052

5153
return true;
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?php
22
$var = 'hello world';
33
utf8_encode($var);
4-
utf8_decode($var);
4+
utf8_decode($var);

0 commit comments

Comments
 (0)