Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into 4.6
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Aug 27, 2024
2 parents 8e1271e + 2800673 commit b352e31
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 36 deletions.
6 changes: 0 additions & 6 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -10327,12 +10327,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Validation/Validation.php',
];
$ignoreErrors[] = [
// identifier: missingType.iterableValue
'message' => '#^Property CodeIgniter\\\\Validation\\\\Validation\\:\\:\\$rules type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Validation/Validation.php',
];
$ignoreErrors[] = [
// identifier: missingType.iterableValue
'message' => '#^Property CodeIgniter\\\\Validation\\\\Validation\\:\\:\\$validated type has no value type specified in iterable type array\\.$#',
Expand Down
5 changes: 4 additions & 1 deletion system/Validation/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Validation implements ValidationInterface
/**
* Stores the actual rules that should be run against $data.
*
* @var array
* @var array<array-key, array{label?: string, rules: list<string>}>
*
* [
* field1 => [
Expand Down Expand Up @@ -162,6 +162,9 @@ public function run(?array $data = null, ?string $group = null, $dbGroup = null)
// Run through each rule. If we have any field set for
// this rule, then we need to run them through!
foreach ($this->rules as $field => $setup) {
// An array key might be int.
$field = (string) $field;

$rules = $setup['rules'];

if (is_string($rules)) {
Expand Down
10 changes: 10 additions & 0 deletions tests/system/Validation/ValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,16 @@ public function testRunDoesTheBasics(): void
$this->assertSame([], $this->validation->getValidated());
}

public function testRunWithNumericFieldName(): void
{
// The array key will be int.
$data = ['123' => 'notanumber'];
$this->validation->setRules(['123' => 'is_numeric']);

$this->assertFalse($this->validation->run($data));
$this->assertSame([], $this->validation->getValidated());
}

public function testClosureRule(): void
{
$this->validation->setRules(
Expand Down
57 changes: 28 additions & 29 deletions user_guide_src/source/helpers/html_helper.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
HTML Helper
###########

The HTML Helper file contains functions that assist in working with
HTML.
The HTML Helper file contains functions that assist in working with HTML.

.. contents::
:local:
Expand Down Expand Up @@ -31,10 +30,10 @@ The following functions are available:
:param string|array $src: Image source URI, or array of attributes and values
:param bool $indexPage: Whether to treat ``$src`` as a routed URI string
:param mixed $attributes: Additional HTML attributes
:returns: HTML image tag
:returns: HTML image element
:rtype: string

Lets you create HTML ``<img />`` tags. The first parameter contains the
Lets you create HTML ``<img>`` elements. The first parameter contains the
image source. Example:

.. literalinclude:: html_helper/002.php
Expand Down Expand Up @@ -84,10 +83,10 @@ The following functions are available:
:param string $media: Media type
:param bool $indexPage: Whether to treat ``$src`` as a routed URI string
:param string $hreflang: Hreflang type
:returns: HTML link tag
:returns: An HTML link element
:rtype: string

Lets you create HTML ``<link />`` tags. This is useful for stylesheet links,
Lets you create HTML ``<link>`` elements. This is useful for stylesheet links,
as well as other links. The parameters are *href*, with optional *rel*,
*type*, *title*, *media* and *indexPage*.

Expand All @@ -111,10 +110,10 @@ The following functions are available:
: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
:returns: An HTML script element
:rtype: string

Lets you create HTML ``<script></script>`` tags. The parameters is *src*, with optional *indexPage*.
Lets you create HTML ``<script>`` elements. The parameters are *src* and optional *indexPage*.

*indexPage* is a boolean value that specifies if the *src* should have
the page specified by ``$config['indexPage']`` added to the address it creates.
Expand All @@ -132,11 +131,11 @@ The following functions are available:
:param array $list: List entries
:param array $attributes: HTML attributes
:returns: HTML-formatted unordered list
:returns: An HTML unordered list element
:rtype: string

Permits you to generate unordered HTML lists from simple or
multi-dimensional arrays. Example:
Permits you to generate an unordered HTML list from a simple or
multi-dimensional array. Example:

.. literalinclude:: html_helper/012.php

Expand Down Expand Up @@ -205,20 +204,20 @@ The following functions are available:
:param array $list: List entries
:param array $attributes: HTML attributes
:returns: HTML-formatted ordered list
:returns: An HTML ordered list element
:rtype: string

Identical to :php:func:`ul()`, only it produces the ``<ol>`` tag for
Identical to :php:func:`ul()`, only it produces ``<ol>`` element for
ordered lists instead of ``<ul>``.

.. php:function:: video($src[, $unsupportedMessage = ''[, $attributes = ''[, $tracks = [][, $indexPage = false]]]])
:param mixed $src: Either a source string or an array of sources. See :php:func:`source()` function
:param string $unsupportedMessage: The message to display if the media tag is not supported by the browser
:param string $unsupportedMessage: The message to display if the video element is not supported by the browser
:param string $attributes: HTML attributes
:param array $tracks: Use the track function inside an array. See :php:func:`track()` function
:param bool $indexPage:
:returns: HTML-formatted video element
:returns: An HTML video element
:rtype: string

Permits you to generate HTML video element from simple or
Expand Down Expand Up @@ -253,24 +252,24 @@ The following functions are available:
.. php:function:: audio($src[, $unsupportedMessage = ''[, $attributes = ''[, $tracks = [][, $indexPage = false]]]])
:param mixed $src: Either a source string or an array of sources. See :php:func:`source()` function
:param string $unsupportedMessage: The message to display if the media tag is not supported by the browser
:param string $unsupportedMessage: The message to display if the audio element is not supported by the browser
:param string $attributes:
:param array $tracks: Use the track function inside an array. See :php:func:`track()` function
:param bool $indexPage:
:returns: HTML-formatted audio element
:returns: An HTML audio element
:rtype: string

Identical to :php:func:`video()`, only it produces the ``<audio>`` tag instead of ``<video>``.
Identical to :php:func:`video()`, only it produces ``<audio>`` element instead of ``<video>``.

.. php:function:: source($src = ''[, $type = false[, $attributes = '']])
:param string $src: The path of the media resource
:param bool $type: The MIME-type of the resource with optional codecs parameters
:param array $attributes: HTML attributes
:returns: HTML source tag
:returns: An HTML source element
:rtype: string

Lets you create HTML ``<source />`` tags. The first parameter contains the
Lets you create HTML ``<source>`` elements. The first parameter contains the
source source. Example:

.. literalinclude:: html_helper/015.php
Expand All @@ -281,10 +280,10 @@ The following functions are available:
:param bool $type: MIME-type
:param array $attributes: HTML attributes
:param bool $indexPage:
:returns: HTML embed tag
:returns: An HTML embed element
:rtype: string

Lets you create HTML ``<embed />`` tags. The first parameter contains the
Lets you create HTML ``<embed>`` elements. The first parameter contains the
embed source. Example:

.. literalinclude:: html_helper/016.php
Expand All @@ -295,10 +294,10 @@ The following functions are available:
:param bool $type: Content-type of the resource
:param array $attributes: HTML attributes
:param array $params: Use the param function inside an array. See :php:func:`param()` function
:returns: HTML object tag
:returns: An HTML object element
:rtype: string

Lets you create HTML ``<object />`` tags. The first parameter contains the
Lets you create HTML ``<object>`` elements. The first parameter contains the
object data. Example:

.. literalinclude:: html_helper/017.php
Expand All @@ -319,10 +318,10 @@ The following functions are available:
:param string $name: The name of the parameter
:param string $value: The value of the parameter
:param array $attributes: HTML attributes
:returns: HTML param tag
:returns: An HTML param element
:rtype: string

Lets you create HTML ``<param />`` tags. The first parameter contains the
Lets you create HTML ``<param>`` elements. The first parameter contains the
param source. Example:

.. literalinclude:: html_helper/018.php
Expand All @@ -332,7 +331,7 @@ The following functions are available:
:param string $name: The name of the parameter
:param string $value: The value of the parameter
:param array $attributes: HTML attributes
:returns: HTML track tag
:returns: An HTML track element
:rtype: string

Generates a track element to specify timed tracks. The tracks are
Expand All @@ -343,10 +342,10 @@ The following functions are available:
.. php:function:: doctype([$type = 'html5'])
:param string $type: Doctype name
:returns: HTML DocType tag
:returns: An HTML DocType declaration
:rtype: string

Helps you generate document type declarations, or DTD's. HTML 5
Helps you generate document type declarations (DTD's). HTML 5
is used by default, but many doctypes are available.

Example:
Expand Down

0 comments on commit b352e31

Please sign in to comment.