From 171b4793556ecb44b382bdb61315e3e008bfd5ee Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 30 Mar 2026 01:28:29 +0200 Subject: [PATCH] CS fixes/src: limit line length ... to improve code readability. --- .../Actions/CallRerouting.php | 37 +++++++++++++++---- .../Actions/RedefinitionOfInternals.php | 13 ++++++- src/CodeManipulation/Stream.php | 11 +++++- 3 files changed, 50 insertions(+), 11 deletions(-) diff --git a/src/CodeManipulation/Actions/CallRerouting.php b/src/CodeManipulation/Actions/CallRerouting.php index b146c93..cb2fc10 100644 --- a/src/CodeManipulation/Actions/CallRerouting.php +++ b/src/CodeManipulation/Actions/CallRerouting.php @@ -21,7 +21,14 @@ $__pwFrame = \count(\debug_backtrace(0)); $__pwRefs = %s; $__pwRefOffset = 0; - if (\Patchwork\CallRerouting\dispatch($__pwClass, $__pwCalledClass, __FUNCTION__, $__pwFrame, $__pwResult, \array_merge(\array_slice($__pwRefs, $__pwRefOffset, \func_num_args()), \array_slice(\func_get_args(), \count($__pwRefs))))) { + if (\Patchwork\CallRerouting\dispatch( + $__pwClass, + $__pwCalledClass, + __FUNCTION__, + $__pwFrame, + $__pwResult, + \array_merge(\array_slice($__pwRefs, $__pwRefOffset, \func_num_args()), \array_slice(\func_get_args(), \count($__pwRefs))) + )) { return $__pwResult; } } @@ -36,12 +43,19 @@ $__pwFrame = \count(\debug_backtrace(0)); $__pwRefs = %s; $__pwRefOffset = 0; - if (\Patchwork\CallRerouting\dispatch($__pwClass, $__pwCalledClass, __FUNCTION__, $__pwFrame, $__pwResult, \array_merge(\array_slice($__pwRefs, $__pwRefOffset, \func_num_args()), \array_slice(\func_get_args(), \count($__pwRefs))))) { - if ($__pwResult !== null) { - throw new \Patchwork\Exceptions\NonNullToVoid; - } - return; - } + if (\Patchwork\CallRerouting\dispatch( + $__pwClass, + $__pwCalledClass, + __FUNCTION__, + $__pwFrame, + $__pwResult, + \array_merge(\array_slice($__pwRefs, $__pwRefOffset, \func_num_args()), \array_slice(\func_get_args(), \count($__pwRefs))) + )) { + if ($__pwResult !== null) { + throw new \Patchwork\Exceptions\NonNullToVoid; + } + return; + } } unset($__pwClass, $__pwCalledClass, $__pwResult, $__pwClosureName, $__pwFrame, $__pwRefOffset); '; @@ -54,7 +68,14 @@ $__pwFrame = \count(\debug_backtrace(0)); $__pwRefs = %s; $__pwRefOffset = 0; - if (\Patchwork\CallRerouting\dispatch($__pwClass, $__pwCalledClass, __FUNCTION__, $__pwFrame, $__pwResult, \array_merge(\array_slice($__pwRefs, $__pwRefOffset, \func_num_args()), \array_slice(\func_get_args(), \count($__pwRefs))))) { + if (\Patchwork\CallRerouting\dispatch( + $__pwClass, + $__pwCalledClass, + __FUNCTION__, + $__pwFrame, + $__pwResult, + \array_merge(\array_slice($__pwRefs, $__pwRefOffset, \func_num_args()), \array_slice(\func_get_args(), \count($__pwRefs))) + )) { throw new \Patchwork\Exceptions\ReturnFromNever; } } diff --git a/src/CodeManipulation/Actions/RedefinitionOfInternals.php b/src/CodeManipulation/Actions/RedefinitionOfInternals.php index 871df4b..b57e4ca 100644 --- a/src/CodeManipulation/Actions/RedefinitionOfInternals.php +++ b/src/CodeManipulation/Actions/RedefinitionOfInternals.php @@ -48,6 +48,17 @@ function spliceNamedFunctionCalls() function spliceNamedCallsWithin(Source $s, $begin, $end, array $names, array $aliases) { + $tokenList = [ + T_FUNCTION, + T_OBJECT_OPERATOR, + T_DOUBLE_COLON, + T_STRING, + T_NEW, + Generic\NAME_FULLY_QUALIFIED, + Generic\NAME_QUALIFIED, + Generic\NAME_RELATIVE, + ]; + foreach ($s->within([T_STRING, Generic\NAME_FULLY_QUALIFIED, Generic\NAME_QUALIFIED, Generic\NAME_RELATIVE], $begin, $end) as $string) { $original = strtolower($s->read($string)); if ($original[0] == '\\') { @@ -67,7 +78,7 @@ function spliceNamedCallsWithin(Source $s, $begin, $end, array $names, array $al } $hadBackslash = true; } - if ($s->is([T_FUNCTION, T_OBJECT_OPERATOR, T_DOUBLE_COLON, T_STRING, T_NEW, Generic\NAME_FULLY_QUALIFIED, Generic\NAME_QUALIFIED, Generic\NAME_RELATIVE], $previous)) { + if ($s->is($tokenList, $previous)) { continue; } $next = $s->skip(Source::junk(), $string); diff --git a/src/CodeManipulation/Stream.php b/src/CodeManipulation/Stream.php index de8e28d..b4a28d2 100644 --- a/src/CodeManipulation/Stream.php +++ b/src/CodeManipulation/Stream.php @@ -90,8 +90,15 @@ public static function getOtherWrapper($context) } } - public static function alternate(callable $internal, $resource, $wrapped, array $args = [], array $extraArgs = [], $context = null, $shouldReturnResource = false) - { + public static function alternate( + callable $internal, + $resource, + $wrapped, + array $args = [], + array $extraArgs = [], + $context = null, + $shouldReturnResource = false + ) { $shouldAddResourceArg = true; if ($resource === null) { $resource = static::getOtherWrapper($context);