Skip to content

Commit 707bd56

Browse files
committed
Bump nikic/php-parser to ^5.6.2 and Fix AttributeGroupNewLiner for already has new line
1 parent 6602925 commit 707bd56

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"doctrine/inflector": "^2.1",
2121
"illuminate/container": "^11.46",
2222
"nette/utils": "^4.0",
23-
"nikic/php-parser": "^5.6.1",
23+
"nikic/php-parser": "^5.6.2",
2424
"ondram/ci-detector": "^4.2",
2525
"phpstan/phpdoc-parser": "^2.3",
2626
"phpstan/phpstan": "^2.1.26",

rules-tests/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector/Fixture/do_not_remove_parameter_attribute.php.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace Rector\Tests\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromo
2525
final class DoNotRemoveParameterAttribute
2626
{
2727
public function __construct(
28-
#[\SensitiveParameter]private string $password
28+
#[\SensitiveParameter] private string $password
2929
)
3030
{
3131
}

rules/Php81/NodeManipulator/AttributeGroupNewLiner.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,14 @@ public function newLine(File $file, Node $node): void
4848
break;
4949
}
5050

51-
if (trim($oldTokens[$startTokenPos + $iteration + 1]->text ?? '') === '') {
52-
$space = ltrim($oldTokens[$startTokenPos + $iteration + 1]->text ?? '', "\r\n");
51+
$nextTokenText = $oldTokens[$startTokenPos + $iteration + 1]->text ?? '';
52+
if (str_starts_with($nextTokenText, "\n") || str_starts_with($nextTokenText, "\r")) {
53+
// already has newline
54+
break;
55+
}
56+
57+
if (trim($nextTokenText) === '') {
58+
$space = ltrim($nextTokenText, "\r\n");
5359
} elseif (trim($oldTokens[$startTokenPos - 1]->text ?? '') === '') {
5460
$space = ltrim($oldTokens[$startTokenPos - 1]->text ?? '', "\r\n");
5561
} else {

0 commit comments

Comments
 (0)