-
-
Notifications
You must be signed in to change notification settings - Fork 737
Closed
rectorphp/rector-src
#7564Labels
Description
Bug Report
| Subject | Details |
|---|---|
| Rector version | last dev-main |
| Installed as | composer dependency |
Minimal PHP Code Causing Issue
See https://getrector.com/demo/7d8588dd-1b3c-4f3b-8886-7608a24269ff
<?php
// Library code
final readonly class Renderer {
public function __construct(private string $name, private object $object) {}
public function render(callable $formatter): string
{
return $formatter($this->name, $this->object);
}
}
// My code
$formatter = fn(string $label, object $object): string => ucfirst($label);
echo (new Renderer('name', new stdClass()))->render($formatter);Responsible rules
FunctionLikeToFirstClassCallableRector
Expected Behavior
Rector should skip the change, because the code fails when the library code calls my callable with two arguments.
-$formatter = fn(string $label, object $object): string => ucfirst($label);
+$formatter = ucfirst(...);