Skip to content

Commit

Permalink
Merge branch 'develop' into feature/typed_class_properties
Browse files Browse the repository at this point in the history
  • Loading branch information
ihor-sviziev committed Dec 18, 2023
2 parents ec3b1e4 + 372d4c6 commit 18bfbe7
Show file tree
Hide file tree
Showing 72 changed files with 1,310 additions and 6,068 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,11 @@ jobs:
fail-fast: false
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
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 +89,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 18bfbe7

Please sign in to comment.