Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into html-after-php-tag
Browse files Browse the repository at this point in the history
  • Loading branch information
fredden committed Jan 2, 2024
2 parents 6f35ad8 + 7521587 commit bee870f
Show file tree
Hide file tree
Showing 72 changed files with 1,454 additions and 6,167 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,12 @@ jobs:
fail-fast: false
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"
dependencies:
- "lowest"
- "highest"
exclude:
- php-version: "8.1"
dependencies: "lowest"
name: Tests with PHP ${{ matrix.php-version }} and ${{ matrix.dependencies }} dependencies

steps:
Expand Down Expand Up @@ -93,4 +90,4 @@ jobs:
run: composer install

- name: Run rector
run: vendor/bin/rector process Magento2 Magento2Framework PHP_CodeSniffer --dry-run --autoload-file vendor/squizlabs/php_codesniffer/autoload.php --autoload-file vendor/phpcompatibility/php-compatibility/PHPCSAliases.php
run: vendor/bin/rector process Magento2 Magento2Framework PHP_CodeSniffer --dry-run --autoload-file vendor/squizlabs/php_codesniffer/autoload.php --autoload-file vendor/magento/php-compatibility-fork/PHPCSAliases.php
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@

.phpunit.result.cache
.DS_Store
phpunit.xml
55 changes: 55 additions & 0 deletions Magento2/Helpers/Assert.php
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;
}
}
109 changes: 0 additions & 109 deletions Magento2/Helpers/PHPCSUtils/BackCompat/BCTokens.php

This file was deleted.

Loading

0 comments on commit bee870f

Please sign in to comment.