From 88583928f4fb13a897811eeaf9b32db794fc5cc6 Mon Sep 17 00:00:00 2001 From: Jonathan Vollebregt Date: Tue, 1 Nov 2022 08:31:33 +0100 Subject: [PATCH] CallFinder: Skip first-class callables --- build/kint.phar | Bin 434424 -> 434590 bytes src/CallFinder.php | 5 +++++ tests/CallFinderTest.php | 22 ++++++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/build/kint.phar b/build/kint.phar index b8ad56136fecd05e301944fbaae7541fadd82dad..8834b715bd0200d44a8c73f101d0888634f4c08a 100644 GIT binary patch delta 232 zcmexyP-@;`sSS4Q0;}8@7#jBJ$bjgnO`JB(e(clz*co5R2WMv%D5PZ;6_@BH=Oh*v zDh6-wG3Wf@{wzdi}$@!&uB^oLPiA9OI#hM@qbv->j zb+9BvG+MnNu_R;q!LKZ0lP7%CXt&^C1Y#y2W(HywAZFce!NFEB!{eRY$>8WIN($Y7 zx81i?-S{m~{@IUJ`*}8=4)48q#&-FFG+*wQ;(j~sZ|f5)O=2@mr!EEInD~ Swc(<5;7k?<1_pO0Unc;$GgQz3 delta 133 zcmbPtSn9_?sSS4Q0xWI}3=R8qWI(jI8P}3#KlbTEu@3v*`vQ4DsBm0EDQ_`?oPf=02AyqAOHXW diff --git a/src/CallFinder.php b/src/CallFinder.php index 113007869..33e022e96 100644 --- a/src/CallFinder.php +++ b/src/CallFinder.php @@ -382,6 +382,11 @@ public static function getFunctionCalls(string $source, int $line, $function): a ]; } + // Skip first-class callables + if (KINT_PHP81 && 1 === \count($params) && '...' === $param['path']) { + continue; + } + // Get the modifiers --$index; diff --git a/tests/CallFinderTest.php b/tests/CallFinderTest.php index c8ac8f94b..6ab60577a 100644 --- a/tests/CallFinderTest.php +++ b/tests/CallFinderTest.php @@ -1101,6 +1101,28 @@ public function sourceProvider() ]; } + if (KINT_PHP81) { + $data['ignore firstclass callables'] = [ + ' 3, + 'function' => 'test', + 'result' => [ + [ + 'modifiers' => [], + 'parameters' => [ + [ + 'path' => '$a', + 'name' => '$a', + 'expression' => false, + ], + ], + ], + ], + ]; + } + if (KINT_PHP82) { $data['dnf types'] = [ '