From 86d93b2cc2633665dd793f0279d6ca64dae6d184 Mon Sep 17 00:00:00 2001 From: Shish Date: Wed, 29 Jan 2020 20:20:17 +0000 Subject: [PATCH] bool_escape('1') should be True --- core/polyfills.php | 2 +- core/tests/polyfills.test.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/core/polyfills.php b/core/polyfills.php index 894d6164..26dc4aac 100644 --- a/core/polyfills.php +++ b/core/polyfills.php @@ -490,7 +490,7 @@ function bool_escape($input): bool */ if (is_bool($input)) { return $input; - } elseif (is_numeric($input)) { + } elseif (is_int($input)) { return ($input === 1); } else { $value = filter_var($input, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); diff --git a/core/tests/polyfills.test.php b/core/tests/polyfills.test.php index ea7a3d1a..6fa3389a 100644 --- a/core/tests/polyfills.test.php +++ b/core/tests/polyfills.test.php @@ -59,6 +59,9 @@ class PolyfillsTest extends \PHPUnit\Framework\TestCase $this->assertTrue(bool_escape(1)); $this->assertFalse(bool_escape(0)); + + $this->assertTrue(bool_escape("1")); + $this->assertFalse(bool_escape("0")); } public function test_clamp()