fix: OrderedClassElementsFixer - do not crash on property hook#8517
Merged
keradus merged 2 commits intoPHP-CS-Fixer:masterfrom Mar 19, 2025
Merged
Conversation
keradus
reviewed
Mar 18, 2025
Comment on lines
+488
to
+491
| if ($tokens[$index]->equals('(')) { | ||
| $index = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $index); | ||
| $index = $tokens->getNextTokenOfKind($index, ['{', ';']); | ||
| } |
Member
There was a problem hiding this comment.
is this PR fixing out-of-memory or crash on finding "end" token?
(or both)
Member
Author
There was a problem hiding this comment.
I have not managed to get an issue with "end" token yet, got this one first. Does "Segmentation fault (core dumped)" stand for lack of memory or too deep recursion? IDK:
kub@:~/code/friendsofphp/PHP-CS-Fixer(master)$ cat test.php
<?php class Foo
{
public function __construct(
public string $x {
set(string $value) {
$this->x = $value;
}
},
public bool $y,
) {}
}
kub@:~/code/friendsofphp/PHP-CS-Fixer(master)$ php php-cs-fixer check test.php -vvv --rules=ordered_class_elements,single_class_element_per_statement
PHP needs to be a minimum version of PHP 7.4.0 and maximum version of PHP 8.3.*.
Current PHP version: 8.4.5.
Ignoring environment requirements because `PHP_CS_FIXER_IGNORE_ENV` is set. Execution may be unstable.
PHP CS Fixer 3.72.1-DEV Persian Successor by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.4.5
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from "/home/kuba/code/friendsofphp/PHP-CS-Fixer-3/.php-cs-fixer.dist.php".
Using cache file ".php-cs-fixer.cache".
Paths from configuration file have been overridden by paths provided as command arguments.
0/1 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 0%Segmentation fault (core dumped)
Member
There was a problem hiding this comment.
it helped with memory issue.
before, freezing
after, solved.
yet, still problems with style of outcome
OrderedClassElementsFixerOrderedClassElementsFixer - do not crash on property hook
keradus
approved these changes
Mar 19, 2025
2 tasks
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes part of #8516