From 72194195a71b112f132fbf0a69ac0f2bc496e647 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Fri, 16 Oct 2020 14:28:16 +0200 Subject: [PATCH] Fixed casting CurlMultiHandle to (int) --- src/Type/ObjectType.php | 2 +- tests/PHPStan/Rules/Cast/data/invalid-cast.php | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Type/ObjectType.php b/src/Type/ObjectType.php index 6d309e77c0..8d159ab7b1 100644 --- a/src/Type/ObjectType.php +++ b/src/Type/ObjectType.php @@ -310,7 +310,7 @@ public function toInteger(): Type return new IntegerType(); } - if ($this->getClassName() === 'CurlHandle') { + if (in_array($this->getClassName(), ['CurlHandle', 'CurlMultiHandle'], true)) { return new IntegerType(); } diff --git a/tests/PHPStan/Rules/Cast/data/invalid-cast.php b/tests/PHPStan/Rules/Cast/data/invalid-cast.php index db34d9456a..4c48e6acfa 100644 --- a/tests/PHPStan/Rules/Cast/data/invalid-cast.php +++ b/tests/PHPStan/Rules/Cast/data/invalid-cast.php @@ -62,3 +62,8 @@ function (): void { $ch = curl_init(); (int) $ch; }; + +function (): void { + $ch = curl_multi_init(); + (int) $ch; +};