mago
mago copied to clipboard
[formatter] Infinity formatting the body of arrow function on every run
🐞 Describe the Bug
When running mago format one file is changed every run. I made a small example that has this problem.
I tested it and has anything to do with the lenght of the result and the function name inside the array_map.
If variable is on letter bigger or smaller or the function name one bigger or smaller. It format once and stays the same.
🔄 Steps to Reproduce
- Add the example code to a file
- Run
mago format - Run again
- Both code blocks change every time
⚙️ Configuration (mago.toml)
# Mago configuration for RemindoTest
# Docs: https://mago.carthage.software/guide/configuration
# Use the PHP version we target in CI and tools
php-version = "8.4"
📜 Command Output
$MAGO_LOG=trace mago format example.php
DEBUG Sourcing configuration from /var/www/mago.toml.
DEBUG Configuration specifies 8 threads.
DEBUG Configuration specifies a stack size of 12582912 bytes.
INFO Formatted 1 file(s) successfully.
$MAGO_LOG=trace mago format example.php
DEBUG Sourcing configuration from /var/www/mago.toml.
DEBUG Configuration specifies 8 threads.
DEBUG Configuration specifies a stack size of 12582912 bytes.
INFO Formatted 1 file(s) successfully.
📂 PHP Code Sample (If Applicable)
<?php
class AClass
{
public function run(): void
{
// When result and function are 15 long together, formatter will change every run
$result = array_map(fn(array $row): string => (
reset($row) ?: ''
), $this->function1('FOOO BARBAR FOOO barbarbar'));
$result = array_map(
fn(array $row): string => reset($row) ?: '',
$this->function1('FOOO BARBAR FOOO barbarbar'),
);
}
}
🖥️ Operating System
Linux
📦 How did you install Mago?
Composer (composer require carthage-software/mago)
📝 Additional Context
Version 1.0.0-rc.6