diff --git a/system/Helpers/html_helper.php b/system/Helpers/html_helper.php
index a15b18ff47e8..c2e48d890fef 100755
--- a/system/Helpers/html_helper.php
+++ b/system/Helpers/html_helper.php
@@ -189,8 +189,8 @@ function doctype(string $type = 'html5'): string
*
* Generates link to a JS file
*
- * @param mixed $src Script source or an array
- * @param bool $indexPage Should indexPage be added to the JS path
+ * @param array|string $src Script source or an array of attributes
+ * @param bool $indexPage Should indexPage be added to the JS path
*/
function script_tag($src = '', bool $indexPage = false): string
{
diff --git a/tests/system/Helpers/HTMLHelperTest.php b/tests/system/Helpers/HTMLHelperTest.php
index 74b087228fdd..d539d7421be6 100755
--- a/tests/system/Helpers/HTMLHelperTest.php
+++ b/tests/system/Helpers/HTMLHelperTest.php
@@ -269,6 +269,16 @@ public function testScriptTagWithSrcAndAttributes()
$this->assertSame($expected, script_tag($target));
}
+ /**
+ * This test has probably no real-world value but may help detecting
+ * a change in the default behaviour.
+ */
+ public function testScriptTagWithoutAnyArg()
+ {
+ $expected = '';
+ $this->assertSame($expected, script_tag());
+ }
+
public function testLinkTag()
{
$target = 'css/mystyles.css';
diff --git a/user_guide_src/source/changelogs/v4.2.0.rst b/user_guide_src/source/changelogs/v4.2.0.rst
index 0ed69ab0760a..fa88608dc355 100644
--- a/user_guide_src/source/changelogs/v4.2.0.rst
+++ b/user_guide_src/source/changelogs/v4.2.0.rst
@@ -38,6 +38,7 @@ Enhancements
- The log format has also changed. If users are depending on the log format in their apps, the new log format is "<1-based count> (): "
- Added support for webp files to **app/Config/Mimes.php**.
- Added 4th parameter ``$includeDir`` to ``get_filenames()``. See :php:func:`get_filenames`.
+- HTML helper ``script_tag()`` now uses ``null`` values to write boolean attributes in minimized form: ````. See the sample code for :php:func:`script_tag`.
Changes
*******
diff --git a/user_guide_src/source/helpers/html_helper.rst b/user_guide_src/source/helpers/html_helper.rst
index 44d0089ac6c7..220e94ebee64 100755
--- a/user_guide_src/source/helpers/html_helper.rst
+++ b/user_guide_src/source/helpers/html_helper.rst
@@ -104,8 +104,8 @@ The following functions are available:
.. php:function:: script_tag([$src = ''[, $indexPage = false]])
- :param mixed $src: The source name of a JavaScript file
- :param bool $indexPage: Whether to treat ``$src`` as a routed URI string
+ :param array|string $src: The source name or URL of a JavaScript file, or an associative array specifying the attributes
+ :param bool $indexPage: Whether to treat ``$src`` as a routed URI string
:returns: HTML script tag
:rtype: string