From b12e643963f4a48beb9ed081010ac70b7731f965 Mon Sep 17 00:00:00 2001 From: Tom Klingenberg Date: Thu, 6 Jan 2022 14:52:40 +0100 Subject: [PATCH] Assertion::classExists() emits a PHP Warning asserting an expression with classExists(), and the expression is an array, it shows me the following warning: > PHP Warning: class_exists() expects parameter 1 to be string, array > given in beberlei/assert/lib/Assert/Assertion.php on line 1860 on beberlei/assert v3.3.2 with php 7.4 and with php 8.0 > PHP Fatal error: Uncaught TypeError: class_exists(): Argument #1 ( > $class) must be of type string, array given in [...] Assertion.php:1860 add an is_string check. --- lib/Assert/Assertion.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Assert/Assertion.php b/lib/Assert/Assertion.php index 243e64d..c3dcc2c 100644 --- a/lib/Assert/Assertion.php +++ b/lib/Assert/Assertion.php @@ -1857,7 +1857,7 @@ public static function false($value, $message = null, string $propertyPath = nul */ public static function classExists($value, $message = null, string $propertyPath = null): bool { - if (!\class_exists($value)) { + if (!\is_string($value) || !\class_exists($value)) { $message = \sprintf( static::generateMessage($message ?: 'Class "%s" does not exist.'), static::stringify($value)