-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/typed_class_properties
- Loading branch information
Showing
72 changed files
with
1,310 additions
and
6,068 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ | |
|
||
.phpunit.result.cache | ||
.DS_Store | ||
phpunit.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento2\Helpers; | ||
|
||
use PHP_CodeSniffer\Files\File; | ||
use PHP_CodeSniffer\Util\Tokens; | ||
use PHPCSUtils\Tokens\Collections; | ||
|
||
/** | ||
* phpcs:disable Magento2.Functions.StaticFunction.StaticFunction | ||
*/ | ||
class Assert | ||
{ | ||
/** | ||
* Checks whether it is a built-in function call. | ||
* | ||
* @param File $phpcsFile | ||
* @param int $stackPtr | ||
* @return bool | ||
*/ | ||
public static function isBuiltinFunctionCall(File $phpcsFile, int $stackPtr): bool | ||
{ | ||
$tokens = $phpcsFile->getTokens(); | ||
$nextPtr = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true); | ||
if ($nextPtr === false | ||
|| $tokens[$nextPtr]['code'] !== \T_OPEN_PARENTHESIS | ||
|| isset($tokens[$nextPtr]['parenthesis_owner']) | ||
) { | ||
return false; | ||
} | ||
|
||
$prevPtr = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); | ||
if ($prevPtr !== false) { | ||
if (isset(Collections::objectOperators()[$tokens[$prevPtr]['code']]) | ||
|| $tokens[$prevPtr]['code'] === \T_NEW | ||
) { | ||
return false; | ||
} | ||
|
||
if ($tokens[$prevPtr]['code'] === \T_NS_SEPARATOR) { | ||
$prevPrevPr = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($prevPtr - 1), null, true); | ||
if ($prevPrevPr !== false && \in_array($tokens[$prevPrevPr]['code'], [\T_STRING, \T_NAMESPACE], true)) { | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.