From 2c48d42904c768fb612e26a4c9d4e58293af5467 Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Fri, 17 Jan 2020 10:02:58 -0500 Subject: [PATCH] Allow destructuring of callable array Fixes #2653 --- src/Psalm/Type/Union.php | 2 +- tests/CallableTest.php | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Psalm/Type/Union.php b/src/Psalm/Type/Union.php index c3283b8a393..63dcce98c30 100644 --- a/src/Psalm/Type/Union.php +++ b/src/Psalm/Type/Union.php @@ -625,7 +625,7 @@ public function hasType($type_string) */ public function hasArray() { - return isset($this->types['array']); + return isset($this->types['array']) || isset($this->types['callable-array']); } /** diff --git a/tests/CallableTest.php b/tests/CallableTest.php index 55f4d0243ce..08f60f9daea 100644 --- a/tests/CallableTest.php +++ b/tests/CallableTest.php @@ -713,6 +713,24 @@ function c(callable $c) : void { } }' ], + 'destructureCallableArray' => [ + ' 'class-string|object', + '$method' => 'string' + ] + ], ]; }