Open oruborus opened 2 months ago
When extracting code using the source text referred to by the reflection of the Closure, the following possibilities are not handled correctly:
Closure
function ($notThisOne) {}; $funciton = function ($thisOne) {}; function ($notThisOneEither) {}; $rf = new ReflectionFunction($function); $code = ClosureTransformer::getCode($rf); // "function ($notThisOne) {}"
function ($notThisOne) {}; $funciton = fn($thisOne) => null; function ($notThisOneEither) {}; $rf = new ReflectionFunction($function); $code = ClosureTransformer::getCode($rf); // "function ($notThisOne) {}"
function ($notThisOne) {}; $funciton = static function ($thisOne) {}; function ($notThisOneEither) {}; $rf = new ReflectionFunction($function); $code = ClosureTransformer::getCode($rf); // "function ($notThisOne) {}"
function ($notThisOne) {}; $funciton = static fn($thisOne) => null; function ($notThisOneEither) {}; $rf = new ReflectionFunction($function); $code = ClosureTransformer::getCode($rf); // "function ($notThisOne) {}"
T_STATIC
T_FUNCTION
$function = static /* ignore me */ function ($thisOne) {}; $rf = new ReflectionFunction($function); $code = ClosureTransformer::getCode($rf); // "function ($thisOne) {}", note the missing "static /* ignore me */ "
T_FN
$function = static /* ignore me */ fn($thisOne) => null; $rf = new ReflectionFunction($function); $code = ClosureTransformer::getCode($rf); // "fn($thisOne) => null", note the missing "static /* ignore me */ "
$function = static function ($thisOne) {}; $rf = new ReflectionFunction($function); $code = ClosureTransformer::getCode($rf); // "function ($thisOne) {}", note the missing "static "
$function = static fn($thisOne) => null; $rf = new ReflectionFunction($function); $code = ClosureTransformer::getCode($rf); // "fn($thisOne) => null", note the missing "static "
I can tackle that issue if you want - but I'd like to add more tests to avoid regressions.
When extracting code using the source text referred to by the reflection of the
Closure
, the following possibilities are not handled correctly:T_STATIC
andT_FUNCTION
T_STATIC
andT_FN
T_STATIC
on a other line thanT_FUNCTION
T_STATIC
on a other line thanT_FN
I can tackle that issue if you want - but I'd like to add more tests to avoid regressions.