Skip to content

Commit

Permalink
minor #6326 Bump migration sets used to PHP7.4 (SpacePossum)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the master branch (closes #6326).

Discussion
----------

Bump migration sets used to PHP7.4

First commit updates project config.
Second is the result when running the tool, no additional changes are made.
3rd is to fix SCA checks on PHP8.1 (`highest`) migrations testing

Commits
-------

22d3cbf Bump migration sets used to PHP7.4
  • Loading branch information
SpacePossum committed Mar 8, 2022
2 parents 8ce3339 + 22d3cbf commit d34ccf8
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 13 deletions.
18 changes: 10 additions & 8 deletions .php-cs-fixer.dist.php
Expand Up @@ -13,14 +13,14 @@
*/

$header = <<<'EOF'
This file is part of PHP CS Fixer.
This file is part of PHP CS Fixer.
(c) Fabien Potencier <fabien@symfony.com>
Dariusz Rumiński <dariusz.ruminski@gmail.com>
(c) Fabien Potencier <fabien@symfony.com>
Dariusz Rumiński <dariusz.ruminski@gmail.com>
This source file is subject to the MIT license that is bundled
with this source code in the file LICENSE.
EOF;
This source file is subject to the MIT license that is bundled
with this source code in the file LICENSE.
EOF;

$finder = PhpCsFixer\Finder::create()
->ignoreDotFiles(false)
Expand All @@ -37,14 +37,16 @@
$config
->setRiskyAllowed(true)
->setRules([
'@PHP71Migration' => true,
'@PHP71Migration:risky' => true,
'@PHP74Migration' => true,
'@PHP74Migration:risky' => true,
'@PHPUnit75Migration:risky' => true,
'@PhpCsFixer' => true,
'@PhpCsFixer:risky' => true,
'general_phpdoc_annotation_remove' => ['annotations' => ['expectedDeprecation']], // one should use PHPUnit built-in method instead
'header_comment' => ['header' => $header],
'heredoc_indentation' => false, // TODO switch on when # of PR's is lower
'modernize_strpos' => true, // needs PHP 8+ or polyfill
'use_arrow_functions' => false, // TODO switch on when # of PR's is lower
])
->setFinder($finder)
;
Expand Down
2 changes: 1 addition & 1 deletion src/AbstractFunctionReferenceFixer.php
Expand Up @@ -58,7 +58,7 @@ protected function find(string $functionNameToSearch, Tokens $tokens, int $start
}

// make interface consistent with findSequence
$end = $end ?? $tokens->count();
$end ??= $tokens->count();

// find raw sequence which we can analyse for context
$candidateSequence = [[T_STRING, $functionNameToSearch], '('];
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/Whitespace/HeredocIndentationFixer.php
Expand Up @@ -164,7 +164,7 @@ private function fixIndentation(Tokens $tokens, int $start, int $end): void

$content = $tokens[$index]->getContent();

if (!\in_array($content[0], ["\r", "\n"], true) && (!$currentIndent || $currentIndent === substr($content, 0, $currentIndentLength))) {
if (!\in_array($content[0], ["\r", "\n"], true) && (!$currentIndent || str_starts_with($content, $currentIndent))) {
$content = $indent.substr($content, $currentIndentLength);
} elseif ($currentIndent) {
$content = Preg::replace('/^(?!'.$currentIndent.')\h+/', '', $content);
Expand Down
6 changes: 4 additions & 2 deletions tests/Fixer/StringNotation/SingleQuoteFixerTest.php
Expand Up @@ -78,10 +78,12 @@ public function provideTestFixCases(): array
'<?php $a = \'foo "bar"\';',
'<?php $a = "foo \"bar\"";',
],
[<<<'EOF'
[
<<<'EOF'
<?php $a = '\\foo\\bar\\\\';
EOF
, <<<'EOF'
,
<<<'EOF'
<?php $a = "\\foo\\bar\\\\";
EOF
],
Expand Down
2 changes: 1 addition & 1 deletion tests/Test/AbstractFixerTestCase.php
Expand Up @@ -379,7 +379,7 @@ protected function doTest(string $expected, ?string $input = null, ?\SplFileInfo
throw new \InvalidArgumentException('Input parameter must not be equal to expected parameter.');
}

$file = $file ?? $this->getTestFile();
$file ??= $this->getTestFile();
$fileIsSupported = $this->fixer->supports($file);

if (null !== $input) {
Expand Down

0 comments on commit d34ccf8

Please sign in to comment.